Commit bc1fc390 authored by Tom Herbert's avatar Tom Herbert Committed by David S. Miller

ip_tunnel: Add GUE support

This patch allows configuring IPIP, sit, and GRE tunnels to use GUE.
This is very similar to fou excpet that we need to insert the GUE header
in addition to the UDP header on transmit.
Signed-off-by: default avatarTom Herbert <therbert@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 37dd0247
...@@ -64,6 +64,7 @@ enum { ...@@ -64,6 +64,7 @@ enum {
enum tunnel_encap_types { enum tunnel_encap_types {
TUNNEL_ENCAP_NONE, TUNNEL_ENCAP_NONE,
TUNNEL_ENCAP_FOU, TUNNEL_ENCAP_FOU,
TUNNEL_ENCAP_GUE,
}; };
#define TUNNEL_ENCAP_FLAG_CSUM (1<<0) #define TUNNEL_ENCAP_FLAG_CSUM (1<<0)
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include <net/rtnetlink.h> #include <net/rtnetlink.h>
#include <net/udp.h> #include <net/udp.h>
#include <net/gue.h>
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
#include <net/ipv6.h> #include <net/ipv6.h>
...@@ -495,6 +496,8 @@ static int ip_encap_hlen(struct ip_tunnel_encap *e) ...@@ -495,6 +496,8 @@ static int ip_encap_hlen(struct ip_tunnel_encap *e)
return 0; return 0;
case TUNNEL_ENCAP_FOU: case TUNNEL_ENCAP_FOU:
return sizeof(struct udphdr); return sizeof(struct udphdr);
case TUNNEL_ENCAP_GUE:
return sizeof(struct udphdr) + sizeof(struct guehdr);
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -546,6 +549,15 @@ static int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, ...@@ -546,6 +549,15 @@ static int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
uh = udp_hdr(skb); uh = udp_hdr(skb);
if (e->type == TUNNEL_ENCAP_GUE) {
struct guehdr *guehdr = (struct guehdr *)&uh[1];
guehdr->version = 0;
guehdr->hlen = 0;
guehdr->flags = 0;
guehdr->next_hdr = *protocol;
}
uh->dest = e->dport; uh->dest = e->dport;
uh->source = sport; uh->source = sport;
uh->len = htons(skb->len); uh->len = htons(skb->len);
...@@ -565,6 +577,7 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, ...@@ -565,6 +577,7 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
case TUNNEL_ENCAP_NONE: case TUNNEL_ENCAP_NONE:
return 0; return 0;
case TUNNEL_ENCAP_FOU: case TUNNEL_ENCAP_FOU:
case TUNNEL_ENCAP_GUE:
return fou_build_header(skb, &t->encap, t->encap_hlen, return fou_build_header(skb, &t->encap, t->encap_hlen,
protocol, fl4); protocol, fl4);
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment