patch-2.2.18 linux/net/core/dev.c

Next file: linux/net/core/dv.c
Previous file: linux/net/core/Makefile
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/net/core/dev.c linux/net/core/dev.c
@@ -59,6 +59,7 @@
  *	Paul Rusty Russel	:	SIOCSIFNAME
  *	Andrea Arcangeli	:	dev_clear_backlog() needs the
  *					skb_queue_lock held.
+ *	Benoit Locher	:	Added the Frame Diversion code
  */
 
 #include <asm/uaccess.h>
@@ -84,6 +85,7 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <net/br.h>
+#include <linux/divert.h>
 #include <net/dst.h>
 #include <net/pkt_sched.h>
 #include <net/profile.h>
@@ -839,6 +841,17 @@
 }
 #endif
 
+
+#ifdef CONFIG_NET_DIVERT
+static inline void handle_diverter(struct sk_buff *skb)
+{
+	/* if diversion is supported on device, then divert */
+	if (skb->dev->divert && skb->dev->divert->divert)
+		divert_frame(skb);
+	return;
+}
+#endif	 /* CONFIG_NET_DIVERT */
+
 /*
  *	When we are called the queue is ready to grab, the interrupts are
  *	on and hardware can interrupt and queue to the receive queue as we
@@ -900,6 +913,12 @@
 		 */
 		skb = skb_dequeue(&backlog);
 
+		/* This can happen if dev_clear_backlog is running
+		 * at the same time and it empties the queue.
+		 */
+		if (skb == NULL)
+			break;
+
 #ifdef CONFIG_CPU_IS_SLOW
 		if (ave_busy > 128*16) {
 			kfree_skb(skb);
@@ -942,6 +961,15 @@
 
 		type = skb->protocol;
 
+#ifdef CONFIG_NET_DIVERT
+		/*
+		 * Have the frame diverted ?
+		 *
+		 */
+		handle_diverter(skb);
+#endif	/* CONFIG_NET_DIVERT */
+		
+
 #ifdef CONFIG_BRIDGE
 		/*
 		 *	If we are bridging then pass the frame up to the
@@ -1754,10 +1782,12 @@
 
 static int dev_boot_phase = 1;
 
-
 int register_netdevice(struct device *dev)
 {
 	struct device *d, **dp;
+#ifdef CONFIG_NET_DIVERT
+	int	ret;
+#endif
 
 	if (dev_boot_phase) {
 		/* This is NOT bug, but I am not sure, that all the
@@ -1780,6 +1810,11 @@
 		}
 		dev->next = NULL;
 		*dp = dev;
+#ifdef CONFIG_NET_DIVERT
+		ret=alloc_divert_blk(dev);
+		if (ret)
+			return ret;
+#endif /* CONFIG_NET_DIVERT */
 		return 0;
 	}
 
@@ -1803,7 +1838,11 @@
 
 	/* Notify protocols, that a new device appeared. */
 	notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev);
-
+#ifdef CONFIG_NET_DIVERT
+	ret=alloc_divert_blk(dev);
+	if (ret)
+		return ret;
+#endif
 	return 0;
 }
 
@@ -1851,6 +1890,9 @@
 
 			if (dev->destructor)
 				dev->destructor(dev);
+#ifdef CONFIG_NET_DIVERT
+			free_divert_blk(dev);	
+#endif /* CONFIG_NET_DIVERT */
 			return 0;
 		}
 	}
@@ -1872,6 +1914,7 @@
 extern void dlci_setup(void);
 extern int dmascc_init(void);
 extern int sm_init(void);
+extern void xpdsl_init(void);
 
 extern int baycom_ser_fdx_init(void);
 extern int baycom_ser_hdx_init(void);
@@ -1926,6 +1969,13 @@
 #ifdef CONFIG_BRIDGE	 
 	br_init();
 #endif	
+
+	/*
+	 * Frame Diverter init
+	 */
+#ifdef CONFIG_NET_DIVERT
+	dv_init();
+#endif /* CONFIG_NET_DIVERT */
 	
 	/*
 	 * This is Very Ugly(tm).
@@ -2048,6 +2098,9 @@
 #endif
 #ifdef CONFIG_WANXL
 	wanxl_init();
+#endif
+#ifdef CONFIG_XPEED
+	xpdsl_init();
 #endif
 #ifdef CONFIG_PC300
 	cpc_init();

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)