Skip to contentSkip to conversation

net/ipv6: seperate sit driver to extra module

PATCH Applied Joerg Roedel 4 participants 14 messages Oct 10, 2006 – Nov 5, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 net/ipv6: seperate sit driver to extra module

This patch removes the driver of the IPv6-in-IPv4 tunnel driver (sit) from the IPv6 module. It adds an option to Kconfig which makes it possible to compile it as a seperate module.

net/ipv6/af_inet6.c +0 -2
diff -upr -X linux-2.6.18/Documentation/dontdiff linux-2.6.18-vanilla/net/ipv6/af_inet6.c linux-2.6.18/net/ipv6/af_inet6.c
@@ -849,7 +849,6 @@ static int __init inet6_init(void)
 	err = addrconf_init();
 	if (err)
 		goto addrconf_fail;
-	sit_init();
 
 	/* Init v6 extension headers. */
 	ipv6_rthdr_init();
@@ -920,7 +919,6 @@ static void __exit inet6_exit(void)
  	raw6_proc_exit();
 #endif
 	/* Cleanup code parts. */
-	sit_cleanup();
 	ip6_flowlabel_cleanup();
 	addrconf_cleanup();
 	ip6_route_cleanup();
net/ipv6/Kconfig +13 -0
diff -upr -X linux-2.6.18/Documentation/dontdiff linux-2.6.18-vanilla/net/ipv6/Kconfig linux-2.6.18/net/ipv6/Kconfig
@@ -126,6 +126,19 @@ config INET6_XFRM_MODE_TUNNEL
 
 	  If unsure, say Y.
 
+config IPV6_SIT
+	tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)"
+	depends on IPV6
+	default y
+	---help---
+	  Tunneling means encapsulating data of one protocol type within
+	  another protocol and sending it over a channel that understands the
+	  encapsulating protocol. This driver implements encapsulation of IPv6
+	  into IPv4 packets. This is useful if you want to connect two IPv6
+	  networks over an IPv4-only path.
+
+	  Saying M here will produce a module called sit.ko. If unsure, say Y.
+
 config IPV6_TUNNEL
 	tristate "IPv6: IPv6-in-IPv6 tunnel"
 	select INET6_TUNNEL
net/ipv6/Makefile +2 -1
diff -upr -X linux-2.6.18/Documentation/dontdiff linux-2.6.18-vanilla/net/ipv6/Makefile linux-2.6.18/net/ipv6/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_IPV6) += ipv6.o
 
-ipv6-objs :=	af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o sit.o \
+ipv6-objs :=	af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \
 		route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \
 		protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
 		exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \
@@ -24,6 +24,7 @@ obj-$(CONFIG_INET6_XFRM_MODE_TRANSPORT) 
 obj-$(CONFIG_INET6_XFRM_MODE_TUNNEL) += xfrm6_mode_tunnel.o
 obj-$(CONFIG_NETFILTER)	+= netfilter/
 
+obj-$(CONFIG_IPV6_SIT) += sit.o
 obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
 
 obj-y += exthdrs_core.o
net/ipv6/sit.c +3 -0
diff -upr -X linux-2.6.18/Documentation/dontdiff linux-2.6.18-vanilla/net/ipv6/sit.c linux-2.6.18/net/ipv6/sit.c
@@ -850,3 +850,6 @@ int __init sit_init(void)
 	inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
 	goto out;
 }
+
+module_init(sit_init);
+module_exit(sit_cleanup);
#2 lore raw

PATCH v3 2/2 net/ipv6: seperate sit driver to extra module (addrconf.c changes)

In reply to Joerg Roedel

This patch contains the changes to net/ipv6/addrconf.c to remove sit specific code if the sit driver is not selected.

net/ipv6/addrconf.c +16 -2
diff -upr -X linux-2.6.18/Documentation/dontdiff linux-2.6.18-vanilla/net/ipv6/addrconf.c linux-2.6.18/net/ipv6/addrconf.c
@@ -389,8 +389,10 @@ static struct inet6_dev * ipv6_add_dev(s
 	ndev->regen_timer.data = (unsigned long) ndev;
 	if ((dev->flags&IFF_LOOPBACK) ||
 	    dev->type == ARPHRD_TUNNEL ||
-	    dev->type == ARPHRD_NONE ||
-	    dev->type == ARPHRD_SIT) {
+#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
+	    dev->type == ARPHRD_SIT ||
+#endif
+	    dev->type == ARPHRD_NONE) {
 		printk(KERN_INFO
 		       "%s: Disabled Privacy Extensions\n",
 		       dev->name);
@@ -1522,8 +1524,10 @@ addrconf_prefix_route(struct in6_addr *p
 	   This thing is done here expecting that the whole
 	   class of non-broadcast devices need not cloning.
 	 */
+#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
 	if (dev->type == ARPHRD_SIT && (dev->flags&IFF_POINTOPOINT))
 		rtmsg.rtmsg_flags |= RTF_NONEXTHOP;
+#endif
 
 	ip6_route_add(&rtmsg, NULL, NULL, NULL);
 }
@@ -1545,6 +1549,7 @@ static void addrconf_add_mroute(struct n
 	ip6_route_add(&rtmsg, NULL, NULL, NULL);
 }
 
+#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
 static void sit_route_add(struct net_device *dev)
 {
 	struct in6_rtmsg rtmsg;
@@ -1561,6 +1566,7 @@ static void sit_route_add(struct net_dev
 
 	ip6_route_add(&rtmsg, NULL, NULL, NULL);
 }
+#endif
 
 static void addrconf_add_lroute(struct net_device *dev)
 {
@@ -1831,6 +1837,7 @@ int addrconf_set_dstaddr(void __user *ar
 	if (dev == NULL)
 		goto err_exit;
 
+#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
 	if (dev->type == ARPHRD_SIT) {
 		struct ifreq ifr;
 		mm_segment_t	oldfs;
@@ -1860,6 +1867,7 @@ int addrconf_set_dstaddr(void __user *ar
 			err = dev_open(dev);
 		}
 	}
+#endif
 
 err_exit:
 	rtnl_unlock();
@@ -1993,6 +2001,7 @@ int addrconf_del_ifaddr(void __user *arg
 	return err;
 }
 
+#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
 static void sit_add_v4_addrs(struct inet6_dev *idev)
 {
 	struct inet6_ifaddr * ifp;
@@ -2061,6 +2070,7 @@ static void sit_add_v4_addrs(struct inet
 		}
         }
 }
+#endif
 
 static void init_loopback(struct net_device *dev)
 {
@@ -2124,6 +2134,7 @@ static void addrconf_dev_config(struct n
 		addrconf_add_linklocal(idev, &addr);
 }
 
+#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
 static void addrconf_sit_config(struct net_device *dev)
 {
 	struct inet6_dev *idev;
@@ -2149,6 +2160,7 @@ static void addrconf_sit_config(struct n
 	} else
 		sit_route_add(dev);
 }
+#endif
 
 static inline int
 ipv6_inherit_linklocal(struct inet6_dev *idev, struct net_device *link_dev)
@@ -2243,9 +2255,11 @@ static int addrconf_notify(struct notifi
 		}
 
 		switch(dev->type) {
+#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
 		case ARPHRD_SIT:
 			addrconf_sit_config(dev);
 			break;
+#endif
 		case ARPHRD_TUNNEL6:
 			addrconf_ip6_tnl_config(dev);
 			break;
#5 lore raw
In reply to Joerg Roedel

This is missing the MODULE_LICENSE statements and taints the kernel upon loading. License is obvious from the beginning of the file.

net/ipv6/sit.c int __init sit_init(void) · line 855

Quoted 9 lines · Joerg Roedel
net/ipv6/sit.c +3 -0
@@ -850,3 +850,6 @@ int __init sit_init(void)
 	inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
 	goto out;
 }
+
+module_init(sit_init);
+module_exit(sit_cleanup);
net/ipv6/sit.c renamed from net/ipv6/sit.c~ +1 -0
@@ -853,3 +853,4 @@ int __init sit_init(void)
 
 module_init(sit_init);
 module_exit(sit_cleanup);
+MODULE_LICENSE("GPL");
#6 lore raw
Quoted 2 lines · Jan Dittmer

This is missing the MODULE_LICENSE statements and taints the kernel upon loading. License is obvious from the beginning of the file.

Ah, ok. I forgot that. Thanks for the fix.

Quoted 12 lines

net/ipv6/sit.c int __init sit_init(void) · line 855

Quoted 9 lines · Joerg Roedel
net/ipv6/sit.c +3 -0
@@ -850,3 +850,6 @@ int __init sit_init(void)
 	inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
 	goto out;
 }
+
+module_init(sit_init);
+module_exit(sit_cleanup);
Quoted 8 lines
net/ipv6/sit.c renamed from net/ipv6/sit.c~ +1 -0
@@ -853,3 +853,4 @@ int __init sit_init(void)
 
 module_init(sit_init);
 module_exit(sit_cleanup);
+MODULE_LICENSE("GPL");
#8 lore raw
Quoted 12 lines · David Miller

From: Joerg Roedel <[email protected]>
Date: Fri, 13 Oct 2006 21:17:45 +0200

Quoted 3 lines · Jan Dittmer
Quoted 2 lines

This is missing the MODULE_LICENSE statements and taints the kernel upon loading. License is obvious from the beginning of the file.

...

Quoted 2 lines
Quoted 1 line

Applied, thanks for catching this Jan.

Btw. is there any way to autoload the sit module or is this the task of the distribution tools? Debian etch at least does not automatically probe the module when trying to bring up a 6to4 tunnel.

Jan

#9 lore raw
Quoted 9 lines · Jan Dittmer
Quoted 8 lines · David Miller

From: Joerg Roedel <[email protected]>
Date: Fri, 13 Oct 2006 21:17:45 +0200

Quoted 3 lines · Jan Dittmer
Quoted 2 lines

This is missing the MODULE_LICENSE statements and taints the kernel upon loading. License is obvious from the beginning of the file.

...

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Applied, thanks for catching this Jan.

Btw. is there any way to autoload the sit module or is this the task of the distribution tools? Debian etch at least does not automatically probe the module when trying to bring up a 6to4 tunnel.

AFAIK there is no way to automatically load the driver from the kernel space. The configuration of the tunnel devices requires the sit0 device. But this device is installed by the sit driver. I mailed a bug report to the Debian people and informed them about the change.

Joerg

#10 lore raw
Quoted 11 lines · Joerg Roedel
Quoted 3 lines · Jan Dittmer

Btw. is there any way to autoload the sit module or is this the task of the distribution tools? Debian etch at least does not automatically probe the module when trying to bring up a 6to4 tunnel.

AFAIK there is no way to automatically load the driver from the kernel space. The configuration of the tunnel devices requires the sit0 device. But this device is installed by the sit driver. I mailed a bug report to the Debian people and informed them about the change.

It would be nice to keep things working even with this built as a module, it took me some time to realize my IPv6 tunnel was broken because of the missing sit module. This module alias fixes things until distributions have added an appropriate alias to modprobe.conf.

net/ipv6/sit.c +1 -0
index b481a4d..be699f8 100644
@@ -854,3 +854,4 @@ int __init sit_init(void)
 module_init(sit_init);
 module_exit(sit_cleanup);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("sit0");
maintainer
#11 lore raw

From: Patrick McHardy <[email protected]>
Date: Sun, 05 Nov 2006 23:35:07 +0100

Quoted 6 lines

It would be nice to keep things working even with this built as a module, it took me some time to realize my IPv6 tunnel was broken because of the missing sit module. This module alias fixes things until distributions have added an appropriate alias to modprobe.conf.

Would you like me to apply this or is this a temp workaround for folks?

#12 lore raw
Quoted 2 lines · David Miller

Would you like me to apply this or is this a temp workaround for folks?

Please apply it. I usually build things as module if possible, which in this case caused my tunnel to break. This will probably happen to others as well.

maintainer
#13 lore raw

From: Patrick McHardy <[email protected]>
Date: Mon, 06 Nov 2006 00:38:14 +0100

Quoted 7 lines
Quoted 2 lines · David Miller

Would you like me to apply this or is this a temp workaround for folks?

Please apply it. I usually build things as module if possible, which in this case caused my tunnel to break. This will probably happen to others as well.

Ok, done.

Thanks.