All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection
@ 2015-03-25 14:00 Hannes Frederic Sowa
  2015-03-25 14:00 ` [PATCH net-next 2/2] ipv6: " Hannes Frederic Sowa
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hannes Frederic Sowa @ 2015-03-25 14:00 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet, Flavio Leitner

As namespaces are sometimes used with overlapping ip address ranges,
we should also use the namespace as input to the hash to select the ip
fragmentation counter bucket.

Cc: Eric Dumazet <edumazet@google.com>
Cc: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 drivers/net/ppp/pptp.c          | 2 +-
 net/netfilter/ipvs/ip_vs_xmit.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 1dc628f..e3bfbd4d 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
 	nf_reset(skb);
 
 	skb->ip_summed = CHECKSUM_NONE;
-	ip_select_ident(skb, NULL);
+	ip_select_ident(sock_net(sk), skb, NULL);
 	ip_send_check(iph);
 
 	ip_local_out(skb);
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index f35c15b..bf02932 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -924,7 +924,8 @@ int
 ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 		  struct ip_vs_protocol *pp, struct ip_vs_iphdr *ipvsh)
 {
-	struct netns_ipvs *ipvs = net_ipvs(skb_net(skb));
+	struct net *net = skb_net(skb);
+	struct netns_ipvs *ipvs = net_ipvs(net);
 	struct rtable *rt;			/* Route to the other host */
 	__be32 saddr;				/* Source for tunnel */
 	struct net_device *tdev;		/* Device to other host */
@@ -991,7 +992,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 	iph->daddr		=	cp->daddr.ip;
 	iph->saddr		=	saddr;
 	iph->ttl		=	ttl;
-	ip_select_ident(skb, NULL);
+	ip_select_ident(net, skb, NULL);
 
 	/* Another hack: avoid icmp_send in ip_fragment */
 	skb->ignore_df = 1;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/2] ipv6: hash net ptr into fragmentation bucket selection
  2015-03-25 14:00 [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection Hannes Frederic Sowa
@ 2015-03-25 14:00 ` Hannes Frederic Sowa
  2015-03-25 14:04 ` [PATCH net-next 1/2] ipv4: " Hannes Frederic Sowa
  2015-03-25 14:45 ` Eric Dumazet
  2 siblings, 0 replies; 5+ messages in thread
From: Hannes Frederic Sowa @ 2015-03-25 14:00 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet, Flavio Leitner

As namespaces are sometimes used with overlapping ip address ranges,
we should also use the namespace as input to the hash to select the ip
fragmentation counter bucket.

Cc: Eric Dumazet <edumazet@google.com>
Cc: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 include/net/ipv6.h     |  5 +++--
 net/ipv6/ip6_output.c  |  6 +++---
 net/ipv6/output_core.c | 14 ++++++++------
 net/ipv6/udp_offload.c |  4 ++--
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index e7ba975..65142e6 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -671,8 +671,9 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
 	return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
 }
 
-void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt);
-void ipv6_proxy_select_ident(struct sk_buff *skb);
+void ipv6_select_ident(struct net *net, struct frag_hdr *fhdr,
+		       struct rt6_info *rt);
+void ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb);
 
 int ip6_dst_hoplimit(struct dst_entry *dst);
 
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 7e80b61..b06ad00 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -628,7 +628,7 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
 		skb_reset_network_header(skb);
 		memcpy(skb_network_header(skb), tmp_hdr, hlen);
 
-		ipv6_select_ident(fh, rt);
+		ipv6_select_ident(net, fh, rt);
 		fh->nexthdr = nexthdr;
 		fh->reserved = 0;
 		fh->frag_off = htons(IP6_MF);
@@ -775,7 +775,7 @@ slow_path:
 		fh->nexthdr = nexthdr;
 		fh->reserved = 0;
 		if (!frag_id) {
-			ipv6_select_ident(fh, rt);
+			ipv6_select_ident(net, fh, rt);
 			frag_id = fh->identification;
 		} else
 			fh->identification = frag_id;
@@ -1079,7 +1079,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
 	skb_shinfo(skb)->gso_size = (mtu - fragheaderlen -
 				     sizeof(struct frag_hdr)) & ~7;
 	skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-	ipv6_select_ident(&fhdr, rt);
+	ipv6_select_ident(sock_net(sk), &fhdr, rt);
 	skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
 
 append:
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index 74581f7..4016a6e 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -9,13 +9,14 @@
 #include <net/addrconf.h>
 #include <net/secure_seq.h>
 
-static u32 __ipv6_select_ident(u32 hashrnd, struct in6_addr *dst,
-			       struct in6_addr *src)
+static u32 __ipv6_select_ident(struct net *net, u32 hashrnd,
+			       struct in6_addr *dst, struct in6_addr *src)
 {
 	u32 hash, id;
 
 	hash = __ipv6_addr_jhash(dst, hashrnd);
 	hash = __ipv6_addr_jhash(src, hash);
+	hash ^= net_hash_mix(net);
 
 	/* Treat id of 0 as unset and if we get 0 back from ip_idents_reserve,
 	 * set the hight order instead thus minimizing possible future
@@ -36,7 +37,7 @@ static u32 __ipv6_select_ident(u32 hashrnd, struct in6_addr *dst,
  *
  * The network header must be set before calling this.
  */
-void ipv6_proxy_select_ident(struct sk_buff *skb)
+void ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb)
 {
 	static u32 ip6_proxy_idents_hashrnd __read_mostly;
 	struct in6_addr buf[2];
@@ -53,20 +54,21 @@ void ipv6_proxy_select_ident(struct sk_buff *skb)
 	net_get_random_once(&ip6_proxy_idents_hashrnd,
 			    sizeof(ip6_proxy_idents_hashrnd));
 
-	id = __ipv6_select_ident(ip6_proxy_idents_hashrnd,
+	id = __ipv6_select_ident(net, ip6_proxy_idents_hashrnd,
 				 &addrs[1], &addrs[0]);
 	skb_shinfo(skb)->ip6_frag_id = htonl(id);
 }
 EXPORT_SYMBOL_GPL(ipv6_proxy_select_ident);
 
-void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
+void ipv6_select_ident(struct net *net, struct frag_hdr *fhdr,
+		       struct rt6_info *rt)
 {
 	static u32 ip6_idents_hashrnd __read_mostly;
 	u32 id;
 
 	net_get_random_once(&ip6_idents_hashrnd, sizeof(ip6_idents_hashrnd));
 
-	id = __ipv6_select_ident(ip6_idents_hashrnd, &rt->rt6i_dst.addr,
+	id = __ipv6_select_ident(net, ip6_idents_hashrnd, &rt->rt6i_dst.addr,
 				 &rt->rt6i_src.addr);
 	fhdr->identification = htonl(id);
 }
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index be2c0ba..7441e1e 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -54,7 +54,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 
 		/* Set the IPv6 fragment id if not set yet */
 		if (!skb_shinfo(skb)->ip6_frag_id)
-			ipv6_proxy_select_ident(skb);
+			ipv6_proxy_select_ident(dev_net(skb->dev), skb);
 
 		segs = NULL;
 		goto out;
@@ -113,7 +113,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 		fptr->nexthdr = nexthdr;
 		fptr->reserved = 0;
 		if (!skb_shinfo(skb)->ip6_frag_id)
-			ipv6_proxy_select_ident(skb);
+			ipv6_proxy_select_ident(dev_net(skb->dev), skb);
 		fptr->identification = skb_shinfo(skb)->ip6_frag_id;
 
 		/* Fragment the skb. ipv6 header and the remaining fields of the
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection
  2015-03-25 14:00 [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection Hannes Frederic Sowa
  2015-03-25 14:00 ` [PATCH net-next 2/2] ipv6: " Hannes Frederic Sowa
@ 2015-03-25 14:04 ` Hannes Frederic Sowa
  2015-03-25 14:45 ` Eric Dumazet
  2 siblings, 0 replies; 5+ messages in thread
From: Hannes Frederic Sowa @ 2015-03-25 14:04 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet, Flavio Leitner

On Wed, Mar 25, 2015, at 15:00, Hannes Frederic Sowa wrote:
> As namespaces are sometimes used with overlapping ip address ranges,
> we should also use the namespace as input to the hash to select the ip
> fragmentation counter bucket.
> 
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Flavio Leitner <fbl@redhat.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Oh, the rebase broke. Sending v2.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection
  2015-03-25 14:00 [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection Hannes Frederic Sowa
  2015-03-25 14:00 ` [PATCH net-next 2/2] ipv6: " Hannes Frederic Sowa
  2015-03-25 14:04 ` [PATCH net-next 1/2] ipv4: " Hannes Frederic Sowa
@ 2015-03-25 14:45 ` Eric Dumazet
  2015-03-25 15:16   ` Hannes Frederic Sowa
  2 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2015-03-25 14:45 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: netdev, Eric Dumazet, Flavio Leitner

On Wed, 2015-03-25 at 15:00 +0100, Hannes Frederic Sowa wrote:
> As namespaces are sometimes used with overlapping ip address ranges,
> we should also use the namespace as input to the hash to select the ip
> fragmentation counter bucket.
> 
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Flavio Leitner <fbl@redhat.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---
>  drivers/net/ppp/pptp.c          | 2 +-
>  net/netfilter/ipvs/ip_vs_xmit.c | 5 +++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
> index 1dc628f..e3bfbd4d 100644
> --- a/drivers/net/ppp/pptp.c
> +++ b/drivers/net/ppp/pptp.c
> @@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
>  	nf_reset(skb);
>  
>  	skb->ip_summed = CHECKSUM_NONE;
> -	ip_select_ident(skb, NULL);
> +	ip_select_ident(sock_net(sk), skb, NULL);
>  	ip_send_check(iph);
>  

I do not see how this would compile, without corresponding change in
ip_select_ident() ?

Or maybe I should drink this coffee ;)

Really, Redhat should tell truth to its customers : frags are bad

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection
  2015-03-25 14:45 ` Eric Dumazet
@ 2015-03-25 15:16   ` Hannes Frederic Sowa
  0 siblings, 0 replies; 5+ messages in thread
From: Hannes Frederic Sowa @ 2015-03-25 15:16 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, Eric Dumazet, Flavio Leitner



On Wed, Mar 25, 2015, at 15:45, Eric Dumazet wrote:
> On Wed, 2015-03-25 at 15:00 +0100, Hannes Frederic Sowa wrote:
> > As namespaces are sometimes used with overlapping ip address ranges,
> > we should also use the namespace as input to the hash to select the ip
> > fragmentation counter bucket.
> > 
> > Cc: Eric Dumazet <edumazet@google.com>
> > Cc: Flavio Leitner <fbl@redhat.com>
> > Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> > ---
> >  drivers/net/ppp/pptp.c          | 2 +-
> >  net/netfilter/ipvs/ip_vs_xmit.c | 5 +++--
> >  2 files changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
> > index 1dc628f..e3bfbd4d 100644
> > --- a/drivers/net/ppp/pptp.c
> > +++ b/drivers/net/ppp/pptp.c
> > @@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
> >  	nf_reset(skb);
> >  
> >  	skb->ip_summed = CHECKSUM_NONE;
> > -	ip_select_ident(skb, NULL);
> > +	ip_select_ident(sock_net(sk), skb, NULL);
> >  	ip_send_check(iph);
> >  
> 
> I do not see how this would compile, without corresponding change in
> ip_select_ident() ?

Cheers! ;)

We have a very slow coffee machine, so while waiting for a new one to be
produced I forgot to squash the ipv4 commits and just send them out.

> Or maybe I should drink this coffee ;)
> 
> Really, Redhat should tell truth to its customers : frags are bad

We still have to support Google's DNS servers, too. ;)

Bye,
Hannes

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-25 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25 14:00 [PATCH net-next 1/2] ipv4: hash net ptr into fragmentation bucket selection Hannes Frederic Sowa
2015-03-25 14:00 ` [PATCH net-next 2/2] ipv6: " Hannes Frederic Sowa
2015-03-25 14:04 ` [PATCH net-next 1/2] ipv4: " Hannes Frederic Sowa
2015-03-25 14:45 ` Eric Dumazet
2015-03-25 15:16   ` Hannes Frederic Sowa

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.