Skip to content

Commit a25b91f

Browse files
borkmannSasha Levin
authored andcommitted
net, team, bonding: Add netdev_base_features helper
[ Upstream commit d2516c3 ] 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 <[email protected]> Cc: Nikolay Aleksandrov <[email protected]> Cc: Ido Schimmel <[email protected]> Cc: Jiri Pirko <[email protected]> Reviewed-by: Hangbin Liu <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]> Stable-dep-of: d064ea7 ("bonding: Fix initial {vlan,mpls}_feature set in bond_compute_features") Signed-off-by: Sasha Levin <[email protected]>
1 parent 7b13214 commit a25b91f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,9 +1520,7 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
15201520
struct slave *slave;
15211521

15221522
mask = features;
1523-
1524-
features &= ~NETIF_F_ONE_FOR_ALL;
1525-
features |= NETIF_F_ALL_FOR_ALL;
1523+
features = netdev_base_features(features);
15261524

15271525
bond_for_each_slave(bond, slave, iter) {
15281526
features = netdev_increment_features(features,

drivers/net/team/team_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,8 +2012,7 @@ static netdev_features_t team_fix_features(struct net_device *dev,
20122012
netdev_features_t mask;
20132013

20142014
mask = features;
2015-
features &= ~NETIF_F_ONE_FOR_ALL;
2016-
features |= NETIF_F_ALL_FOR_ALL;
2015+
features = netdev_base_features(features);
20172016

20182017
rcu_read_lock();
20192018
list_for_each_entry_rcu(port, &team->port_list, list) {

include/linux/netdev_features.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,11 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
253253
NETIF_F_GSO_UDP_TUNNEL | \
254254
NETIF_F_GSO_UDP_TUNNEL_CSUM)
255255

256+
static inline netdev_features_t netdev_base_features(netdev_features_t features)
257+
{
258+
features &= ~NETIF_F_ONE_FOR_ALL;
259+
features |= NETIF_F_ALL_FOR_ALL;
260+
return features;
261+
}
262+
256263
#endif /* _LINUX_NETDEV_FEATURES_H */

0 commit comments

Comments
 (0)