[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openvswitch-dev
Subject:    [ovs-dev] [PATCH 1/5] bridge: Drop redundant 'iface_cfg' parameter to set_up_iface().
From:       blp () nicira ! com (Ben Pfaff)
Date:       2010-07-29 23:06:08
Message-ID: 1280444772-11347-1-git-send-email-blp () nicira ! com
[Download RAW message or body]

iface_cfg is also available as iface->cfg, so there's no benefit in also
passing it as a separate parameter.

Also, get rid of the one-liner reconfigure_iface() function that wasn't
helping with anything.
---
 vswitchd/bridge.c |   33 +++++++++++++--------------------
 1 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index ede9dcd..ea8680e 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -376,29 +376,28 @@ bridge_configure_ssl(const struct ovsrec_ssl *ssl)
 /* Attempt to create the network device 'iface_name' through the netdev
  * library. */
 static int
-set_up_iface(const struct ovsrec_interface *iface_cfg, struct iface *iface,
-             bool create)
+set_up_iface(struct iface *iface, bool create)
 {
     struct shash options;
     int error = 0;
     size_t i;
 
     shash_init(&options);
-    for (i = 0; i < iface_cfg->n_options; i++) {
-        shash_add(&options, iface_cfg->key_options[i],
-                  xstrdup(iface_cfg->value_options[i]));
+    for (i = 0; i < iface->cfg->n_options; i++) {
+        shash_add(&options, iface->cfg->key_options[i],
+                  xstrdup(iface->cfg->value_options[i]));
     }
 
     if (create) {
         struct netdev_options netdev_options;
 
         memset(&netdev_options, 0, sizeof netdev_options);
-        netdev_options.name = iface_cfg->name;
-        if (!strcmp(iface_cfg->type, "internal")) {
+        netdev_options.name = iface->cfg->name;
+        if (!strcmp(iface->cfg->type, "internal")) {
             /* An "internal" config type maps to a netdev "system" type. */
             netdev_options.type = "system";
         } else {
-            netdev_options.type = iface_cfg->type;
+            netdev_options.type = iface->cfg->type;
         }
         netdev_options.args = &options;
         netdev_options.ethertype = NETDEV_ETH_TYPE_NONE;
@@ -410,8 +409,8 @@ set_up_iface(const struct ovsrec_interface *iface_cfg, struct iface *iface,
         }
     } else if (iface->netdev) {
         const char *netdev_type = netdev_get_type(iface->netdev);
-        const char *iface_type = iface_cfg->type && strlen(iface_cfg->type)
-                                  ? iface_cfg->type : NULL;
+        const char *iface_type = iface->cfg->type && strlen(iface->cfg->type)
+                                  ? iface->cfg->type : NULL;
 
         /* An "internal" config type maps to a netdev "system" type. */
         if (iface_type && !strcmp(iface_type, "internal")) {
@@ -422,7 +421,7 @@ set_up_iface(const struct ovsrec_interface *iface_cfg, struct iface *iface,
             error = netdev_reconfigure(iface->netdev, &options);
         } else {
             VLOG_WARN("%s: attempting change device type from %s to %s",
-                      iface_cfg->name, netdev_type, iface_type);
+                      iface->cfg->name, netdev_type, iface_type);
             error = EINVAL;
         }
     }
@@ -431,18 +430,12 @@ set_up_iface(const struct ovsrec_interface *iface_cfg, struct iface *iface,
     return error;
 }
 
-static int
-reconfigure_iface(const struct ovsrec_interface *iface_cfg, struct iface *iface)
-{
-    return set_up_iface(iface_cfg, iface, false);
-}
-
 static bool
 check_iface_netdev(struct bridge *br OVS_UNUSED, struct iface *iface,
                    void *aux OVS_UNUSED)
 {
     if (!iface->netdev) {
-        int error = set_up_iface(iface->cfg, iface, true);
+        int error = set_up_iface(iface, true);
         if (error) {
             VLOG_WARN("could not open netdev on %s, dropping: %s", iface->name,
                                                                strerror(error));
@@ -674,7 +667,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
             if (shash_find(&cur_ifaces, if_name)) {
                 /* Already exists, just reconfigure it. */
                 if (iface) {
-                    reconfigure_iface(iface->cfg, iface);
+                    set_up_iface(iface, false);
                 }
             } else {
                 /* Need to add to datapath. */
@@ -3626,7 +3619,7 @@ iface_create(struct port *port, const struct ovsrec_interface *if_cfg)
 
     /* Attempt to create the network interface in case it doesn't exist yet. */
     if (!iface_is_internal(br, iface->name)) {
-        error = set_up_iface(if_cfg, iface, true);
+        error = set_up_iface(iface, true);
         if (error) {
             VLOG_WARN("could not create iface %s: %s", iface->name,
                       strerror(error));
-- 
1.7.1




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic