From: Andrew Evans Date: Mon, 17 Jan 2011 23:37:13 +0000 (-0800) Subject: bridge: Store status of physical network interfaces in Interface table. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e210037edde788ffcc03497019903dadd6eadcfa;p=openvswitch bridge: Store status of physical network interfaces in Interface table. New columns in Interface table: admin_state, link_state, link_speed, duplex, mtu. New keys in status map in Interface table: driver_name, driver_version, firmware_version. Requested-by: Peter Balland Bug #4299. --- diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 168cd012..72541c79 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2025,6 +2025,26 @@ netdev_linux_get_next_hop(const struct in_addr *host, struct in_addr *next_hop, return ENXIO; } +static int +netdev_linux_get_status(const struct netdev *netdev, struct shash *sh) +{ + struct ethtool_drvinfo drvinfo; + int error; + + memset(&drvinfo, 0, sizeof drvinfo); + error = netdev_linux_do_ethtool(netdev_get_name(netdev), + (struct ethtool_cmd *)&drvinfo, + ETHTOOL_GDRVINFO, + "ETHTOOL_GDRVINFO"); + if (!error) { + shash_add(sh, "driver_name", xstrdup(drvinfo.driver)); + shash_add(sh, "driver_version", xstrdup(drvinfo.version)); + shash_add(sh, "firmware_version", xstrdup(drvinfo.fw_version)); + } + + return error; +} + /* Looks up the ARP table entry for 'ip' on 'netdev'. If one exists and can be * successfully retrieved, it stores the corresponding MAC address in 'mac' and * returns 0. Otherwise, it returns a positive errno value; in particular, @@ -2238,7 +2258,7 @@ netdev_linux_poll_remove(struct netdev_notifier *notifier_) netdev_linux_get_in6, \ netdev_linux_add_router, \ netdev_linux_get_next_hop, \ - NULL, /* get_status */ \ + netdev_linux_get_status, \ netdev_linux_arp_lookup, \ \ netdev_linux_update_flags, \ diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index fb8ce5f1..680c1adf 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1120,6 +1120,13 @@ iface_refresh_status(struct iface *iface) { struct shash sh; + enum netdev_flags flags; + uint32_t current; + int64_t bps; + int mtu; + int64_t mtu_64; + int error; + shash_init(&sh); if (!netdev_get_status(iface->netdev, &sh)) { @@ -1136,6 +1143,42 @@ iface_refresh_status(struct iface *iface) } shash_destroy_free_data(&sh); + + error = netdev_get_flags(iface->netdev, &flags); + if (!error) { + ovsrec_interface_set_admin_state(iface->cfg, flags & NETDEV_UP ? "up" : "down"); + } + else { + ovsrec_interface_set_admin_state(iface->cfg, NULL); + } + + error = netdev_get_features(iface->netdev, ¤t, NULL, NULL, NULL); + if (!error) { + ovsrec_interface_set_duplex(iface->cfg, + netdev_features_is_full_duplex(current) + ? "full" : "half"); + /* warning: uint64_t -> int64_t conversion */ + bps = netdev_features_to_bps(current); + ovsrec_interface_set_link_speed(iface->cfg, &bps, 1); + } + else { + ovsrec_interface_set_duplex(iface->cfg, NULL); + ovsrec_interface_set_link_speed(iface->cfg, NULL, 0); + } + + + ovsrec_interface_set_link_state(iface->cfg, + netdev_get_carrier(iface->netdev) + ? "up" : "down"); + + error = netdev_get_mtu(iface->netdev, &mtu); + if (!error) { + mtu_64 = mtu; + ovsrec_interface_set_mtu(iface->cfg, &mtu_64, 1); + } + else { + ovsrec_interface_set_mtu(iface->cfg, NULL, 0); + } } static void diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema index 70e56f4c..e078ce00 100644 --- a/vswitchd/vswitch.ovsschema +++ b/vswitchd/vswitch.ovsschema @@ -1,6 +1,6 @@ {"name": "Open_vSwitch", - "version": "1.0.5", - "cksum": "2737967217 14145", + "version": "1.0.6", + "cksum": "271866752 14882", "tables": { "Open_vSwitch": { "columns": { @@ -171,6 +171,27 @@ "ephemeral": true}, "status": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}, + "ephemeral": true}, + "admin_state": { + "type": {"key": {"type": "string", + "enum": ["set", ["up", "down"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "link_state": { + "type": {"key": {"type": "string", + "enum": ["set", ["up", "down"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "link_speed": { + "type": {"key": "integer", "min": 0, "max": 1}, + "ephemeral": true}, + "duplex": { + "type": {"key": {"type": "string", + "enum": ["set", ["half", "full"]]}, + "min": 0, "max": 1}, + "ephemeral": true}, + "mtu": { + "type": {"key": "integer", "min": 0, "max": 1}, "ephemeral": true}}}, "Monitor": { "columns": { diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 53c2650d..d92489ce 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -982,18 +982,77 @@ Configuration options whose interpretation varies based on . + + + +

+ Status information about interfaces attached to bridges, updated every + 5 seconds. Not all interfaces have all of these properties; virtual + interfaces don't have a link speed, for example. Non-applicable + columns will have empty values. +

+ +

+ The administrative state of the physical network link. +

+
+ + +

+ The observed state of the physical network link; + i.e. whether a carrier is detected by the interface. +

+
+ + +

+ The negotiated speed of the physical network link. + Valid values are positive integers greater than 0. +

+
+ + +

+ The duplex mode of the physical network link. +

+
+ + +

+ The MTU (maximum transmission unit); i.e. the largest + amount of data that can fit into a single Ethernet frame. + The standard Ethernet MTU is 1500 bytes. Some physical media + and many kinds of virtual interfaces can be configured with + higher MTUs. +

+

Key-value pairs that report port status. Supported status - values are type-dependent. + values are type-dependent; some interfaces may not have + a valid driver_name, for example.

The currently defined key-value pairs are:

+
+
driver_name
+
The name of the device driver controlling the network + adapter.
+
+
+
driver_version
+
The version string of the device driver controlling the + network adapter.
+
+
+
firmware_version
+
The version string of the network adapter's firmware, if + available.
+
source_ip
The source IP address used for an IPv4 tunnel end-point, - such as gre or capwap. Not - supported by all implementations.
+ such as gre or capwap.
tunnel_egress_iface