Commit 40f98e1a authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[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: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a5250a36
...@@ -80,16 +80,13 @@ static int __init vlan_proto_init(void) ...@@ -80,16 +80,13 @@ static int __init vlan_proto_init(void)
{ {
int err; int err;
printk(VLAN_INF "%s v%s %s\n", pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
vlan_fullname, vlan_version, vlan_copyright); pr_info("All bugs added by %s\n", vlan_buggyright);
printk(VLAN_INF "All bugs added by %s\n",
vlan_buggyright);
/* proc file system initialization */ /* proc file system initialization */
err = vlan_proc_init(); err = vlan_proc_init();
if (err < 0) { if (err < 0) {
printk(KERN_ERR pr_err("%s: can't create entry in proc filesystem!\n",
"%s: can't create entry in proc filesystem!\n",
__FUNCTION__); __FUNCTION__);
return err; return err;
} }
...@@ -233,10 +230,6 @@ static int unregister_vlan_dev(struct net_device *real_dev, ...@@ -233,10 +230,6 @@ static int unregister_vlan_dev(struct net_device *real_dev,
struct vlan_group *grp; struct vlan_group *grp;
int i, ret; int i, ret;
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: VID: %i\n", __FUNCTION__, vlan_id);
#endif
/* sanity check */ /* sanity check */
if (vlan_id >= VLAN_VID_MASK) if (vlan_id >= VLAN_VID_MASK)
return -EINVAL; return -EINVAL;
...@@ -329,23 +322,22 @@ static void vlan_transfer_operstate(const struct net_device *dev, struct net_dev ...@@ -329,23 +322,22 @@ static void vlan_transfer_operstate(const struct net_device *dev, struct net_dev
int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id) int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
{ {
char *name = real_dev->name;
if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
printk(VLAN_DBG "%s: VLANs not supported on %s.\n", pr_info("8021q: VLANs not supported on %s\n", name);
__FUNCTION__, real_dev->name);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if ((real_dev->features & NETIF_F_HW_VLAN_RX) && if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
!real_dev->vlan_rx_register) { !real_dev->vlan_rx_register) {
printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
__FUNCTION__, real_dev->name);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
(!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) { (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) {
printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
__FUNCTION__, real_dev->name);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -355,11 +347,8 @@ int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id) ...@@ -355,11 +347,8 @@ int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
if (!(real_dev->flags & IFF_UP)) if (!(real_dev->flags & IFF_UP))
return -ENETDOWN; return -ENETDOWN;
if (__find_vlan_dev(real_dev, vlan_id) != NULL) { if (__find_vlan_dev(real_dev, vlan_id) != NULL)
/* was already registered. */
printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__);
return -EEXIST; return -EEXIST;
}
return 0; return 0;
} }
...@@ -399,8 +388,8 @@ int register_vlan_dev(struct net_device *dev) ...@@ -399,8 +388,8 @@ int register_vlan_dev(struct net_device *dev)
real_dev->vlan_rx_add_vid(real_dev, vlan_id); real_dev->vlan_rx_add_vid(real_dev, vlan_id);
if (vlan_proc_add_dev(dev) < 0) if (vlan_proc_add_dev(dev) < 0)
printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n", pr_warning("8021q: failed to add proc entry for %s\n",
dev->name); dev->name);
return 0; return 0;
out_free_group: out_free_group:
...@@ -419,11 +408,6 @@ static int register_vlan_device(struct net_device *real_dev, ...@@ -419,11 +408,6 @@ static int register_vlan_device(struct net_device *real_dev,
char name[IFNAMSIZ]; char name[IFNAMSIZ];
int err; int err;
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: if_name -:%s:- vid: %i\n",
__FUNCTION__, eth_IF_name, VLAN_ID);
#endif
if (VLAN_ID >= VLAN_VID_MASK) if (VLAN_ID >= VLAN_VID_MASK)
return -ERANGE; return -ERANGE;
...@@ -432,10 +416,6 @@ static int register_vlan_device(struct net_device *real_dev, ...@@ -432,10 +416,6 @@ static int register_vlan_device(struct net_device *real_dev,
return err; return err;
/* Gotta set up the fields for the device. */ /* Gotta set up the fields for the device. */
#ifdef VLAN_DEBUG
printk(VLAN_DBG "About to allocate name, vlan_name_type: %i\n",
vlan_name_type);
#endif
switch (vlan_name_type) { switch (vlan_name_type) {
case VLAN_NAME_TYPE_RAW_PLUS_VID: case VLAN_NAME_TYPE_RAW_PLUS_VID:
/* name will look like: eth1.0005 */ /* name will look like: eth1.0005 */
...@@ -472,13 +452,6 @@ static int register_vlan_device(struct net_device *real_dev, ...@@ -472,13 +452,6 @@ static int register_vlan_device(struct net_device *real_dev,
*/ */
new_dev->mtu = real_dev->mtu; new_dev->mtu = real_dev->mtu;
#ifdef VLAN_DEBUG
printk(VLAN_DBG "Allocated new name -:%s:-\n", new_dev->name);
VLAN_MEM_DBG("new_dev->priv malloc, addr: %p size: %i\n",
new_dev->priv,
sizeof(struct vlan_dev_info));
#endif
VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */ VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
VLAN_DEV_INFO(new_dev)->real_dev = real_dev; VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
VLAN_DEV_INFO(new_dev)->dent = NULL; VLAN_DEV_INFO(new_dev)->dent = NULL;
...@@ -489,9 +462,6 @@ static int register_vlan_device(struct net_device *real_dev, ...@@ -489,9 +462,6 @@ static int register_vlan_device(struct net_device *real_dev,
if (err < 0) if (err < 0)
goto out_free_newdev; goto out_free_newdev;
#ifdef VLAN_DEBUG
printk(VLAN_DBG "Allocated new device successfully, returning.\n");
#endif
return 0; return 0;
out_free_newdev: out_free_newdev:
...@@ -641,10 +611,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -641,10 +611,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
args.device1[23] = 0; args.device1[23] = 0;
args.u.device2[23] = 0; args.u.device2[23] = 0;
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: args.cmd: %x\n", __FUNCTION__, args.cmd);
#endif
rtnl_lock(); rtnl_lock();
switch (args.cmd) { switch (args.cmd) {
...@@ -763,8 +729,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -763,8 +729,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
default: default:
/* pass on to underlying device instead?? */ /* pass on to underlying device instead?? */
printk(VLAN_DBG "%s: Unknown VLAN CMD: %x \n",
__FUNCTION__, args.cmd);
err = -EINVAL; err = -EINVAL;
break; break;
} }
......
...@@ -3,31 +3,6 @@ ...@@ -3,31 +3,6 @@
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
/* Uncomment this if you want debug traces to be shown. */
/* #define VLAN_DEBUG */
#define VLAN_ERR KERN_ERR
#define VLAN_INF KERN_INFO
#define VLAN_DBG KERN_ALERT /* change these... to debug, having a hard time
* changing the log level at run-time..for some reason.
*/
/*
These I use for memory debugging. I feared a leak at one time, but
I never found it..and the problem seems to have dissappeared. Still,
I'll bet they might prove useful again... --Ben
#define VLAN_MEM_DBG(x, y, z) printk(VLAN_DBG "%s: " x, __FUNCTION__, y, z);
#define VLAN_FMEM_DBG(x, y) printk(VLAN_DBG "%s: " x, __FUNCTION__, y);
*/
/* This way they don't do anything! */
#define VLAN_MEM_DBG(x, y, z)
#define VLAN_FMEM_DBG(x, y)
extern unsigned short vlan_name_type; extern unsigned short vlan_name_type;
#define VLAN_GRP_HASH_SHIFT 5 #define VLAN_GRP_HASH_SHIFT 5
......
...@@ -60,9 +60,8 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb) ...@@ -60,9 +60,8 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb)
return arp_find(veth->h_dest, skb); return arp_find(veth->h_dest, skb);
#endif #endif
default: default:
printk(VLAN_DBG pr_debug("%s: unable to resolve type %X addresses.\n",
"%s: unable to resolve type %X addresses.\n", dev->name, ntohs(veth->h_vlan_encapsulated_proto));
dev->name, ntohs(veth->h_vlan_encapsulated_proto));
memcpy(veth->h_source, dev->dev_addr, ETH_ALEN); memcpy(veth->h_source, dev->dev_addr, ETH_ALEN);
break; break;
...@@ -142,11 +141,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -142,11 +141,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
vid = (vlan_TCI & VLAN_VID_MASK); vid = (vlan_TCI & VLAN_VID_MASK);
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: skb: %p vlan_id: %hx\n",
__FUNCTION__, skb, vid);
#endif
/* Ok, we will find the correct VLAN device, strip the header, /* Ok, we will find the correct VLAN device, strip the header,
* and then go on as usual. * and then go on as usual.
*/ */
...@@ -162,11 +156,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -162,11 +156,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
skb->dev = __find_vlan_dev(dev, vid); skb->dev = __find_vlan_dev(dev, vid);
if (!skb->dev) { if (!skb->dev) {
rcu_read_unlock(); rcu_read_unlock();
pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s [%i]\n",
#ifdef VLAN_DEBUG __FUNCTION__, (unsigned int)vid, dev->name, dev->ifindex);
printk(VLAN_DBG "%s: ERROR: No net_device for VID: %i on dev: %s [%i]\n",
__FUNCTION__, (unsigned int)(vid), dev->name, dev->ifindex);
#endif
kfree_skb(skb); kfree_skb(skb);
return -1; return -1;
} }
...@@ -186,11 +177,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -186,11 +177,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
*/ */
skb->priority = vlan_get_ingress_priority(skb->dev, ntohs(vhdr->h_vlan_TCI)); skb->priority = vlan_get_ingress_priority(skb->dev, ntohs(vhdr->h_vlan_TCI));
#ifdef VLAN_DEBUG pr_debug("%s: priority: %u for TCI: %hu\n",
printk(VLAN_DBG "%s: priority: %lu for TCI: %hu (hbo)\n", __FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI));
__FUNCTION__, (unsigned long)(skb->priority),
ntohs(vhdr->h_vlan_TCI));
#endif
/* The ethernet driver already did the pkt_type calculations /* The ethernet driver already did the pkt_type calculations
* for us... * for us...
...@@ -335,10 +323,8 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, ...@@ -335,10 +323,8 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
int build_vlan_header = 0; int build_vlan_header = 0;
struct net_device *vdev = dev; /* save this for the bottom of the method */ struct net_device *vdev = dev; /* save this for the bottom of the method */
#ifdef VLAN_DEBUG pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n",
printk(VLAN_DBG "%s: skb: %p type: %hx len: %x vlan_id: %hx, daddr: %p\n", __FUNCTION__, skb, type, len, VLAN_DEV_INFO(dev)->vlan_id, daddr);
__FUNCTION__, skb, type, len, VLAN_DEV_INFO(dev)->vlan_id, daddr);
#endif
/* build vlan header only if re_order_header flag is NOT set. This /* build vlan header only if re_order_header flag is NOT set. This
* fixes some programs that get confused when they see a VLAN device * 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,9 +396,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
return -ENOMEM; return -ENOMEM;
} }
VLAN_DEV_INFO(vdev)->cnt_inc_headroom_on_tx++; VLAN_DEV_INFO(vdev)->cnt_inc_headroom_on_tx++;
#ifdef VLAN_DEBUG pr_debug("%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
printk(VLAN_DBG "%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
#endif
} }
if (build_vlan_header) { if (build_vlan_header) {
...@@ -453,10 +437,8 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -453,10 +437,8 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* This is not a VLAN frame...but we can fix that! */ /* This is not a VLAN frame...but we can fix that! */
VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++; VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++;
#ifdef VLAN_DEBUG pr_debug("%s: proto to encap: 0x%hx\n",
printk(VLAN_DBG "%s: proto to encap: 0x%hx (hbo)\n", __FUNCTION__, htons(veth->h_vlan_proto));
__FUNCTION__, htons(veth->h_vlan_proto));
#endif
/* Construct the second two bytes. This field looks something /* Construct the second two bytes. This field looks something
* like: * like:
* usr_priority: 3 bits (high bits) * 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,14 +459,15 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
} }
} }
#ifdef VLAN_DEBUG pr_debug("%s: about to send skb: %p to dev: %s\n",
printk(VLAN_DBG "%s: about to send skb: %p to dev: %s\n",
__FUNCTION__, skb, skb->dev->name); __FUNCTION__, skb, skb->dev->name);
printk(VLAN_DBG " %2hx.%2hx.%2hx.%2xh.%2hx.%2hx %2hx.%2hx.%2hx.%2hx.%2hx.%2hx %4hx %4hx %4hx\n", pr_debug(" " MAC_FMT " " MAC_FMT " %4hx %4hx %4hx\n",
veth->h_dest[0], veth->h_dest[1], veth->h_dest[2], veth->h_dest[3], veth->h_dest[4], veth->h_dest[5], veth->h_dest[0], veth->h_dest[1], veth->h_dest[2],
veth->h_source[0], veth->h_source[1], veth->h_source[2], veth->h_source[3], veth->h_source[4], veth->h_source[5], veth->h_dest[3], veth->h_dest[4], veth->h_dest[5],
veth->h_vlan_proto, veth->h_vlan_TCI, veth->h_vlan_encapsulated_proto); veth->h_source[0], veth->h_source[1], veth->h_source[2],
#endif veth->h_source[3], veth->h_source[4], veth->h_source[5],
veth->h_vlan_proto, veth->h_vlan_TCI,
veth->h_vlan_encapsulated_proto);
stats->tx_packets++; /* for statics only */ stats->tx_packets++; /* for statics only */
stats->tx_bytes += skb->len; stats->tx_bytes += skb->len;
...@@ -596,7 +579,6 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev, ...@@ -596,7 +579,6 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
} }
return 0; return 0;
} }
printk(KERN_ERR "%s: flag %i is not valid.\n", __FUNCTION__, flag);
return -EINVAL; return -EINVAL;
} }
......
...@@ -179,13 +179,6 @@ int vlan_proc_add_dev (struct net_device *vlandev) ...@@ -179,13 +179,6 @@ int vlan_proc_add_dev (struct net_device *vlandev)
{ {
struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev); struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
if (!(vlandev->priv_flags & IFF_802_1Q_VLAN)) {
printk(KERN_ERR
"ERROR: vlan_proc_add, device -:%s:- is NOT a VLAN\n",
vlandev->name);
return -EINVAL;
}
dev_info->dent = create_proc_entry(vlandev->name, dev_info->dent = create_proc_entry(vlandev->name,
S_IFREG|S_IRUSR|S_IWUSR, S_IFREG|S_IRUSR|S_IWUSR,
proc_vlan_dir); proc_vlan_dir);
...@@ -194,11 +187,6 @@ int vlan_proc_add_dev (struct net_device *vlandev) ...@@ -194,11 +187,6 @@ int vlan_proc_add_dev (struct net_device *vlandev)
dev_info->dent->proc_fops = &vlandev_fops; dev_info->dent->proc_fops = &vlandev_fops;
dev_info->dent->data = vlandev; dev_info->dent->data = vlandev;
#ifdef VLAN_DEBUG
printk(KERN_ERR "vlan_proc_add, device -:%s:- being added.\n",
vlandev->name);
#endif
return 0; return 0;
} }
...@@ -207,28 +195,11 @@ int vlan_proc_add_dev (struct net_device *vlandev) ...@@ -207,28 +195,11 @@ int vlan_proc_add_dev (struct net_device *vlandev)
*/ */
int vlan_proc_rem_dev(struct net_device *vlandev) int vlan_proc_rem_dev(struct net_device *vlandev)
{ {
if (!vlandev) {
printk(VLAN_ERR "%s: invalid argument: %p\n",
__FUNCTION__, vlandev);
return -EINVAL;
}
if (!(vlandev->priv_flags & IFF_802_1Q_VLAN)) {
printk(VLAN_DBG "%s: invalid argument, device: %s is not a VLAN device, priv_flags: 0x%4hX.\n",
__FUNCTION__, vlandev->name, vlandev->priv_flags);
return -EINVAL;
}
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: dev: %p\n", __FUNCTION__, vlandev);
#endif
/** NOTE: This will consume the memory pointed to by dent, it seems. */ /** NOTE: This will consume the memory pointed to by dent, it seems. */
if (VLAN_DEV_INFO(vlandev)->dent) { if (VLAN_DEV_INFO(vlandev)->dent) {
remove_proc_entry(VLAN_DEV_INFO(vlandev)->dent->name, proc_vlan_dir); remove_proc_entry(VLAN_DEV_INFO(vlandev)->dent->name, proc_vlan_dir);
VLAN_DEV_INFO(vlandev)->dent = NULL; VLAN_DEV_INFO(vlandev)->dent = NULL;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment