Skip to content

Commit 3b05aa9

Browse files
Jiawen Wukuba-moo
authored andcommitted
net: wangxun: restrict feature flags for tunnel packets
Implement ndo_features_check to restrict Tx checksum offload flags, since there are some inner layer length and protocols unsupported. Signed-off-by: Jiawen Wu <[email protected]> Reviewed-by: Michal Kubiak <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f294516 commit 3b05aa9

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

drivers/net/ethernet/wangxun/libwx/wx_lib.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,6 +3000,33 @@ netdev_features_t wx_fix_features(struct net_device *netdev,
30003000
}
30013001
EXPORT_SYMBOL(wx_fix_features);
30023002

3003+
#define WX_MAX_TUNNEL_HDR_LEN 80
3004+
netdev_features_t wx_features_check(struct sk_buff *skb,
3005+
struct net_device *netdev,
3006+
netdev_features_t features)
3007+
{
3008+
struct wx *wx = netdev_priv(netdev);
3009+
3010+
if (!skb->encapsulation)
3011+
return features;
3012+
3013+
if (wx->mac.type == wx_mac_em)
3014+
return features & ~NETIF_F_CSUM_MASK;
3015+
3016+
if (unlikely(skb_inner_mac_header(skb) - skb_transport_header(skb) >
3017+
WX_MAX_TUNNEL_HDR_LEN))
3018+
return features & ~NETIF_F_CSUM_MASK;
3019+
3020+
if (skb->inner_protocol_type == ENCAP_TYPE_ETHER &&
3021+
skb->inner_protocol != htons(ETH_P_IP) &&
3022+
skb->inner_protocol != htons(ETH_P_IPV6) &&
3023+
skb->inner_protocol != htons(ETH_P_TEB))
3024+
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
3025+
3026+
return features;
3027+
}
3028+
EXPORT_SYMBOL(wx_features_check);
3029+
30033030
void wx_set_ring(struct wx *wx, u32 new_tx_count,
30043031
u32 new_rx_count, struct wx_ring *temp_ring)
30053032
{

drivers/net/ethernet/wangxun/libwx/wx_lib.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ void wx_get_stats64(struct net_device *netdev,
3333
int wx_set_features(struct net_device *netdev, netdev_features_t features);
3434
netdev_features_t wx_fix_features(struct net_device *netdev,
3535
netdev_features_t features);
36+
netdev_features_t wx_features_check(struct sk_buff *skb,
37+
struct net_device *netdev,
38+
netdev_features_t features);
3639
void wx_set_ring(struct wx *wx, u32 new_tx_count,
3740
u32 new_rx_count, struct wx_ring *temp_ring);
3841

drivers/net/ethernet/wangxun/ngbe/ngbe_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ static const struct net_device_ops ngbe_netdev_ops = {
587587
.ndo_set_rx_mode = wx_set_rx_mode,
588588
.ndo_set_features = wx_set_features,
589589
.ndo_fix_features = wx_fix_features,
590+
.ndo_features_check = wx_features_check,
590591
.ndo_validate_addr = eth_validate_addr,
591592
.ndo_set_mac_address = wx_set_mac,
592593
.ndo_get_stats64 = wx_get_stats64,

drivers/net/ethernet/wangxun/txgbe/txgbe_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ static const struct net_device_ops txgbe_netdev_ops = {
579579
.ndo_set_rx_mode = wx_set_rx_mode,
580580
.ndo_set_features = wx_set_features,
581581
.ndo_fix_features = wx_fix_features,
582+
.ndo_features_check = wx_features_check,
582583
.ndo_validate_addr = eth_validate_addr,
583584
.ndo_set_mac_address = wx_set_mac,
584585
.ndo_get_stats64 = wx_get_stats64,

0 commit comments

Comments
 (0)