aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q/vlan_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/8021q/vlan_dev.c')
-rw-r--r--net/8021q/vlan_dev.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index a846559da85e..2ff7659b5e5f 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -106,13 +106,13 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
106 * SANITY NOTE 2: We are referencing to the VLAN_HDR frields, which MAY be 106 * SANITY NOTE 2: We are referencing to the VLAN_HDR frields, which MAY be
107 * stored UNALIGNED in the memory. RISC systems don't like 107 * stored UNALIGNED in the memory. RISC systems don't like
108 * such cases very much... 108 * such cases very much...
109 * SANITY NOTE 2a: According to Dave Miller & Alexey, it will always be aligned, 109 * SANITY NOTE 2a: According to Dave Miller & Alexey, it will always be
110 * so there doesn't need to be any of the unaligned stuff. It has 110 * aligned, so there doesn't need to be any of the unaligned
111 * been commented out now... --Ben 111 * stuff. It has been commented out now... --Ben
112 * 112 *
113 */ 113 */
114int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, 114int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
115 struct packet_type* ptype, struct net_device *orig_dev) 115 struct packet_type *ptype, struct net_device *orig_dev)
116{ 116{
117 unsigned char *rawp = NULL; 117 unsigned char *rawp = NULL;
118 struct vlan_hdr *vhdr; 118 struct vlan_hdr *vhdr;
@@ -126,7 +126,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
126 return -1; 126 return -1;
127 } 127 }
128 128
129 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) 129 skb = skb_share_check(skb, GFP_ATOMIC);
130 if (skb == NULL)
130 return -1; 131 return -1;
131 132
132 if (unlikely(!pskb_may_pull(skb, VLAN_HLEN))) { 133 if (unlikely(!pskb_may_pull(skb, VLAN_HLEN))) {
@@ -156,8 +157,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
156 skb->dev = __find_vlan_dev(dev, vid); 157 skb->dev = __find_vlan_dev(dev, vid);
157 if (!skb->dev) { 158 if (!skb->dev) {
158 rcu_read_unlock(); 159 rcu_read_unlock();
159 pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s [%i]\n", 160 pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n",
160 __FUNCTION__, (unsigned int)vid, dev->name, dev->ifindex); 161 __FUNCTION__, (unsigned int)vid, dev->name);
161 kfree_skb(skb); 162 kfree_skb(skb);
162 return -1; 163 return -1;
163 } 164 }
@@ -175,7 +176,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
175 /* 176 /*
176 * Deal with ingress priority mapping. 177 * Deal with ingress priority mapping.
177 */ 178 */
178 skb->priority = vlan_get_ingress_priority(skb->dev, ntohs(vhdr->h_vlan_TCI)); 179 skb->priority = vlan_get_ingress_priority(skb->dev,
180 ntohs(vhdr->h_vlan_TCI));
179 181
180 pr_debug("%s: priority: %u for TCI: %hu\n", 182 pr_debug("%s: priority: %u for TCI: %hu\n",
181 __FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI)); 183 __FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI));
@@ -185,7 +187,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
185 */ 187 */
186 switch (skb->pkt_type) { 188 switch (skb->pkt_type) {
187 case PACKET_BROADCAST: /* Yeah, stats collect these together.. */ 189 case PACKET_BROADCAST: /* Yeah, stats collect these together.. */
188 // stats->broadcast ++; // no such counter :-( 190 /* stats->broadcast ++; // no such counter :-( */
189 break; 191 break;
190 192
191 case PACKET_MULTICAST: 193 case PACKET_MULTICAST:
@@ -194,13 +196,13 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
194 196
195 case PACKET_OTHERHOST: 197 case PACKET_OTHERHOST:
196 /* Our lower layer thinks this is not local, let's make sure. 198 /* Our lower layer thinks this is not local, let's make sure.
197 * This allows the VLAN to have a different MAC than the underlying 199 * This allows the VLAN to have a different MAC than the
198 * device, and still route correctly. 200 * underlying device, and still route correctly.
199 */ 201 */
200 if (!compare_ether_addr(eth_hdr(skb)->h_dest, skb->dev->dev_addr)) { 202 if (!compare_ether_addr(eth_hdr(skb)->h_dest,
203 skb->dev->dev_addr))
201 /* It is for our (changed) MAC-address! */ 204 /* It is for our (changed) MAC-address! */
202 skb->pkt_type = PACKET_HOST; 205 skb->pkt_type = PACKET_HOST;
203 }
204 break; 206 break;
205 default: 207 default:
206 break; 208 break;
@@ -244,8 +246,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
244 */ 246 */
245 if (*(unsigned short *)rawp == 0xFFFF) { 247 if (*(unsigned short *)rawp == 0xFFFF) {
246 skb->protocol = htons(ETH_P_802_3); 248 skb->protocol = htons(ETH_P_802_3);
247 /* place it back on the queue to be handled by true layer 3 protocols. 249 /* place it back on the queue to be handled by true layer 3
248 */ 250 * protocols. */
249 251
250 /* See if we are configured to re-write the VLAN header 252 /* See if we are configured to re-write the VLAN header
251 * to make it look like ethernet... 253 * to make it look like ethernet...
@@ -286,17 +288,17 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
286 return 0; 288 return 0;
287} 289}
288 290
289static inline unsigned short vlan_dev_get_egress_qos_mask(struct net_device* dev, 291static inline unsigned short
290 struct sk_buff* skb) 292vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
291{ 293{
292 struct vlan_priority_tci_mapping *mp = 294 struct vlan_priority_tci_mapping *mp;
293 vlan_dev_info(dev)->egress_priority_map[(skb->priority & 0xF)];
294 295
296 mp = vlan_dev_info(dev)->egress_priority_map[(skb->priority & 0xF)];
295 while (mp) { 297 while (mp) {
296 if (mp->priority == skb->priority) { 298 if (mp->priority == skb->priority) {
297 return mp->vlan_qos; /* This should already be shifted to mask 299 return mp->vlan_qos; /* This should already be shifted
298 * correctly with the VLAN's TCI 300 * to mask correctly with the
299 */ 301 * VLAN's TCI */
300 } 302 }
301 mp = mp->next; 303 mp = mp->next;
302 } 304 }
@@ -321,10 +323,11 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
321 unsigned short veth_TCI = 0; 323 unsigned short veth_TCI = 0;
322 int rc = 0; 324 int rc = 0;
323 int build_vlan_header = 0; 325 int build_vlan_header = 0;
324 struct net_device *vdev = dev; /* save this for the bottom of the method */ 326 struct net_device *vdev = dev;
325 327
326 pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n", 328 pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n",
327 __FUNCTION__, skb, type, len, vlan_dev_info(dev)->vlan_id, daddr); 329 __FUNCTION__, skb, type, len, vlan_dev_info(dev)->vlan_id,
330 daddr);
328 331
329 /* build vlan header only if re_order_header flag is NOT set. This 332 /* build vlan header only if re_order_header flag is NOT set. This
330 * fixes some programs that get confused when they see a VLAN device 333 * fixes some programs that get confused when they see a VLAN device
@@ -342,8 +345,8 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
342 345
343 /* build the four bytes that make this a VLAN header. */ 346 /* build the four bytes that make this a VLAN header. */
344 347
345 /* Now, construct the second two bytes. This field looks something 348 /* Now, construct the second two bytes. This field looks
346 * like: 349 * something like:
347 * usr_priority: 3 bits (high bits) 350 * usr_priority: 3 bits (high bits)
348 * CFI 1 bit 351 * CFI 1 bit
349 * VLAN ID 12 bits (low bits) 352 * VLAN ID 12 bits (low bits)
@@ -355,16 +358,15 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
355 vhdr->h_vlan_TCI = htons(veth_TCI); 358 vhdr->h_vlan_TCI = htons(veth_TCI);
356 359
357 /* 360 /*
358 * Set the protocol type. 361 * Set the protocol type. For a packet of type ETH_P_802_3 we
359 * For a packet of type ETH_P_802_3 we put the length in here instead. 362 * put the length in here instead. It is up to the 802.2
360 * It is up to the 802.2 layer to carry protocol information. 363 * layer to carry protocol information.
361 */ 364 */
362 365
363 if (type != ETH_P_802_3) { 366 if (type != ETH_P_802_3)
364 vhdr->h_vlan_encapsulated_proto = htons(type); 367 vhdr->h_vlan_encapsulated_proto = htons(type);
365 } else { 368 else
366 vhdr->h_vlan_encapsulated_proto = htons(len); 369 vhdr->h_vlan_encapsulated_proto = htons(len);
367 }
368 370
369 skb->protocol = htons(ETH_P_8021Q); 371 skb->protocol = htons(ETH_P_8021Q);
370 skb_reset_network_header(skb); 372 skb_reset_network_header(skb);
@@ -376,14 +378,14 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
376 378
377 dev = vlan_dev_info(dev)->real_dev; 379 dev = vlan_dev_info(dev)->real_dev;
378 380
379 /* MPLS can send us skbuffs w/out enough space. This check will grow the 381 /* MPLS can send us skbuffs w/out enough space. This check will grow
380 * skb if it doesn't have enough headroom. Not a beautiful solution, so 382 * the skb if it doesn't have enough headroom. Not a beautiful solution,
381 * I'll tick a counter so that users can know it's happening... If they 383 * so I'll tick a counter so that users can know it's happening...
382 * care... 384 * If they care...
383 */ 385 */
384 386
385 /* NOTE: This may still break if the underlying device is not the final 387 /* NOTE: This may still break if the underlying device is not the final
386 * device (and thus there are more headers to add...) It should work for 388 * device (and thus there are more headers to add...) It should work for
387 * good-ole-ethernet though. 389 * good-ole-ethernet though.
388 */ 390 */
389 if (skb_headroom(skb) < dev->hard_header_len) { 391 if (skb_headroom(skb) < dev->hard_header_len) {
@@ -396,7 +398,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
396 return -ENOMEM; 398 return -ENOMEM;
397 } 399 }
398 vlan_dev_info(vdev)->cnt_inc_headroom_on_tx++; 400 vlan_dev_info(vdev)->cnt_inc_headroom_on_tx++;
399 pr_debug("%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name); 401 pr_debug("%s: %s: had to grow skb\n", __FUNCTION__, vdev->name);
400 } 402 }
401 403
402 if (build_vlan_header) { 404 if (build_vlan_header) {
@@ -408,10 +410,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
408 else if (rc < 0) 410 else if (rc < 0)
409 rc -= VLAN_HLEN; 411 rc -= VLAN_HLEN;
410 } else 412 } else
411 /* If here, then we'll just make a normal looking ethernet frame, 413 /* If here, then we'll just make a normal looking ethernet
412 * but, the hard_start_xmit method will insert the tag (it has to 414 * frame, but, the hard_start_xmit method will insert the tag
413 * be able to do this for bridged and other skbs that don't come 415 * (it has to be able to do this for bridged and other skbs
414 * down the protocol stack in an orderly manner. 416 * that don't come down the protocol stack in an orderly manner.
415 */ 417 */
416 rc = dev_hard_header(skb, dev, type, daddr, saddr, len); 418 rc = dev_hard_header(skb, dev, type, daddr, saddr, len);
417 419
@@ -454,9 +456,8 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
454 return 0; 456 return 0;
455 } 457 }
456 458
457 if (orig_headroom < VLAN_HLEN) { 459 if (orig_headroom < VLAN_HLEN)
458 vlan_dev_info(dev)->cnt_inc_headroom_on_tx++; 460 vlan_dev_info(dev)->cnt_inc_headroom_on_tx++;
459 }
460 } 461 }
461 462
462 pr_debug("%s: about to send skb: %p to dev: %s\n", 463 pr_debug("%s: about to send skb: %p to dev: %s\n",
@@ -572,11 +573,10 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
572{ 573{
573 /* verify flag is supported */ 574 /* verify flag is supported */
574 if (flag == VLAN_FLAG_REORDER_HDR) { 575 if (flag == VLAN_FLAG_REORDER_HDR) {
575 if (flag_val) { 576 if (flag_val)
576 vlan_dev_info(dev)->flags |= VLAN_FLAG_REORDER_HDR; 577 vlan_dev_info(dev)->flags |= VLAN_FLAG_REORDER_HDR;
577 } else { 578 else
578 vlan_dev_info(dev)->flags &= ~VLAN_FLAG_REORDER_HDR; 579 vlan_dev_info(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
579 }
580 return 0; 580 return 0;
581 } 581 }
582 return -EINVAL; 582 return -EINVAL;
@@ -667,7 +667,7 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
667 strncpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ); 667 strncpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ);
668 ifrr.ifr_ifru = ifr->ifr_ifru; 668 ifrr.ifr_ifru = ifr->ifr_ifru;
669 669
670 switch(cmd) { 670 switch (cmd) {
671 case SIOCGMIIPHY: 671 case SIOCGMIIPHY:
672 case SIOCGMIIREG: 672 case SIOCGMIIREG:
673 case SIOCSMIIREG: 673 case SIOCSMIIREG: