Skip to content

Commit c12b395

Browse files
xebddavem330
authored andcommitted
gre: Support GRE over IPv6
GRE over IPv6 implementation. Signed-off-by: Dmitry Kozlov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b7bc2a5 commit c12b395

File tree

9 files changed

+1933
-26
lines changed

9 files changed

+1933
-26
lines changed

include/linux/if_arp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#define ARPHRD_PHONET 820 /* PhoNet media type */
9393
#define ARPHRD_PHONET_PIPE 821 /* PhoNet pipe header */
9494
#define ARPHRD_CAIF 822 /* CAIF media type */
95+
#define ARPHRD_IP6GRE 823 /* GRE over IPv6 */
9596

9697
#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known */
9798
#define ARPHRD_NONE 0xFFFE /* zero header length */

include/linux/if_tunnel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ enum {
7575
IFLA_GRE_TTL,
7676
IFLA_GRE_TOS,
7777
IFLA_GRE_PMTUDISC,
78+
IFLA_GRE_ENCAP_LIMIT,
79+
IFLA_GRE_FLOWINFO,
80+
IFLA_GRE_FLAGS,
7881
__IFLA_GRE_MAX,
7982
};
8083

include/linux/ip6_tunnel.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,21 @@ struct ip6_tnl_parm {
3131
struct in6_addr raddr; /* remote tunnel end-point address */
3232
};
3333

34+
struct ip6_tnl_parm2 {
35+
char name[IFNAMSIZ]; /* name of tunnel device */
36+
int link; /* ifindex of underlying L2 interface */
37+
__u8 proto; /* tunnel protocol */
38+
__u8 encap_limit; /* encapsulation limit for tunnel */
39+
__u8 hop_limit; /* hop limit for tunnel */
40+
__be32 flowinfo; /* traffic class and flowlabel for tunnel */
41+
__u32 flags; /* tunnel flags */
42+
struct in6_addr laddr; /* local tunnel end-point address */
43+
struct in6_addr raddr; /* remote tunnel end-point address */
44+
45+
__be16 i_flags;
46+
__be16 o_flags;
47+
__be32 i_key;
48+
__be32 o_key;
49+
};
50+
3451
#endif

include/net/ip6_tunnel.h

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,49 @@
55
#include <linux/netdevice.h>
66
#include <linux/ip6_tunnel.h>
77

8+
#define IP6TUNNEL_ERR_TIMEO (30*HZ)
9+
810
/* capable of sending packets */
911
#define IP6_TNL_F_CAP_XMIT 0x10000
1012
/* capable of receiving packets */
1113
#define IP6_TNL_F_CAP_RCV 0x20000
1214
/* determine capability on a per-packet basis */
1315
#define IP6_TNL_F_CAP_PER_PACKET 0x40000
1416

15-
/* IPv6 tunnel */
17+
struct __ip6_tnl_parm {
18+
char name[IFNAMSIZ]; /* name of tunnel device */
19+
int link; /* ifindex of underlying L2 interface */
20+
__u8 proto; /* tunnel protocol */
21+
__u8 encap_limit; /* encapsulation limit for tunnel */
22+
__u8 hop_limit; /* hop limit for tunnel */
23+
__be32 flowinfo; /* traffic class and flowlabel for tunnel */
24+
__u32 flags; /* tunnel flags */
25+
struct in6_addr laddr; /* local tunnel end-point address */
26+
struct in6_addr raddr; /* remote tunnel end-point address */
27+
28+
__be16 i_flags;
29+
__be16 o_flags;
30+
__be32 i_key;
31+
__be32 o_key;
32+
};
1633

34+
/* IPv6 tunnel */
1735
struct ip6_tnl {
1836
struct ip6_tnl __rcu *next; /* next tunnel in list */
1937
struct net_device *dev; /* virtual device associated with tunnel */
20-
struct ip6_tnl_parm parms; /* tunnel configuration parameters */
38+
struct __ip6_tnl_parm parms; /* tunnel configuration parameters */
2139
struct flowi fl; /* flowi template for xmit */
2240
struct dst_entry *dst_cache; /* cached dst */
2341
u32 dst_cookie;
42+
43+
int err_count;
44+
unsigned long err_time;
45+
46+
/* These fields used only by GRE */
47+
__u32 i_seqno; /* The last seen seqno */
48+
__u32 o_seqno; /* The last output seqno */
49+
int hlen; /* Precalculated GRE header length */
50+
int mlink;
2451
};
2552

2653
/* Tunnel encapsulation limit destination sub-option */
@@ -31,4 +58,14 @@ struct ipv6_tlv_tnl_enc_lim {
3158
__u8 encap_limit; /* tunnel encapsulation limit */
3259
} __packed;
3360

61+
struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t);
62+
void ip6_tnl_dst_reset(struct ip6_tnl *t);
63+
void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst);
64+
int ip6_tnl_rcv_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
65+
const struct in6_addr *raddr);
66+
int ip6_tnl_xmit_ctl(struct ip6_tnl *t);
67+
__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
68+
__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
69+
const struct in6_addr *raddr);
70+
3471
#endif

include/net/ipv6.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define NEXTHDR_IPV6 41 /* IPv6 in IPv6 */
3535
#define NEXTHDR_ROUTING 43 /* Routing header. */
3636
#define NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */
37+
#define NEXTHDR_GRE 47 /* GRE header. */
3738
#define NEXTHDR_ESP 50 /* Encapsulating security payload. */
3839
#define NEXTHDR_AUTH 51 /* Authentication header. */
3940
#define NEXTHDR_ICMP 58 /* ICMP for IPv6. */

net/ipv6/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,22 @@ config IPV6_TUNNEL
201201

202202
If unsure, say N.
203203

204+
config IPV6_GRE
205+
tristate "IPv6: GRE tunnel"
206+
select IPV6_TUNNEL
207+
---help---
208+
Tunneling means encapsulating data of one protocol type within
209+
another protocol and sending it over a channel that understands the
210+
encapsulating protocol. This particular tunneling driver implements
211+
GRE (Generic Routing Encapsulation) and at this time allows
212+
encapsulating of IPv4 or IPv6 over existing IPv6 infrastructure.
213+
This driver is useful if the other endpoint is a Cisco router: Cisco
214+
likes GRE much better than the other Linux tunneling driver ("IP
215+
tunneling" above). In addition, GRE allows multicast redistribution
216+
through the tunnel.
217+
218+
Saying M here will produce a module called ip6_gre. If unsure, say N.
219+
204220
config IPV6_MULTIPLE_TABLES
205221
bool "IPv6: Multiple Routing Tables"
206222
depends on EXPERIMENTAL

net/ipv6/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ obj-$(CONFIG_NETFILTER) += netfilter/
3636

3737
obj-$(CONFIG_IPV6_SIT) += sit.o
3838
obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
39+
obj-$(CONFIG_IPV6_GRE) += ip6_gre.o
3940

4041
obj-y += addrconf_core.o exthdrs_core.o
4142

0 commit comments

Comments
 (0)