]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net, team, bonding: Add netdev_base_features helper
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 10 Dec 2024 14:12:41 +0000 (15:12 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 12 Dec 2024 10:59:18 +0000 (11:59 +0100)
Both bonding and team driver have logic to derive the base feature
flags before iterating over their slave devices to refine the set
via netdev_increment_features().

Add a small helper netdev_base_features() so this can be reused
instead of having it open-coded multiple times.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
Cc: Ido Schimmel <idosch@idosch.org>
Cc: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20241210141245.327886-1-daniel@iogearbox.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/bonding/bond_main.c
drivers/net/team/team_core.c
include/linux/netdev_features.h

index 49dd4fe195e5788f8e4e0c4cdfa065accd9ee816..42c835c60cd80617f296d298bb82ef26199b4af4 100644 (file)
@@ -1520,9 +1520,7 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
        struct slave *slave;
 
        mask = features;
-
-       features &= ~NETIF_F_ONE_FOR_ALL;
-       features |= NETIF_F_ALL_FOR_ALL;
+       features = netdev_base_features(features);
 
        bond_for_each_slave(bond, slave, iter) {
                features = netdev_increment_features(features,
index a1b27b69f010533d4bbd4d7f1e314d2582eb8133..1df062c676408705ee43294bc0685b4cefabdf09 100644 (file)
@@ -2011,8 +2011,7 @@ static netdev_features_t team_fix_features(struct net_device *dev,
        netdev_features_t mask;
 
        mask = features;
-       features &= ~NETIF_F_ONE_FOR_ALL;
-       features |= NETIF_F_ALL_FOR_ALL;
+       features = netdev_base_features(features);
 
        rcu_read_lock();
        list_for_each_entry_rcu(port, &team->port_list, list) {
index 66e7d26b70a4fe575608bfb02a2dbd262370e714..11be70a7929f2891610399367e529062d32f0272 100644 (file)
@@ -253,4 +253,11 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
                                 NETIF_F_GSO_UDP_TUNNEL |               \
                                 NETIF_F_GSO_UDP_TUNNEL_CSUM)
 
+static inline netdev_features_t netdev_base_features(netdev_features_t features)
+{
+       features &= ~NETIF_F_ONE_FOR_ALL;
+       features |= NETIF_F_ALL_FOR_ALL;
+       return features;
+}
+
 #endif /* _LINUX_NETDEV_FEATURES_H */