Skip to contentSkip to conversation

ipvs: allow tunneling with gue encapsulation

PATCH Superseded Jacky Hu 3 participants 5 messages Mar 17, 2019 – Mar 18, 2019

Subsystems (5)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Jacky Hu

author
#0 lore raw

PATCH v4 1/1 ipvs: allow tunneling with gue encapsulation

ipip packets are blocked in some public cloud environments, this patch allows gue encapsulation with the tunneling method, which would make tunneling working in those environments.

---
 include/net/ip_vs.h             |   5 ++
 include/uapi/linux/ip_vs.h      |  11 +++
 net/netfilter/ipvs/ip_vs_ctl.c  |  43 ++++++++++-
 net/netfilter/ipvs/ip_vs_xmit.c | 124 ++++++++++++++++++++++++++++++--
 4 files changed, 178 insertions(+), 5 deletions(-)
include/net/ip_vs.h +5 -0
index a0d2e0bb9a94..56c1770b00fe 100644
@@ -603,6 +603,9 @@ struct ip_vs_dest_user_kern {
 
 	/* Address family of addr */
 	u16			af;
+
+	u16			tun_type;	/* tunnel type */
+	__be16			tun_port;	/* tunnel port */
 };
 
 
@@ -663,6 +666,8 @@ struct ip_vs_dest {
 	atomic_t		conn_flags;	/* flags to copy to conn */
 	atomic_t		weight;		/* server weight */
 	atomic_t		last_weight;	/* server latest weight */
+	atomic_t		tun_type;	/* tunnel type */
+	atomic_t		tun_port;	/* tunnel port */
 
 	refcount_t		refcnt;		/* reference counter */
 	struct ip_vs_stats      stats;          /* statistics */
include/uapi/linux/ip_vs.h +11 -0
index 1c916b2f89dc..e34f436fc79d 100644
@@ -124,6 +124,13 @@
 
 #define IP_VS_PEDATA_MAXLEN     255
 
+/* Tunnel types */
+enum {
+	IP_VS_CONN_F_TUNNEL_TYPE_IPIP = 0,	/* IPIP */
+	IP_VS_CONN_F_TUNNEL_TYPE_GUE,		/* GUE */
+	IP_VS_CONN_F_TUNNEL_TYPE_MAX,
+};
+
 /*
  *	The struct ip_vs_service_user and struct ip_vs_dest_user are
  *	used to set IPVS rules through setsockopt.
@@ -392,6 +399,10 @@ enum {
 
 	IPVS_DEST_ATTR_STATS64,		/* nested attribute for dest stats */
 
+	IPVS_DEST_ATTR_TUN_TYPE,	/* tunnel type */
+
+	IPVS_DEST_ATTR_TUN_PORT,	/* tunnel port */
+
 	__IPVS_DEST_ATTR_MAX,
 };
 
net/netfilter/ipvs/ip_vs_ctl.c +42 -1

96 lines not on this page · raw message

net/netfilter/ipvs/ip_vs_xmit.c +120 -4

207 lines not on this page · raw message

Signature · 1 line
2.21.0
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Jacky,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ipvs-next/master]
[also build test WARNING on v5.1-rc1 next-20190306]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jacky-Hu/ipvs-allow-tunneling-with-gue-encapsulation/20190318-070156
base:   https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git master
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

sparse warnings: (new ones prefixed by >>)

net/netfilter/ipvs/ip_vs_ctl.c:835:42: sparse: incorrect type in argument 2 (different base types) @@ expected int [signed] i @@ got restricted __be1int [signed] i @@
net/netfilter/ipvs/ip_vs_ctl.c:835:42: expected int [signed] i
net/netfilter/ipvs/ip_vs_ctl.c:835:42: got restricted __be16 [usertype] tun_port
net/netfilter/ipvs/ip_vs_ctl.c:1197:44: sparse: expression using sizeof(void)

>> net/netfilter/ipvs/ip_vs_ctl.c:3207:37: sparse: incorrect type in argument 3 (different base types) @@    expected restricted __be16 [usertype] value @@    got e] value @@

net/netfilter/ipvs/ip_vs_ctl.c:3207:37: expected restricted __be16 [usertype] value
net/netfilter/ipvs/ip_vs_ctl.c:3207:37: got int
net/netfilter/ipvs/ip_vs_ctl.c:1313:27: sparse: dereference of noderef expression

vim +3207 net/netfilter/ipvs/ip_vs_ctl.c

3187
3188 static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
3189 {
3190 struct nlattr *nl_dest;
3191 struct ip_vs_kstats kstats;
3192
3193 nl_dest = nla_nest_start(skb, IPVS_CMD_ATTR_DEST);
3194 if (!nl_dest)
3195 return -EMSGSIZE;
3196
3197 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
3198 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
3199 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
3200 (atomic_read(&dest->conn_flags) &
3201 IP_VS_CONN_F_FWD_MASK)) ||
3202 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
3203 atomic_read(&dest->weight)) ||
3204 nla_put_u8(skb, IPVS_DEST_ATTR_TUN_TYPE,
3205 atomic_read(&dest->tun_type)) ||
3206 nla_put_be16(skb, IPVS_DEST_ATTR_TUN_PORT,

> 3207				 atomic_read(&dest->tun_port)) ||
  3208		    nla_put_u32(skb, IPVS_DEST_ATTR_U_THRESH, dest->u_threshold) ||
  3209		    nla_put_u32(skb, IPVS_DEST_ATTR_L_THRESH, dest->l_threshold) ||
  3210		    nla_put_u32(skb, IPVS_DEST_ATTR_ACTIVE_CONNS,

3211 atomic_read(&dest->activeconns)) ||
3212 nla_put_u32(skb, IPVS_DEST_ATTR_INACT_CONNS,
3213 atomic_read(&dest->inactconns)) ||
3214 nla_put_u32(skb, IPVS_DEST_ATTR_PERSIST_CONNS,
3215 atomic_read(&dest->persistconns)) ||
3216 nla_put_u16(skb, IPVS_DEST_ATTR_ADDR_FAMILY, dest->af))
3217 goto nla_put_failure;
3218 ip_vs_copy_stats(&kstats, &dest->stats);
3219 if (ip_vs_genl_fill_stats(skb, IPVS_DEST_ATTR_STATS, &kstats))
3220 goto nla_put_failure;
3221 if (ip_vs_genl_fill_stats64(skb, IPVS_DEST_ATTR_STATS64, &kstats))
3222 goto nla_put_failure;
3223
3224 nla_nest_end(skb, nl_dest);
3225
3226 return 0;
3227
3228 nla_put_failure:
3229 nla_nest_cancel(skb, nl_dest);
3230 return -EMSGSIZE;
3231 }
3232

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author
#2 lore raw
Quoted 41 lines · kbuild test robot

Hi Jacky,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ipvs-next/master]
[also build test WARNING on v5.1-rc1 next-20190306]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jacky-Hu/ipvs-allow-tunneling-with-gue-encapsulation/20190318-070156
base:   https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git master
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

sparse warnings: (new ones prefixed by >>)

net/netfilter/ipvs/ip_vs_ctl.c:835:42: sparse: incorrect type in argument 2 (different base types) @@ expected int [signed] i @@ got restricted __be1int [signed] i @@
net/netfilter/ipvs/ip_vs_ctl.c:835:42: expected int [signed] i
net/netfilter/ipvs/ip_vs_ctl.c:835:42: got restricted __be16 [usertype] tun_port
net/netfilter/ipvs/ip_vs_ctl.c:1197:44: sparse: expression using sizeof(void)

Quoted 1 line
Quoted 1 line

net/netfilter/ipvs/ip_vs_ctl.c:3207:37: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be16 [usertype] value @@ got e] value @@

net/netfilter/ipvs/ip_vs_ctl.c:3207:37: expected restricted __be16 [usertype] value
net/netfilter/ipvs/ip_vs_ctl.c:3207:37: got int
net/netfilter/ipvs/ip_vs_ctl.c:1313:27: sparse: dereference of noderef expression

vim +3207 net/netfilter/ipvs/ip_vs_ctl.c

3187
3188 static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
3189 {
3190 struct nlattr *nl_dest;
3191 struct ip_vs_kstats kstats;
3192
3193 nl_dest = nla_nest_start(skb, IPVS_CMD_ATTR_DEST);
3194 if (!nl_dest)
3195 return -EMSGSIZE;
3196
3197 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
3198 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||

Quoted 9 lines

3199 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
3200 (atomic_read(&dest->conn_flags) &
3201 IP_VS_CONN_F_FWD_MASK)) ||
3202 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
3203 atomic_read(&dest->weight)) ||
3204 nla_put_u8(skb, IPVS_DEST_ATTR_TUN_TYPE,
3205 atomic_read(&dest->tun_type)) ||
3206 nla_put_be16(skb, IPVS_DEST_ATTR_TUN_PORT,

Quoted 1 line

3207 atomic_read(&dest->tun_port)) ||

Should I change the type of tun_port from __be16 to u16? Looks like kbuild bugs a lot on this.

Quoted 29 lines
  3208		    nla_put_u32(skb, IPVS_DEST_ATTR_U_THRESH, dest->u_threshold) ||
  3209		    nla_put_u32(skb, IPVS_DEST_ATTR_L_THRESH, dest->l_threshold) ||
  3210		    nla_put_u32(skb, IPVS_DEST_ATTR_ACTIVE_CONNS,

3211 atomic_read(&dest->activeconns)) ||
3212 nla_put_u32(skb, IPVS_DEST_ATTR_INACT_CONNS,
3213 atomic_read(&dest->inactconns)) ||
3214 nla_put_u32(skb, IPVS_DEST_ATTR_PERSIST_CONNS,
3215 atomic_read(&dest->persistconns)) ||
3216 nla_put_u16(skb, IPVS_DEST_ATTR_ADDR_FAMILY, dest->af))
3217 goto nla_put_failure;
3218 ip_vs_copy_stats(&kstats, &dest->stats);
3219 if (ip_vs_genl_fill_stats(skb, IPVS_DEST_ATTR_STATS, &kstats))
3220 goto nla_put_failure;
3221 if (ip_vs_genl_fill_stats64(skb, IPVS_DEST_ATTR_STATS64, &kstats))
3222 goto nla_put_failure;
3223
3224 nla_nest_end(skb, nl_dest);
3225
3226 return 0;
3227
3228 nla_put_failure:
3229 nla_nest_cancel(skb, nl_dest);
3230 return -EMSGSIZE;
3231 }
3232

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

maintainer
#3 lore raw

Hello,

Quoted 28 lines · Jacky Hu
Quoted 27 lines · kbuild test robot

Hi Jacky,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ipvs-next/master]
[also build test WARNING on v5.1-rc1 next-20190306]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jacky-Hu/ipvs-allow-tunneling-with-gue-encapsulation/20190318-070156
base:   https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git master
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

sparse warnings: (new ones prefixed by >>)

net/netfilter/ipvs/ip_vs_ctl.c:835:42: sparse: incorrect type in argument 2 (different base types) @@ expected int [signed] i @@ got restricted __be1int [signed] i @@
net/netfilter/ipvs/ip_vs_ctl.c:835:42: expected int [signed] i
net/netfilter/ipvs/ip_vs_ctl.c:835:42: got restricted __be16 [usertype] tun_port
net/netfilter/ipvs/ip_vs_ctl.c:1197:44: sparse: expression using sizeof(void)

Quoted 1 line
Quoted 1 line

net/netfilter/ipvs/ip_vs_ctl.c:3207:37: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be16 [usertype] value @@ got e] value @@

net/netfilter/ipvs/ip_vs_ctl.c:3207:37: expected restricted __be16 [usertype] value
net/netfilter/ipvs/ip_vs_ctl.c:3207:37: got int
net/netfilter/ipvs/ip_vs_ctl.c:1313:27: sparse: dereference of noderef expression

Quoted 7 lines
Quoted 4 lines

vim +3207 net/netfilter/ipvs/ip_vs_ctl.c

Quoted 1 line

3207 atomic_read(&dest->tun_port)) ||

Should I change the type of tun_port from __be16 to u16? Looks like kbuild bugs a lot on this.

In struct ip_vs_dest you should use __be16 for tun_port and
__u16 for tun_type and avoid any atomic_t usage. To test it with sparse:

make C=2 CF="-D__CHECK_ENDIAN__" net/netfilter/ipvs/

And this is the only problem in v4 of the patch. Then may be
you should wait when net-next opens again before submitting v5.

Regards

--
Julian Anastasov <[email protected]>

author
#4 lore raw

Hello,

Quoted 46 lines · Julian Anastasov

Hello,

Quoted 28 lines · Jacky Hu
Quoted 27 lines · kbuild test robot

Hi Jacky,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ipvs-next/master]
[also build test WARNING on v5.1-rc1 next-20190306]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jacky-Hu/ipvs-allow-tunneling-with-gue-encapsulation/20190318-070156
base:   https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git master
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

sparse warnings: (new ones prefixed by >>)

net/netfilter/ipvs/ip_vs_ctl.c:835:42: sparse: incorrect type in argument 2 (different base types) @@ expected int [signed] i @@ got restricted __be1int [signed] i @@
net/netfilter/ipvs/ip_vs_ctl.c:835:42: expected int [signed] i
net/netfilter/ipvs/ip_vs_ctl.c:835:42: got restricted __be16 [usertype] tun_port
net/netfilter/ipvs/ip_vs_ctl.c:1197:44: sparse: expression using sizeof(void)

Quoted 1 line
Quoted 1 line

net/netfilter/ipvs/ip_vs_ctl.c:3207:37: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be16 [usertype] value @@ got e] value @@

net/netfilter/ipvs/ip_vs_ctl.c:3207:37: expected restricted __be16 [usertype] value
net/netfilter/ipvs/ip_vs_ctl.c:3207:37: got int
net/netfilter/ipvs/ip_vs_ctl.c:1313:27: sparse: dereference of noderef expression

Quoted 7 lines
Quoted 4 lines

vim +3207 net/netfilter/ipvs/ip_vs_ctl.c

Quoted 1 line

3207 atomic_read(&dest->tun_port)) ||

Should I change the type of tun_port from __be16 to u16? Looks like kbuild bugs a lot on this.

In struct ip_vs_dest you should use __be16 for tun_port and
__u16 for tun_type and avoid any atomic_t usage. To test it with sparse:

make C=2 CF="-D__CHECK_ENDIAN__" net/netfilter/ipvs/

Quoted 7 lines

And this is the only problem in v4 of the patch. Then may be
you should wait when net-next opens again before submitting v5.

Regards

--
Julian Anastasov <[email protected]>

I have made the required changes locally, also updated ipvsadm accordingly, once it opens, I'll submit them.

Thanks.
Best Regards,
Jacky