[ovs-discuss] [abstract-netdev v2 08/21] netdev: Add 'netdev' parameter to netdev_add_router().

Ben Pfaff blp at nicira.com
Tue Jul 28 21:13:34 UTC 2009


When there is the possibility of multiple classes of netdevs,
netdev_add_router() needs to know which of these to use, so it needs a
"struct netdev *" parameter.
---
 lib/dhcp-client.c |    2 +-
 lib/netdev.c      |    5 +++--
 lib/netdev.h      |    2 +-
 vswitchd/bridge.c |    2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/dhcp-client.c b/lib/dhcp-client.c
index a9163c7..c8ae00e 100644
--- a/lib/dhcp-client.c
+++ b/lib/dhcp-client.c
@@ -411,7 +411,7 @@ dhclient_configure_netdev(struct dhclient *cli)
     }
 
     if (!error && router.s_addr) {
-        error = netdev_add_router(router);
+        error = netdev_add_router(cli->netdev, router);
         if (error) {
             VLOG_ERR("failed to add default route to "IP_FMT" on %s: %s",
                      IP_ARGS(&router), netdev_get_name(cli->netdev),
diff --git a/lib/netdev.c b/lib/netdev.c
index 903d14c..701bb53 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -879,9 +879,10 @@ netdev_set_in4(struct netdev *netdev, struct in_addr addr, struct in_addr mask)
     return error;
 }
 
-/* Adds 'router' as a default IP gateway. */
+/* Adds 'router' as a default IP gateway for the TCP/IP stack that corresponds
+ * to 'netdev'. */
 int
-netdev_add_router(struct in_addr router)
+netdev_add_router(struct netdev *netdev UNUSED, struct in_addr router)
 {
     struct in_addr any = { INADDR_ANY };
     struct rtentry rt;
diff --git a/lib/netdev.h b/lib/netdev.h
index 01eebeb..fb8c1e5 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -94,7 +94,7 @@ int netdev_get_features(struct netdev *,
 int netdev_set_advertisements(struct netdev *, uint32_t advertise);
 int netdev_get_in4(const struct netdev *, struct in_addr *);
 int netdev_set_in4(struct netdev *, struct in_addr addr, struct in_addr mask);
-int netdev_add_router(struct in_addr router);
+int netdev_add_router(struct netdev *, struct in_addr router);
 bool netdev_get_in6(const struct netdev *, struct in6_addr *);
 int netdev_get_flags(const struct netdev *, enum netdev_flags *);
 int netdev_set_flags(struct netdev *, enum netdev_flags, bool permanent);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index f977c2b..7c6c69f 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1142,7 +1142,7 @@ bridge_reconfigure_controller(struct bridge *br)
                     }
 
                     if (gateway.s_addr) {
-                        if (!netdev_add_router(gateway)) {
+                        if (!netdev_add_router(netdev, gateway)) {
                             VLOG_INFO("bridge %s: configured gateway "IP_FMT,
                                       br->name, IP_ARGS(&gateway.s_addr));
                         }
-- 
1.6.3.3





More information about the discuss mailing list