hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/net/8021q/vlan.h
....@@ -36,7 +36,7 @@
3636 struct rcu_head rcu;
3737 };
3838
39
-static inline unsigned int vlan_proto_idx(__be16 proto)
39
+static inline int vlan_proto_idx(__be16 proto)
4040 {
4141 switch (proto) {
4242 case htons(ETH_P_8021Q):
....@@ -44,8 +44,8 @@
4444 case htons(ETH_P_8021AD):
4545 return VLAN_PROTO_8021AD;
4646 default:
47
- BUG();
48
- return 0;
47
+ WARN(1, "invalid VLAN protocol: 0x%04x\n", ntohs(proto));
48
+ return -EINVAL;
4949 }
5050 }
5151
....@@ -64,17 +64,24 @@
6464 __be16 vlan_proto,
6565 u16 vlan_id)
6666 {
67
- return __vlan_group_get_device(vg, vlan_proto_idx(vlan_proto), vlan_id);
67
+ int pidx = vlan_proto_idx(vlan_proto);
68
+
69
+ if (pidx < 0)
70
+ return NULL;
71
+
72
+ return __vlan_group_get_device(vg, pidx, vlan_id);
6873 }
6974
7075 static inline void vlan_group_set_device(struct vlan_group *vg,
7176 __be16 vlan_proto, u16 vlan_id,
7277 struct net_device *dev)
7378 {
79
+ int pidx = vlan_proto_idx(vlan_proto);
7480 struct net_device **array;
75
- if (!vg)
81
+
82
+ if (!vg || pidx < 0)
7683 return;
77
- array = vg->vlan_devices_arrays[vlan_proto_idx(vlan_proto)]
84
+ array = vg->vlan_devices_arrays[pidx]
7885 [vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
7986 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
8087 }
....@@ -92,6 +99,18 @@
9299 return NULL;
93100 }
94101
102
+static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev)
103
+{
104
+ netdev_features_t ret;
105
+
106
+ ret = real_dev->hw_enc_features &
107
+ (NETIF_F_CSUM_MASK | NETIF_F_ALL_TSO | NETIF_F_GSO_ENCAP_ALL);
108
+
109
+ if ((ret & NETIF_F_GSO_ENCAP_ALL) && (ret & NETIF_F_CSUM_MASK))
110
+ return (ret & ~NETIF_F_CSUM_MASK) | NETIF_F_HW_CSUM;
111
+ return 0;
112
+}
113
+
95114 #define vlan_group_for_each_dev(grp, i, dev) \
96115 for ((i) = 0; i < VLAN_PROTO_NUM * VLAN_N_VID; i++) \
97116 if (((dev) = __vlan_group_get_device((grp), (i) / VLAN_N_VID, \