Netdev List
 help / color / mirror / Atom feed
* [VLAN 09/18]: Remove non-implemented ioctls
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Remove non-implemented ioctls

The GET_VLAN_INGRESS_PRIORITY_CMD/GET_VLAN_EGRESS_PRIORITY_CMD ioctls are
not implemented and won't be, new functionality will be added to the netlink
interface. Remove the code and make the ioctl handler return -EOPNOTSUPP
for unknown commands instead of -EINVAL.

Also remove a comment about passing unknown commands to the underlying
device, that doesn't make any sense since its a VLAN specific ioctl and
if its not implemented here, its implemented nowhere.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 8798cc926478d29231ad48d5e0ff31e434660ddb
tree bd5a582834f284db01ad92e19153ad307a425510
parent 7d925b47858e2f18fd474c673a0a75a0cfd00ebf
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100

 net/8021q/vlan.c |   23 +----------------------
 1 files changed, 1 insertions(+), 22 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 6edd191..69a9e02 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -688,26 +688,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
 		err = unregister_vlan_device(dev);
 		break;
 
-	case GET_VLAN_INGRESS_PRIORITY_CMD:
-		/* TODO:  Implement
-		   err = vlan_dev_get_ingress_priority(args);
-		   if (copy_to_user((void*)arg, &args,
-			sizeof(struct vlan_ioctl_args))) {
-			err = -EFAULT;
-		   }
-		*/
-		err = -EINVAL;
-		break;
-	case GET_VLAN_EGRESS_PRIORITY_CMD:
-		/* TODO:  Implement
-		   err = vlan_dev_get_egress_priority(args.device1, &(args.args);
-		   if (copy_to_user((void*)arg, &args,
-			sizeof(struct vlan_ioctl_args))) {
-			err = -EFAULT;
-		   }
-		*/
-		err = -EINVAL;
-		break;
 	case GET_VLAN_REALDEV_NAME_CMD:
 		err = 0;
 		vlan_dev_get_realdev_name(dev, args.u.device2);
@@ -728,8 +708,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
 		break;
 
 	default:
-		/* pass on to underlying device instead?? */
-		err = -EINVAL;
+		err = -EOPNOTSUPP;
 		break;
 	}
 out:

^ permalink raw reply related

* [VLAN 08/18]: Clean up debugging and printks
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[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>

---
commit 7d925b47858e2f18fd474c673a0a75a0cfd00ebf
tree 25c74a419d2f5451b57e810897d4704c4e5fa467
parent ead4b3ca023de4d4f05d185e8111c01784ee08e2
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:31 +0100

 net/8021q/vlan.c     |   58 +++++++++-----------------------------------------
 net/8021q/vlan.h     |   25 ----------------------
 net/8021q/vlan_dev.c |   56 ++++++++++++++++--------------------------------
 net/8021q/vlanproc.c |   29 -------------------------
 4 files changed, 30 insertions(+), 138 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8bc6385..6edd191 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -80,16 +80,13 @@ static int __init vlan_proto_init(void)
 {
 	int err;
 
-	printk(VLAN_INF "%s v%s %s\n",
-	       vlan_fullname, vlan_version, vlan_copyright);
-	printk(VLAN_INF "All bugs added by %s\n",
-	       vlan_buggyright);
+	pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
+	pr_info("All bugs added by %s\n", vlan_buggyright);
 
 	/* proc file system initialization */
 	err = vlan_proc_init();
 	if (err < 0) {
-		printk(KERN_ERR
-		       "%s: can't create entry in proc filesystem!\n",
+		pr_err("%s: can't create entry in proc filesystem!\n",
 		       __FUNCTION__);
 		return err;
 	}
@@ -233,10 +230,6 @@ static int unregister_vlan_dev(struct net_device *real_dev,
 	struct vlan_group *grp;
 	int i, ret;
 
-#ifdef VLAN_DEBUG
-	printk(VLAN_DBG "%s: VID: %i\n", __FUNCTION__, vlan_id);
-#endif
-
 	/* sanity check */
 	if (vlan_id >= VLAN_VID_MASK)
 		return -EINVAL;
@@ -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)
 {
+	char *name = real_dev->name;
+
 	if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
-		printk(VLAN_DBG "%s: VLANs not supported on %s.\n",
-			__FUNCTION__, real_dev->name);
+		pr_info("8021q: VLANs not supported on %s\n", name);
 		return -EOPNOTSUPP;
 	}
 
 	if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
 	    !real_dev->vlan_rx_register) {
-		printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
-			__FUNCTION__, real_dev->name);
+		pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
 		return -EOPNOTSUPP;
 	}
 
 	if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
 	    (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) {
-		printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
-			__FUNCTION__, real_dev->name);
+		pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
 		return -EOPNOTSUPP;
 	}
 
@@ -355,11 +347,8 @@ int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
 	if (!(real_dev->flags & IFF_UP))
 		return -ENETDOWN;
 
-	if (__find_vlan_dev(real_dev, vlan_id) != NULL) {
-		/* was already registered. */
-		printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__);
+	if (__find_vlan_dev(real_dev, vlan_id) != NULL)
 		return -EEXIST;
-	}
 
 	return 0;
 }
@@ -399,8 +388,8 @@ int register_vlan_dev(struct net_device *dev)
 		real_dev->vlan_rx_add_vid(real_dev, vlan_id);
 
 	if (vlan_proc_add_dev(dev) < 0)
-		printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n",
-		       dev->name);
+		pr_warning("8021q: failed to add proc entry for %s\n",
+			   dev->name);
 	return 0;
 
 out_free_group:
@@ -419,11 +408,6 @@ static int register_vlan_device(struct net_device *real_dev,
 	char name[IFNAMSIZ];
 	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)
 		return -ERANGE;
 
@@ -432,10 +416,6 @@ static int register_vlan_device(struct net_device *real_dev,
 		return err;
 
 	/* 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) {
 	case VLAN_NAME_TYPE_RAW_PLUS_VID:
 		/* name will look like:	 eth1.0005 */
@@ -472,13 +452,6 @@ static int register_vlan_device(struct net_device *real_dev,
 	 */
 	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)->real_dev = real_dev;
 	VLAN_DEV_INFO(new_dev)->dent = NULL;
@@ -489,9 +462,6 @@ static int register_vlan_device(struct net_device *real_dev,
 	if (err < 0)
 		goto out_free_newdev;
 
-#ifdef VLAN_DEBUG
-	printk(VLAN_DBG "Allocated new device successfully, returning.\n");
-#endif
 	return 0;
 
 out_free_newdev:
@@ -641,10 +611,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
 	args.device1[23] = 0;
 	args.u.device2[23] = 0;
 
-#ifdef VLAN_DEBUG
-	printk(VLAN_DBG "%s: args.cmd: %x\n", __FUNCTION__, args.cmd);
-#endif
-
 	rtnl_lock();
 
 	switch (args.cmd) {
@@ -763,8 +729,6 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
 
 	default:
 		/* pass on to underlying device instead?? */
-		printk(VLAN_DBG "%s: Unknown VLAN CMD: %x \n",
-			__FUNCTION__, args.cmd);
 		err = -EINVAL;
 		break;
 	}
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 7b615d6..5637865 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -3,31 +3,6 @@
 
 #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;
 
 #define VLAN_GRP_HASH_SHIFT	5
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 50d8edc..756a71c 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)
 		return arp_find(veth->h_dest, skb);
 #endif
 	default:
-		printk(VLAN_DBG
-		       "%s: unable to resolve type %X addresses.\n",
-		       dev->name, ntohs(veth->h_vlan_encapsulated_proto));
+		pr_debug("%s: unable to resolve type %X addresses.\n",
+			 dev->name, ntohs(veth->h_vlan_encapsulated_proto));
 
 		memcpy(veth->h_source, dev->dev_addr, ETH_ALEN);
 		break;
@@ -142,11 +141,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 
 	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,
 	 * and then go on as usual.
 	 */
@@ -162,11 +156,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	skb->dev = __find_vlan_dev(dev, vid);
 	if (!skb->dev) {
 		rcu_read_unlock();
-
-#ifdef VLAN_DEBUG
-		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
+		pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s [%i]\n",
+			 __FUNCTION__, (unsigned int)vid, dev->name, dev->ifindex);
 		kfree_skb(skb);
 		return -1;
 	}
@@ -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));
 
-#ifdef VLAN_DEBUG
-	printk(VLAN_DBG "%s: priority: %lu  for TCI: %hu (hbo)\n",
-		__FUNCTION__, (unsigned long)(skb->priority),
-		ntohs(vhdr->h_vlan_TCI));
-#endif
+	pr_debug("%s: priority: %u for TCI: %hu\n",
+		 __FUNCTION__, skb->priority, ntohs(vhdr->h_vlan_TCI));
 
 	/* The ethernet driver already did the pkt_type calculations
 	 * for us...
@@ -335,10 +323,8 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 	int build_vlan_header = 0;
 	struct net_device *vdev = dev; /* save this for the bottom of the method */
 
-#ifdef VLAN_DEBUG
-	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);
-#endif
+	pr_debug("%s: skb: %p type: %hx len: %u vlan_id: %hx, daddr: %p\n",
+		 __FUNCTION__, skb, type, len, VLAN_DEV_INFO(dev)->vlan_id, daddr);
 
 	/* 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
@@ -410,9 +396,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 			return -ENOMEM;
 		}
 		VLAN_DEV_INFO(vdev)->cnt_inc_headroom_on_tx++;
-#ifdef VLAN_DEBUG
-		printk(VLAN_DBG "%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
-#endif
+		pr_debug("%s: %s: had to grow skb.\n", __FUNCTION__, vdev->name);
 	}
 
 	if (build_vlan_header) {
@@ -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! */
 		VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++;
 
-#ifdef VLAN_DEBUG
-		printk(VLAN_DBG "%s: proto to encap: 0x%hx (hbo)\n",
-			__FUNCTION__, htons(veth->h_vlan_proto));
-#endif
+		pr_debug("%s: proto to encap: 0x%hx\n",
+			 __FUNCTION__, htons(veth->h_vlan_proto));
 		/* Construct the second two bytes. This field looks something
 		 * like:
 		 * 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)
 		}
 	}
 
-#ifdef VLAN_DEBUG
-	printk(VLAN_DBG "%s: about to send skb: %p to dev: %s\n",
+	pr_debug("%s: about to send skb: %p to dev: %s\n",
 		__FUNCTION__, skb, skb->dev->name);
-	printk(VLAN_DBG "  %2hx.%2hx.%2hx.%2xh.%2hx.%2hx %2hx.%2hx.%2hx.%2hx.%2hx.%2hx %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_source[0], veth->h_source[1], veth->h_source[2], 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);
-#endif
+	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_source[0], veth->h_source[1], veth->h_source[2],
+		 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_bytes += skb->len;
@@ -596,7 +579,6 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
 		}
 		return 0;
 	}
-	printk(KERN_ERR "%s: flag %i is not valid.\n", __FUNCTION__, flag);
 	return -EINVAL;
 }
 
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 1972d5c..5da02e2 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -179,13 +179,6 @@ int vlan_proc_add_dev (struct net_device *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,
 					   S_IFREG|S_IRUSR|S_IWUSR,
 					   proc_vlan_dir);
@@ -194,11 +187,6 @@ int vlan_proc_add_dev (struct net_device *vlandev)
 
 	dev_info->dent->proc_fops = &vlandev_fops;
 	dev_info->dent->data = vlandev;
-
-#ifdef VLAN_DEBUG
-	printk(KERN_ERR "vlan_proc_add, device -:%s:- being added.\n",
-	       vlandev->name);
-#endif
 	return 0;
 }
 
@@ -207,28 +195,11 @@ int vlan_proc_add_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. */
 	if (VLAN_DEV_INFO(vlandev)->dent) {
 		remove_proc_entry(VLAN_DEV_INFO(vlandev)->dent->name, proc_vlan_dir);
 		VLAN_DEV_INFO(vlandev)->dent = NULL;
 	}
-
 	return 0;
 }
 

^ permalink raw reply related

* [ETHER 07/18]: Bring back MAC_FMT
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[ETHER]: Bring back MAC_FMT

The print_mac function is not very suitable for debugging printks
in performance critical paths since without ifdefs it will always
get called. MAC_FMT can be used with pr_debug without any overhead
when debugging is disabled.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit ead4b3ca023de4d4f05d185e8111c01784ee08e2
tree d9616532b4fcc9137828d9ed9da941512bdc6841
parent 99c94d927602635ca0994a99bf75edc0d2f80871
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:28 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:28 +0100

 include/linux/if_ether.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 7a1e011..e157c13 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -130,6 +130,7 @@ extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
  *	Display a 6 byte device address (MAC) in a readable format.
  */
 extern char *print_mac(char *buf, const unsigned char *addr);
+#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
 #define MAC_BUF_SIZE	18
 #define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE] __maybe_unused
 

^ permalink raw reply related

* [VLAN 06/18]: Kill useless check
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Kill useless check

vlan->real_dev is always equal to the device since thats what we used
for the lookup. It doesn't even seem worth a WARN_ON or BUG_ON.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 99c94d927602635ca0994a99bf75edc0d2f80871
tree b7455cbbe55a60f0d13a3b9b64694099e718e6d9
parent aa7c9ed461cf1cf1977a7d5735d464a7539d2518
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:55 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:55 +0100

 net/8021q/vlan_dev.c |   18 ------------------
 1 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 51ce421..50d8edc 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -181,24 +181,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	/* Take off the VLAN header (4 bytes currently) */
 	skb_pull_rcsum(skb, VLAN_HLEN);
 
-	/* Ok, lets check to make sure the device (dev) we
-	 * came in on is what this VLAN is attached to.
-	 */
-
-	if (dev != VLAN_DEV_INFO(skb->dev)->real_dev) {
-		rcu_read_unlock();
-
-#ifdef VLAN_DEBUG
-		printk(VLAN_DBG "%s: dropping skb: %p because came in on wrong device, dev: %s  real_dev: %s, skb_dev: %s\n",
-			__FUNCTION__, skb, dev->name,
-			VLAN_DEV_INFO(skb->dev)->real_dev->name,
-			skb->dev->name);
-#endif
-		kfree_skb(skb);
-		stats->rx_errors++;
-		return -1;
-	}
-
 	/*
 	 * Deal with ingress priority mapping.
 	 */

^ permalink raw reply related

* [VLAN 05/18]: Move device setup to vlan_dev.c
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Move device setup to vlan_dev.c

Move device setup to vlan_dev.c and make all the VLAN device methods
static.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit aa7c9ed461cf1cf1977a7d5735d464a7539d2518
tree 06a7feef01dfd6494de6ed687895c6ca58a44f3d
parent fef4f968b4704bf2b37417ca6ba0dedda696e611
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:55 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:55 +0100

 net/8021q/vlan.c     |   81 -----------------------------------------
 net/8021q/vlan.h     |   13 -------
 net/8021q/vlan_dev.c |  100 +++++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 86 insertions(+), 108 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 54f2346..8bc6385 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -307,87 +307,6 @@ int unregister_vlan_device(struct net_device *dev)
 	return ret;
 }
 
-/*
- * vlan network devices have devices nesting below it, and are a special
- * "super class" of normal network devices; split their locks off into a
- * separate class since they always nest.
- */
-static struct lock_class_key vlan_netdev_xmit_lock_key;
-
-static const struct header_ops vlan_header_ops = {
-	.create	 = vlan_dev_hard_header,
-	.rebuild = vlan_dev_rebuild_header,
-	.parse	 = eth_header_parse,
-};
-
-static int vlan_dev_init(struct net_device *dev)
-{
-	struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
-	int subclass = 0;
-
-	/* IFF_BROADCAST|IFF_MULTICAST; ??? */
-	dev->flags  = real_dev->flags & ~IFF_UP;
-	dev->iflink = real_dev->ifindex;
-	dev->state  = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
-					  (1<<__LINK_STATE_DORMANT))) |
-		      (1<<__LINK_STATE_PRESENT);
-
-	/* ipv6 shared card related stuff */
-	dev->dev_id = real_dev->dev_id;
-
-	if (is_zero_ether_addr(dev->dev_addr))
-		memcpy(dev->dev_addr, real_dev->dev_addr, dev->addr_len);
-	if (is_zero_ether_addr(dev->broadcast))
-		memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);
-
-	if (real_dev->features & NETIF_F_HW_VLAN_TX) {
-		dev->header_ops      = real_dev->header_ops;
-		dev->hard_header_len = real_dev->hard_header_len;
-		dev->hard_start_xmit = vlan_dev_hwaccel_hard_start_xmit;
-	} else {
-		dev->header_ops      = &vlan_header_ops;
-		dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
-		dev->hard_start_xmit = vlan_dev_hard_start_xmit;
-	}
-
-	if (real_dev->priv_flags & IFF_802_1Q_VLAN)
-		subclass = 1;
-
-	lockdep_set_class_and_subclass(&dev->_xmit_lock,
-				&vlan_netdev_xmit_lock_key, subclass);
-	return 0;
-}
-
-void vlan_setup(struct net_device *new_dev)
-{
-	ether_setup(new_dev);
-
-	/* new_dev->ifindex = 0;  it will be set when added to
-	 * the global list.
-	 * iflink is set as well.
-	 */
-	/* Make this thing known as a VLAN device */
-	new_dev->priv_flags |= IFF_802_1Q_VLAN;
-
-	/* Set us up to have no queue, as the underlying Hardware device
-	 * can do all the queueing we could want.
-	 */
-	new_dev->tx_queue_len = 0;
-
-	/* set up method calls */
-	new_dev->change_mtu = vlan_dev_change_mtu;
-	new_dev->init = vlan_dev_init;
-	new_dev->open = vlan_dev_open;
-	new_dev->stop = vlan_dev_stop;
-	new_dev->set_mac_address = vlan_set_mac_address;
-	new_dev->set_multicast_list = vlan_dev_set_multicast_list;
-	new_dev->change_rx_flags = vlan_change_rx_flags;
-	new_dev->destructor = free_netdev;
-	new_dev->do_ioctl = vlan_dev_ioctl;
-
-	memset(new_dev->broadcast, 0, ETH_ALEN);
-}
-
 static void vlan_transfer_operstate(const struct net_device *dev, struct net_device *vlandev)
 {
 	/* Have to respect userspace enforced dormant state
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 2cd1393..7b615d6 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -49,19 +49,8 @@ struct net_device *__find_vlan_dev(struct net_device* real_dev,
 				   unsigned short VID); /* vlan.c */
 
 /* found in vlan_dev.c */
-int vlan_dev_rebuild_header(struct sk_buff *skb);
 int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		  struct packet_type *ptype, struct net_device *orig_dev);
-int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
-			 unsigned short type, const void *daddr,
-			 const void *saddr, unsigned len);
-int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
-int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
-int vlan_dev_change_mtu(struct net_device *dev, int new_mtu);
-int vlan_dev_open(struct net_device* dev);
-int vlan_dev_stop(struct net_device* dev);
-int vlan_set_mac_address(struct net_device *dev, void *p);
-int vlan_dev_ioctl(struct net_device* dev, struct ifreq *ifr, int cmd);
 void vlan_dev_set_ingress_priority(const struct net_device *dev,
 				   u32 skb_prio, short vlan_prio);
 int vlan_dev_set_egress_priority(const struct net_device *dev,
@@ -70,8 +59,6 @@ int vlan_dev_set_vlan_flag(const struct net_device *dev,
 			   u32 flag, short flag_val);
 void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
 void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result);
-void vlan_change_rx_flags(struct net_device *dev, int change);
-void vlan_dev_set_multicast_list(struct net_device *vlan_dev);
 
 int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id);
 void vlan_setup(struct net_device *dev);
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 9543e91..51ce421 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -47,7 +47,7 @@
  *
  * TODO:  This needs a checkup, I'm ignorant here. --BLG
  */
-int vlan_dev_rebuild_header(struct sk_buff *skb)
+static int vlan_dev_rebuild_header(struct sk_buff *skb)
 {
 	struct net_device *dev = skb->dev;
 	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data);
@@ -342,9 +342,10 @@ static inline unsigned short vlan_dev_get_egress_qos_mask(struct net_device* dev
  *  This is called when the SKB is moving down the stack towards the
  *  physical devices.
  */
-int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
-			 unsigned short type,
-			 const void *daddr, const void *saddr, unsigned len)
+static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
+				unsigned short type,
+				const void *daddr, const void *saddr,
+				unsigned int len)
 {
 	struct vlan_hdr *vhdr;
 	unsigned short veth_TCI = 0;
@@ -451,7 +452,7 @@ int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 	return rc;
 }
 
-int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct net_device_stats *stats = &dev->stats;
 	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data);
@@ -512,7 +513,8 @@ int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	return 0;
 }
 
-int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
+					    struct net_device *dev)
 {
 	struct net_device_stats *stats = &dev->stats;
 	unsigned short veth_TCI;
@@ -536,7 +538,7 @@ int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev
 	return 0;
 }
 
-int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
+static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
 {
 	/* TODO: gotta make sure the underlying layer can handle it,
 	 * maybe an IFF_VLAN_CAPABLE flag for devices?
@@ -626,7 +628,7 @@ void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result)
 	*result = VLAN_DEV_INFO(dev)->vlan_id;
 }
 
-int vlan_dev_open(struct net_device *dev)
+static int vlan_dev_open(struct net_device *dev)
 {
 	struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
 	struct net_device *real_dev = vlan->real_dev;
@@ -650,7 +652,7 @@ int vlan_dev_open(struct net_device *dev)
 	return 0;
 }
 
-int vlan_dev_stop(struct net_device *dev)
+static int vlan_dev_stop(struct net_device *dev)
 {
 	struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
 
@@ -666,7 +668,7 @@ int vlan_dev_stop(struct net_device *dev)
 	return 0;
 }
 
-int vlan_set_mac_address(struct net_device *dev, void *p)
+static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
 {
 	struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
 	struct sockaddr *addr = p;
@@ -692,7 +694,7 @@ out:
 	return 0;
 }
 
-int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
 	struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
 	struct ifreq ifrr;
@@ -716,7 +718,7 @@ int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	return err;
 }
 
-void vlan_change_rx_flags(struct net_device *dev, int change)
+static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
 {
 	struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
 
@@ -726,8 +728,78 @@ void vlan_change_rx_flags(struct net_device *dev, int change)
 		dev_set_promiscuity(real_dev, dev->flags & IFF_PROMISC ? 1 : -1);
 }
 
-/** Taken from Gleb + Lennert's VLAN code, and modified... */
-void vlan_dev_set_multicast_list(struct net_device *vlan_dev)
+static void vlan_dev_set_multicast_list(struct net_device *vlan_dev)
 {
 	dev_mc_sync(VLAN_DEV_INFO(vlan_dev)->real_dev, vlan_dev);
 }
+
+/*
+ * vlan network devices have devices nesting below it, and are a special
+ * "super class" of normal network devices; split their locks off into a
+ * separate class since they always nest.
+ */
+static struct lock_class_key vlan_netdev_xmit_lock_key;
+
+static const struct header_ops vlan_header_ops = {
+	.create	 = vlan_dev_hard_header,
+	.rebuild = vlan_dev_rebuild_header,
+	.parse	 = eth_header_parse,
+};
+
+static int vlan_dev_init(struct net_device *dev)
+{
+	struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
+	int subclass = 0;
+
+	/* IFF_BROADCAST|IFF_MULTICAST; ??? */
+	dev->flags  = real_dev->flags & ~IFF_UP;
+	dev->iflink = real_dev->ifindex;
+	dev->state  = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
+					  (1<<__LINK_STATE_DORMANT))) |
+		      (1<<__LINK_STATE_PRESENT);
+
+	/* ipv6 shared card related stuff */
+	dev->dev_id = real_dev->dev_id;
+
+	if (is_zero_ether_addr(dev->dev_addr))
+		memcpy(dev->dev_addr, real_dev->dev_addr, dev->addr_len);
+	if (is_zero_ether_addr(dev->broadcast))
+		memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);
+
+	if (real_dev->features & NETIF_F_HW_VLAN_TX) {
+		dev->header_ops      = real_dev->header_ops;
+		dev->hard_header_len = real_dev->hard_header_len;
+		dev->hard_start_xmit = vlan_dev_hwaccel_hard_start_xmit;
+	} else {
+		dev->header_ops      = &vlan_header_ops;
+		dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
+		dev->hard_start_xmit = vlan_dev_hard_start_xmit;
+	}
+
+	if (real_dev->priv_flags & IFF_802_1Q_VLAN)
+		subclass = 1;
+
+	lockdep_set_class_and_subclass(&dev->_xmit_lock,
+				&vlan_netdev_xmit_lock_key, subclass);
+	return 0;
+}
+
+void vlan_setup(struct net_device *dev)
+{
+	ether_setup(dev);
+
+	dev->priv_flags		|= IFF_802_1Q_VLAN;
+	dev->tx_queue_len	= 0;
+
+	dev->change_mtu		= vlan_dev_change_mtu;
+	dev->init		= vlan_dev_init;
+	dev->open		= vlan_dev_open;
+	dev->stop		= vlan_dev_stop;
+	dev->set_mac_address	= vlan_dev_set_mac_address;
+	dev->set_multicast_list	= vlan_dev_set_multicast_list;
+	dev->change_rx_flags	= vlan_dev_change_rx_flags;
+	dev->do_ioctl		= vlan_dev_ioctl;
+	dev->destructor		= free_netdev;
+
+	memset(dev->broadcast, 0, ETH_ALEN);
+}

^ permalink raw reply related

* [VLAN 04/18]: Use dev->stats
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Use dev->stats

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit fef4f968b4704bf2b37417ca6ba0dedda696e611
tree a5f8d87d4e193b681fba07727fc3ba1a078d0cfa
parent 6fcdd6b0d244f103898c3a37be2a3f4fec50fbd8
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:54 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:54 +0100

 include/linux/if_vlan.h |    9 +--------
 net/8021q/vlan.c        |    2 --
 net/8021q/vlan_dev.c    |    8 ++++----
 net/8021q/vlanproc.c    |    5 +----
 4 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 0325d6b..07db416 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -140,18 +140,11 @@ struct vlan_dev_info {
 	struct proc_dir_entry *dent;    /* Holds the proc data */
 	unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
 	unsigned long cnt_encap_on_xmit;      /* How many times did we have to encapsulate the skb on TX. */
-	struct net_device_stats dev_stats; /* Device stats (rx-bytes, tx-pkts, etc...) */
 };
 
 #define VLAN_DEV_INFO(x) ((struct vlan_dev_info *)(x->priv))
 
 /* inline functions */
-
-static inline struct net_device_stats *vlan_dev_get_stats(struct net_device *dev)
-{
-	return &(VLAN_DEV_INFO(dev)->dev_stats);
-}
-
 static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
 					      unsigned short vlan_tag)
 {
@@ -196,7 +189,7 @@ static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
 
 	skb->dev->last_rx = jiffies;
 
-	stats = vlan_dev_get_stats(skb->dev);
+	stats = &skb->dev->stats;
 	stats->rx_packets++;
 	stats->rx_bytes += skb->len;
 
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index af25255..54f2346 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -366,8 +366,6 @@ void vlan_setup(struct net_device *new_dev)
 	 * the global list.
 	 * iflink is set as well.
 	 */
-	new_dev->get_stats = vlan_dev_get_stats;
-
 	/* Make this thing known as a VLAN device */
 	new_dev->priv_flags |= IFF_802_1Q_VLAN;
 
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 4f99bb8..9543e91 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -174,7 +174,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	skb->dev->last_rx = jiffies;
 
 	/* Bump the rx counters for the VLAN device. */
-	stats = vlan_dev_get_stats(skb->dev);
+	stats = &skb->dev->stats;
 	stats->rx_packets++;
 	stats->rx_bytes += skb->len;
 
@@ -422,7 +422,7 @@ int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 		skb = skb_realloc_headroom(sk_tmp, dev->hard_header_len);
 		kfree_skb(sk_tmp);
 		if (skb == NULL) {
-			struct net_device_stats *stats = vlan_dev_get_stats(vdev);
+			struct net_device_stats *stats = &vdev->stats;
 			stats->tx_dropped++;
 			return -ENOMEM;
 		}
@@ -453,7 +453,7 @@ int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 
 int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct net_device_stats *stats = vlan_dev_get_stats(dev);
+	struct net_device_stats *stats = &dev->stats;
 	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data);
 
 	/* Handle non-VLAN frames if they are sent to us, for example by DHCP.
@@ -514,7 +514,7 @@ int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	struct net_device_stats *stats = vlan_dev_get_stats(dev);
+	struct net_device_stats *stats = &dev->stats;
 	unsigned short veth_TCI;
 
 	/* Construct the second two bytes. This field looks something
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 6cefdf8..1972d5c 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -316,7 +316,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
 {
 	struct net_device *vlandev = (struct net_device *) seq->private;
 	const struct vlan_dev_info *dev_info = VLAN_DEV_INFO(vlandev);
-	struct net_device_stats *stats;
+	struct net_device_stats *stats = &vlandev->stats;
 	static const char fmt[] = "%30s %12lu\n";
 	int i;
 
@@ -327,9 +327,6 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
 		       vlandev->name, dev_info->vlan_id,
 		       (int)(dev_info->flags & 1), vlandev->priv_flags);
 
-
-	stats = vlan_dev_get_stats(vlandev);
-
 	seq_printf(seq, fmt, "total frames received", stats->rx_packets);
 	seq_printf(seq, fmt, "total bytes received", stats->rx_bytes);
 	seq_printf(seq, fmt, "Broadcast/Multicast Rcvd", stats->multicast);

^ permalink raw reply related

* [VLAN 03/18]: Kill useless VLAN_NAME define
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Kill useless VLAN_NAME define

The only user already includes __FUNCTION__ (vlan_proto_init) in the output,
which is enough to identify what the message is about.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 6fcdd6b0d244f103898c3a37be2a3f4fec50fbd8
tree 6554c7cab6fdf09ac27fa1c75c93f0c105e249bd
parent f12d203e024ce5e0c98a9e88f6fdf8517a665ce4
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:54 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:54 +0100

 include/linux/if_vlan.h |    2 --
 net/8021q/vlan.c        |    4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index a1b0066..0325d6b 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -72,8 +72,6 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
 /* found in socket.c */
 extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
 
-#define VLAN_NAME "vlan"
-
 /* if this changes, algorithm will have to be reworked because this
  * depends on completely exhausting the VLAN identifier space.  Thus
  * it gives constant time look-up, but in many cases it wastes memory.
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 032bf44..af25255 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -89,8 +89,8 @@ static int __init vlan_proto_init(void)
 	err = vlan_proc_init();
 	if (err < 0) {
 		printk(KERN_ERR
-		       "%s %s: can't create entry in proc filesystem!\n",
-		       __FUNCTION__, VLAN_NAME);
+		       "%s: can't create entry in proc filesystem!\n",
+		       __FUNCTION__);
 		return err;
 	}
 

^ permalink raw reply related

* [VLAN 01/18]: Remove unnecessary structure declarations
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Remove unnecessary structure declarations

- struct packet_type is not used
- struct vlan_group is declared later in the file before the first use
- struct net_device is not needed since netdevice.h is included
- struct vlan_collection does not exist
- struct vlan_dev_info is declared later in the file before the first use

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit a8d2fc16ef0ffc7eb3502130f87994ba07129dae
tree 15638920f44a6854f8a570ce87caae9f748ba77f
parent ad50adbc891ee4e2fb0ea442303a5df16b9501ea
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:52 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:52 +0100

 include/linux/if_vlan.h |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 4562105..a268051 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -16,11 +16,6 @@
 #ifdef __KERNEL__
 
 /* externally defined structs */
-struct vlan_group;
-struct net_device;
-struct packet_type;
-struct vlan_collection;
-struct vlan_dev_info;
 struct hlist_node;
 
 #include <linux/netdevice.h>

^ permalink raw reply related

* [VLAN 00/18]: Vlan update
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

Hi Dave,

the following patches contain a VLAN update for 2.6.25, consisting mainly
of minor cleanups removing duplicate code, avoiding forward declarations,
makeing functions static etc. Next I'll look into the skb->cb issues
with VLAN.

Please apply, thanks.


 drivers/net/cxgb3/l2t.c      |    2 +-
 drivers/s390/net/qeth_main.c |    4 +-
 include/linux/if_ether.h     |    1 +
 include/linux/if_vlan.h      |   61 +++---
 net/8021q/vlan.c             |  437 ++++++++++----------------------------
 net/8021q/vlan.h             |   42 +----
 net/8021q/vlan_dev.c         |  484 ++++++++++++++++++++----------------------
 net/8021q/vlan_netlink.c     |   17 +-
 net/8021q/vlanproc.c         |  107 ++++------
 net/8021q/vlanproc.h         |   11 +-
 10 files changed, 436 insertions(+), 730 deletions(-)

Patrick McHardy (17):
      [VLAN]: Remove unnecessary structure declarations
      [VLAN]: Clean up vlan_hdr/vlan_ethhdr structs
      [VLAN]: Kill useless VLAN_NAME define
      [VLAN]: Use dev->stats
      [VLAN]: Move device setup to vlan_dev.c
      [VLAN]: Kill useless check
      [ETHER]: Bring back MAC_FMT
      [VLAN]: Clean up debugging and printks
      [VLAN]: Remove non-implemented ioctls
      [VLAN]: Clean up initialization code
      [VLAN]: Clean up unregister_vlan_dev
      [VLAN]: Simplify vlan unregistration
      [VLAN]: Turn VLAN_DEV_INFO into inline function
      [VLAN]: Turn __constant_htons into htons where possible
      [VLAN]: checkpatch cleanups
      [VLAN]: Update list address
      [VLAN]: Clean up vlan_skb_recv()

Pavel Emelyanov (1):
      [VLAN]: Move protocol determination to seperate function

^ permalink raw reply

* [VLAN 02/18]: Clean up vlan_hdr/vlan_ethhdr structs
From: Patrick McHardy @ 2008-01-20 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Clean up vlan_hdr/vlan_ethhdr structs

Fix 3 space indentation and some overly long lines by moving the comments
to a kdoc structure description.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit f12d203e024ce5e0c98a9e88f6fdf8517a665ce4
tree cebd9edb5b883aa901eaad4702ec428b2af87fc1
parent a8d2fc16ef0ffc7eb3502130f87994ba07129dae
author Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:52 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 16:24:52 +0100

 include/linux/if_vlan.h |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index a268051..a1b0066 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -34,12 +34,30 @@ struct hlist_node;
 #define VLAN_ETH_DATA_LEN	1500	/* Max. octets in payload	 */
 #define VLAN_ETH_FRAME_LEN	1518	/* Max. octets in frame sans FCS */
 
+/*
+ * 	struct vlan_hdr - vlan header
+ * 	@h_vlan_TCI: priority and VLAN ID
+ *	@h_vlan_encapsulated_proto: packet type ID or len
+ */
+struct vlan_hdr {
+	__be16	h_vlan_TCI;
+	__be16	h_vlan_encapsulated_proto;
+};
+
+/**
+ *	struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr)
+ *	@h_dest: destination ethernet address
+ *	@h_source: source ethernet address
+ *	@h_vlan_proto: ethernet protocol (always 0x8100)
+ *	@h_vlan_TCI: priority and VLAN ID
+ *	@h_vlan_encapsulated_proto: packet type ID or len
+ */
 struct vlan_ethhdr {
-   unsigned char	h_dest[ETH_ALEN];	   /* destination eth addr	*/
-   unsigned char	h_source[ETH_ALEN];	   /* source ether addr	*/
-   __be16               h_vlan_proto;              /* Should always be 0x8100 */
-   __be16               h_vlan_TCI;                /* Encapsulates priority and VLAN ID */
-   __be16		h_vlan_encapsulated_proto; /* packet type ID field (or len) */
+	unsigned char	h_dest[ETH_ALEN];
+	unsigned char	h_source[ETH_ALEN];
+	__be16		h_vlan_proto;
+	__be16		h_vlan_TCI;
+	__be16		h_vlan_encapsulated_proto;
 };
 
 #include <linux/skbuff.h>
@@ -49,11 +67,6 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
 	return (struct vlan_ethhdr *)skb_mac_header(skb);
 }
 
-struct vlan_hdr {
-   __be16               h_vlan_TCI;                /* Encapsulates priority and VLAN ID */
-   __be16               h_vlan_encapsulated_proto; /* packet type ID field (or len) */
-};
-
 #define VLAN_VID_MASK	0xfff
 
 /* found in socket.c */

^ permalink raw reply related

* Re: [NET_SCHED 00/09]: sch_ingress cleanups
From: Stephen Hemminger @ 2008-01-20 16:35 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netdev
In-Reply-To: <47936A25.9070306@trash.net>

On Sun, 20 Jan 2008 16:35:01 +0100
Patrick McHardy <kaber@trash.net> wrote:

> jamal wrote:
> > On Sun, 2008-20-01 at 15:32 +0100, Patrick McHardy wrote:
> >> These patches clean up sch_ingress by reformatting the code to match the
> >> usual kernel style, removing lots of debugging statements that seem
> >> unnecessary after years of stable operation, removing some "future use"
> >> stuff that doesn't seem likely to ever get used and some minor additional
> >> cleanups.
> >>
> > 
> > Patrick - if you are in mopping-mode then you will find some of the same
> > things in dsmark (LinuxWay(tm)).
> 
> 
> Indeed, that one could use a bit of cleanup as well. I took care
> of sch_ingress first since I had these patches queued for multiple
> years now and always forgot to send them out, but I'll look into
> sch_dsmark next time I'm in the area :)
> 
> > For all patches:
> > Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>

I'll fix dsmark, I need it for some other stuff.

-- 
Stephen Hemminger <stephen.hemminger@vyatta.com>

^ permalink raw reply

* netconsole on bnx2 not working?
From: Denys Fedoryshchenko @ 2008-01-20 15:54 UTC (permalink / raw)
  To: netdev

Hi

I am trying to run netconsole on Dell PowerEdge 1950, equipped with two
Broadcom NIC, without any success.

Tried to load netconsole on eth1 and eth0 (interface was renamed by udev), and
after that i am loading ppp_generic (which generate some data in kernel log).
Watching by tcpdump on remote, and local host - nothing is shown there.

The same time i am testing on RTL8139, same commands(just ip/mac different,
and sure machine is different) work fine.

Is any specific reason for that here? How i can debug this issue?
Do i need to enable netpoll for that?

I tried to create target over configfs, without any luck. Still no data is sent.

visp-1 test # pwd
/config/netconsole/test
visp-1 test # ls
dev_name  enabled  local_ip  local_mac  local_port  remote_ip  remote_mac 
remote_port
visp-1 test # grep "" *
dev_name:eth0
enabled:1
local_ip:217.151.X.Y
local_mac:00:13:72:f8:73:ac
local_port:6665
remote_ip:217.151.X.X
remote_mac:00:30:48:90:09:06
remote_port:514


dmesg
[537625.200501] Broadcom NetXtreme II Gigabit Ethernet Driver bnx2 v1.6.9
(December 8, 2007)
[537625.200888] ACPI: PCI Interrupt 0000:08:00.0[A] -> GSI 16 (level, low) ->
IRQ 16
[537625.531219] eth0: Broadcom NetXtreme II BCM5708 1000Base-T (B1) PCI-X
64-bit 133MHz found at mem f4000000, IRQ 16, node addr 00:13:72:f8:73:ae
[537625.531268] ACPI: PCI Interrupt 0000:04:00.0[A] -> GSI 16 (level, low) ->
IRQ 16
[537625.532352] udev: renamed network interface eth0 to eth1
[537625.888397] eth0: Broadcom NetXtreme II BCM5708 1000Base-T (B1) PCI-X
64-bit 133MHz found at mem f8000000, IRQ 16, node addr 00:13:72:f8:73:ac

dmesg on loading netconsole on eth0 and eth1
[538036.561776] netconsole: local port 111
[538036.561785] netconsole: local IP 217.151.X.X
[538036.561789] netconsole: interface eth1
[538036.561793] netconsole: remote port 514
[538036.561802] netconsole: remote IP 217.151.X.X
[538036.561808] netconsole: remote ethernet address 00:30:48:90:09:06
[538036.565989] console [netcon0] enabled
[538036.565998] netconsole: network logging started

[537899.157053] netconsole: couldn't parse config at 217.151.224.117!
[537899.157064] netconsole: cleaning up
[537942.772496] netconsole: local port 111
[537942.772505] netconsole: local IP 217.151.X.X
[537942.772510] netconsole: interface eth0
[537942.772514] netconsole: remote port 514
[537942.772518] netconsole: remote IP 217.151.X.X
[537942.772549] netconsole: remote ethernet address 00:30:48:90:09:06
[537942.780203] console [netcon0] enabled
[537942.780213] netconsole: network logging started




--
Denys Fedoryshchenko
Technical Manager
Virtual ISP S.A.L.


^ permalink raw reply

* Re: [NET_SCHED 00/09]: sch_ingress cleanups
From: Patrick McHardy @ 2008-01-20 15:35 UTC (permalink / raw)
  To: hadi; +Cc: davem, netdev
In-Reply-To: <1200843096.4433.145.camel@localhost>

jamal wrote:
> On Sun, 2008-20-01 at 15:32 +0100, Patrick McHardy wrote:
>> These patches clean up sch_ingress by reformatting the code to match the
>> usual kernel style, removing lots of debugging statements that seem
>> unnecessary after years of stable operation, removing some "future use"
>> stuff that doesn't seem likely to ever get used and some minor additional
>> cleanups.
>>
> 
> Patrick - if you are in mopping-mode then you will find some of the same
> things in dsmark (LinuxWay(tm)).


Indeed, that one could use a bit of cleanup as well. I took care
of sch_ingress first since I had these patches queued for multiple
years now and always forgot to send them out, but I'll look into
sch_dsmark next time I'm in the area :)

> For all patches:
> Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>


Thanks.

^ permalink raw reply

* Re: [NET_SCHED 00/09]: sch_ingress cleanups
From: jamal @ 2008-01-20 15:31 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

On Sun, 2008-20-01 at 15:32 +0100, Patrick McHardy wrote:
> These patches clean up sch_ingress by reformatting the code to match the
> usual kernel style, removing lots of debugging statements that seem
> unnecessary after years of stable operation, removing some "future use"
> stuff that doesn't seem likely to ever get used and some minor additional
> cleanups.
> 

Patrick - if you are in mopping-mode then you will find some of the same
things in dsmark (LinuxWay(tm)).

For all patches:
Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>

cheers,
jamal


^ permalink raw reply

* [AF_KEY]: Fix skb leak on pfkey_send_migrate() error
From: Patrick McHardy @ 2008-01-20 15:12 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1440 bytes --]

commit 4dd3440faa345731c27337ee041c0e9abf2b70dc
Author: Patrick McHardy <kaber@trash.net>
Date:   Sun Jan 20 16:10:04 2008 +0100

    [AF_KEY]: Fix skb leak on pfkey_send_migrate() error
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/key/af_key.c b/net/key/af_key.c
index 3667f44..16b72b5 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3591,27 +3591,29 @@ static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
 		/* old ipsecrequest */
 		int mode = pfkey_mode_from_xfrm(mp->mode);
 		if (mode < 0)
-			return -EINVAL;
+			goto err;
 		if (set_ipsecrequest(skb, mp->proto, mode,
 				     (mp->reqid ?  IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
 				     mp->reqid, mp->old_family,
-				     &mp->old_saddr, &mp->old_daddr) < 0) {
-			return -EINVAL;
-		}
+				     &mp->old_saddr, &mp->old_daddr) < 0)
+			goto err;
 
 		/* new ipsecrequest */
 		if (set_ipsecrequest(skb, mp->proto, mode,
 				     (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
 				     mp->reqid, mp->new_family,
-				     &mp->new_saddr, &mp->new_daddr) < 0) {
-			return -EINVAL;
-		}
+				     &mp->new_saddr, &mp->new_daddr) < 0)
+			goto err;
 	}
 
 	/* broadcast migrate message to sockets */
 	pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL);
 
 	return 0;
+
+err:
+	kfree_skb(skb);
+	return -EINVAL;
 }
 #else
 static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,

^ permalink raw reply related

* Re: [PATCH] mv643xx_eth: fix byte order when checksum offload is enabled
From: Byron Bradley @ 2008-01-20 15:05 UTC (permalink / raw)
  To: Al Viro
  Cc: Byron Bradley, netdev, hvr, akpm, Dale Farnsworth,
	Manish Lachwani, Tzachi Perelstein
In-Reply-To: <20080119200900.GE27894@ZenIV.linux.org.uk>

The Marvell Orion system on chips have an integrated mv643xx MAC.
On these little endian ARM devices mv643xx will oops when checksum
offload is enabled. Swapping the byte order of the protocol and
checksum solves this problem.

Signed-off-by: Byron Bradley <byron.bbradley@gmail.com>
Cc: Dale Farnsworth <dale@farnsworth.org>
Cc: Manish Lachwani <mlachwani@mvista.com>
---

Resubmitted after comments from Al Viro. udp_hdr(skb)->check returns
a __sum16 so I have called the function sum16_as_be(). Again lightly
tested only on two Marvell Orion boards.

 drivers/net/mv643xx_eth.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 651c269..b528ce7 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1652,6 +1652,11 @@ static void eth_tx_fill_frag_descs(struct mv643xx_private *mp,
 	}
 }

+static inline __be16 sum16_as_be(__sum16 sum)
+{
+	return (__force __be16)sum;
+}
+
 /**
  * eth_tx_submit_descs_for_skb - submit data from an skb to the tx hw
  *
@@ -1689,7 +1694,7 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
 	desc->buf_ptr = dma_map_single(NULL, skb->data, length, DMA_TO_DEVICE);

 	if (skb->ip_summed == CHECKSUM_PARTIAL) {
-		BUG_ON(skb->protocol != ETH_P_IP);
+		BUG_ON(skb->protocol != htons(ETH_P_IP));

 		cmd_sts |= ETH_GEN_TCP_UDP_CHECKSUM |
 			   ETH_GEN_IP_V_4_CHECKSUM  |
@@ -1698,10 +1703,10 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
 		switch (ip_hdr(skb)->protocol) {
 		case IPPROTO_UDP:
 			cmd_sts |= ETH_UDP_FRAME;
-			desc->l4i_chk = udp_hdr(skb)->check;
+			desc->l4i_chk = ntohs(sum16_as_be(udp_hdr(skb)->check));
 			break;
 		case IPPROTO_TCP:
-			desc->l4i_chk = tcp_hdr(skb)->check;
+			desc->l4i_chk = ntohs(sum16_as_be(tcp_hdr(skb)->check));
 			break;
 		default:
 			BUG();
-- 
1.5.4.rc2.38.gd6da3



^ permalink raw reply related

* [NET_SCHED]: kill obsolete NET_CLS_POLICE option
From: Patrick McHardy @ 2008-01-20 14:48 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1177 bytes --]

commit 2af10cb220dd73b91323d052f7ca4cb808906e78
Author: Patrick McHardy <kaber@trash.net>
Date:   Wed Jan 16 12:22:06 2008 +0100

    [NET_SCHED]: kill obsolete NET_CLS_POLICE option
    
    The code is already gone for about half a year, the config option
    has been kept around to select the replacement options for easier
    upgrades. This seems long enough, people upgrading from older
    kernels will have to reconfigure a lot anyway.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 63882c5..4eb73ec 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -481,15 +481,6 @@ config NET_ACT_SIMP
 	  To compile this code as a module, choose M here: the
 	  module will be called simple.
 
-config NET_CLS_POLICE
-	bool "Traffic Policing (obsolete)"
-	select NET_CLS_ACT
-	select NET_ACT_POLICE
-	---help---
-	  Say Y here if you want to do traffic policing, i.e. strict
-	  bandwidth limiting. This option is obsolete and just selects
-	  the option replacing it. It will be removed in the future.
-
 config NET_CLS_IND
 	bool "Incoming device classification"
 	depends on NET_CLS_U32 || NET_CLS_FW

^ permalink raw reply related

* [MACVLAN]: Fix thinko in macvlan_transfer_operstate()
From: Patrick McHardy @ 2008-01-20 14:47 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List

[-- Attachment #1: Type: text/plain, Size: 93 bytes --]

Fix a minor thinko in macvlan. The bug is uncritical, so this
doesn't need to go in 2.6.24.


[-- Attachment #2: x --]
[-- Type: text/plain, Size: 966 bytes --]

commit b40b16bb72ae1ad192daef55a3e9f81d76cd97ab
Author: Patrick McHardy <kaber@trash.net>
Date:   Thu Jan 17 09:18:11 2008 +0100

    [MACVLAN]: Fix thinko in macvlan_transfer_operstate()
    
    When the lower device's carrier is off, the macvlan devices's
    carrier state should be checked to decide whether it needs to
    be turned off. Currently the lower device's state is checked
    a second time.
    
    This still works, but unnecessarily tries to turn off the
    carrier when its already off.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 3acf8cd..312526b 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -375,7 +375,7 @@ static void macvlan_transfer_operstate(struct net_device *dev)
 		if (!netif_carrier_ok(dev))
 			netif_carrier_on(dev);
 	} else {
-		if (netif_carrier_ok(lowerdev))
+		if (netif_carrier_ok(dev))
 			netif_carrier_off(dev);
 	}
 }

^ permalink raw reply related

* [NET_SCHED 09/09]: sch_ingress: remove useless printk
From: Patrick McHardy @ 2008-01-20 14:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, hadi
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

commit f8d51e131177c26c1033dfc804f11d9cac7637f4
Author: Patrick McHardy <kaber@trash.net>
Date:   Thu Jan 17 09:17:59 2008 +0100

    [NET_SCHED]: sch_ingress: remove useless printk
    
    The printk about ingress qdisc registration error can't be triggered under
    normal circumstances. Since register_qdisc only fails for two identical
    registrations, the only way to trigger it is by loading the sch_ingress
    modules multiple times under different names, in which case we already
    return -EEXIST to userspace.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index 4c7f7e7..7252571 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -221,14 +221,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
 
 static int __init ingress_module_init(void)
 {
-	int ret = 0;
-
-	if ((ret = register_qdisc(&ingress_qdisc_ops)) < 0) {
-		printk("Unable to register Ingress qdisc\n");
-		return ret;
-	}
-
-	return ret;
+	return register_qdisc(&ingress_qdisc_ops);
 }
 
 static void __exit ingress_module_exit(void)

^ permalink raw reply related

* [NET_SCHED 08/09]: sch_ingress: avoid a few
From: Patrick McHardy @ 2008-01-20 14:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, hadi
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

commit 3320bc3c5d9a6c1dd96d515b7b6a4dee9cd31fd7
Author: Patrick McHardy <kaber@trash.net>
Date:   Thu Jan 17 09:17:58 2008 +0100

    [NET_SCHED]: sch_ingress: avoid a few #ifdefs
    
    Move the repeating "ifndef CONFIG_NET_CLS_ACT/ifdef CONFIG_NETFILTER" ifdefs
    into a single condition.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index b30ca01..4c7f7e7 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -20,11 +20,9 @@
 
 
 /* Thanks to Doron Oz for this hack */
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
 static int nf_registered;
 #endif
-#endif
 
 struct ingress_qdisc_data {
 	struct tcf_proto	*filter_list;
@@ -118,8 +116,7 @@ static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	return result;
 }
 
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
 static unsigned int ing_hook(unsigned int hook, struct sk_buff *skb,
 			     const struct net_device *indev,
 			     const struct net_device *outdev,
@@ -158,12 +155,10 @@ static struct nf_hook_ops ing_ops[] __read_mostly = {
 	},
 };
 #endif
-#endif
 
 static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
 {
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
 	printk("Ingress scheduler: Classifier actions prefered over netfilter\n");
 
 	if (!nf_registered) {
@@ -174,7 +169,6 @@ static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
 		nf_registered++;
 	}
 #endif
-#endif
 	return 0;
 }
 
@@ -240,12 +234,10 @@ static int __init ingress_module_init(void)
 static void __exit ingress_module_exit(void)
 {
 	unregister_qdisc(&ingress_qdisc_ops);
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
 	if (nf_registered)
 		nf_unregister_hooks(ing_ops, ARRAY_SIZE(ing_ops));
 #endif
-#endif
 }
 
 module_init(ingress_module_init)

^ permalink raw reply related

* [NET_SCHED 07/09]: sch_ingress: move dependencies to Kconfig
From: Patrick McHardy @ 2008-01-20 14:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, hadi
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

commit 4c939213974319d9457dbbf038d38ef1fcf57ef9
Author: Patrick McHardy <kaber@trash.net>
Date:   Wed Jan 16 12:22:08 2008 +0100

    [NET_SCHED]: sch_ingress: move dependencies to Kconfig
    
    Instead of complaining at scheduler initialization time, check the dependencies
    in Kconfig.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 4eb73ec..a047cd5 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -204,6 +204,7 @@ config NET_SCH_NETEM
 
 config NET_SCH_INGRESS
 	tristate "Ingress Qdisc"
+	depends on NET_CLS_ACT || NETFILTER
 	---help---
 	  Say Y here if you want to use classifiers for incoming packets.
 	  If unsure, say Y.
diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index c69e7bc..b30ca01 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -162,19 +162,10 @@ static struct nf_hook_ops ing_ops[] __read_mostly = {
 
 static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
 {
-	/* Make sure either netfilter or preferably CLS_ACT is
-	 * compiled in */
 #ifndef CONFIG_NET_CLS_ACT
-#ifndef CONFIG_NETFILTER
-	printk("You MUST compile classifier actions into the kernel\n");
-	return -EINVAL;
-#else
+#ifdef CONFIG_NETFILTER
 	printk("Ingress scheduler: Classifier actions prefered over netfilter\n");
-#endif
-#endif
 
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
 	if (!nf_registered) {
 		if (nf_register_hooks(ing_ops, ARRAY_SIZE(ing_ops)) < 0) {
 			printk("ingress qdisc registration error \n");

^ permalink raw reply related

* [NET_SCHED 06/09]: sch_ingress: remove unnecessary ops
From: Patrick McHardy @ 2008-01-20 14:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, hadi
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

commit c96158287d0c87fc3e4d005ce8bf2c778a5c2cb6
Author: Patrick McHardy <kaber@trash.net>
Date:   Wed Jan 16 12:22:07 2008 +0100

    [NET_SCHED]: sch_ingress: remove unnecessary ops
    
    - ->reset is optional
    - sch_api provides identical defaults for ->dequeue/->requeue
    - ->drop can't happen since ingress never has a parent qdisc
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index 1bbc648..c69e7bc 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -118,21 +118,6 @@ static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	return result;
 }
 
-static struct sk_buff *ingress_dequeue(struct Qdisc *sch)
-{
-	return NULL;
-}
-
-static int ingress_requeue(struct sk_buff *skb, struct Qdisc *sch)
-{
-	return 0;
-}
-
-static unsigned int ingress_drop(struct Qdisc *sch)
-{
-	return 0;
-}
-
 #ifndef CONFIG_NET_CLS_ACT
 #ifdef CONFIG_NETFILTER
 static unsigned int ing_hook(unsigned int hook, struct sk_buff *skb,
@@ -202,11 +187,6 @@ static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
 	return 0;
 }
 
-static void ingress_reset(struct Qdisc *sch)
-{
-	return;
-}
-
 /* ------------------------------------------------------------- */
 
 static void ingress_destroy(struct Qdisc *sch)
@@ -248,11 +228,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
 	.id		=	"ingress",
 	.priv_size	=	sizeof(struct ingress_qdisc_data),
 	.enqueue	=	ingress_enqueue,
-	.dequeue	=	ingress_dequeue,
-	.requeue	=	ingress_requeue,
-	.drop		=	ingress_drop,
 	.init		=	ingress_init,
-	.reset		=	ingress_reset,
 	.destroy	=	ingress_destroy,
 	.dump		=	ingress_dump,
 	.owner		=	THIS_MODULE,

^ permalink raw reply related

* [NET_SCHED 05/09]: sch_ingress: return proper error code in ingress_graft()
From: Patrick McHardy @ 2008-01-20 14:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, hadi
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

commit e039da57d244f15d4b920de63a20ab516a76ed5b
Author: Patrick McHardy <kaber@trash.net>
Date:   Wed Jan 16 12:22:07 2008 +0100

    [NET_SCHED]: sch_ingress: return proper error code in ingress_graft()
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index d803cd1..1bbc648 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -35,7 +35,7 @@ struct ingress_qdisc_data {
 static int ingress_graft(struct Qdisc *sch, unsigned long arg,
 			 struct Qdisc *new, struct Qdisc **old)
 {
-	return 1;
+	return -EOPNOTSUPP;
 }
 
 static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)

^ permalink raw reply related

* [NET_SCHED 04/09]: sch_ingress: remove unused inner qdisc
From: Patrick McHardy @ 2008-01-20 14:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, hadi
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

commit bb582f29b1f403d0df8a4a54daca89eafd2bfb69
Author: Patrick McHardy <kaber@trash.net>
Date:   Wed Jan 16 12:22:07 2008 +0100

    [NET_SCHED]: sch_ingress: remove unused inner qdisc
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index cb8ba8b..d803cd1 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -27,7 +27,6 @@ static int nf_registered;
 #endif
 
 struct ingress_qdisc_data {
-	struct Qdisc		*q;
 	struct tcf_proto	*filter_list;
 };
 
@@ -178,8 +177,6 @@ static struct nf_hook_ops ing_ops[] __read_mostly = {
 
 static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
 {
-	struct ingress_qdisc_data *p = qdisc_priv(sch);
-
 	/* Make sure either netfilter or preferably CLS_ACT is
 	 * compiled in */
 #ifndef CONFIG_NET_CLS_ACT
@@ -202,7 +199,6 @@ static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
 	}
 #endif
 #endif
-	p->q = &noop_qdisc;
 	return 0;
 }
 

^ permalink raw reply related

* [NET_SCHED 03/09]: sch_ingress: remove qdisc_priv() wrapper
From: Patrick McHardy @ 2008-01-20 14:32 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, hadi
In-Reply-To: <20080120143130.27801.94188.sendpatchset@localhost.localdomain>

commit ec46354d4ba87fe98b8510f2d91fff4e106022ec
Author: Patrick McHardy <kaber@trash.net>
Date:   Wed Jan 16 12:22:07 2008 +0100

    [NET_SCHED]: sch_ingress: remove qdisc_priv() wrapper
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index bdda28d..cb8ba8b 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -19,8 +19,6 @@
 #include <net/pkt_sched.h>
 
 
-#define PRIV(sch) qdisc_priv(sch)
-
 /* Thanks to Doron Oz for this hack */
 #ifndef CONFIG_NET_CLS_ACT
 #ifdef CONFIG_NETFILTER
@@ -74,7 +72,7 @@ static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker)
 
 static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch, unsigned long cl)
 {
-	struct ingress_qdisc_data *p = PRIV(sch);
+	struct ingress_qdisc_data *p = qdisc_priv(sch);
 
 	return &p->filter_list;
 }
@@ -83,7 +81,7 @@ static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch, unsigned long cl)
 
 static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 {
-	struct ingress_qdisc_data *p = PRIV(sch);
+	struct ingress_qdisc_data *p = qdisc_priv(sch);
 	struct tcf_result res;
 	int result;
 
@@ -180,7 +178,7 @@ static struct nf_hook_ops ing_ops[] __read_mostly = {
 
 static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
 {
-	struct ingress_qdisc_data *p = PRIV(sch);
+	struct ingress_qdisc_data *p = qdisc_priv(sch);
 
 	/* Make sure either netfilter or preferably CLS_ACT is
 	 * compiled in */
@@ -217,7 +215,7 @@ static void ingress_reset(struct Qdisc *sch)
 
 static void ingress_destroy(struct Qdisc *sch)
 {
-	struct ingress_qdisc_data *p = PRIV(sch);
+	struct ingress_qdisc_data *p = qdisc_priv(sch);
 
 	tcf_destroy_chain(p->filter_list);
 }

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox