From 3d9c99ab8ad579dc57a1174cf2aae186b0357522 Mon Sep 17 00:00:00 2001 From: John Hurley Date: Thu, 28 Jun 2018 17:03:05 +0100 Subject: [PATCH] netdev-linux: indicate if netdev is a LAG master If a linux netdev is added to OvS that is a LAG master (for example, a bond or team netdev) then record this in bool form in the dev struct. Use the link info extracted from rtnetlink calls to determine this. Signed-off-by: John Hurley Reviewed-by: Dirk van der Merwe Reviewed-by: Simon Horman Signed-off-by: Jakub Kicinski Signed-off-by: Simon Horman --- lib/netdev-linux.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 8feab9882b5..6ed2f056405 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -509,6 +509,9 @@ struct netdev_linux { int tap_fd; bool present; /* If the device is present in the namespace */ uint64_t tx_dropped; /* tap device can drop if the iface is down */ + + /* LAG information. */ + bool is_lag_master; /* True if the netdev is a LAG master. */ }; struct netdev_rxq_linux { @@ -678,6 +681,16 @@ netdev_linux_miimon_enabled(void) return atomic_count_get(&miimon_cnt) > 0; } +static bool +netdev_linux_kind_is_lag(const char *kind) +{ + if (!strcmp(kind, "bond") || !strcmp(kind, "team")) { + return true; + } + + return false; +} + static void netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED) { @@ -812,6 +825,10 @@ netdev_linux_update__(struct netdev_linux *dev, rtnetlink_report_link(); } + if (change->master && netdev_linux_kind_is_lag(change->master)) { + dev->is_lag_master = true; + } + dev->ifindex = change->if_index; dev->cache_valid |= VALID_IFINDEX; dev->get_ifindex_error = 0; @@ -5764,6 +5781,9 @@ netdev_linux_update_via_netlink(struct netdev_linux *netdev) netdev->get_ifindex_error = 0; changed = true; } + if (change->master && netdev_linux_kind_is_lag(change->master)) { + netdev->is_lag_master = true; + } if (changed) { netdev_change_seq_changed(&netdev->up); }