From b2f17b151d15dd9869408c1faa025631003f50f6 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 23 Jul 2009 13:36:08 -0700 Subject: [PATCH] netdev: Make netdev_get_vlan_vid() take a netdev instead of a name. 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 | 14 +++++++------- lib/netdev.h | 2 +- vswitchd/bridge.c | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/netdev.c b/lib/netdev.c index a36ab972..79a6820e 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -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; diff --git a/lib/netdev.h b/lib/netdev.h index 2ac0f2e4..b6330e74 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -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 **); diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 8a63ef8b..6b05d132 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -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 -- 2.30.2