diff options
author | Eric Dumazet <edumazet@google.com> | 2015-06-04 21:30:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-06-07 18:19:52 -0400 |
commit | b80c0e78582d4a3a004dc1ade4eb06babc6a4eea (patch) | |
tree | f2dda925e65212d4baacaa01a8b85f462a35b753 | |
parent | 13ea657806cf73b379a0109f7042182f47c351a7 (diff) |
tcp: get_cookie_sock() consolidation
IPv4 and IPv6 share same implementation of get_cookie_sock(),
and there is no point inlining it.
We add tcp_ prefix to the common helper name and export it.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/tcp.h | 3 | ||||
-rw-r--r-- | net/ipv4/syncookies.c | 10 | ||||
-rw-r--r-- | net/ipv6/syncookies.c | 19 |
3 files changed, 9 insertions, 23 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 2bb2bad21d5c..978cebedd3fc 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -469,6 +469,9 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size); | |||
469 | void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb); | 469 | void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb); |
470 | 470 | ||
471 | /* From syncookies.c */ | 471 | /* From syncookies.c */ |
472 | struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb, | ||
473 | struct request_sock *req, | ||
474 | struct dst_entry *dst); | ||
472 | int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th, | 475 | int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th, |
473 | u32 cookie); | 476 | u32 cookie); |
474 | struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb); | 477 | struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb); |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index df849e5a10f1..d70b1f603692 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -219,9 +219,9 @@ int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th, | |||
219 | } | 219 | } |
220 | EXPORT_SYMBOL_GPL(__cookie_v4_check); | 220 | EXPORT_SYMBOL_GPL(__cookie_v4_check); |
221 | 221 | ||
222 | static struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, | 222 | struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb, |
223 | struct request_sock *req, | 223 | struct request_sock *req, |
224 | struct dst_entry *dst) | 224 | struct dst_entry *dst) |
225 | { | 225 | { |
226 | struct inet_connection_sock *icsk = inet_csk(sk); | 226 | struct inet_connection_sock *icsk = inet_csk(sk); |
227 | struct sock *child; | 227 | struct sock *child; |
@@ -235,7 +235,7 @@ static struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, | |||
235 | } | 235 | } |
236 | return child; | 236 | return child; |
237 | } | 237 | } |
238 | 238 | EXPORT_SYMBOL(tcp_get_cookie_sock); | |
239 | 239 | ||
240 | /* | 240 | /* |
241 | * when syncookies are in effect and tcp timestamps are enabled we stored | 241 | * when syncookies are in effect and tcp timestamps are enabled we stored |
@@ -391,7 +391,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) | |||
391 | ireq->rcv_wscale = rcv_wscale; | 391 | ireq->rcv_wscale = rcv_wscale; |
392 | ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), &rt->dst); | 392 | ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), &rt->dst); |
393 | 393 | ||
394 | ret = get_cookie_sock(sk, skb, req, &rt->dst); | 394 | ret = tcp_get_cookie_sock(sk, skb, req, &rt->dst); |
395 | /* ip_queue_xmit() depends on our flow being setup | 395 | /* ip_queue_xmit() depends on our flow being setup |
396 | * Normal sockets get it right from inet_csk_route_child_sock() | 396 | * Normal sockets get it right from inet_csk_route_child_sock() |
397 | */ | 397 | */ |
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 21bc2eb53c57..0909f4e0d53c 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c | |||
@@ -41,23 +41,6 @@ static __u16 const msstab[] = { | |||
41 | 9000 - 60, | 41 | 9000 - 60, |
42 | }; | 42 | }; |
43 | 43 | ||
44 | static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, | ||
45 | struct request_sock *req, | ||
46 | struct dst_entry *dst) | ||
47 | { | ||
48 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
49 | struct sock *child; | ||
50 | |||
51 | child = icsk->icsk_af_ops->syn_recv_sock(sk, skb, req, dst); | ||
52 | if (child) { | ||
53 | atomic_set(&req->rsk_refcnt, 1); | ||
54 | inet_csk_reqsk_queue_add(sk, req, child); | ||
55 | } else { | ||
56 | reqsk_free(req); | ||
57 | } | ||
58 | return child; | ||
59 | } | ||
60 | |||
61 | static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS], | 44 | static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS], |
62 | ipv6_cookie_scratch); | 45 | ipv6_cookie_scratch); |
63 | 46 | ||
@@ -264,7 +247,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
264 | ireq->rcv_wscale = rcv_wscale; | 247 | ireq->rcv_wscale = rcv_wscale; |
265 | ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), dst); | 248 | ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), dst); |
266 | 249 | ||
267 | ret = get_cookie_sock(sk, skb, req, dst); | 250 | ret = tcp_get_cookie_sock(sk, skb, req, dst); |
268 | out: | 251 | out: |
269 | return ret; | 252 | return ret; |
270 | out_free: | 253 | out_free: |