public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Julian Anastasov <ja@ssi.bg>
Cc: "Yurij M. Plotnikov" <Yurij.Plotnikov@oktetlabs.ru>,
	David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: Connect hangs for a while before returns -1 with ECONNREFUSED on 3.2 for loopback
Date: Sat, 04 Feb 2012 20:43:50 +0100	[thread overview]
Message-ID: <1328384630.2731.46.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.LFD.2.00.1202041912430.1496@ja.ssi.bg>

Le samedi 04 février 2012 à 19:39 +0200, Julian Anastasov a écrit :

> [PATCH] ipv4: reset flowi parameters on route connect
> 
> 	ip_route_connect and ip_route_newports need to reset
> some flowi fields that are input parameters because we do not
> want unnecessary binding to oif. Fixes problem with lost
> RST packets when connecting to local port that has no
> listener.
> 
> Signed-off-by: Julian Anastasov <ja@ssi.bg>

Please Julian, dont submit an official patch like this without proper
credits, and proper reference to bug origin, to help stable backport.

Issue was reported by Yurij, and I spent some time on it to find the
problem, introduced in 3.0.


> ---
>  include/net/flow.h  |   10 ++++++++++
>  include/net/route.h |    4 ++++
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/include/net/flow.h b/include/net/flow.h
> index 9b58243..6c469db 100644
> --- a/include/net/flow.h
> +++ b/include/net/flow.h
> @@ -93,6 +93,16 @@ static inline void flowi4_init_output(struct flowi4 *fl4, int oif,
>  	fl4->fl4_dport = dport;
>  	fl4->fl4_sport = sport;
>  }
> +
> +/* Reset some input parameters after previous lookup */
> +static inline void flowi4_update_output(struct flowi4 *fl4, int oif, __u8 tos,
> +					__be32 daddr, __be32 saddr)
> +{
> +	fl4->flowi4_oif = oif;
> +	fl4->flowi4_tos = tos;
> +	fl4->daddr = daddr;
> +	fl4->saddr = saddr;

> +}
>  				      


>  
>  struct flowi6 {
> diff --git a/include/net/route.h b/include/net/route.h
> index 91855d1..b1c0d5b 100644
> --- a/include/net/route.h
> +++ b/include/net/route.h
> @@ -270,6 +270,7 @@ static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
>  		if (IS_ERR(rt))
>  			return rt;
>  		ip_rt_put(rt);
> +		flowi4_update_output(fl4, oif, tos, fl4->daddr, fl4->saddr);
>  	}
>  	security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
>  	return ip_route_output_flow(net, fl4, sk);
> @@ -284,6 +285,9 @@ static inline struct rtable *ip_route_newports(struct flowi4 *fl4, struct rtable
>  		fl4->fl4_dport = dport;
>  		fl4->fl4_sport = sport;
>  		ip_rt_put(rt);
> +		flowi4_update_output(fl4, sk->sk_bound_dev_if,
> +				     RT_CONN_FLAGS(sk), fl4->daddr,
> +				     fl4->saddr);
>  		security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
>  		return ip_route_output_flow(sock_net(sk), fl4, sk);
>  	}

I dont understand the saddr/daddr part, since you basically have :

	fl4->daddr = fl4->daddr;
	fl4->saddr = fl4->saddr;


__ip_route_output_key() always had the possibility to change
saddr/daddr, I dont think we have to deal with it.

  reply	other threads:[~2012-02-04 19:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03  6:25 Connect hangs for a while before returns -1 with ECONNREFUSED on 3.2 for loopback Yurij M. Plotnikov
2012-02-03 14:38 ` Eric Dumazet
2012-02-03 15:15   ` Eric Dumazet
2012-02-04 12:26     ` Eric Dumazet
2012-02-04 15:48       ` Julian Anastasov
2012-02-04 16:58         ` Eric Dumazet
2012-02-04 17:39           ` Julian Anastasov
2012-02-04 19:43             ` Eric Dumazet [this message]
2012-02-04 20:51               ` Julian Anastasov
2012-02-04 21:26                 ` Eric Dumazet
2012-02-04 20:39       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328384630.2731.46.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=Yurij.Plotnikov@oktetlabs.ru \
    --cc=davem@davemloft.net \
    --cc=ja@ssi.bg \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox