Skip to contentSkip to conversation

ipvsadm: allow tunneling with gre encapsulation

PATCH In review Julian Anastasov 2 participants 4 messages Jul 1, 2019 – Dec 5, 2019

Subsystems (2)
lore
Share & tools
lore

Julian Anastasov

author maintainer
#0 lore raw

PATCH 1/1 ipvsadm: allow tunneling with gre encapsulation

Add support for real server tunnels with GRE encapsulation:
--tun-type gre [--tun-nocsum|--tun-csum]

---
 ipvsadm.8       | 19 ++++++++++++++-----
 ipvsadm.c       | 20 +++++++++++++++++++-
 libipvs/ip_vs.h |  1 +
 3 files changed, 34 insertions(+), 6 deletions(-)

Jesper, this will follow the other patchset from 30-MAY-2019,
"Allow tunneling with gue encapsulation".

ipvsadm.8 +14 -5
index 256718e..6b81fc7 100644
@@ -342,7 +342,7 @@ the request sent to the virtual service.
 .ti +8
 .B --tun-type \fItun-type\fP
 .ti +16
-\fItun-type\fP is one of \fIipip\fP|\fIgue\fP.
+\fItun-type\fP is one of \fIipip\fP|\fIgue\fP|\fIgre\fP.
 The default value of \fItun-type\fP is \fIipip\fP.
 .sp
 .ti +8
@@ -354,14 +354,14 @@ Only valid for \fItun-type\fP \fIgue\fP.
 .ti +8
 .B --tun-nocsum
 .ti +16
-Specify that UDP checksums are disabled. This is the default.
-Only valid for \fItun-type\fP \fIgue\fP.
+Specify that tunnel checksums are disabled. This is the default.
+Only valid for \fItun-type\fP \fIgue\fP and \fIgre\fP.
 .sp
 .ti +8
 .B --tun-csum
 .ti +16
-Specify that UDP checksums are enabled.
-Only valid for \fItun-type\fP \fIgue\fP.
+Specify that tunnel checksums are enabled.
+Only valid for \fItun-type\fP \fIgue\fP and \fIgre\fP.
 .sp
 .ti +8
 .B --tun-remcsum
@@ -623,6 +623,15 @@ echo "
 -a -t 207.175.44.110:80 -r 192.168.10.5:80 -i --tun-type gue --tun-port 6079
 " | ipvsadm -R
 .fi
+.SH EXAMPLE 4 - Virtual Service with GRE Tunneling
+The following commands configure a Linux Director to use GRE
+encapsulation.
+.PP
+.nf
+ipvsadm -A -t 10.0.0.1:80 -s rr
+ipvsadm -a -t 10.0.0.1:80 -r 192.168.11.1:80 -i --tun-type gre \
+--tun-csum
+.fi
 .SH IPv6
 IPv6 addresses should be surrounded by square brackets ([ and ]).
 .PP
ipvsadm.c +19 -1
index 2f103cd..7619740 100644
@@ -297,6 +297,7 @@ static const char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] =
 static const char * const tunnames[] = {
 	"ipip",
 	"gue",
+	"gre",
 };
 
 static const char * const tunflags[] = {
@@ -334,6 +335,7 @@ tunnel_types_v_options[IP_VS_CONN_F_TUNNEL_TYPE_MAX][NUMBER_OF_TUN_OPT] = {
 	/*  tprt nocs csum remc */
 /* ipip */ {'x', 'x', 'x', 'x'},
 /* gue */  {'+', '1', '1', '1'},
+/* gre */  {'x', '1', '1', 'x'},
 };
 
 /* printing format flags */
@@ -1335,6 +1337,8 @@ static int parse_tun_type(const char *tun_type)
 		type = IP_VS_CONN_F_TUNNEL_TYPE_IPIP;
 	else if (!strcmp(tun_type, "gue"))
 		type = IP_VS_CONN_F_TUNNEL_TYPE_GUE;
+	else if (!strcmp(tun_type, "gre"))
+		type = IP_VS_CONN_F_TUNNEL_TYPE_GRE;
 	else
 		type = -1;
 
@@ -1506,7 +1510,7 @@ static void usage_exit(const char *program, const int exit_status)
 		"  --gatewaying   -g                   gatewaying (direct routing) (default)\n"
 		"  --ipip         -i                   ipip encapsulation (tunneling)\n"
 		"  --masquerading -m                   masquerading (NAT)\n"
-		"  --tun-type      type                one of ipip|gue,\n"
+		"  --tun-type      type                one of ipip|gue|gre,\n"
 		"                                      the default tunnel type is %s.\n"
 		"  --tun-port      port                tunnel destination port\n"
 		"  --tun-nocsum                        tunnel encapsulation without checksum\n"
@@ -1795,6 +1799,11 @@ static inline char *fwd_tun_info(ipvs_dest_entry_t *e)
 				 tunnames[e->tun_type], ntohs(e->tun_port),
 				 tunflags[e->tun_flags]);
 			break;
+		case IP_VS_CONN_F_TUNNEL_TYPE_GRE:
+			snprintf(info, 16, "%s:%s",
+				 tunnames[e->tun_type],
+				 tunflags[e->tun_flags]);
+			break;
 		default:
 			free(info);
 			return NULL;
@@ -1896,6 +1905,15 @@ static inline void
 print_tunnel_rule(char *svc_name, char *dname, ipvs_dest_entry_t *e)
 {
 	switch (e->tun_type) {
+	case IP_VS_CONN_F_TUNNEL_TYPE_GRE:
+		printf("-a %s -r %s %s -w %d --tun-type %s %s\n",
+		       svc_name,
+		       dname,
+		       fwd_switch(e->conn_flags),
+		       e->weight,
+		       tunnames[e->tun_type],
+		       tun_flags_opts[e->tun_flags]);
+		break;
 	case IP_VS_CONN_F_TUNNEL_TYPE_GUE:
 		printf("-a %s -r %s %s -w %d --tun-type %s --tun-port %d %s\n",
 		       svc_name,
libipvs/ip_vs.h +1 -0
index fa3770c..2670c23 100644
@@ -111,6 +111,7 @@
 enum {
 	IP_VS_CONN_F_TUNNEL_TYPE_IPIP = 0,	/* IPIP */
 	IP_VS_CONN_F_TUNNEL_TYPE_GUE,		/* GUE */
+	IP_VS_CONN_F_TUNNEL_TYPE_GRE,		/* GRE */
 	IP_VS_CONN_F_TUNNEL_TYPE_MAX,
 };
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 6 lines · On Mon, 1 Jul 2019 22:25:37 +0300 Julian Anastasov <[email protected]> wrote:

Add support for real server tunnels with GRE encapsulation:
--tun-type gre [--tun-nocsum|--tun-csum]

Quoted 8 lines
---
 ipvsadm.8       | 19 ++++++++++++++-----
 ipvsadm.c       | 20 +++++++++++++++++++-
 libipvs/ip_vs.h |  1 +
 3 files changed, 34 insertions(+), 6 deletions(-)

Jesper, this will follow the other patchset from 30-MAY-2019,
"Allow tunneling with gue encapsulation".

I've applied Jacky's patches, which this patch builds on top of, to the ipvsadm kernel.org git tree[1].

Simon already signed off on your kernel side patch, but it's not applied to a kernel git tree yet... Do you want me to apply this, or wait for this to hit a kernel tree?

[1] https://git.kernel.org/pub/scm/utils/kernel/ipvsadm/ipvsadm.git/

Signature · 4 lines
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer
author maintainer
#2 lore raw

Hello,

Quoted 18 lines · Jesper Dangaard Brouer
Quoted 6 lines · On Mon, 1 Jul 2019 22:25:37 +0300 Julian Anastasov <[email protected]> wrote:

Add support for real server tunnels with GRE encapsulation:
--tun-type gre [--tun-nocsum|--tun-csum]

Quoted 8 lines
---
 ipvsadm.8       | 19 ++++++++++++++-----
 ipvsadm.c       | 20 +++++++++++++++++++-
 libipvs/ip_vs.h |  1 +
 3 files changed, 34 insertions(+), 6 deletions(-)

Jesper, this will follow the other patchset from 30-MAY-2019,
"Allow tunneling with gue encapsulation".

Quoted 6 lines

I've applied Jacky's patches, which this patch builds on top of, to the ipvsadm kernel.org git tree[1].

Simon already signed off on your kernel side patch, but it's not applied to a kernel git tree yet... Do you want me to apply this, or wait for this to hit a kernel tree?

The both GRE patches are already part of nf-next, so
it is fine to apply this ipvsadm patch for GRE now. It would be better in case one wants to test the new features...

Regards

--
Julian Anastasov <[email protected]>

#3 lore raw
Quoted 25 lines · On Tue, 2 Jul 2019 22:21:01 +0300 (EEST) Julian Anastasov <[email protected]> wrote:

Hello,

Quoted 21 lines · Jesper Dangaard Brouer
Quoted 6 lines · On Mon, 1 Jul 2019 22:25:37 +0300 Julian Anastasov <[email protected]> wrote:

Add support for real server tunnels with GRE encapsulation:
--tun-type gre [--tun-nocsum|--tun-csum]

Quoted 8 lines
---
 ipvsadm.8       | 19 ++++++++++++++-----
 ipvsadm.c       | 20 +++++++++++++++++++-
 libipvs/ip_vs.h |  1 +
 3 files changed, 34 insertions(+), 6 deletions(-)

Jesper, this will follow the other patchset from 30-MAY-2019,
"Allow tunneling with gue encapsulation".

I've applied Jacky's patches, which this patch builds on top of, to the ipvsadm kernel.org git tree[1].

Quoted 7 lines
Quoted 3 lines

Simon already signed off on your kernel side patch, but it's not applied to a kernel git tree yet... Do you want me to apply this, or wait for this to hit a kernel tree?

The both GRE patches are already part of nf-next, so
it is fine to apply this ipvsadm patch for GRE now. It would be better in case one wants to test the new features...

I noticed that I had applied this patch, but forgot to push the ipvsadm git tree[1] on kernel.org. I've now pushed this...

https://git.kernel.org/pub/scm/utils/kernel/ipvsadm/ipvsadm.git/commit/?id=4a72198e7a3f9f275ff5752

Signature · 6 lines
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

[1] https://git.kernel.org/pub/scm/utils/kernel/ipvsadm/ipvsadm.git/