A port can be configured to use miimon reporting as the criterion for
enabling or disabling an interface, but in some cases (such as for reading
the initial link status) the code was reading the carrier status instead.
This commit fixes the problem.
This changes the meaning of the link_status column in the Interface table.
I don't think that the old meaning was useful to the controller in the
case of a bond configured for miimon monitoring, because the controller
could not use it to detect which interfaces the bond considered to be up
or down.
static void iface_update_cfm(struct iface *);
static void iface_refresh_cfm_stats(struct iface *iface);
static void iface_send_packet(struct iface *, struct ofpbuf *packet);
static void iface_update_cfm(struct iface *);
static void iface_refresh_cfm_stats(struct iface *iface);
static void iface_send_packet(struct iface *, struct ofpbuf *packet);
-static void iface_update_carrier(struct iface *, bool carrier);
+static void iface_update_carrier(struct iface *);
+static bool iface_get_carrier(const struct iface *);
static void shash_from_ovs_idl_map(char **keys, char **values, size_t n,
struct shash *);
static void shash_from_ovs_idl_map(char **keys, char **values, size_t n,
struct shash *);
/* Update 'iface'. */
if (iface) {
iface->netdev = netdev;
/* Update 'iface'. */
if (iface) {
iface->netdev = netdev;
- iface->enabled = netdev_get_carrier(iface->netdev);
+ iface->enabled = iface_get_carrier(iface);
iface->up = iface->enabled;
}
} else if (iface && iface->netdev) {
iface->up = iface->enabled;
}
} else if (iface && iface->netdev) {
ovsrec_interface_set_link_state(iface->cfg,
ovsrec_interface_set_link_state(iface->cfg,
- netdev_get_carrier(iface->netdev)
- ? "up" : "down");
+ iface_get_carrier(iface) ? "up" : "down");
error = netdev_get_mtu(iface->netdev, &mtu);
if (!error && mtu != INT_MAX) {
error = netdev_get_mtu(iface->netdev, &mtu);
if (!error && mtu != INT_MAX) {
iface = port_lookup_iface(port, devname);
if (iface) {
iface = port_lookup_iface(port, devname);
if (iface) {
- iface_update_carrier(iface, netdev_get_carrier(iface->netdev));
+ iface_update_carrier(iface);
for (i = 0; i < port->n_ifaces; i++) {
struct iface *iface = port->ifaces[i];
for (i = 0; i < port->n_ifaces; i++) {
struct iface *iface = port->ifaces[i];
- iface_update_carrier(iface, netdev_get_miimon(iface->netdev));
+ iface_update_carrier(iface);
}
port->miimon_next_update = time_msec() + port->miimon_interval;
}
}
port->miimon_next_update = time_msec() + port->miimon_interval;
}
-iface_update_carrier(struct iface *iface, bool carrier)
+iface_update_carrier(struct iface *iface)
+ bool carrier = iface_get_carrier(iface);
if (carrier == iface->up) {
return;
}
if (carrier == iface->up) {
return;
}
+
+/* Read carrier or miimon status directly from 'iface''s netdev, according to
+ * how 'iface''s port is configured.
+ *
+ * Returns true if 'iface' is up, false otherwise. */
+static bool
+iface_get_carrier(const struct iface *iface)
+{
+ return (iface->port->monitor
+ ? netdev_get_carrier(iface->netdev)
+ : netdev_get_miimon(iface->netdev));
+}
<column name="link_state">
<p>
<column name="link_state">
<p>
- The observed state of the physical network link;
- i.e. whether a carrier is detected by the interface.
+ The observed state of the physical network link. This is ordinarily
+ the link's carrier status. If the interface's <ref table="Port"/> is
+ a bond configured for miimon monitoring, it is instead the network
+ link's miimon status.