From 65c3058c22803c7e8d8fd0bfbb84fe27456fb137 Mon Sep 17 00:00:00 2001
From: Ethan Jackson
Date: Fri, 14 Oct 2011 12:49:57 -0700
Subject: [PATCH] vswitchd: New column "link_resets".
An interface's 'link_resets' column represents the number of times
Open vSwitch has observed its link_state change.
---
lib/netdev-dummy.c | 1 +
lib/netdev-linux.c | 10 ++++++++++
lib/netdev-provider.h | 6 ++++++
lib/netdev-vport.c | 1 +
lib/netdev.c | 9 +++++++++
lib/netdev.h | 1 +
vswitchd/bridge.c | 5 +++++
vswitchd/vswitch.ovsschema | 8 ++++++--
vswitchd/vswitch.xml | 7 +++++++
9 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 7c301809..f62ea53e 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -270,6 +270,7 @@ static const struct netdev_class dummy_class = {
netdev_dummy_set_mtu,
NULL, /* get_ifindex */
NULL, /* get_carrier */
+ NULL, /* get_carrier_resets */
NULL, /* get_miimon */
netdev_dummy_get_stats,
netdev_dummy_set_stats,
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index fb46561b..8329f226 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -366,6 +366,7 @@ struct netdev_dev_linux {
struct in6_addr in6;
int mtu;
bool carrier;
+ long long int carrier_resets;
uint32_t kbits_rate; /* Policing data. */
uint32_t kbits_burst;
bool have_vport_stats;
@@ -505,6 +506,7 @@ netdev_linux_cache_cb(const struct rtnetlink_link_change *change,
if (dev->carrier != change->running) {
dev->carrier = change->running;
+ dev->carrier_resets++;
}
netdev_dev_linux_changed(dev);
@@ -524,6 +526,7 @@ netdev_linux_cache_cb(const struct rtnetlink_link_change *change,
get_carrier_via_sysfs(node->name, &carrier);
if (dev->carrier != carrier) {
dev->carrier = carrier;
+ dev->carrier_resets++;
}
netdev_dev_linux_changed(dev);
@@ -1041,6 +1044,12 @@ netdev_linux_get_carrier(const struct netdev *netdev_, bool *carrier)
return 0;
}
+static long long int
+netdev_linux_get_carrier_resets(const struct netdev *netdev)
+{
+ return netdev_dev_linux_cast(netdev_get_dev(netdev))->carrier_resets;
+}
+
static int
netdev_linux_do_miimon(const char *name, int cmd, const char *cmd_name,
struct mii_ioctl_data *data)
@@ -2315,6 +2324,7 @@ netdev_linux_change_seq(const struct netdev *netdev)
netdev_linux_set_mtu, \
netdev_linux_get_ifindex, \
netdev_linux_get_carrier, \
+ netdev_linux_get_carrier_resets, \
netdev_linux_set_miimon_interval, \
GET_STATS, \
SET_STATS, \
diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 06312293..921c3974 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -270,6 +270,12 @@ struct netdev_class {
*/
int (*get_carrier)(const struct netdev *netdev, bool *carrier);
+ /* Returns the number of times 'netdev''s carrier has changed since being
+ * initialized.
+ *
+ * If null, callers will assume the number of carrier resets is zero. */
+ long long int (*get_carrier_resets)(const struct netdev *netdev);
+
/* Forces ->get_carrier() to poll 'netdev''s MII registers for link status
* instead of checking 'netdev''s carrier. 'netdev''s MII registers will
* be polled once ever 'interval' milliseconds. If 'netdev' does not
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 301bb43d..0577bd3b 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -906,6 +906,7 @@ unparse_patch_config(const char *name OVS_UNUSED, const char *type OVS_UNUSED,
NULL, /* set_mtu */ \
NULL, /* get_ifindex */ \
NULL, /* get_carrier */ \
+ NULL, /* get_carrier_resets */ \
NULL, /* get_miimon */ \
netdev_vport_get_stats, \
netdev_vport_set_stats, \
diff --git a/lib/netdev.c b/lib/netdev.c
index 70f9678b..9f15b72a 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -892,6 +892,15 @@ netdev_get_carrier(const struct netdev *netdev)
return carrier;
}
+/* Returns the number of times 'netdev''s carrier has changed. */
+long long int
+netdev_get_carrier_resets(const struct netdev *netdev)
+{
+ return (netdev_get_dev(netdev)->netdev_class->get_carrier_resets
+ ? netdev_get_dev(netdev)->netdev_class->get_carrier_resets(netdev)
+ : 0);
+}
+
/* Attempts to force netdev_get_carrier() to poll 'netdev''s MII registers for
* link status instead of checking 'netdev''s carrier. 'netdev''s MII
* registers will be polled once ever 'interval' milliseconds. If 'netdev'
diff --git a/lib/netdev.h b/lib/netdev.h
index f9add0be..85be394c 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -118,6 +118,7 @@ int netdev_get_etheraddr(const struct netdev *, uint8_t mac[6]);
/* PHY interface. */
bool netdev_get_carrier(const struct netdev *);
+long long int netdev_get_carrier_resets(const struct netdev *);
int netdev_set_miimon_interval(struct netdev *, long long int interval);
int netdev_get_features(const struct netdev *,
uint32_t *current, uint32_t *advertised,
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index b3c62187..d4335c10 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -238,6 +238,7 @@ bridge_init(const char *remote)
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_duplex);
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_speed);
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_mtu);
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_ofport);
ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_statistics);
@@ -1574,6 +1575,7 @@ bridge_run(void)
HMAP_FOR_EACH (iface, name_node, &br->iface_by_name) {
const char *link_state;
+ int64_t link_resets;
int current;
if (iface_is_synthetic(iface)) {
@@ -1591,6 +1593,9 @@ bridge_run(void)
link_state = netdev_get_carrier(iface->netdev) ? "up" : "down";
ovsrec_interface_set_link_state(iface->cfg, link_state);
+
+ link_resets = netdev_get_carrier_resets(iface->netdev);
+ ovsrec_interface_set_link_resets(iface->cfg, &link_resets, 1);
}
}
diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema
index b32e26b2..5fce9890 100644
--- a/vswitchd/vswitch.ovsschema
+++ b/vswitchd/vswitch.ovsschema
@@ -1,6 +1,6 @@
{"name": "Open_vSwitch",
- "version": "6.1.1",
- "cksum": "282564184 14747",
+ "version": "6.2.0",
+ "cksum": "212779557 14885",
"tables": {
"Open_vSwitch": {
"columns": {
@@ -209,6 +209,10 @@
"enum": ["set", ["up", "down"]]},
"min": 0, "max": 1},
"ephemeral": true},
+ "link_resets": {
+ "type": {"key": {"type": "integer"},
+ "min": 0, "max": 1},
+ "ephemeral": true},
"link_speed": {
"type": {"key": "integer", "min": 0, "max": 1},
"ephemeral": true},
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index d579b872..683b27ea 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -1181,6 +1181,13 @@
+
+
+ The number of times Open vSwitch has observed the
+ of this change.
+
+
+
The negotiated speed of the physical network link.
--
2.30.2