netdev: Make netdev_get_vlan_vid() take a netdev instead of a name.
authorBen Pfaff <blp@nicira.com>
Thu, 23 Jul 2009 20:36:08 +0000 (13:36 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 30 Jul 2009 23:07:14 +0000 (16:07 -0700)
For consistency, it's best if every netdev function takes a netdev instead
of a device name.  The netdev_nodev_*() functions have always been a bit
ugly.

lib/netdev.c
lib/netdev.h
vswitchd/bridge.c

index a36ab97..79a6820 100644 (file)
@@ -1379,13 +1379,13 @@ netdev_nodev_get_etheraddr(const char *netdev_name, uint8_t mac[6])
     return get_etheraddr(netdev_name, mac, NULL);
 }
 
-/* If 'netdev_name' is the name of a VLAN network device (e.g. one created with
- * vconfig(8)), sets '*vlan_vid' to the VLAN VID associated with that device
- * and returns 0.  Otherwise returns a errno value (specifically ENOENT if
- * 'netdev_name' is the name of a network device that is not a VLAN device) and
- * sets '*vlan_vid' to -1. */
+/* If 'netdev' is a VLAN network device (e.g. one created with vconfig(8)),
+ * sets '*vlan_vid' to the VLAN VID associated with that device and returns 0.
+ * Otherwise returns a errno value (specifically ENOENT if 'netdev_name' is the
+ * name of a network device that is not a VLAN device) and sets '*vlan_vid' to
+ * -1. */
 int
-netdev_get_vlan_vid(const char *netdev_name, int *vlan_vid)
+netdev_get_vlan_vid(const struct netdev *netdev, int *vlan_vid)
 {
     struct ds line = DS_EMPTY_INITIALIZER;
     FILE *stream = NULL;
@@ -1393,7 +1393,7 @@ netdev_get_vlan_vid(const char *netdev_name, int *vlan_vid)
     char *fn;
 
     COVERAGE_INC(netdev_get_vlan_vid);
-    fn = xasprintf("/proc/net/vlan/%s", netdev_name);
+    fn = xasprintf("/proc/net/vlan/%s", netdev_get_name(netdev));
     stream = fopen(fn, "r");
     if (!stream) {
         error = errno;
index 2ac0f2e..b6330e7 100644 (file)
@@ -119,7 +119,7 @@ int netdev_nodev_arp_lookup(const char *netdev_name, uint32_t ip,
                             uint8_t mac[6]);
 int netdev_nodev_get_carrier(const char *netdev_name, bool *carrier);
 
-int netdev_get_vlan_vid(const char *netdev_name, int *vlan_vid);
+int netdev_get_vlan_vid(const struct netdev *, int *vlan_vid);
 
 struct netdev_monitor;
 int netdev_monitor_create(struct netdev_monitor **);
index 8a63ef8..6b05d13 100644 (file)
@@ -724,8 +724,7 @@ bridge_pick_datapath_id(struct bridge *br,
 
     if (hw_addr_iface) {
         int vlan;
-        if (!netdev_get_vlan_vid(netdev_get_name(hw_addr_iface->netdev),
-                                 &vlan)) {
+        if (!netdev_get_vlan_vid(hw_addr_iface->netdev, &vlan)) {
             /*
              * A bridge whose MAC address is taken from a VLAN network device
              * (that is, a network device created with vconfig(8) or similar