Skip to content

Commit fee9dee

Browse files
Vlad Yasevichdavem330
authored andcommitted
[UDP]: Make use of inet_iif() when doing socket lookups.
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> Acked-by: David L Stevens <dlstevens@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 41fb285 commit fee9dee

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎include/net/inet_hashtables.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
#include <net/inet_connection_sock.h>
2828
#include <net/inet_sock.h>
29-
#include <net/route.h>
3029
#include <net/sock.h>
3130
#include <net/tcp_states.h>
3231

@@ -266,11 +265,6 @@ static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk)
266265
wake_up(&hashinfo->lhash_wait);
267266
}
268267

269-
static inline int inet_iif(const struct sk_buff *skb)
270-
{
271-
return ((struct rtable *)skb->dst)->rt_iif;
272-
}
273-
274268
extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo,
275269
const __be32 daddr,
276270
const unsigned short hnum,

‎include/net/inet_sock.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <net/flow.h>
2525
#include <net/sock.h>
2626
#include <net/request_sock.h>
27+
#include <net/route.h>
2728

2829
/** struct ip_options - IP Options
2930
*
@@ -190,4 +191,10 @@ static inline int inet_sk_ehashfn(const struct sock *sk)
190191
return inet_ehashfn(laddr, lport, faddr, fport);
191192
}
192193

194+
195+
static inline int inet_iif(const struct sk_buff *skb)
196+
{
197+
return ((struct rtable *)skb->dst)->rt_iif;
198+
}
199+
193200
#endif /* _INET_SOCK_H */

‎net/ipv4/udp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
11521152
return __udp4_lib_mcast_deliver(skb, uh, saddr, daddr, udptable);
11531153

11541154
sk = __udp4_lib_lookup(saddr, uh->source, daddr, uh->dest,
1155-
skb->dev->ifindex, udptable );
1155+
inet_iif(skb), udptable);
11561156

11571157
if (sk != NULL) {
11581158
int ret = udp_queue_rcv_skb(sk, skb);

0 commit comments

Comments
 (0)