| To: | kuznet@xxxxxxxxxxxxx |
|---|---|
| Subject: | Re: Fw: Re: [PATCH] ipv4 tcp autobind problem |
| From: | Kovacs Krisztian <hidden@xxxxxxxxxx> |
| Date: | Tue, 30 Sep 2003 16:19:39 +0200 |
| Cc: | "David S. Miller" <davem@xxxxxxxxxx>, jmorris@xxxxxxxxxx, netdev@xxxxxxxxxxx, linux-net@xxxxxxxxxxxxxxxx, Balazs Scheidler <bazsi@xxxxxxxxxx> |
| In-reply-to: | <200309301237.QAA01426@yakov.inr.ac.ru> |
| References: | <200309301237.QAA01426@yakov.inr.ac.ru> |
| Sender: | netdev-bounce@xxxxxxxxxxx |
kuznet@xxxxxxxxxxxxx wrote: in inet_sendmsg() is that when an RST is received, sk->num is set to zero, No, sk->sport does not remain unchanged. Imagine the following situation: the TCP stack receives an RST, tcp_reset() gets called. It calls tcp_done() -> tcp_set_state(TCP_CLOSE) -> tcp_put_port() -> __tcp_put_port(). __tcp_put_port() sets sk->num to zero. So, when you call send() from userspace, the mentioned part of inet_sendmsg() calls inet_autobind(), which changes sk->sport, too... I do recognize that current behaviour is weird, but I still want to know how this marginal weirdness escaped to be seen in reality. Yes, it is our "transparent proxy kernel hack" ((C) davem :) that have problem with this behaviour. Transparent proxying works the following way: - You have to assign a foreign address to a bound socket using a specific setsockopt call. This creates a new entry in the tproxy local IP hash table, and the hash key is based on the local ip:port. - tproxy registers its Netfilter hooks, and if a new connection comes in, it looks up its hash tables, to see if it is a transparent proxied connection (it uses Netfilter's connection tracking subsystem). If it has to be proxyed, the appropriate NAT mappings are applied to the connection. - When the socket is closed (inet_release() is called, tproxy has its "callback" function here), the corresponding entries are deleted from tproxy's hash tables, again, based on the local ip:port pair. So, the weirdness causes the following problem: since sk->sport changes after the corresponding entry was inserted into the hash table, it changes, so the entry cannot be deleted when userspace calls close() on the socket. Eventually, it should be enough if inet_sendmsg() did not call inet_autobind() if the socket is in an errorneous state, but I had no idea how this could be implemented. (sk->err gets zeroed by sock_error(), so it cannot be checked twice.) In the case of UDP, you cannot get an RST-like thing, so AFAIK there is no such situation in which sk->num of a bound socket could be reset to zero. This is why inet_sendmsg()'s mentioned part did not cause problems for us. --
Regards,
Krisztian KOVACS |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: RFC: [2.6 patch] disallow modular IPv6, Kai Germaschewski |
|---|---|
| Next by Date: | Re: copybreak and gige network drivers, Donald Becker |
| Previous by Thread: | Re: Fw: Re: [PATCH] ipv4 tcp autobind problem, David S. Miller |
| Next by Thread: | [PATCH][ATM]: Remove modules.txt in drivers/atm/Kconfig (Nicolas Kaiser <nikai@nikai.net>), Chas Williams |
| Indexes: | [Date] [Thread] [Top] [All Lists] |