* [PATCH] UDP: Make use of inet_iif() when doing socket lookups.
@ 2007-10-23 18:40 Vlad Yasevich
2007-10-24 3:26 ` David Miller
2007-10-25 21:58 ` David Stevens
0 siblings, 2 replies; 5+ messages in thread
From: Vlad Yasevich @ 2007-10-23 18:40 UTC (permalink / raw)
To: netdev
UDP currently uses skb->dev->ifindex which may provide the wrong
information when the socket bound to a specific interface.
This patch makes inet_iif() accessible to UDP and makes UDP use it.
The scenario we are trying to fix is when a client is running on
the same system and the server and both client and server bind to
a non-loopback device.
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
include/net/inet_hashtables.h | 6 ------
include/net/inet_sock.h | 7 +++++++
net/ipv4/udp.c | 2 +-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 8228b57..4427dcd 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -26,7 +26,6 @@
#include <net/inet_connection_sock.h>
#include <net/inet_sock.h>
-#include <net/route.h>
#include <net/sock.h>
#include <net/tcp_states.h>
@@ -266,11 +265,6 @@ out:
wake_up(&hashinfo->lhash_wait);
}
-static inline int inet_iif(const struct sk_buff *skb)
-{
- return ((struct rtable *)skb->dst)->rt_iif;
-}
-
extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo,
const __be32 daddr,
const unsigned short hnum,
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 62daf21..70013c5 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -24,6 +24,7 @@
#include <net/flow.h>
#include <net/sock.h>
#include <net/request_sock.h>
+#include <net/route.h>
/** struct ip_options - IP Options
*
@@ -190,4 +191,10 @@ static inline int inet_sk_ehashfn(const struct sock *sk)
return inet_ehashfn(laddr, lport, faddr, fport);
}
+
+static inline int inet_iif(const struct sk_buff *skb)
+{
+ return ((struct rtable *)skb->dst)->rt_iif;
+}
+
#endif /* _INET_SOCK_H */
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 35d2b0e..4bc25b4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1152,7 +1152,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
return __udp4_lib_mcast_deliver(skb, uh, saddr, daddr, udptable);
sk = __udp4_lib_lookup(saddr, uh->source, daddr, uh->dest,
- skb->dev->ifindex, udptable );
+ inet_iif(skb), udptable);
if (sk != NULL) {
int ret = udp_queue_rcv_skb(sk, skb);
--
1.5.2.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] UDP: Make use of inet_iif() when doing socket lookups.
2007-10-23 18:40 [PATCH] UDP: Make use of inet_iif() when doing socket lookups Vlad Yasevich
@ 2007-10-24 3:26 ` David Miller
2007-10-25 21:58 ` David Stevens
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2007-10-24 3:26 UTC (permalink / raw)
To: vladislav.yasevich; +Cc: netdev, dlstevens
From: Vlad Yasevich <vladislav.yasevich@hp.com>
Date: Tue, 23 Oct 2007 14:40:58 -0400
> UDP currently uses skb->dev->ifindex which may provide the wrong
> information when the socket bound to a specific interface.
> This patch makes inet_iif() accessible to UDP and makes UDP use it.
>
> The scenario we are trying to fix is when a client is running on
> the same system and the server and both client and server bind to
> a non-loopback device.
>
> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
David, could you take a quick look at this one?
I have a hunch that this will have side-effects for multicast
applications and I'd feel better if you went over this patch
with that in mind.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] UDP: Make use of inet_iif() when doing socket lookups.
2007-10-23 18:40 [PATCH] UDP: Make use of inet_iif() when doing socket lookups Vlad Yasevich
2007-10-24 3:26 ` David Miller
@ 2007-10-25 21:58 ` David Stevens
2007-10-25 22:36 ` David Miller
2007-10-26 1:55 ` David Miller
1 sibling, 2 replies; 5+ messages in thread
From: David Stevens @ 2007-10-25 21:58 UTC (permalink / raw)
To: Vlad Yasevich, davem; +Cc: netdev, netdev-owner
I don't see any problem with this. If you're using IP_MULTICAST_IF with
a bound socket, it forces you to use that interface, anyway.
I'm not sure multicasting works as expected in some other cases with
bound sockets (looks like there may be some holes to evade the
binding), but that's in old code. I don't see any problems from this
patch.
+-DLS
Acked-by: David L Stevens <dlstevens@us.ibm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] UDP: Make use of inet_iif() when doing socket lookups.
2007-10-25 21:58 ` David Stevens
@ 2007-10-25 22:36 ` David Miller
2007-10-26 1:55 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2007-10-25 22:36 UTC (permalink / raw)
To: dlstevens; +Cc: vladislav.yasevich, netdev, netdev-owner
From: David Stevens <dlstevens@us.ibm.com>
Date: Thu, 25 Oct 2007 14:58:29 -0700
> I don't see any problem with this. If you're using IP_MULTICAST_IF with
> a bound socket, it forces you to use that interface, anyway.
>
> I'm not sure multicasting works as expected in some other cases with
> bound sockets (looks like there may be some holes to evade the
> binding), but that's in old code. I don't see any problems from this
> patch.
>
> +-DLS
>
> Acked-by: David L Stevens <dlstevens@us.ibm.com>
Thanks for reviewing David.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] UDP: Make use of inet_iif() when doing socket lookups.
2007-10-25 21:58 ` David Stevens
2007-10-25 22:36 ` David Miller
@ 2007-10-26 1:55 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2007-10-26 1:55 UTC (permalink / raw)
To: dlstevens; +Cc: vladislav.yasevich, netdev, netdev-owner
From: David Stevens <dlstevens@us.ibm.com>
Date: Thu, 25 Oct 2007 14:58:29 -0700
> I don't see any problem with this. If you're using IP_MULTICAST_IF with
> a bound socket, it forces you to use that interface, anyway.
>
> I'm not sure multicasting works as expected in some other cases with
> bound sockets (looks like there may be some holes to evade the
> binding), but that's in old code. I don't see any problems from this
> patch.
>
> +-DLS
>
> Acked-by: David L Stevens <dlstevens@us.ibm.com>
Patch applied, thanks everyone!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-10-26 1:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-23 18:40 [PATCH] UDP: Make use of inet_iif() when doing socket lookups Vlad Yasevich
2007-10-24 3:26 ` David Miller
2007-10-25 21:58 ` David Stevens
2007-10-25 22:36 ` David Miller
2007-10-26 1:55 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).