[squid-users] Re: Linux WCCP Patch

From: Awie <[email protected]>
Date: Thu, 25 Mar 2004 14:28:21 +0800

All,

I attach Linux WCCP patch that support kernel 2.4.18 (I even forget where I
got it). Because of kernel version being updated very quickly, this Linux
WCCP patch should be flexible following the kernel version.

My question is:

Does it as simple as replace the version number in the patch to be the
version of kernel be used?

 Your advise is very apprecited.

Thx & Rgds,

Awie

====================================================================

diff -uNr linux-2.4.18/Documentation/Configure.help
linux/Documentation/Configure.help
--- linux-2.4.18/Documentation/Configure.help Tue Feb 26 01:07:51 2002
+++ linux/Documentation/Configure.help Sat Mar 2 12:28:17 2002
@@ -5198,6 +5198,15 @@
Network), but can be distributed all over the Internet. If you want
to do that, say Y here and to "IP multicast routing" below.
+WCCP tunnels over IP
+CONFIG_NET_IPWCCP
+ Tunneling means encapsulating data of one protocol type within
+ another protocol and sending it over a channel that understands the
+ encapsulating protocol. This particular tunneling driver implements
+ WCCP (Web Cache Coordination Protocol) GRE. This driver is useful
+ if you have a WCCP-enabled router, and would like to use WCCP to
+ redirect packets to a web cache.
+
IP multicast routing
CONFIG_IP_MROUTE
This is used if you want your machine to act as a router for IP
diff -uNr linux-2.4.18/net/ipv4/Config.in linux/net/ipv4/Config.in
--- linux-2.4.18/net/ipv4/Config.in Fri Dec 21 23:12:05 2001
+++ linux/net/ipv4/Config.in Sat Mar 2 12:29:19 2002
@@ -26,6 +26,7 @@
fi
tristate ' IP: tunneling' CONFIG_NET_IPIP
tristate ' IP: GRE tunnels over IP' CONFIG_NET_IPGRE
+tristate ' IP: WCCP GRE tunnels over IP' CONFIG_NET_IPWCCP
if [ "$CONFIG_IP_MULTICAST" = "y" ]; then
if [ "$CONFIG_NET_IPGRE" != "n" ]; then
bool ' IP: broadcast GRE over IP' CONFIG_NET_IPGRE_BROADCAST
diff -uNr linux-2.4.18/net/ipv4/Makefile linux/net/ipv4/Makefile
--- linux-2.4.18/net/ipv4/Makefile Fri Dec 21 23:12:05 2001
+++ linux/net/ipv4/Makefile Fri Jul 5 09:00:53 2002
@@ -9,7 +9,7 @@
O_TARGET := ipv4.o
-export-objs = ipip.o ip_gre.o
+export-objs = ipip.o ip_gre.o ip_wccp.o
obj-y := utils.o route.o inetpeer.o proc.o protocol.o \
ip_input.o ip_fragment.o ip_forward.o ip_options.o \
@@ -23,6 +23,7 @@
obj-$(CONFIG_IP_MROUTE) += ipmr.o
obj-$(CONFIG_NET_IPIP) += ipip.o
obj-$(CONFIG_NET_IPGRE) += ip_gre.o
+obj-$(CONFIG_NET_IPWCCP) += ip_wccp.o
obj-$(CONFIG_SYN_COOKIES) += syncookies.o
obj-$(CONFIG_IP_PNP) += ipconfig.o
diff -uNr linux-2.4.18/net/ipv4/ip_wccp.c linux/net/ipv4/ip_wccp.c
--- linux-2.4.18/net/ipv4/ip_wccp.c Fri Jul 5 11:14:24 2002
+++ linux/net/ipv4/ip_wccp.c Tue Mar 5 11:44:11 2002
@@ -0,0 +1,91 @@
+/*
+ * $Id: ip_wccp.c,v 1.1 1999/09/30 20:43:37 wessels Exp $
+ *
+ * Glenn Chisholm <glenn@ircache.net>
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/in.h>
+#include <linux/if_arp.h>
+#include <linux/init.h>
+#include <linux/inetdevice.h>
+
+#include <net/ip.h>
+
+#define WCCP_PROTOCOL_TYPE 0x883E
+#define WCCP_GRE_LEN sizeof(long)
+#define WCCP2_GRE_EXTRA sizeof(long)
+
+/* Deal with CONFIG_MODVERSIONS */
+#if CONFIG_MODVERSIONS==1
+#define MODVERSIONS
+#include <linux/modversions.h>
+#endif
+
+int ip_wccp_rcv(struct sk_buff *skb, unsigned short len)
+{
+ long *gre_hdr;
+
+ gre_hdr = (unsigned long *)skb->h.raw;
+ if(*gre_hdr != htonl(WCCP_PROTOCOL_TYPE)) {
+ goto drop;
+ }
+
+ skb->mac.raw = skb->nh.raw;
+ /* WCCP2 puts an extra 4 octets into the header, but uses the same
+ encapsulation type; if it looks as if the first octet of the packet
+ isn't the beginning of an IPv4 header, assume it's WCCP2. */
+ if ((skb->h.raw[WCCP_GRE_LEN] & 0xF0) != 0x40) {
+ skb->nh.raw = skb_pull(skb, skb->h.raw + WCCP_GRE_LEN + WCCP2_GRE_EXTRA -
skb->data);
+ } else {
+ skb->nh.raw = skb_pull(skb, skb->h.raw + WCCP_GRE_LEN - skb->data);
+ }
+
+ if (skb->len <= 0)
+ goto drop;
+
+ memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
+ skb->protocol = __constant_htons(ETH_P_IP);
+ skb->pkt_type = PACKET_HOST;
+ skb->ip_summed = 0;
+ dst_release(skb->dst);
+ skb->dst = NULL;
+
+ return ip_rcv(skb, skb->dev, NULL);
+
+drop:
+ kfree_skb(skb);
+ return(0);
+}
+
+static struct inet_protocol ipgre_protocol = {
+ ip_wccp_rcv,
+ NULL,
+ 0,
+ IPPROTO_GRE,
+ 0,
+ NULL,
+ "GRE"
+};
+
+int init_module(void)
+{
+ printk(KERN_INFO "WCCP IPv4/GRE driver\n");
+ inet_add_protocol(&ipgre_protocol);
+ return 0;
+}
+
+void cleanup_module(void)
+{
+ if ( inet_del_protocol(&ipgre_protocol) < 0 )
+ printk(KERN_INFO "ipgre close: can't remove protocol\n");
+ else
+ printk(KERN_INFO "WCCP IPv4/GRE driver unloaded\n");
+}
+
Received on Wed Mar 24 2004 - 23:26:37 MST

This archive was generated by hypermail pre-2.1.9 : Thu Apr 01 2004 - 12:00:03 MST