aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorCraig Gallek <kraig@google.com>2016-02-10 11:50:38 -0500
committerDavid S. Miller <davem@davemloft.net>2016-02-11 03:54:14 -0500
commita583636a83ea383fd07517e5a7a2eedbc5d90fb1 (patch)
tree98ebf6de1532c7693c9b1026cf1a898070a9c344 /include/net
parentd9b3fca27385eafe61c3ca6feab6cb1e7dc77482 (diff)
inet: refactor inet[6]_lookup functions to take skb
This is a preliminary step to allow fast socket lookup of SO_REUSEPORT groups. Doing so with a BPF filter will require access to the skb in question. This change plumbs the skb (and offset to payload data) through the call stack to the listening socket lookup implementations where it will be used in a following patch. Signed-off-by: Craig Gallek <kraig@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/addrconf.h2
-rw-r--r--include/net/inet6_hashtables.h11
-rw-r--r--include/net/inet_hashtables.h18
3 files changed, 21 insertions, 10 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 47f52d3cd8df..730d856683e5 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -87,6 +87,8 @@ int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
87 u32 banned_flags); 87 u32 banned_flags);
88int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr, 88int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr,
89 u32 banned_flags); 89 u32 banned_flags);
90int ipv4_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2,
91 bool match_wildcard);
90int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2, 92int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2,
91 bool match_wildcard); 93 bool match_wildcard);
92void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr); 94void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr);
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index b3c28a9dfbf1..28332bdac333 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -53,6 +53,7 @@ struct sock *__inet6_lookup_established(struct net *net,
53 53
54struct sock *inet6_lookup_listener(struct net *net, 54struct sock *inet6_lookup_listener(struct net *net,
55 struct inet_hashinfo *hashinfo, 55 struct inet_hashinfo *hashinfo,
56 struct sk_buff *skb, int doff,
56 const struct in6_addr *saddr, 57 const struct in6_addr *saddr,
57 const __be16 sport, 58 const __be16 sport,
58 const struct in6_addr *daddr, 59 const struct in6_addr *daddr,
@@ -60,6 +61,7 @@ struct sock *inet6_lookup_listener(struct net *net,
60 61
61static inline struct sock *__inet6_lookup(struct net *net, 62static inline struct sock *__inet6_lookup(struct net *net,
62 struct inet_hashinfo *hashinfo, 63 struct inet_hashinfo *hashinfo,
64 struct sk_buff *skb, int doff,
63 const struct in6_addr *saddr, 65 const struct in6_addr *saddr,
64 const __be16 sport, 66 const __be16 sport,
65 const struct in6_addr *daddr, 67 const struct in6_addr *daddr,
@@ -71,12 +73,12 @@ static inline struct sock *__inet6_lookup(struct net *net,
71 if (sk) 73 if (sk)
72 return sk; 74 return sk;
73 75
74 return inet6_lookup_listener(net, hashinfo, saddr, sport, 76 return inet6_lookup_listener(net, hashinfo, skb, doff, saddr, sport,
75 daddr, hnum, dif); 77 daddr, hnum, dif);
76} 78}
77 79
78static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo, 80static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo,
79 struct sk_buff *skb, 81 struct sk_buff *skb, int doff,
80 const __be16 sport, 82 const __be16 sport,
81 const __be16 dport, 83 const __be16 dport,
82 int iif) 84 int iif)
@@ -86,13 +88,14 @@ static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo,
86 if (sk) 88 if (sk)
87 return sk; 89 return sk;
88 90
89 return __inet6_lookup(dev_net(skb_dst(skb)->dev), hashinfo, 91 return __inet6_lookup(dev_net(skb_dst(skb)->dev), hashinfo, skb,
90 &ipv6_hdr(skb)->saddr, sport, 92 doff, &ipv6_hdr(skb)->saddr, sport,
91 &ipv6_hdr(skb)->daddr, ntohs(dport), 93 &ipv6_hdr(skb)->daddr, ntohs(dport),
92 iif); 94 iif);
93} 95}
94 96
95struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, 97struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo,
98 struct sk_buff *skb, int doff,
96 const struct in6_addr *saddr, const __be16 sport, 99 const struct in6_addr *saddr, const __be16 sport,
97 const struct in6_addr *daddr, const __be16 dport, 100 const struct in6_addr *daddr, const __be16 dport,
98 const int dif); 101 const int dif);
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 554440e7f83d..82403390af58 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -213,6 +213,7 @@ void inet_unhash(struct sock *sk);
213 213
214struct sock *__inet_lookup_listener(struct net *net, 214struct sock *__inet_lookup_listener(struct net *net,
215 struct inet_hashinfo *hashinfo, 215 struct inet_hashinfo *hashinfo,
216 struct sk_buff *skb, int doff,
216 const __be32 saddr, const __be16 sport, 217 const __be32 saddr, const __be16 sport,
217 const __be32 daddr, 218 const __be32 daddr,
218 const unsigned short hnum, 219 const unsigned short hnum,
@@ -220,10 +221,11 @@ struct sock *__inet_lookup_listener(struct net *net,
220 221
221static inline struct sock *inet_lookup_listener(struct net *net, 222static inline struct sock *inet_lookup_listener(struct net *net,
222 struct inet_hashinfo *hashinfo, 223 struct inet_hashinfo *hashinfo,
224 struct sk_buff *skb, int doff,
223 __be32 saddr, __be16 sport, 225 __be32 saddr, __be16 sport,
224 __be32 daddr, __be16 dport, int dif) 226 __be32 daddr, __be16 dport, int dif)
225{ 227{
226 return __inet_lookup_listener(net, hashinfo, saddr, sport, 228 return __inet_lookup_listener(net, hashinfo, skb, doff, saddr, sport,
227 daddr, ntohs(dport), dif); 229 daddr, ntohs(dport), dif);
228} 230}
229 231
@@ -299,6 +301,7 @@ static inline struct sock *
299 301
300static inline struct sock *__inet_lookup(struct net *net, 302static inline struct sock *__inet_lookup(struct net *net,
301 struct inet_hashinfo *hashinfo, 303 struct inet_hashinfo *hashinfo,
304 struct sk_buff *skb, int doff,
302 const __be32 saddr, const __be16 sport, 305 const __be32 saddr, const __be16 sport,
303 const __be32 daddr, const __be16 dport, 306 const __be32 daddr, const __be16 dport,
304 const int dif) 307 const int dif)
@@ -307,12 +310,13 @@ static inline struct sock *__inet_lookup(struct net *net,
307 struct sock *sk = __inet_lookup_established(net, hashinfo, 310 struct sock *sk = __inet_lookup_established(net, hashinfo,
308 saddr, sport, daddr, hnum, dif); 311 saddr, sport, daddr, hnum, dif);
309 312
310 return sk ? : __inet_lookup_listener(net, hashinfo, saddr, sport, 313 return sk ? : __inet_lookup_listener(net, hashinfo, skb, doff, saddr,
311 daddr, hnum, dif); 314 sport, daddr, hnum, dif);
312} 315}
313 316
314static inline struct sock *inet_lookup(struct net *net, 317static inline struct sock *inet_lookup(struct net *net,
315 struct inet_hashinfo *hashinfo, 318 struct inet_hashinfo *hashinfo,
319 struct sk_buff *skb, int doff,
316 const __be32 saddr, const __be16 sport, 320 const __be32 saddr, const __be16 sport,
317 const __be32 daddr, const __be16 dport, 321 const __be32 daddr, const __be16 dport,
318 const int dif) 322 const int dif)
@@ -320,7 +324,8 @@ static inline struct sock *inet_lookup(struct net *net,
320 struct sock *sk; 324 struct sock *sk;
321 325
322 local_bh_disable(); 326 local_bh_disable();
323 sk = __inet_lookup(net, hashinfo, saddr, sport, daddr, dport, dif); 327 sk = __inet_lookup(net, hashinfo, skb, doff, saddr, sport, daddr,
328 dport, dif);
324 local_bh_enable(); 329 local_bh_enable();
325 330
326 return sk; 331 return sk;
@@ -328,6 +333,7 @@ static inline struct sock *inet_lookup(struct net *net,
328 333
329static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo, 334static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
330 struct sk_buff *skb, 335 struct sk_buff *skb,
336 int doff,
331 const __be16 sport, 337 const __be16 sport,
332 const __be16 dport) 338 const __be16 dport)
333{ 339{
@@ -337,8 +343,8 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
337 if (sk) 343 if (sk)
338 return sk; 344 return sk;
339 else 345 else
340 return __inet_lookup(dev_net(skb_dst(skb)->dev), hashinfo, 346 return __inet_lookup(dev_net(skb_dst(skb)->dev), hashinfo, skb,
341 iph->saddr, sport, 347 doff, iph->saddr, sport,
342 iph->daddr, dport, inet_iif(skb)); 348 iph->daddr, dport, inet_iif(skb));
343} 349}
344 350