net: Move check for multiple vlans to drivers
authorToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Fri, 27 Mar 2015 05:31:12 +0000 (14:31 +0900)
committerDavid S. Miller <davem@davemloft.net>
Sun, 29 Mar 2015 20:33:22 +0000 (13:33 -0700)
To allow drivers to handle the features check for multiple tags,
move the check to ndo_features_check().
As no drivers currently handle multiple tagged TSO, introduce
dflt_features_check() and call it if the driver does not have
ndo_features_check().

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
include/linux/if_vlan.h
net/core/dev.c

index 9677431c582a663eccffd85dde334f5f713bbf80..039b0c1f480ee002510e623fc6cf2ba52f6b356e 100644 (file)
@@ -12557,6 +12557,7 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb,
                                              struct net_device *dev,
                                              netdev_features_t features)
 {
+       features = vlan_features_check(skb, features);
        return vxlan_features_check(skb, features);
 }
 
index a8339e98ad24ade71ff69f49ff88135221dca079..ebc93a101c9376c56c3ae41c2c03d3787b43c0bb 100644 (file)
@@ -2373,6 +2373,7 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
                                                struct net_device *dev,
                                                netdev_features_t features)
 {
+       features = vlan_features_check(skb, features);
        return vxlan_features_check(skb, features);
 }
 #endif
index a430a34a4434aa78a87cb43d90c805fa83ac8252..367f3976df5690d71ba845214423296913aa07dd 100644 (file)
@@ -507,6 +507,7 @@ static netdev_features_t qlcnic_features_check(struct sk_buff *skb,
                                               struct net_device *dev,
                                               netdev_features_t features)
 {
+       features = vlan_features_check(skb, features);
        return vxlan_features_check(skb, features);
 }
 #endif
index 4265d440ec4d69d1c1a892616fdedf2f35b28a2d..920e4457ce6eab1541a9322595fe2894559ce16f 100644 (file)
@@ -606,4 +606,26 @@ static inline bool skb_vlan_tagged_multi(const struct sk_buff *skb)
        return true;
 }
 
+/**
+ * vlan_features_check - drop unsafe features for skb with multiple tags.
+ * @skb: skbuff to query
+ * @features: features to be checked
+ *
+ * Returns features without unsafe ones if the skb has multiple tags.
+ */
+static inline netdev_features_t vlan_features_check(const struct sk_buff *skb,
+                                                   netdev_features_t features)
+{
+       if (skb_vlan_tagged_multi(skb))
+               features = netdev_intersect_features(features,
+                                                    NETIF_F_SG |
+                                                    NETIF_F_HIGHDMA |
+                                                    NETIF_F_FRAGLIST |
+                                                    NETIF_F_GEN_CSUM |
+                                                    NETIF_F_HW_VLAN_CTAG_TX |
+                                                    NETIF_F_HW_VLAN_STAG_TX);
+
+       return features;
+}
+
 #endif /* !(_LINUX_IF_VLAN_H_) */
index 04bffcd4a48de6300adc3354cc18efc2cb9972ce..cb46badbef5a7d791fdbf374ac06fb61a71d6869 100644 (file)
@@ -2562,6 +2562,13 @@ static netdev_features_t harmonize_features(struct sk_buff *skb,
        return features;
 }
 
+static netdev_features_t dflt_features_check(const struct sk_buff *skb,
+                                            struct net_device *dev,
+                                            netdev_features_t features)
+{
+       return vlan_features_check(skb, features);
+}
+
 netdev_features_t netif_skb_features(struct sk_buff *skb)
 {
        struct net_device *dev = skb->dev;
@@ -2583,22 +2590,12 @@ netdev_features_t netif_skb_features(struct sk_buff *skb)
                                                     dev->vlan_features |
                                                     NETIF_F_HW_VLAN_CTAG_TX |
                                                     NETIF_F_HW_VLAN_STAG_TX);
-       else
-               goto finalize;
 
-       if (skb_vlan_tagged_multi(skb))
-               features = netdev_intersect_features(features,
-                                                    NETIF_F_SG |
-                                                    NETIF_F_HIGHDMA |
-                                                    NETIF_F_FRAGLIST |
-                                                    NETIF_F_GEN_CSUM |
-                                                    NETIF_F_HW_VLAN_CTAG_TX |
-                                                    NETIF_F_HW_VLAN_STAG_TX);
-
-finalize:
        if (dev->netdev_ops->ndo_features_check)
                features &= dev->netdev_ops->ndo_features_check(skb, dev,
                                                                features);
+       else
+               features &= dflt_features_check(skb, dev, features);
 
        return harmonize_features(skb, features);
 }