* Some network devices may not implement support for this function. In such
* cases this function will always return EOPNOTSUPP. */
int
-netdev_get_features(struct netdev *netdev,
+netdev_get_features(const struct netdev *netdev,
uint32_t *current, uint32_t *advertised,
uint32_t *supported, uint32_t *peer)
{
- int (*get_features)(struct netdev *netdev,
+ int (*get_features)(const struct netdev *netdev,
uint32_t *current, uint32_t *advertised,
uint32_t *supported, uint32_t *peer);
uint32_t dummy[4];
return error;
}
-const char *
-netdev_get_tnl_iface(const struct netdev *netdev)
+/* Populates 'sh' with status information.
+ *
+ * Populates 'sh' with 'netdev' specific status information. This information
+ * may be used to populate the status column of the Interface table as defined
+ * in ovs-vswitchd.conf.db(5). */
+int
+netdev_get_status(const struct netdev *netdev, struct shash *sh)
{
struct netdev_dev *dev = netdev_get_dev(netdev);
- return (dev->netdev_class->get_tnl_iface
- ? dev->netdev_class->get_tnl_iface(netdev)
- : NULL);
+ return (dev->netdev_class->get_status
+ ? dev->netdev_class->get_status(netdev, sh)
+ : EOPNOTSUPP);
}
/* If 'netdev' has an assigned IPv6 address, sets '*in6' to that address and
return carrier;
}
+/* Returns true if 'netdev' is up according to its MII. */
+bool
+netdev_get_miimon(const struct netdev *netdev)
+{
+ int error;
+ enum netdev_flags flags;
+ bool miimon;
+
+ netdev_get_flags(netdev, &flags);
+ if (!(flags & NETDEV_UP)) {
+ return false;
+ }
+
+ if (!netdev_get_dev(netdev)->netdev_class->get_miimon) {
+ return true;
+ }
+
+ error = netdev_get_dev(netdev)->netdev_class->get_miimon(netdev, &miimon);
+
+ if (error) {
+ VLOG_DBG("%s: failed to get network device MII status, assuming "
+ "down: %s", netdev_get_name(netdev), strerror(error));
+ miimon = false;
+ }
+
+ return miimon;
+}
+
/* Retrieves current device stats for 'netdev'. */
int
netdev_get_stats(const struct netdev *netdev, struct netdev_stats *stats)