2 #include <linux/netdevice.h>
3 #include <linux/if_vlan.h>
5 #include <linux/export.h>
15 vlan_dev = vlan_find_dev(skb->
dev, vlan_id);
19 skb = *skbp = skb_share_check(skb,
GFP_ATOMIC);
33 unsigned int offset = skb->
data - skb_mac_header(skb);
41 skb = *skbp = vlan_insert_tag(skb, skb->
vlan_tci);
45 skb_reset_mac_len(skb);
53 u64_stats_update_begin(&rx_stats->
syncp);
58 u64_stats_update_end(&rx_stats->
syncp);
70 return vlan_group_get_device(&vlan_info->
grp, vlan_id);
76 if (netif_is_bond_slave(real_dev))
98 if (skb_cow(skb, skb_headroom(skb)) < 0)
124 __vlan_hwaccel_put_tag(skb, vlan_tci);
127 vlan_set_encap_proto(skb, vhdr);
129 skb = vlan_reorder_header(skb);
133 skb_reset_network_header(skb);
134 skb_reset_transport_header(skb);
135 skb_reset_mac_len(skb);
149 static void vlan_group_free(
struct vlan_group *grp)
159 vlan_group_free(&vlan_info->
grp);
163 static void vlan_info_rcu_free(
struct rcu_head *rcu)
172 vlan_info = kzalloc(
sizeof(
struct vlan_info),
GFP_KERNEL);
177 INIT_LIST_HEAD(&vlan_info->
vid_list);
187 static struct vlan_vid_info *vlan_vid_info_get(
struct vlan_info *vlan_info,
193 if (vid_info->
vid == vid)
211 static int __vlan_vid_add(
struct vlan_info *vlan_info,
unsigned short vid,
219 vid_info = vlan_vid_info_alloc(vid);
233 *pvid_info = vid_info;
239 struct vlan_info *vlan_info;
241 bool vlan_info_created =
false;
248 vlan_info = vlan_info_alloc(dev);
251 vlan_info_created =
true;
253 vid_info = vlan_vid_info_get(vlan_info, vid);
255 err = __vlan_vid_add(vlan_info, vid, &vid_info);
257 goto out_free_vlan_info;
261 if (vlan_info_created)
267 if (vlan_info_created)
273 static void __vlan_vid_del(
struct vlan_info *vlan_info,
278 unsigned short vid = vid_info->
vid;
285 pr_warn(
"failed to kill vid %d for device %s\n",
296 struct vlan_info *vlan_info;
305 vid_info = vlan_vid_info_get(vlan_info, vid);
310 __vlan_vid_del(vlan_info, vid_info);
323 struct vlan_info *vlan_info;
354 struct vlan_info *vlan_info;
369 struct vlan_info *vlan_info;
376 return vlan_info->
grp.nr_vlan_devs ?
true :
false;