[ovs-dev] [PATCH 3/6] netdev: Rename get_drv_info() to get_status().
Ethan Jackson
ethan at nicira.com
Thu Dec 27 01:16:43 UTC 2012
get_status() is a much more intuitive name since "status" is what
the database column is called.
Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
lib/netdev-bsd.c | 4 +--
lib/netdev-dummy.c | 2 +-
lib/netdev-linux.c | 55 +++++++++++++++++------------------------
lib/netdev-provider.h | 8 +++---
lib/netdev-vport.c | 65 +++++++++++++++++++------------------------------
lib/netdev.c | 6 ++---
lib/netdev.h | 2 +-
vswitchd/bridge.c | 2 +-
8 files changed, 60 insertions(+), 84 deletions(-)
diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c
index 6e562db..9094d04 100644
--- a/lib/netdev-bsd.c
+++ b/lib/netdev-bsd.c
@@ -1297,7 +1297,7 @@ const struct netdev_class netdev_bsd_class = {
netdev_bsd_get_in6,
NULL, /* add_router */
NULL, /* get_next_hop */
- NULL, /* get_drv_info */
+ NULL, /* get_status */
NULL, /* arp_lookup */
netdev_bsd_update_flags,
@@ -1357,7 +1357,7 @@ const struct netdev_class netdev_tap_class = {
netdev_bsd_get_in6,
NULL, /* add_router */
NULL, /* get_next_hop */
- NULL, /* get_drv_info */
+ NULL, /* get_status */
NULL, /* arp_lookup */
netdev_bsd_update_flags,
diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 6aa4084..5138f1b 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -362,7 +362,7 @@ static const struct netdev_class dummy_class = {
NULL, /* get_in6 */
NULL, /* add_router */
NULL, /* get_next_hop */
- NULL, /* get_drv_info */
+ NULL, /* get_status */
NULL, /* arp_lookup */
netdev_dummy_update_flags,
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 60f985e..f85e002 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -497,28 +497,6 @@ netdev_linux_wait(void)
netdev_linux_miimon_wait();
}
-static int
-netdev_linux_get_drvinfo(struct netdev_dev_linux *netdev_dev)
-{
-
- int error;
-
- if (netdev_dev->cache_valid & VALID_DRVINFO) {
- return 0;
- }
-
- COVERAGE_INC(netdev_get_ethtool);
- memset(&netdev_dev->drvinfo, 0, sizeof netdev_dev->drvinfo);
- error = netdev_linux_do_ethtool(netdev_dev->netdev_dev.name,
- (struct ethtool_cmd *)&netdev_dev->drvinfo,
- ETHTOOL_GDRVINFO,
- "ETHTOOL_GDRVINFO");
- if (!error) {
- netdev_dev->cache_valid |= VALID_DRVINFO;
- }
- return error;
-}
-
static void
netdev_dev_linux_changed(struct netdev_dev_linux *dev,
unsigned int ifi_flags,
@@ -2323,13 +2301,26 @@ netdev_linux_get_next_hop(const struct in_addr *host, struct in_addr *next_hop,
}
static int
-netdev_linux_get_drv_info(const struct netdev *netdev, struct smap *smap)
+netdev_linux_get_status(const struct netdev *netdev, struct smap *smap)
{
- int error;
- struct netdev_dev_linux *netdev_dev =
- netdev_dev_linux_cast(netdev_get_dev(netdev));
+ struct netdev_dev_linux *netdev_dev;
+ int error = 0;
+
+ netdev_dev = netdev_dev_linux_cast(netdev_get_dev(netdev));
+ if (!(netdev_dev->cache_valid & VALID_DRVINFO)) {
+ struct ethtool_cmd *cmd = (struct ethtool_cmd *) &netdev_dev->drvinfo;
+
+ COVERAGE_INC(netdev_get_ethtool);
+ memset(&netdev_dev->drvinfo, 0, sizeof netdev_dev->drvinfo);
+ error = netdev_linux_do_ethtool(netdev_dev->netdev_dev.name,
+ cmd,
+ ETHTOOL_GDRVINFO,
+ "ETHTOOL_GDRVINFO");
+ if (!error) {
+ netdev_dev->cache_valid |= VALID_DRVINFO;
+ }
+ }
- error = netdev_linux_get_drvinfo(netdev_dev);
if (!error) {
smap_add(smap, "driver_name", netdev_dev->drvinfo.driver);
smap_add(smap, "driver_version", netdev_dev->drvinfo.version);
@@ -2339,8 +2330,8 @@ netdev_linux_get_drv_info(const struct netdev *netdev, struct smap *smap)
}
static int
-netdev_internal_get_drv_info(const struct netdev *netdev OVS_UNUSED,
- struct smap *smap)
+netdev_internal_get_status(const struct netdev *netdev OVS_UNUSED,
+ struct smap *smap)
{
smap_add(smap, "driver_name", "openvswitch");
return 0;
@@ -2500,7 +2491,7 @@ const struct netdev_class netdev_linux_class =
netdev_linux_get_stats,
NULL, /* set_stats */
netdev_linux_get_features,
- netdev_linux_get_drv_info);
+ netdev_linux_get_status);
const struct netdev_class netdev_tap_class =
NETDEV_LINUX_CLASS(
@@ -2509,7 +2500,7 @@ const struct netdev_class netdev_tap_class =
netdev_tap_get_stats,
NULL, /* set_stats */
netdev_linux_get_features,
- netdev_linux_get_drv_info);
+ netdev_linux_get_status);
const struct netdev_class netdev_internal_class =
NETDEV_LINUX_CLASS(
@@ -2518,7 +2509,7 @@ const struct netdev_class netdev_internal_class =
netdev_internal_get_stats,
netdev_internal_set_stats,
NULL, /* get_features */
- netdev_internal_get_drv_info);
+ netdev_internal_get_status);
/* HTB traffic control class. */
diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 94f60af..2cf0b78 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -546,16 +546,16 @@ struct netdev_class {
/* Retrieves driver information of the device.
*
- * Populates 'sh' with key-value pairs representing the status of the
- * device. Driver info is a set of key-value string pairs
- * representing netdev type specific information. For more information see
+ * Populates 'smap' with key-value pairs representing the status of the
+ * device. 'smap' is a set of key-value string pairs representing netdev
+ * type specific information. For more information see
* ovs-vswitchd.conf.db(5).
*
* The caller is responsible for destroying 'smap' and its data.
*
* This function may be set to null if it would always return EOPNOTSUPP
* anyhow. */
- int (*get_drv_info)(const struct netdev *netdev, struct smap *smap);
+ int (*get_status)(const struct netdev *netdev, struct smap *smap);
/* Looks up the ARP table entry for 'ip' on 'netdev' and stores the
* corresponding MAC address in 'mac'. A return value of ENXIO, in
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 9bb5d36..259d1d1 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -81,8 +81,6 @@ static int tnl_port_config_from_nlattr(const struct nlattr *options,
size_t options_len,
struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1]);
-static const char *netdev_vport_get_tnl_iface(const struct netdev *netdev);
-
static bool
is_vport_class(const struct netdev_class *class)
{
@@ -400,11 +398,27 @@ netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
}
static int
-netdev_vport_get_drv_info(const struct netdev *netdev, struct smap *smap)
+tunnel_get_status(const struct netdev *netdev, struct smap *smap)
{
- const char *iface = netdev_vport_get_tnl_iface(netdev);
+ struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
+ struct netdev_dev_vport *ndv;
+ static char iface[IFNAMSIZ];
+ ovs_be32 route;
+
+ ndv = netdev_dev_vport_cast(netdev_get_dev(netdev));
+ if (!ndv->options) {
+ /* Race condition when 'ndv' was created, but did not have it's
+ * configuration set yet. */
+ return 0;
+ }
+
+ if (tnl_port_config_from_nlattr(ndv->options->data,
+ ndv->options->size, a)) {
+ return 0;
+ }
+ route = nl_attr_get_be32(a[OVS_TUNNEL_ATTR_DST_IPV4]);
- if (iface) {
+ if (route_table_get_name(route, iface)) {
struct netdev *egress_netdev;
smap_add(smap, "tunnel_egress_iface", iface);
@@ -450,35 +464,6 @@ netdev_vport_wait(void)
route_table_wait();
}
-/* get_tnl_iface() implementation. */
-static const char *
-netdev_vport_get_tnl_iface(const struct netdev *netdev)
-{
- struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
- ovs_be32 route;
- struct netdev_dev_vport *ndv;
- static char name[IFNAMSIZ];
-
- ndv = netdev_dev_vport_cast(netdev_get_dev(netdev));
- if (!ndv->options) {
- /* Race condition when 'ndv' was created, but did not have it's
- * configuration set yet. */
- return NULL;
- }
-
- if (tnl_port_config_from_nlattr(ndv->options->data, ndv->options->size,
- a)) {
- return NULL;
- }
- route = nl_attr_get_be32(a[OVS_TUNNEL_ATTR_DST_IPV4]);
-
- if (route_table_get_name(route, name)) {
- return name;
- }
-
- return NULL;
-}
-
/* Helper functions. */
static void
@@ -930,27 +915,27 @@ netdev_vport_register(void)
{
static const struct vport_class vport_classes[] = {
{ OVS_VPORT_TYPE_GRE,
- { "gre", VPORT_FUNCTIONS(netdev_vport_get_drv_info) },
+ { "gre", VPORT_FUNCTIONS(tunnel_get_status) },
parse_tunnel_config, unparse_tunnel_config },
{ OVS_VPORT_TYPE_GRE,
- { "ipsec_gre", VPORT_FUNCTIONS(netdev_vport_get_drv_info) },
+ { "ipsec_gre", VPORT_FUNCTIONS(tunnel_get_status) },
parse_tunnel_config, unparse_tunnel_config },
{ OVS_VPORT_TYPE_GRE64,
- { "gre64", VPORT_FUNCTIONS(netdev_vport_get_drv_info) },
+ { "gre64", VPORT_FUNCTIONS(tunnel_get_status) },
parse_tunnel_config, unparse_tunnel_config },
{ OVS_VPORT_TYPE_GRE64,
- { "ipsec_gre64", VPORT_FUNCTIONS(netdev_vport_get_drv_info) },
+ { "ipsec_gre64", VPORT_FUNCTIONS(tunnel_get_status) },
parse_tunnel_config, unparse_tunnel_config },
{ OVS_VPORT_TYPE_CAPWAP,
- { "capwap", VPORT_FUNCTIONS(netdev_vport_get_drv_info) },
+ { "capwap", VPORT_FUNCTIONS(tunnel_get_status) },
parse_tunnel_config, unparse_tunnel_config },
{ OVS_VPORT_TYPE_VXLAN,
- { "vxlan", VPORT_FUNCTIONS(netdev_vport_get_drv_info) },
+ { "vxlan", VPORT_FUNCTIONS(tunnel_get_status) },
parse_tunnel_config, unparse_tunnel_config },
{ OVS_VPORT_TYPE_PATCH,
diff --git a/lib/netdev.c b/lib/netdev.c
index 1921ac0..c63b2cc 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -771,12 +771,12 @@ netdev_get_next_hop(const struct netdev *netdev,
* information may be used to populate the status column of the Interface table
* as defined in ovs-vswitchd.conf.db(5). */
int
-netdev_get_drv_info(const struct netdev *netdev, struct smap *smap)
+netdev_get_status(const struct netdev *netdev, struct smap *smap)
{
struct netdev_dev *dev = netdev_get_dev(netdev);
- return (dev->netdev_class->get_drv_info
- ? dev->netdev_class->get_drv_info(netdev, smap)
+ return (dev->netdev_class->get_status
+ ? dev->netdev_class->get_status(netdev, smap)
: EOPNOTSUPP);
}
diff --git a/lib/netdev.h b/lib/netdev.h
index 67122ee..de869e3 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -160,7 +160,7 @@ int netdev_get_in6(const struct netdev *, struct in6_addr *);
int netdev_add_router(struct netdev *, struct in_addr router);
int netdev_get_next_hop(const struct netdev *, const struct in_addr *host,
struct in_addr *next_hop, char **);
-int netdev_get_drv_info(const struct netdev *, struct smap *);
+int netdev_get_status(const struct netdev *, struct smap *);
int netdev_arp_lookup(const struct netdev *, ovs_be32 ip, uint8_t mac[6]);
int netdev_get_flags(const struct netdev *, enum netdev_flags *);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index e58c3c4..be3c305 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1712,7 +1712,7 @@ iface_refresh_status(struct iface *iface)
smap_init(&smap);
- if (!netdev_get_drv_info(iface->netdev, &smap)) {
+ if (!netdev_get_status(iface->netdev, &smap)) {
ovsrec_interface_set_status(iface->cfg, &smap);
} else {
ovsrec_interface_set_status(iface->cfg, NULL);
--
1.7.9.5
More information about the dev
mailing list