aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-21 03:24:30 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:08:28 -0500
commit40f98e1af4c6082f7f98391540a2a1ade030480a (patch)
tree3e1c0ea34e63ad65adcf8a75ae583e21cd14ace9
parenta5250a36954c6658e28cc2e7e07e314e0c79e8bb (diff)
[VLAN]: Clean up debugging and printks
- use pr_* functions and common prefix for non-device related messages - remove VLAN_ printk levels - kill lots of useless debugging statements - remove a few unnecessary printks like for double VID registration (already returns -EEXIST) and kill of a number of unnecessary checks in vlan_proc_{add,rem}_dev() that are already performed by the caller Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/8021q/vlan.c58
-rw-r--r--net/8021q/vlan.h25
-rw-r--r--net/8021q/vlan_dev.c56
-rw-r--r--net/8021q/vlanproc.c29
4 files changed, 30 insertions, 138 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8bc6385a06ee..6edd1919d183 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -80,16 +80,13 @@ static int __init vlan_proto_init(void)
80{ 80{
81 int err; 81 int err;
82 82
83 printk(VLAN_INF "%s v%s %s\n", 83 pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
84 vlan_fullname, vlan_version, vlan_copyright); 84 pr_info("All bugs added by %s\n", vlan_buggyright);
85 printk(VLAN_INF "All bugs added by %s\n",
86 vlan_buggyright);
87 85
88 /* proc file system initialization */ 86 /* proc file system initialization */
89 err = vlan_proc_init(); 87 err = vlan_proc_init();
90 if (err < 0) { 88 if (err < 0) {
91 printk(KERN_ERR 89 pr_err("%s: can't create entry in proc filesystem!\n",
92 "%s: can't create entry in proc filesystem!\n",
93 __FUNCTION__); 90 __FUNCTION__);
94 return err; 91 return err;
95 } 92 }
@@ -233,10 +230,6 @@ static int unregister_vlan_dev(struct net_device *real_dev,
233 struct vlan_group *grp; 230 struct vlan_group *grp;
234 int i, ret; 231 int i, ret;
235 232
236#ifdef VLAN_DEBUG
237 printk(VLAN_DBG "%s: VID: %i\n", __FUNCTION__, vlan_id);
238#endif
239
240 /* sanity check */ 233 /* sanity check */
241 if (vlan_id >= VLAN_VID_MASK) 234 if (vlan_id >= VLAN_VID_MASK)
242 return -EINVAL; 235 return -EINVAL;
@@ -329,23 +322,22 @@ static void vlan_transfer_operstate(const struct net_device *dev, struct net_dev
329 322
330int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id) 323int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
331{ 324{
325 char *name = real_dev->name;
326
332 if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { 327 if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
333 printk(VLAN_DBG "%s: VLANs not supported on %s.\n", 328 pr_info("8021q: VLANs not supported on %s\n", name);
334 __FUNCTION__, real_dev->name);
335 return -EOPNOTSUPP; 329 return -EOPNOTSUPP;
336 } 330 }
337 331
338 if ((real_dev->features & NETIF_F_HW_VLAN_RX) && 332 if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
339 !real_dev->vlan_rx_register) { 333 !real_dev->vlan_rx_register) {
340 printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", 334 pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
341 __FUNCTION__, real_dev->name);
342 return -EOPNOTSUPP; 335 return -EOPNOTSUPP;
343 } 336 }
344 337
345 if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && 338 if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
346 (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) { 339 (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) {
347 printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", 340 pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
348 __FUNCTION__, real_dev->name);
349 return -EOPNOTSUPP; 341 return -EOPNOTSUPP;
350 } 342 }
351 343
@@ -355,11 +347,8 @@ int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
355 if (!(real_dev->flags & IFF_UP)) 347 if (!(real_dev->flags & IFF_UP))
356 return -ENETDOWN; 348 return -ENETDOWN;
357 349
358 if (__find_vlan_dev(real_dev, vlan_id) != NULL) { 350 if (__find_vlan_dev(real_dev, vlan_id) != NULL)
359 /* was already registered. */
360 printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__);
361 return -EEXIST; 351 return -EEXIST;
362 }
363 352
364 return 0; 353 return 0;
365} 354}
@@ -399,8 +388,8 @@ int register_vlan_dev(struct net_device *dev)
399 real_dev->vlan_rx_add_vid(real_dev, vlan_id); 388 real_dev->vlan_rx_add_vid(real_dev, vlan_id);
400 389
401 if (vlan_proc_add_dev(dev) < 0) 390 if (vlan_proc_add_dev(dev) < 0)
402 printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n", 391 pr_warning("8021q: failed to add proc entry for %s\n",
403 dev->name); 392 dev->name);
404 return 0; 393 return 0;
405 394
406out_free_group: 395out_free_group:
@@ -419,11 +408,6 @@ static int register_vlan_device(struct net_device *real_dev,
419 char name[IFNAMSIZ]; 408 char name[IFNAMSIZ];
420 int err; 409 int err;
421 410
422#ifdef VLAN_DEBUG
423 printk(VLAN_DBG "%s: if_name -:%s:- vid: %i\n",
424 __FUNCTION__, eth_IF_name, VLAN_ID);
425#endif
426
427 if (VLAN_ID >= VLAN_VID_MASK) 411 if (VLAN_ID >= VLAN_VID_MASK)
428 return -ERANGE; 412 return -ERANGE;
429 413
@@ -432,10 +416,6 @@ static int register_vlan_device(struct net_device *real_dev,
432 return err; 416 return err;
433 417
434 /* Gotta set up the fields for the device. */ 418 /* Gotta set up the fields for the device. */
435#ifdef VLAN_DEBUG
436 printk(VLAN_DBG "About to allocate name, vlan_name_type: %i\n",
437 vlan_name_type);
438#endif
439 switch (vlan_name_type) { 419 switch (vlan_name_type) {
440 case VLAN_NAME_TYPE_RAW_PLUS_VID: 420 case VLAN_NAME_TYPE_RAW_PLUS_VID:
441 /* name will look like: eth1.0005 */ 421 /* name will look like: eth1.0005 */
@@ -472,13 +452,6 @@ static int register_vlan_device(struct net_device *real_dev,
472 */ 452 */
473 new_dev->mtu = real_dev->mtu; 453 new_dev->mtu = real_dev->mtu;
474 454
475#ifdef VLAN_DEBUG
476 printk(VLAN_DBG "Allocated new name -:%s:-\n", new_dev->name);
477 VLAN_MEM_DBG("new_dev->priv malloc, addr: %p size: %i\n",
478 new_dev->priv,
479 sizeof(struct vlan_dev_info));
480#endif
481
482 VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */ 455 VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
483 VLAN_DEV_INFO(new_dev)->real_dev = real_dev; 456 VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
484 VLAN_DEV_INFO(new_dev)->dent = NULL; 457 VLAN_DEV_INFO(new_dev)->dent = NULL;
@@ -489,9 +462,6 @@ static int register_vlan_device(struct net_device *real_dev,
489 if (err < 0) 462 if (err < 0)
490 goto out_free_newdev; 463 goto out_free_newdev;
491 464
492#ifdef VLAN_DEBUG
493 printk(VLAN_DBG "Allocated new device successfully, returning.\n");
494#endif
495 return 0; 465 return 0;
496 466
497out_free_newdev: 467out_free_newdev:
@@ -641,10 +611,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
641 args.device1[23] = 0; 611 args.device1[23] = 0;
642 args.u.device2[23] = 0; 612 args.u.device2[23] = 0;
643 613
644#ifdef VLAN_DEBUG
645 printk(VLAN_DBG "%s: args.cmd: %x\n", __FUNCTION__, args.cmd);
646#endif
647
648 rtnl_lock(); 614 rtnl_lock();
649 615
650 switch (args.cmd) { 616 switch (args.cmd) {
@@ -763,8 +729,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
763 729
764 default: 730 default:
765 /* pass on to underlying device instead?? */ 731 /* pass on to underlying device instead?? */
766 printk(VLAN_DBG "%s: Unknown VLAN CMD: %x \n",
767 __FUNCTION__, args.cmd);
768 err = -EINVAL; 732 err = -EINVAL;
769 break; 733 break;
770 } 734 }
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 7b615d6b6f46..56378651cc46 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -3,31 +3,6 @@
3 3
4#include <linux/if_vlan.h> 4#include <linux/if_vlan.h>
5 5
6/* Uncomment this if you want debug traces to be shown. */
7/* #define VLAN_DEBUG */
8
9#define VLAN_ERR KERN_ERR
10#define VLAN_INF KERN_INFO
11#define VLAN_DBG KERN_ALERT /* change these... to debug, having a hard time
12 * changing the log level at run-time..for some reason.
13 */
14
15/*
16
17These I use for memory debugging. I feared a leak at one time, but
18I never found it..and the problem seems to have dissappeared. Still,
19I'll bet they might prove useful again... --Ben
20
21
22#define VLAN_MEM_DBG(x, y, z) printk(VLAN_DBG "%s: " x, __FUNCTION__, y, z);
23#define VLAN_FMEM_DBG(x, y) printk(VLAN_DBG "%s: " x, __FUNCTION__, y);
24*/
25
26/* This way they don't do anything! */
27#define VLAN_MEM_DBG(x, y, z)
28#define VLAN_FMEM_DBG(x, y)
29
30
31extern unsigned short vlan_name_type; 6extern unsigned short vlan_name_type;
32 7
33#define VLAN_GRP_HASH_SHIFT 5 8#define VLAN_GRP_HASH_SHIFT 5
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 50d8edcbb897..756a71c1f4a5 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -60,9 +60,8 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb)
60 return arp_find(veth->h_dest, skb); 60 return arp_find(veth->h_dest, skb);
61#endif 61#endif
62 default: 62 default:
63 printk(VLAN_DBG 63 pr_debug("%s: unable to resolve type %X addresses.\n",
64 "%s: unable to resolve type %X addresses.\n", 64 dev->name, ntohs(veth->h_vlan_encapsulated_proto));
65 dev->name, ntohs(veth->h_vlan_encapsulated_proto));
66 65
67 memcpy(veth->h_source, dev->dev_addr, ETH_ALEN); 66 memcpy(veth->h_source, dev->dev_addr, ETH_ALEN);
68 break; 67 break;
@@ -142,11 +141,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
142 141
143 vid = (vlan_TCI & VLAN_VID_MASK); 142 vid = (vlan_TCI & VLAN_VID_MASK);
144 143
145#ifdef VLAN_DEBUG
146 printk(VLAN_DBG "%s: skb: %p vlan_id: %hx\n",
147 __FUNCTION__, skb, vid);
148#endif
149
150 /* Ok, we will find the correct VLAN device, strip the header, 144 /* Ok, we will find the correct VLAN device, strip the header,
151 * and then go on as usual. 145 * and then go on as usual.
152 */ 146 */
@@ -162,11 +156,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
162 skb->dev = __find_vlan_dev(dev, vid); 156 skb->dev = __find_vlan_dev(dev, vid);
163 if (!skb->dev) { 157 if (!skb->dev) {
164 rcu_read_unlock(); 158 rcu_read_unlock();
165 159 pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s [%i]\n",
166#ifdef VLAN_DEBUG 160 __FUNCTION__, (unsigned int)vid, dev->name, dev->ifindex);
167 printk(VLAN_DBG "%s: ERROR: No net_device for VID: %i on dev: %s [%i]\n",
168 __FUNCTION__, (unsigned int)(vid), dev->name, dev->ifindex);
169#endif
170 kfree_skb(skb); 161 kfree_skb(skb);
171 return -1; 162 return -1;
172 } 163 }
@@ -186,11 +177,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
186 */ 177 */
187 skb->priority = vlan_get_ingress_priority(skb->dev, ntohs(vhdr->h_vlan_TCI)); 178 skb->priority = vlan_get_ingress_priority(skb->dev, ntohs(vhdr->h_vlan_TCI));
188 179
189#ifdef VLAN_DEBUG 180 pr_debug("%s: priority: %u for TCI: %hu\n",
190 printk(VLAN_DBG "%s: priority: %lu for TCI: %hu (hbo)\n", 181 __FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI));
191 __FUNCTION__, (unsigned long)(skb->priority),
192 ntohs(vhdr->h_vlan_TCI));
193#endif
194 182
195 /* The ethernet driver already did the pkt_type calculations 183 /* The ethernet driver already did the pkt_type calculations
196 * for us... 184 * for us...
@@ -335,10 +323,8 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
335 int build_vlan_header = 0; 323 int build_vlan_header = 0;
336 struct net_device *vdev = dev; /* save this for the bottom of the method */ 324 struct net_device *vdev = dev; /* save this for the bottom of the method */
337 325
338#ifdef VLAN_DEBUG 326 pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n",
339 printk(VLAN_DBG "%s: skb: %p type: %hx len: %x vlan_id: %hx, daddr: %p\n", 327 __FUNCTION__, skb, type, len, VLAN_DEV_INFO(dev)->vlan_id, daddr);
340 __FUNCTION__, skb, type, len, VLAN_DEV_INFO(dev)->vlan_id, daddr);
341#endif
342 328
343 /* build vlan header only if re_order_header flag is NOT set. This 329 /* build vlan header only if re_order_header flag is NOT set. This
344 * fixes some programs that get confused when they see a VLAN device 330 * fixes some programs that get confused when they see a VLAN device
@@ -410,9 +396,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
410 return -ENOMEM; 396 return -ENOMEM;
411 } 397 }
412 VLAN_DEV_INFO(vdev)->cnt_inc_headroom_on_tx++; 398 VLAN_DEV_INFO(vdev)->cnt_inc_headroom_on_tx++;
413#ifdef VLAN_DEBUG 399 pr_debug("%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
414 printk(VLAN_DBG "%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
415#endif
416 } 400 }
417 401
418 if (build_vlan_header) { 402 if (build_vlan_header) {
@@ -453,10 +437,8 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
453 /* This is not a VLAN frame...but we can fix that! */ 437 /* This is not a VLAN frame...but we can fix that! */
454 VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++; 438 VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++;
455 439
456#ifdef VLAN_DEBUG 440 pr_debug("%s: proto to encap: 0x%hx\n",
457 printk(VLAN_DBG "%s: proto to encap: 0x%hx (hbo)\n", 441 __FUNCTION__, htons(veth->h_vlan_proto));
458 __FUNCTION__, htons(veth->h_vlan_proto));
459#endif
460 /* Construct the second two bytes. This field looks something 442 /* Construct the second two bytes. This field looks something
461 * like: 443 * like:
462 * usr_priority: 3 bits (high bits) 444 * usr_priority: 3 bits (high bits)
@@ -477,14 +459,15 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
477 } 459 }
478 } 460 }
479 461
480#ifdef VLAN_DEBUG 462 pr_debug("%s: about to send skb: %p to dev: %s\n",
481 printk(VLAN_DBG "%s: about to send skb: %p to dev: %s\n",
482 __FUNCTION__, skb, skb->dev->name); 463 __FUNCTION__, skb, skb->dev->name);
483 printk(VLAN_DBG " %2hx.%2hx.%2hx.%2xh.%2hx.%2hx %2hx.%2hx.%2hx.%2hx.%2hx.%2hx %4hx %4hx %4hx\n", 464 pr_debug(" " MAC_FMT " " MAC_FMT " %4hx %4hx %4hx\n",
484 veth->h_dest[0], veth->h_dest[1], veth->h_dest[2], veth->h_dest[3], veth->h_dest[4], veth->h_dest[5], 465 veth->h_dest[0], veth->h_dest[1], veth->h_dest[2],
485 veth->h_source[0], veth->h_source[1], veth->h_source[2], veth->h_source[3], veth->h_source[4], veth->h_source[5], 466 veth->h_dest[3], veth->h_dest[4], veth->h_dest[5],
486 veth->h_vlan_proto, veth->h_vlan_TCI, veth->h_vlan_encapsulated_proto); 467 veth->h_source[0], veth->h_source[1], veth->h_source[2],
487#endif 468 veth->h_source[3], veth->h_source[4], veth->h_source[5],
469 veth->h_vlan_proto, veth->h_vlan_TCI,
470 veth->h_vlan_encapsulated_proto);
488 471
489 stats->tx_packets++; /* for statics only */ 472 stats->tx_packets++; /* for statics only */
490 stats->tx_bytes += skb->len; 473 stats->tx_bytes += skb->len;
@@ -596,7 +579,6 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
596 } 579 }
597 return 0; 580 return 0;
598 } 581 }
599 printk(KERN_ERR "%s: flag %i is not valid.\n", __FUNCTION__, flag);
600 return -EINVAL; 582 return -EINVAL;
601} 583}
602 584
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 1972d5cc34e4..5da02e29a2c6 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -179,13 +179,6 @@ int vlan_proc_add_dev (struct net_device *vlandev)
179{ 179{
180 struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev); 180 struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
181 181
182 if (!(vlandev->priv_flags & IFF_802_1Q_VLAN)) {
183 printk(KERN_ERR
184 "ERROR: vlan_proc_add, device -:%s:- is NOT a VLAN\n",
185 vlandev->name);
186 return -EINVAL;
187 }
188
189 dev_info->dent = create_proc_entry(vlandev->name, 182 dev_info->dent = create_proc_entry(vlandev->name,
190 S_IFREG|S_IRUSR|S_IWUSR, 183 S_IFREG|S_IRUSR|S_IWUSR,
191 proc_vlan_dir); 184 proc_vlan_dir);
@@ -194,11 +187,6 @@ int vlan_proc_add_dev (struct net_device *vlandev)
194 187
195 dev_info->dent->proc_fops = &vlandev_fops; 188 dev_info->dent->proc_fops = &vlandev_fops;
196 dev_info->dent->data = vlandev; 189 dev_info->dent->data = vlandev;
197
198#ifdef VLAN_DEBUG
199 printk(KERN_ERR "vlan_proc_add, device -:%s:- being added.\n",
200 vlandev->name);
201#endif
202 return 0; 190 return 0;
203} 191}
204 192
@@ -207,28 +195,11 @@ int vlan_proc_add_dev (struct net_device *vlandev)
207 */ 195 */
208int vlan_proc_rem_dev(struct net_device *vlandev) 196int vlan_proc_rem_dev(struct net_device *vlandev)
209{ 197{
210 if (!vlandev) {
211 printk(VLAN_ERR "%s: invalid argument: %p\n",
212 __FUNCTION__, vlandev);
213 return -EINVAL;
214 }
215
216 if (!(vlandev->priv_flags & IFF_802_1Q_VLAN)) {
217 printk(VLAN_DBG "%s: invalid argument, device: %s is not a VLAN device, priv_flags: 0x%4hX.\n",
218 __FUNCTION__, vlandev->name, vlandev->priv_flags);
219 return -EINVAL;
220 }
221
222#ifdef VLAN_DEBUG
223 printk(VLAN_DBG "%s: dev: %p\n", __FUNCTION__, vlandev);
224#endif
225
226 /** NOTE: This will consume the memory pointed to by dent, it seems. */ 198 /** NOTE: This will consume the memory pointed to by dent, it seems. */
227 if (VLAN_DEV_INFO(vlandev)->dent) { 199 if (VLAN_DEV_INFO(vlandev)->dent) {
228 remove_proc_entry(VLAN_DEV_INFO(vlandev)->dent->name, proc_vlan_dir); 200 remove_proc_entry(VLAN_DEV_INFO(vlandev)->dent->name, proc_vlan_dir);
229 VLAN_DEV_INFO(vlandev)->dent = NULL; 201 VLAN_DEV_INFO(vlandev)->dent = NULL;
230 } 202 }
231
232 return 0; 203 return 0;
233} 204}
234 205