diff options
Diffstat (limited to 'net/8021q')
-rw-r--r-- | net/8021q/vlan.c | 38 | ||||
-rw-r--r-- | net/8021q/vlan_dev.c | 14 | ||||
-rw-r--r-- | net/8021q/vlanproc.c | 2 |
3 files changed, 32 insertions, 22 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index b33410abfd6b..5975ec3be7f3 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -106,29 +106,35 @@ static void vlan_group_free(struct vlan_group *grp) | |||
106 | static struct vlan_group *vlan_group_alloc(int ifindex) | 106 | static struct vlan_group *vlan_group_alloc(int ifindex) |
107 | { | 107 | { |
108 | struct vlan_group *grp; | 108 | struct vlan_group *grp; |
109 | unsigned int size; | ||
110 | unsigned int i; | ||
111 | 109 | ||
112 | grp = kzalloc(sizeof(struct vlan_group), GFP_KERNEL); | 110 | grp = kzalloc(sizeof(struct vlan_group), GFP_KERNEL); |
113 | if (!grp) | 111 | if (!grp) |
114 | return NULL; | 112 | return NULL; |
115 | 113 | ||
116 | size = sizeof(struct net_device *) * VLAN_GROUP_ARRAY_PART_LEN; | ||
117 | |||
118 | for (i = 0; i < VLAN_GROUP_ARRAY_SPLIT_PARTS; i++) { | ||
119 | grp->vlan_devices_arrays[i] = kzalloc(size, GFP_KERNEL); | ||
120 | if (!grp->vlan_devices_arrays[i]) | ||
121 | goto err; | ||
122 | } | ||
123 | |||
124 | grp->real_dev_ifindex = ifindex; | 114 | grp->real_dev_ifindex = ifindex; |
125 | hlist_add_head_rcu(&grp->hlist, | 115 | hlist_add_head_rcu(&grp->hlist, |
126 | &vlan_group_hash[vlan_grp_hashfn(ifindex)]); | 116 | &vlan_group_hash[vlan_grp_hashfn(ifindex)]); |
127 | return grp; | 117 | return grp; |
118 | } | ||
128 | 119 | ||
129 | err: | 120 | static int vlan_group_prealloc_vid(struct vlan_group *vg, int vid) |
130 | vlan_group_free(grp); | 121 | { |
131 | return NULL; | 122 | struct net_device **array; |
123 | unsigned int size; | ||
124 | |||
125 | ASSERT_RTNL(); | ||
126 | |||
127 | array = vg->vlan_devices_arrays[vid / VLAN_GROUP_ARRAY_PART_LEN]; | ||
128 | if (array != NULL) | ||
129 | return 0; | ||
130 | |||
131 | size = sizeof(struct net_device *) * VLAN_GROUP_ARRAY_PART_LEN; | ||
132 | array = kzalloc(size, GFP_KERNEL); | ||
133 | if (array == NULL) | ||
134 | return -ENOBUFS; | ||
135 | |||
136 | vg->vlan_devices_arrays[vid / VLAN_GROUP_ARRAY_PART_LEN] = array; | ||
137 | return 0; | ||
132 | } | 138 | } |
133 | 139 | ||
134 | static void vlan_rcu_free(struct rcu_head *rcu) | 140 | static void vlan_rcu_free(struct rcu_head *rcu) |
@@ -247,6 +253,10 @@ int register_vlan_dev(struct net_device *dev) | |||
247 | return -ENOBUFS; | 253 | return -ENOBUFS; |
248 | } | 254 | } |
249 | 255 | ||
256 | err = vlan_group_prealloc_vid(grp, vlan_id); | ||
257 | if (err < 0) | ||
258 | goto out_free_group; | ||
259 | |||
250 | err = register_netdevice(dev); | 260 | err = register_netdevice(dev); |
251 | if (err < 0) | 261 | if (err < 0) |
252 | goto out_free_group; | 262 | goto out_free_group; |
@@ -394,7 +404,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, | |||
394 | int i, flgs; | 404 | int i, flgs; |
395 | struct net_device *vlandev; | 405 | struct net_device *vlandev; |
396 | 406 | ||
397 | if (dev->nd_net != &init_net) | 407 | if (dev_net(dev) != &init_net) |
398 | return NOTIFY_DONE; | 408 | return NOTIFY_DONE; |
399 | 409 | ||
400 | if (is_vlan_dev(dev)) { | 410 | if (is_vlan_dev(dev)) { |
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 480ea90e7dcd..0e3b2d3e2339 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -153,7 +153,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
153 | struct net_device_stats *stats; | 153 | struct net_device_stats *stats; |
154 | unsigned short vlan_TCI; | 154 | unsigned short vlan_TCI; |
155 | 155 | ||
156 | if (dev->nd_net != &init_net) | 156 | if (dev_net(dev) != &init_net) |
157 | goto err_free; | 157 | goto err_free; |
158 | 158 | ||
159 | skb = skb_share_check(skb, GFP_ATOMIC); | 159 | skb = skb_share_check(skb, GFP_ATOMIC); |
@@ -171,7 +171,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
171 | skb->dev = __find_vlan_dev(dev, vid); | 171 | skb->dev = __find_vlan_dev(dev, vid); |
172 | if (!skb->dev) { | 172 | if (!skb->dev) { |
173 | pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n", | 173 | pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n", |
174 | __FUNCTION__, (unsigned int)vid, dev->name); | 174 | __func__, (unsigned int)vid, dev->name); |
175 | goto err_unlock; | 175 | goto err_unlock; |
176 | } | 176 | } |
177 | 177 | ||
@@ -187,7 +187,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
187 | ntohs(vhdr->h_vlan_TCI)); | 187 | ntohs(vhdr->h_vlan_TCI)); |
188 | 188 | ||
189 | pr_debug("%s: priority: %u for TCI: %hu\n", | 189 | pr_debug("%s: priority: %u for TCI: %hu\n", |
190 | __FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI)); | 190 | __func__, skb->priority, ntohs(vhdr->h_vlan_TCI)); |
191 | 191 | ||
192 | switch (skb->pkt_type) { | 192 | switch (skb->pkt_type) { |
193 | case PACKET_BROADCAST: /* Yeah, stats collect these together.. */ | 193 | case PACKET_BROADCAST: /* Yeah, stats collect these together.. */ |
@@ -268,7 +268,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, | |||
268 | struct net_device *vdev = dev; | 268 | struct net_device *vdev = dev; |
269 | 269 | ||
270 | pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n", | 270 | pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n", |
271 | __FUNCTION__, skb, type, len, vlan_dev_info(dev)->vlan_id, | 271 | __func__, skb, type, len, vlan_dev_info(dev)->vlan_id, |
272 | daddr); | 272 | daddr); |
273 | 273 | ||
274 | /* build vlan header only if re_order_header flag is NOT set. This | 274 | /* build vlan header only if re_order_header flag is NOT set. This |
@@ -340,7 +340,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, | |||
340 | return -ENOMEM; | 340 | return -ENOMEM; |
341 | } | 341 | } |
342 | vlan_dev_info(vdev)->cnt_inc_headroom_on_tx++; | 342 | vlan_dev_info(vdev)->cnt_inc_headroom_on_tx++; |
343 | pr_debug("%s: %s: had to grow skb\n", __FUNCTION__, vdev->name); | 343 | pr_debug("%s: %s: had to grow skb\n", __func__, vdev->name); |
344 | } | 344 | } |
345 | 345 | ||
346 | if (build_vlan_header) { | 346 | if (build_vlan_header) { |
@@ -382,7 +382,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
382 | vlan_dev_info(dev)->cnt_encap_on_xmit++; | 382 | vlan_dev_info(dev)->cnt_encap_on_xmit++; |
383 | 383 | ||
384 | pr_debug("%s: proto to encap: 0x%hx\n", | 384 | pr_debug("%s: proto to encap: 0x%hx\n", |
385 | __FUNCTION__, ntohs(veth->h_vlan_proto)); | 385 | __func__, ntohs(veth->h_vlan_proto)); |
386 | /* Construct the second two bytes. This field looks something | 386 | /* Construct the second two bytes. This field looks something |
387 | * like: | 387 | * like: |
388 | * usr_priority: 3 bits (high bits) | 388 | * usr_priority: 3 bits (high bits) |
@@ -403,7 +403,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
403 | } | 403 | } |
404 | 404 | ||
405 | pr_debug("%s: about to send skb: %p to dev: %s\n", | 405 | pr_debug("%s: about to send skb: %p to dev: %s\n", |
406 | __FUNCTION__, skb, skb->dev->name); | 406 | __func__, skb, skb->dev->name); |
407 | pr_debug(" " MAC_FMT " " MAC_FMT " %4hx %4hx %4hx\n", | 407 | pr_debug(" " MAC_FMT " " MAC_FMT " %4hx %4hx %4hx\n", |
408 | veth->h_dest[0], veth->h_dest[1], veth->h_dest[2], | 408 | veth->h_dest[0], veth->h_dest[1], veth->h_dest[2], |
409 | veth->h_dest[3], veth->h_dest[4], veth->h_dest[5], | 409 | veth->h_dest[3], veth->h_dest[4], veth->h_dest[5], |
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index 9671aa51af2c..24cd96ee8109 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c | |||
@@ -168,7 +168,7 @@ int __init vlan_proc_init(void) | |||
168 | return 0; | 168 | return 0; |
169 | 169 | ||
170 | err: | 170 | err: |
171 | pr_err("%s: can't create entry in proc filesystem!\n", __FUNCTION__); | 171 | pr_err("%s: can't create entry in proc filesystem!\n", __func__); |
172 | vlan_proc_cleanup(); | 172 | vlan_proc_cleanup(); |
173 | return -ENOBUFS; | 173 | return -ENOBUFS; |
174 | } | 174 | } |