* [PATCH v3] ipvs: allow tunneling with gre encapsulation
@ 2019-07-01 16:49 Vadim Fedorenko
2019-07-01 19:03 ` Julian Anastasov
0 siblings, 1 reply; 4+ messages in thread
From: Vadim Fedorenko @ 2019-07-01 16:49 UTC (permalink / raw)
To: Julian Anastasov
Cc: Simon Horman, Konstantin Khlebnikov, Pablo Neira Ayuso,
netfilter-devel, Vadim Fedorenko
windows real servers can handle gre tunnels, this patch allows
gre encapsulation with the tunneling method, thereby letting ipvs
be load balancer for windows-based services
Signed-off-by: Vadim Fedorenko <vfedorenko@yandex-team.ru>
---
v2: style fix
v3: change dest->tun_type checks to else if statement
---
include/uapi/linux/ip_vs.h | 1 +
net/netfilter/ipvs/ip_vs_ctl.c | 1 +
net/netfilter/ipvs/ip_vs_xmit.c | 66 +++++++++++++++++++++++++++++++++++++++--
3 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/include/uapi/linux/ip_vs.h b/include/uapi/linux/ip_vs.h
index e4f1806..4102ddc 100644
--- a/include/uapi/linux/ip_vs.h
+++ b/include/uapi/linux/ip_vs.h
@@ -128,6 +128,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,
};
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 84384d8..998353b 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -525,6 +525,7 @@ static void ip_vs_rs_hash(struct netns_ipvs *ipvs, struct ip_vs_dest *dest)
port = dest->tun_port;
break;
case IP_VS_CONN_F_TUNNEL_TYPE_IPIP:
+ case IP_VS_CONN_F_TUNNEL_TYPE_GRE:
port = 0;
break;
default:
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 71fc6d6..9c464d2 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -29,6 +29,7 @@
#include <linux/tcp.h> /* for tcphdr */
#include <net/ip.h>
#include <net/gue.h>
+#include <net/gre.h>
#include <net/tcp.h> /* for csum_tcpudp_magic */
#include <net/udp.h>
#include <net/icmp.h> /* for icmp_send */
@@ -388,6 +389,12 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM) &&
skb->ip_summed == CHECKSUM_PARTIAL)
mtu -= GUE_PLEN_REMCSUM + GUE_LEN_PRIV;
+ } else if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
+ __be16 tflags = 0;
+
+ if (dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
+ tflags |= TUNNEL_CSUM;
+ mtu -= gre_calc_hlen(tflags);
}
if (mtu < 68) {
IP_VS_DBG_RL("%s(): mtu less than 68\n", __func__);
@@ -548,6 +555,12 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM) &&
skb->ip_summed == CHECKSUM_PARTIAL)
mtu -= GUE_PLEN_REMCSUM + GUE_LEN_PRIV;
+ } else if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
+ __be16 tflags = 0;
+
+ if (dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
+ tflags |= TUNNEL_CSUM;
+ mtu -= gre_calc_hlen(tflags);
}
if (mtu < IPV6_MIN_MTU) {
IP_VS_DBG_RL("%s(): mtu less than %d\n", __func__,
@@ -1079,6 +1092,24 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
return 0;
}
+static void
+ipvs_gre_encap(struct net *net, struct sk_buff *skb,
+ struct ip_vs_conn *cp, __u8 *next_protocol)
+{
+ __be16 proto = *next_protocol == IPPROTO_IPIP ?
+ htons(ETH_P_IP) : htons(ETH_P_IPV6);
+ __be16 tflags = 0;
+ size_t hdrlen;
+
+ if (cp->dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
+ tflags |= TUNNEL_CSUM;
+
+ hdrlen = gre_calc_hlen(tflags);
+ gre_build_header(skb, hdrlen, tflags, proto, 0, 0);
+
+ *next_protocol = IPPROTO_GRE;
+}
+
/*
* IP Tunneling transmitter
*
@@ -1151,6 +1182,15 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
gue_hdrlen = sizeof(struct guehdr) + gue_optlen;
max_headroom += sizeof(struct udphdr) + gue_hdrlen;
+ } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
+ size_t gre_hdrlen;
+ __be16 tflags = 0;
+
+ if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
+ tflags |= TUNNEL_CSUM;
+ gre_hdrlen = gre_calc_hlen(tflags);
+
+ max_headroom += gre_hdrlen;
}
/* We only care about the df field if sysctl_pmtu_disc(ipvs) is set */
@@ -1172,6 +1212,11 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
skb->ip_summed == CHECKSUM_PARTIAL) {
gso_type |= SKB_GSO_TUNNEL_REMCSUM;
}
+ } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
+ if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
+ gso_type |= SKB_GSO_GRE_CSUM;
+ else
+ gso_type |= SKB_GSO_GRE;
}
if (iptunnel_handle_offloads(skb, gso_type))
@@ -1192,8 +1237,8 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
check = true;
udp_set_csum(!check, skb, saddr, cp->daddr.ip, skb->len);
- }
-
+ } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE)
+ ipvs_gre_encap(net, skb, cp, &next_protocol);
skb_push(skb, sizeof(struct iphdr));
skb_reset_network_header(skb);
@@ -1287,6 +1332,15 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
gue_hdrlen = sizeof(struct guehdr) + gue_optlen;
max_headroom += sizeof(struct udphdr) + gue_hdrlen;
+ } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
+ size_t gre_hdrlen;
+ __be16 tflags = 0;
+
+ if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
+ tflags |= TUNNEL_CSUM;
+ gre_hdrlen = gre_calc_hlen(tflags);
+
+ max_headroom += gre_hdrlen;
}
skb = ip_vs_prepare_tunneled_skb(skb, cp->af, max_headroom,
@@ -1306,6 +1360,11 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
skb->ip_summed == CHECKSUM_PARTIAL) {
gso_type |= SKB_GSO_TUNNEL_REMCSUM;
}
+ } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
+ if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
+ gso_type |= SKB_GSO_GRE_CSUM;
+ else
+ gso_type |= SKB_GSO_GRE;
}
if (iptunnel_handle_offloads(skb, gso_type))
@@ -1326,7 +1385,8 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
check = true;
udp6_set_csum(!check, skb, &saddr, &cp->daddr.in6, skb->len);
- }
+ } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE)
+ ipvs_gre_encap(net, skb, cp, &next_protocol);
skb_push(skb, sizeof(struct ipv6hdr));
skb_reset_network_header(skb);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] ipvs: allow tunneling with gre encapsulation
2019-07-01 16:49 [PATCH v3] ipvs: allow tunneling with gre encapsulation Vadim Fedorenko
@ 2019-07-01 19:03 ` Julian Anastasov
2019-07-02 7:16 ` Simon Horman
0 siblings, 1 reply; 4+ messages in thread
From: Julian Anastasov @ 2019-07-01 19:03 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Simon Horman, Konstantin Khlebnikov, Pablo Neira Ayuso,
netfilter-devel, lvs-devel
Hello,
Added CC to lvs-devel@vger.kernel.org
On Mon, 1 Jul 2019, Vadim Fedorenko wrote:
> windows real servers can handle gre tunnels, this patch allows
> gre encapsulation with the tunneling method, thereby letting ipvs
> be load balancer for windows-based services
>
> Signed-off-by: Vadim Fedorenko <vfedorenko@yandex-team.ru>
Looks good to me, thanks!
Acked-by: Julian Anastasov <ja@ssi.bg>
> ---
> v2: style fix
> v3: change dest->tun_type checks to else if statement
> ---
> include/uapi/linux/ip_vs.h | 1 +
> net/netfilter/ipvs/ip_vs_ctl.c | 1 +
> net/netfilter/ipvs/ip_vs_xmit.c | 66 +++++++++++++++++++++++++++++++++++++++--
> 3 files changed, 65 insertions(+), 3 deletions(-)
>
> diff --git a/include/uapi/linux/ip_vs.h b/include/uapi/linux/ip_vs.h
> index e4f1806..4102ddc 100644
> --- a/include/uapi/linux/ip_vs.h
> +++ b/include/uapi/linux/ip_vs.h
> @@ -128,6 +128,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,
> };
>
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index 84384d8..998353b 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -525,6 +525,7 @@ static void ip_vs_rs_hash(struct netns_ipvs *ipvs, struct ip_vs_dest *dest)
> port = dest->tun_port;
> break;
> case IP_VS_CONN_F_TUNNEL_TYPE_IPIP:
> + case IP_VS_CONN_F_TUNNEL_TYPE_GRE:
> port = 0;
> break;
> default:
> diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
> index 71fc6d6..9c464d2 100644
> --- a/net/netfilter/ipvs/ip_vs_xmit.c
> +++ b/net/netfilter/ipvs/ip_vs_xmit.c
> @@ -29,6 +29,7 @@
> #include <linux/tcp.h> /* for tcphdr */
> #include <net/ip.h>
> #include <net/gue.h>
> +#include <net/gre.h>
> #include <net/tcp.h> /* for csum_tcpudp_magic */
> #include <net/udp.h>
> #include <net/icmp.h> /* for icmp_send */
> @@ -388,6 +389,12 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
> IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM) &&
> skb->ip_summed == CHECKSUM_PARTIAL)
> mtu -= GUE_PLEN_REMCSUM + GUE_LEN_PRIV;
> + } else if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> + __be16 tflags = 0;
> +
> + if (dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> + tflags |= TUNNEL_CSUM;
> + mtu -= gre_calc_hlen(tflags);
> }
> if (mtu < 68) {
> IP_VS_DBG_RL("%s(): mtu less than 68\n", __func__);
> @@ -548,6 +555,12 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
> IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM) &&
> skb->ip_summed == CHECKSUM_PARTIAL)
> mtu -= GUE_PLEN_REMCSUM + GUE_LEN_PRIV;
> + } else if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> + __be16 tflags = 0;
> +
> + if (dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> + tflags |= TUNNEL_CSUM;
> + mtu -= gre_calc_hlen(tflags);
> }
> if (mtu < IPV6_MIN_MTU) {
> IP_VS_DBG_RL("%s(): mtu less than %d\n", __func__,
> @@ -1079,6 +1092,24 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> return 0;
> }
>
> +static void
> +ipvs_gre_encap(struct net *net, struct sk_buff *skb,
> + struct ip_vs_conn *cp, __u8 *next_protocol)
> +{
> + __be16 proto = *next_protocol == IPPROTO_IPIP ?
> + htons(ETH_P_IP) : htons(ETH_P_IPV6);
> + __be16 tflags = 0;
> + size_t hdrlen;
> +
> + if (cp->dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> + tflags |= TUNNEL_CSUM;
> +
> + hdrlen = gre_calc_hlen(tflags);
> + gre_build_header(skb, hdrlen, tflags, proto, 0, 0);
> +
> + *next_protocol = IPPROTO_GRE;
> +}
> +
> /*
> * IP Tunneling transmitter
> *
> @@ -1151,6 +1182,15 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> gue_hdrlen = sizeof(struct guehdr) + gue_optlen;
>
> max_headroom += sizeof(struct udphdr) + gue_hdrlen;
> + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> + size_t gre_hdrlen;
> + __be16 tflags = 0;
> +
> + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> + tflags |= TUNNEL_CSUM;
> + gre_hdrlen = gre_calc_hlen(tflags);
> +
> + max_headroom += gre_hdrlen;
> }
>
> /* We only care about the df field if sysctl_pmtu_disc(ipvs) is set */
> @@ -1172,6 +1212,11 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> skb->ip_summed == CHECKSUM_PARTIAL) {
> gso_type |= SKB_GSO_TUNNEL_REMCSUM;
> }
> + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> + gso_type |= SKB_GSO_GRE_CSUM;
> + else
> + gso_type |= SKB_GSO_GRE;
> }
>
> if (iptunnel_handle_offloads(skb, gso_type))
> @@ -1192,8 +1237,8 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> check = true;
>
> udp_set_csum(!check, skb, saddr, cp->daddr.ip, skb->len);
> - }
> -
> + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE)
> + ipvs_gre_encap(net, skb, cp, &next_protocol);
>
> skb_push(skb, sizeof(struct iphdr));
> skb_reset_network_header(skb);
> @@ -1287,6 +1332,15 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> gue_hdrlen = sizeof(struct guehdr) + gue_optlen;
>
> max_headroom += sizeof(struct udphdr) + gue_hdrlen;
> + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> + size_t gre_hdrlen;
> + __be16 tflags = 0;
> +
> + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> + tflags |= TUNNEL_CSUM;
> + gre_hdrlen = gre_calc_hlen(tflags);
> +
> + max_headroom += gre_hdrlen;
> }
>
> skb = ip_vs_prepare_tunneled_skb(skb, cp->af, max_headroom,
> @@ -1306,6 +1360,11 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> skb->ip_summed == CHECKSUM_PARTIAL) {
> gso_type |= SKB_GSO_TUNNEL_REMCSUM;
> }
> + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> + gso_type |= SKB_GSO_GRE_CSUM;
> + else
> + gso_type |= SKB_GSO_GRE;
> }
>
> if (iptunnel_handle_offloads(skb, gso_type))
> @@ -1326,7 +1385,8 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> check = true;
>
> udp6_set_csum(!check, skb, &saddr, &cp->daddr.in6, skb->len);
> - }
> + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE)
> + ipvs_gre_encap(net, skb, cp, &next_protocol);
>
> skb_push(skb, sizeof(struct ipv6hdr));
> skb_reset_network_header(skb);
> --
> 1.9.1
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] ipvs: allow tunneling with gre encapsulation
2019-07-01 19:03 ` Julian Anastasov
@ 2019-07-02 7:16 ` Simon Horman
2019-07-02 15:58 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2019-07-02 7:16 UTC (permalink / raw)
To: Pablo Neira Ayuso, Julian Anastasov
Cc: Vadim Fedorenko, Konstantin Khlebnikov, netfilter-devel, lvs-devel
On Mon, Jul 01, 2019 at 10:03:13PM +0300, Julian Anastasov wrote:
>
> Hello,
>
> Added CC to lvs-devel@vger.kernel.org
>
> On Mon, 1 Jul 2019, Vadim Fedorenko wrote:
>
> > windows real servers can handle gre tunnels, this patch allows
> > gre encapsulation with the tunneling method, thereby letting ipvs
> > be load balancer for windows-based services
> >
> > Signed-off-by: Vadim Fedorenko <vfedorenko@yandex-team.ru>
>
> Looks good to me, thanks!
>
> Acked-by: Julian Anastasov <ja@ssi.bg>
Likewise,
Signed-off-by: Simon Horman <horms@verge.net.au>
Pablo, please consider including this in nf-next.
>
> > ---
> > v2: style fix
> > v3: change dest->tun_type checks to else if statement
> > ---
> > include/uapi/linux/ip_vs.h | 1 +
> > net/netfilter/ipvs/ip_vs_ctl.c | 1 +
> > net/netfilter/ipvs/ip_vs_xmit.c | 66 +++++++++++++++++++++++++++++++++++++++--
> > 3 files changed, 65 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/uapi/linux/ip_vs.h b/include/uapi/linux/ip_vs.h
> > index e4f1806..4102ddc 100644
> > --- a/include/uapi/linux/ip_vs.h
> > +++ b/include/uapi/linux/ip_vs.h
> > @@ -128,6 +128,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,
> > };
> >
> > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> > index 84384d8..998353b 100644
> > --- a/net/netfilter/ipvs/ip_vs_ctl.c
> > +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> > @@ -525,6 +525,7 @@ static void ip_vs_rs_hash(struct netns_ipvs *ipvs, struct ip_vs_dest *dest)
> > port = dest->tun_port;
> > break;
> > case IP_VS_CONN_F_TUNNEL_TYPE_IPIP:
> > + case IP_VS_CONN_F_TUNNEL_TYPE_GRE:
> > port = 0;
> > break;
> > default:
> > diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
> > index 71fc6d6..9c464d2 100644
> > --- a/net/netfilter/ipvs/ip_vs_xmit.c
> > +++ b/net/netfilter/ipvs/ip_vs_xmit.c
> > @@ -29,6 +29,7 @@
> > #include <linux/tcp.h> /* for tcphdr */
> > #include <net/ip.h>
> > #include <net/gue.h>
> > +#include <net/gre.h>
> > #include <net/tcp.h> /* for csum_tcpudp_magic */
> > #include <net/udp.h>
> > #include <net/icmp.h> /* for icmp_send */
> > @@ -388,6 +389,12 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
> > IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM) &&
> > skb->ip_summed == CHECKSUM_PARTIAL)
> > mtu -= GUE_PLEN_REMCSUM + GUE_LEN_PRIV;
> > + } else if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> > + __be16 tflags = 0;
> > +
> > + if (dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> > + tflags |= TUNNEL_CSUM;
> > + mtu -= gre_calc_hlen(tflags);
> > }
> > if (mtu < 68) {
> > IP_VS_DBG_RL("%s(): mtu less than 68\n", __func__);
> > @@ -548,6 +555,12 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,
> > IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM) &&
> > skb->ip_summed == CHECKSUM_PARTIAL)
> > mtu -= GUE_PLEN_REMCSUM + GUE_LEN_PRIV;
> > + } else if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> > + __be16 tflags = 0;
> > +
> > + if (dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> > + tflags |= TUNNEL_CSUM;
> > + mtu -= gre_calc_hlen(tflags);
> > }
> > if (mtu < IPV6_MIN_MTU) {
> > IP_VS_DBG_RL("%s(): mtu less than %d\n", __func__,
> > @@ -1079,6 +1092,24 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> > return 0;
> > }
> >
> > +static void
> > +ipvs_gre_encap(struct net *net, struct sk_buff *skb,
> > + struct ip_vs_conn *cp, __u8 *next_protocol)
> > +{
> > + __be16 proto = *next_protocol == IPPROTO_IPIP ?
> > + htons(ETH_P_IP) : htons(ETH_P_IPV6);
> > + __be16 tflags = 0;
> > + size_t hdrlen;
> > +
> > + if (cp->dest->tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> > + tflags |= TUNNEL_CSUM;
> > +
> > + hdrlen = gre_calc_hlen(tflags);
> > + gre_build_header(skb, hdrlen, tflags, proto, 0, 0);
> > +
> > + *next_protocol = IPPROTO_GRE;
> > +}
> > +
> > /*
> > * IP Tunneling transmitter
> > *
> > @@ -1151,6 +1182,15 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> > gue_hdrlen = sizeof(struct guehdr) + gue_optlen;
> >
> > max_headroom += sizeof(struct udphdr) + gue_hdrlen;
> > + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> > + size_t gre_hdrlen;
> > + __be16 tflags = 0;
> > +
> > + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> > + tflags |= TUNNEL_CSUM;
> > + gre_hdrlen = gre_calc_hlen(tflags);
> > +
> > + max_headroom += gre_hdrlen;
> > }
> >
> > /* We only care about the df field if sysctl_pmtu_disc(ipvs) is set */
> > @@ -1172,6 +1212,11 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> > skb->ip_summed == CHECKSUM_PARTIAL) {
> > gso_type |= SKB_GSO_TUNNEL_REMCSUM;
> > }
> > + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> > + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> > + gso_type |= SKB_GSO_GRE_CSUM;
> > + else
> > + gso_type |= SKB_GSO_GRE;
> > }
> >
> > if (iptunnel_handle_offloads(skb, gso_type))
> > @@ -1192,8 +1237,8 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> > check = true;
> >
> > udp_set_csum(!check, skb, saddr, cp->daddr.ip, skb->len);
> > - }
> > -
> > + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE)
> > + ipvs_gre_encap(net, skb, cp, &next_protocol);
> >
> > skb_push(skb, sizeof(struct iphdr));
> > skb_reset_network_header(skb);
> > @@ -1287,6 +1332,15 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> > gue_hdrlen = sizeof(struct guehdr) + gue_optlen;
> >
> > max_headroom += sizeof(struct udphdr) + gue_hdrlen;
> > + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> > + size_t gre_hdrlen;
> > + __be16 tflags = 0;
> > +
> > + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> > + tflags |= TUNNEL_CSUM;
> > + gre_hdrlen = gre_calc_hlen(tflags);
> > +
> > + max_headroom += gre_hdrlen;
> > }
> >
> > skb = ip_vs_prepare_tunneled_skb(skb, cp->af, max_headroom,
> > @@ -1306,6 +1360,11 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> > skb->ip_summed == CHECKSUM_PARTIAL) {
> > gso_type |= SKB_GSO_TUNNEL_REMCSUM;
> > }
> > + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE) {
> > + if (tun_flags & IP_VS_TUNNEL_ENCAP_FLAG_CSUM)
> > + gso_type |= SKB_GSO_GRE_CSUM;
> > + else
> > + gso_type |= SKB_GSO_GRE;
> > }
> >
> > if (iptunnel_handle_offloads(skb, gso_type))
> > @@ -1326,7 +1385,8 @@ static inline int __tun_gso_type_mask(int encaps_af, int orig_af)
> > check = true;
> >
> > udp6_set_csum(!check, skb, &saddr, &cp->daddr.in6, skb->len);
> > - }
> > + } else if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GRE)
> > + ipvs_gre_encap(net, skb, cp, &next_protocol);
> >
> > skb_push(skb, sizeof(struct ipv6hdr));
> > skb_reset_network_header(skb);
> > --
> > 1.9.1
>
> Regards
>
> --
> Julian Anastasov <ja@ssi.bg>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] ipvs: allow tunneling with gre encapsulation
2019-07-02 7:16 ` Simon Horman
@ 2019-07-02 15:58 ` Pablo Neira Ayuso
0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2019-07-02 15:58 UTC (permalink / raw)
To: Simon Horman
Cc: Julian Anastasov, Vadim Fedorenko, Konstantin Khlebnikov,
netfilter-devel, lvs-devel
On Tue, Jul 02, 2019 at 09:16:59AM +0200, Simon Horman wrote:
> On Mon, Jul 01, 2019 at 10:03:13PM +0300, Julian Anastasov wrote:
> >
> > Hello,
> >
> > Added CC to lvs-devel@vger.kernel.org
> >
> > On Mon, 1 Jul 2019, Vadim Fedorenko wrote:
> >
> > > windows real servers can handle gre tunnels, this patch allows
> > > gre encapsulation with the tunneling method, thereby letting ipvs
> > > be load balancer for windows-based services
> > >
> > > Signed-off-by: Vadim Fedorenko <vfedorenko@yandex-team.ru>
> >
> > Looks good to me, thanks!
> >
> > Acked-by: Julian Anastasov <ja@ssi.bg>
>
> Likewise,
>
> Signed-off-by: Simon Horman <horms@verge.net.au>
>
> Pablo, please consider including this in nf-next.
Applied, thanks Simon.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-02 15:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-01 16:49 [PATCH v3] ipvs: allow tunneling with gre encapsulation Vadim Fedorenko
2019-07-01 19:03 ` Julian Anastasov
2019-07-02 7:16 ` Simon Horman
2019-07-02 15:58 ` Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.