Skip to content

Commit 1df64a8

Browse files
Ville Nuorvalayoshfuji
authored andcommitted
[IPV6]: Add ip6ip6 tunnel driver.
1 parent 5b29b6f commit 1df64a8

File tree

9 files changed

+1372
-2
lines changed

9 files changed

+1372
-2
lines changed

include/linux/if_arp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#define ARPHRD_RAWHDLC 518 /* Raw HDLC */
6161

6262
#define ARPHRD_TUNNEL 768 /* IPIP tunnel */
63-
#define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel */
63+
#define ARPHRD_TUNNEL6 769 /* IP6IP6 tunnel */
6464
#define ARPHRD_FRAD 770 /* Frame Relay Access Device */
6565
#define ARPHRD_SKIP 771 /* SKIP vif */
6666
#define ARPHRD_LOOPBACK 772 /* Loopback device */

include/linux/ip6_tunnel.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* $Id$
3+
*/
4+
5+
#ifndef _IP6_TUNNEL_H
6+
#define _IP6_TUNNEL_H
7+
8+
#define IPV6_TLV_TNL_ENCAP_LIMIT 4
9+
#define IPV6_DEFAULT_TNL_ENCAP_LIMIT 4
10+
11+
/* don't add encapsulation limit if one isn't present in inner packet */
12+
#define IP6_TNL_F_IGN_ENCAP_LIMIT 0x1
13+
/* copy the traffic class field from the inner packet */
14+
#define IP6_TNL_F_USE_ORIG_TCLASS 0x2
15+
/* copy the flowlabel from the inner packet */
16+
#define IP6_TNL_F_USE_ORIG_FLOWLABEL 0x4
17+
/* being used for Mobile IPv6 */
18+
#define IP6_TNL_F_MIP6_DEV 0x8
19+
20+
struct ip6_tnl_parm {
21+
char name[IFNAMSIZ]; /* name of tunnel device */
22+
int link; /* ifindex of underlying L2 interface */
23+
__u8 proto; /* tunnel protocol */
24+
__u8 encap_limit; /* encapsulation limit for tunnel */
25+
__u8 hop_limit; /* hop limit for tunnel */
26+
__u32 flowinfo; /* traffic class and flowlabel for tunnel */
27+
__u32 flags; /* tunnel flags */
28+
struct in6_addr laddr; /* local tunnel end-point address */
29+
struct in6_addr raddr; /* remote tunnel end-point address */
30+
};
31+
32+
#endif

include/net/ip6_tunnel.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* $Id$
3+
*/
4+
5+
#ifndef _NET_IP6_TUNNEL_H
6+
#define _NET_IP6_TUNNEL_H
7+
8+
#include <linux/ipv6.h>
9+
#include <linux/netdevice.h>
10+
#include <linux/ip6_tunnel.h>
11+
12+
/* capable of sending packets */
13+
#define IP6_TNL_F_CAP_XMIT 0x10000
14+
/* capable of receiving packets */
15+
#define IP6_TNL_F_CAP_RCV 0x20000
16+
17+
#define IP6_TNL_MAX 128
18+
19+
/* IPv6 tunnel */
20+
21+
struct ip6_tnl {
22+
struct ip6_tnl *next; /* next tunnel in list */
23+
struct net_device *dev; /* virtual device associated with tunnel */
24+
struct net_device_stats stat; /* statistics for tunnel device */
25+
int recursion; /* depth of hard_start_xmit recursion */
26+
struct ip6_tnl_parm parms; /* tunnel configuration paramters */
27+
struct flowi fl; /* flowi template for xmit */
28+
};
29+
30+
/* Tunnel encapsulation limit destination sub-option */
31+
32+
struct ipv6_tlv_tnl_enc_lim {
33+
__u8 type; /* type-code for option */
34+
__u8 length; /* option length */
35+
__u8 encap_limit; /* tunnel encapsulation limit */
36+
} __attribute__ ((packed));
37+
38+
#ifdef __KERNEL__
39+
#ifdef CONFIG_IPV6_TUNNEL
40+
extern int __init ip6_tunnel_init(void);
41+
extern void ip6_tunnel_cleanup(void);
42+
#endif
43+
#endif
44+
#endif

net/ipv6/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,12 @@ config INET6_IPCOMP
5555

5656
If unsure, say Y.
5757

58+
config IPV6_TUNNEL
59+
tristate "IPv6: IPv6-in-IPv6 tunnel"
60+
depends on IPV6
61+
---help---
62+
Support for IPv6-in-IPv6 tunnels described in RFC 2473.
63+
64+
If unsure, say N.
65+
5866
source "net/ipv6/netfilter/Kconfig"

net/ipv6/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ obj-$(CONFIG_INET6_AH) += ah6.o
1515
obj-$(CONFIG_INET6_ESP) += esp6.o
1616
obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o
1717
obj-$(CONFIG_NETFILTER) += netfilter/
18+
19+
obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o

net/ipv6/af_inet6.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
#include <net/transp_v6.h>
5858
#include <net/ip6_route.h>
5959
#include <net/addrconf.h>
60+
#if CONFIG_IPV6_TUNNEL
61+
#include <net/ip6_tunnel.h>
62+
#endif
6063

6164
#include <asm/uaccess.h>
6265
#include <asm/system.h>
@@ -776,6 +779,11 @@ static int __init inet6_init(void)
776779
err = ndisc_init(&inet6_family_ops);
777780
if (err)
778781
goto ndisc_fail;
782+
#ifdef CONFIG_IPV6_TUNNEL
783+
err = ip6_tunnel_init();
784+
if (err)
785+
goto ip6_tunnel_fail;
786+
#endif
779787
err = igmp6_init(&inet6_family_ops);
780788
if (err)
781789
goto igmp_fail;
@@ -830,6 +838,10 @@ static int __init inet6_init(void)
830838
igmp6_cleanup();
831839
#endif
832840
igmp_fail:
841+
#ifdef CONFIG_IPV6_TUNNEL
842+
ip6_tunnel_cleanup();
843+
ip6_tunnel_fail:
844+
#endif
833845
ndisc_cleanup();
834846
ndisc_fail:
835847
icmpv6_cleanup();
@@ -865,6 +877,9 @@ static void inet6_exit(void)
865877
ip6_route_cleanup();
866878
ipv6_packet_cleanup();
867879
igmp6_cleanup();
880+
#ifdef CONFIG_IPV6_TUNNEL
881+
ip6_tunnel_cleanup();
882+
#endif
868883
ndisc_cleanup();
869884
icmpv6_cleanup();
870885
#ifdef CONFIG_SYSCTL

0 commit comments

Comments
 (0)