From 275707c33f8f5463154bc3e2f561181a2060ab57 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Sun, 16 Dec 2012 16:42:17 -0800 Subject: [PATCH] netdev: Rename get_drv_info() to get_status(). get_status() is a much more intuitive name since "status" is what the database column is called. Signed-off-by: Ethan Jackson --- lib/netdev-bsd.c | 4 +-- lib/netdev-dummy.c | 4 +-- lib/netdev-linux.c | 57 ++++++++++++++++--------------------- lib/netdev-provider.h | 10 +++---- lib/netdev-vport.c | 65 +++++++++++++++++-------------------------- lib/netdev.c | 8 +++--- lib/netdev.h | 4 +-- vswitchd/bridge.c | 4 +-- 8 files changed, 66 insertions(+), 90 deletions(-) diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c index 6e562db3f..9094d0477 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 6aa4084b2..39b04cfa6 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 60f985e5f..4471778e7 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 94f60af72..910ff5895 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 94acd2603..bc6b9e196 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) { @@ -406,11 +404,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; - if (iface) { + 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 (route_table_get_name(route, iface)) { struct netdev *egress_netdev; smap_add(smap, "tunnel_egress_iface", iface); @@ -456,35 +470,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]; - 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 its - * configuration set yet. */ - return NULL; - } - - if (tnl_port_config_from_nlattr(ndv->options->data, ndv->options->size, - a)) { - return NULL; - } - if (a[OVS_TUNNEL_ATTR_DST_IPV4]) { - ovs_be32 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 @@ -937,27 +922,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 1921ac0da..8c8bacbd8 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 67122eec1..7680156a3 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 beb8b936c..348faef39 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. +/* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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); -- 2.47.0