Convert net_failover to use the new ndo_update_offloads callback instead of manually calling netdev_compute_master_upper_features() during slave registration/unregistration.
This simplifies the failover code significantly by removing the custom feature computation logic and relying on the centralized feature update mechanism. The callback is automatically invoked during feature updates when upper/lower device links change. Signed-off-by: Hangbin Liu <[email protected]> --- drivers/net/net_failover.c | 64 ++++---------------------------------- include/net/net_failover.h | 7 ----- 2 files changed, 6 insertions(+), 65 deletions(-) diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c index d0361aaf25ef..527175f554a6 100644 --- a/drivers/net/net_failover.c +++ b/drivers/net/net_failover.c @@ -300,6 +300,11 @@ static int net_failover_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, return 0; } +static void failover_update_offloads(struct net_device *dev) +{ + netdev_compute_master_upper_features(dev, true); +} + static const struct net_device_ops failover_dev_ops = { .ndo_open = net_failover_open, .ndo_stop = net_failover_close, @@ -312,6 +317,7 @@ static const struct net_device_ops failover_dev_ops = { .ndo_vlan_rx_kill_vid = net_failover_vlan_rx_kill_vid, .ndo_validate_addr = eth_validate_addr, .ndo_features_check = passthru_features_check, + .ndo_update_offloads = failover_update_offloads, }; #define FAILOVER_NAME "net_failover" @@ -373,61 +379,6 @@ static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb) return RX_HANDLER_ANOTHER; } -static void net_failover_compute_features(struct net_device *dev) -{ - netdev_features_t vlan_features = FAILOVER_VLAN_FEATURES & - NETIF_F_ALL_FOR_ALL; - netdev_features_t enc_features = FAILOVER_ENC_FEATURES; - unsigned short max_hard_header_len = ETH_HLEN; - unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE | - IFF_XMIT_DST_RELEASE_PERM; - struct net_failover_info *nfo_info = netdev_priv(dev); - struct net_device *primary_dev, *standby_dev; - - primary_dev = rcu_dereference(nfo_info->primary_dev); - if (primary_dev) { - vlan_features = - netdev_increment_features(vlan_features, - primary_dev->vlan_features, - FAILOVER_VLAN_FEATURES); - enc_features = - netdev_increment_features(enc_features, - primary_dev->hw_enc_features, - FAILOVER_ENC_FEATURES); - - dst_release_flag &= primary_dev->priv_flags; - if (primary_dev->hard_header_len > max_hard_header_len) - max_hard_header_len = primary_dev->hard_header_len; - } - - standby_dev = rcu_dereference(nfo_info->standby_dev); - if (standby_dev) { - vlan_features = - netdev_increment_features(vlan_features, - standby_dev->vlan_features, - FAILOVER_VLAN_FEATURES); - enc_features = - netdev_increment_features(enc_features, - standby_dev->hw_enc_features, - FAILOVER_ENC_FEATURES); - - dst_release_flag &= standby_dev->priv_flags; - if (standby_dev->hard_header_len > max_hard_header_len) - max_hard_header_len = standby_dev->hard_header_len; - } - - dev->vlan_features = vlan_features; - dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL; - dev->hard_header_len = max_hard_header_len; - - dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; - if (dst_release_flag == (IFF_XMIT_DST_RELEASE | - IFF_XMIT_DST_RELEASE_PERM)) - dev->priv_flags |= IFF_XMIT_DST_RELEASE; - - netdev_change_features(dev); -} - static void net_failover_lower_state_changed(struct net_device *slave_dev, struct net_device *primary_dev, struct net_device *standby_dev) @@ -550,7 +501,6 @@ static int net_failover_slave_register(struct net_device *slave_dev, } net_failover_lower_state_changed(slave_dev, primary_dev, standby_dev); - net_failover_compute_features(failover_dev); call_netdevice_notifiers(NETDEV_JOIN, slave_dev); @@ -621,8 +571,6 @@ static int net_failover_slave_unregister(struct net_device *slave_dev, dev_put(slave_dev); - net_failover_compute_features(failover_dev); - netdev_info(failover_dev, "failover %s slave:%s unregistered\n", slave_is_standby ? "standby" : "primary", slave_dev->name); diff --git a/include/net/net_failover.h b/include/net/net_failover.h index b12a1c469d1c..f0f038d113a0 100644 --- a/include/net/net_failover.h +++ b/include/net/net_failover.h @@ -30,11 +30,4 @@ struct net_failover_info { struct failover *net_failover_create(struct net_device *standby_dev); void net_failover_destroy(struct failover *failover); -#define FAILOVER_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ - NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \ - NETIF_F_HIGHDMA | NETIF_F_LRO) - -#define FAILOVER_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ - NETIF_F_RXCSUM | NETIF_F_ALL_TSO) - #endif /* _NET_FAILOVER_H */ -- 2.50.1

