From: Neil McKee Date: Mon, 8 Jul 2013 20:36:06 +0000 (-0700) Subject: bridge: Add ifindex column to Interface table. X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ea401d9ace433e73f2cdd05dfde5debf506b6c5d;p=sliver-openvswitch.git bridge: Add ifindex column to Interface table. This commit adds an "ifindex" column to the "Interface" table in the db. Signed-off-by: Neil McKee Signed-off-by: Ben Pfaff --- diff --git a/NEWS b/NEWS index b07a65162..6ecf8b4a0 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ post-v1.11.0 * New support for matching outer source and destination IP address of tunneled packets, for tunnel ports configured with the newly added "remote_ip=flow" and "local_ip=flow" options. + - The Interface table in the database has a new "ifindex" column to + report the interface's OS-assigned ifindex. - New "check-oftest" Makefile target for running OFTest against Open vSwitch. See README-OFTest for details. - The flow eviction threshold has been moved to the Open_vSwitch table. diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 28bf082ea..686eb9300 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -367,6 +367,7 @@ bridge_init(const char *remote) ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_state); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_resets); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_mac_in_use); + ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_ifindex); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_mtu); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_ofport); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_statistics); @@ -1810,6 +1811,7 @@ iface_refresh_status(struct iface *iface) int mtu; int64_t mtu_64; uint8_t mac[ETH_ADDR_LEN]; + int64_t ifindex64; int error; if (iface_is_synthetic(iface)) { @@ -1855,6 +1857,14 @@ iface_refresh_status(struct iface *iface) } else { ovsrec_interface_set_mac_in_use(iface->cfg, NULL); } + + /* The netdev may return a negative number (such as -EOPNOTSUPP) + * if there is no valid ifindex number. */ + ifindex64 = netdev_get_ifindex(iface->netdev); + if (ifindex64 < 0) { + ifindex64 = 0; + } + ovsrec_interface_set_ifindex(iface->cfg, &ifindex64, 1); } /* Writes 'iface''s CFM statistics to the database. 'iface' must not be @@ -3573,6 +3583,7 @@ iface_clear_db_record(const struct ovsrec_interface *if_cfg) ovsrec_interface_set_cfm_remote_mpids(if_cfg, NULL, 0); ovsrec_interface_set_lacp_current(if_cfg, NULL, 0); ovsrec_interface_set_statistics(if_cfg, NULL, NULL, 0); + ovsrec_interface_set_ifindex(if_cfg, NULL, 0); } } diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema index bb3ca48b4..d51085121 100644 --- a/vswitchd/vswitch.ovsschema +++ b/vswitchd/vswitch.ovsschema @@ -1,6 +1,6 @@ {"name": "Open_vSwitch", - "version": "7.2.0", - "cksum": "543912409 19436", + "version": "7.2.1", + "cksum": "707387125 19667", "tables": { "Open_vSwitch": { "columns": { @@ -185,6 +185,14 @@ "mac": { "type": {"key": {"type": "string"}, "min": 0, "max": 1}}, + "ifindex": { + "type": { + "key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4294967295}, + "min": 0, + "max": 1}, + "ephemeral": true}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, "ofport": { diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 12780d6c1..6c08f7014 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -1208,6 +1208,12 @@ on a host. + + A positive interface index as defined for SNMP MIB-II in RFCs 1213 and + 2863, if the interface has one, otherwise 0. The ifindex is useful for + seamless integration with protocols such as SNMP and sFlow. + + The MAC address in use by this interface.