TUNNEL: IPv6-over-IPv6 tunnel support.
Subsystems (2)
PATCH 7/7 TUNNEL: IPv6-over-IPv6 tunnel support.
From: Masahide NAKAMURA <[email protected]>
Fix ip6tunnel.c to be fit with current ip command style. Unlike other modules currently iptunnel (and ip6tunnel) is not designed as protocol-independent because of unarranged structure between IPv4 and IPv6.
Usage: ip -f inet6 tunnel { add | change | del | show } [ NAME ]
[ remote ADDR local ADDR ] [ dev PHYS_DEV ] [ encaplimit ELIM ]
[ hoplimit HLIM ] [ tc TC ] [ fl FL ]
[ dscp inherit ]
Where: NAME := STRING
ADDR := IPV6_ADDRESS
ELIM := { none | 0..255 }(default=4)
HLIM := 0..255 (default=64)
TC := { 0x0..0xff | inherit }
FL := { 0x0..0xfffff | inherit }Signed-off-by Masahide NAKAMURA <[email protected]>
--- include/linux/ip6_tunnel.h | 34 +++ ip/Makefile | 2 ip/ip6tunnel.c | 543 +++++++++++++++++++++----------------------- ip/ip_common.h | 1 ip/iptunnel.c | 8 + 5 files changed, 308 insertions(+), 280 deletions(-)
include/linux/ip6_tunnel.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* $Id$ +*/ + +#ifndef _IP6_TUNNEL_H +#define _IP6_TUNNEL_H + +#define IPV6_TLV_TNL_ENCAP_LIMIT 4 +#define IPV6_DEFAULT_TNL_ENCAP_LIMIT 4 + +/* don't add encapsulation limit if one isn't present in inner packet */ +#define IP6_TNL_F_IGN_ENCAP_LIMIT 0x1 +/* copy the traffic class field from the inner packet */ +#define IP6_TNL_F_USE_ORIG_TCLASS 0x2 +/* copy the flowlabel from the inner packet */ +#define IP6_TNL_F_USE_ORIG_FLOWLABEL 0x4 +/* being used for Mobile IPv6 */ +#define IP6_TNL_F_MIP6_DEV 0x8 +/* copy DSCP from the outer packet */ +#define IP6_TNL_F_RCV_DSCP_COPY 0x10 + +struct ip6_tnl_parm { +char name[IFNAMSIZ ];/* name of tunnel device */ +int link;/* ifindex of underlying L2 interface */ +__u8 proto;/* tunnel protocol */ +__u8 encap_limit;/* encapsulation limit for tunnel */ +__u8 hop_limit;/* hop limit for tunnel */ +__u32 flowinfo;/* traffic class and flowlabel for tunnel */ +__u32 flags;/* tunnel flags */ +struct in6_addr laddr;/* local tunnel end-point address */ +struct in6_addr raddr;/* remote tunnel end-point address */ +}; + +#endif
ip/Makefile +1 -1
@@ -1,5 +1,5 @@ IPOBJ=ip.o ipaddress.o iproute.o iprule.o \ - rtm_map.o iptunnel.o tunnel.o ipneigh.o ipntable.o iplink.o \ + rtm_map.o iptunnel.o ip6tunnel.o tunnel.o ipneigh.o ipntable.o iplink.o \ ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o \ ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o
ip/ip6tunnel.c +264 -279
638 lines not on this page · raw message
ip/ip_common.h +1 -0
@@ -28,6 +28,7 @@ extern int do_iprule(int argc, char **arextern int do_ipneigh (int argc,char **argv);extern int do_ipntable (int argc,char **argv);extern int do_iptunnel (int argc,char **argv); +extern int do_ip6tunnel (int argc,char **argv);extern int do_iplink (int argc,char **argv);extern int do_ipmonitor (int argc,char **argv);extern int do_multiaddr (int argc,char **argv);
ip/iptunnel.c +8 -0
@@ -31,6 +31,7 @@ #include <linux/if_tunnel.h>#include "rt_names.h" #include "utils.h" +#include "ip_common.h" #include "tunnel.h" static void usage (void ) __attribute__((noreturn));
@@ -455,6 +456,13 @@ int do_iptunnel(int argc, char **argv)break ;case AF_INET :break ; +/* +* This is silly enough but we have no easy way to make it +* protocol-independent because of unarranged structure between +* IPv4 and IPv6. +*/ +case AF_INET6 : +return do_ip6tunnel (argc, argv);default :fprintf (stderr,"Unsupported family:%d\n" , preferred_family);exit (-1 );
Signature · 1 line
1.4.2