aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCong Wang <cwang@twopensource.com>2014-10-15 17:33:22 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-17 12:02:57 -0400
commit461b74c391c4ec9c766794e158508c357d8952e6 (patch)
tree19cfb1a79b6dc5c9141022985c3917fc2d90b7a1
parente25f866fbc8a4bf387b5dbe8e25aa5b07e55c74f (diff)
ipv4: clean up cookie_v4_check()
We can retrieve opt from skb, no need to pass it as a parameter. And opt should always be non-NULL, no need to check. Cc: Krzysztof Kolasa <kkolasa@winsoft.pl> Cc: Eric Dumazet <edumazet@google.com> Tested-by: Krzysztof Kolasa <kkolasa@winsoft.pl> Signed-off-by: Cong Wang <cwang@twopensource.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/tcp.h5
-rw-r--r--net/ipv4/syncookies.c6
-rw-r--r--net/ipv4/tcp_ipv4.c2
3 files changed, 6 insertions, 7 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 869637a7caf7..3a4bbbfdcf8d 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -468,8 +468,7 @@ void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb);
468/* From syncookies.c */ 468/* From syncookies.c */
469int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th, 469int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th,
470 u32 cookie); 470 u32 cookie);
471struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, 471struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb);
472 struct ip_options *opt);
473#ifdef CONFIG_SYN_COOKIES 472#ifdef CONFIG_SYN_COOKIES
474 473
475/* Syncookies use a monotonic timer which increments every 60 seconds. 474/* Syncookies use a monotonic timer which increments every 60 seconds.
@@ -1674,7 +1673,7 @@ static inline struct ip_options_rcu *tcp_v4_save_options(struct sk_buff *skb)
1674 const struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt; 1673 const struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt;
1675 struct ip_options_rcu *dopt = NULL; 1674 struct ip_options_rcu *dopt = NULL;
1676 1675
1677 if (opt && opt->optlen) { 1676 if (opt->optlen) {
1678 int opt_size = sizeof(*dopt) + opt->optlen; 1677 int opt_size = sizeof(*dopt) + opt->optlen;
1679 1678
1680 dopt = kmalloc(opt_size, GFP_ATOMIC); 1679 dopt = kmalloc(opt_size, GFP_ATOMIC);
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index c68d0a1a468e..d346303fac77 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -255,9 +255,9 @@ bool cookie_check_timestamp(struct tcp_options_received *tcp_opt,
255} 255}
256EXPORT_SYMBOL(cookie_check_timestamp); 256EXPORT_SYMBOL(cookie_check_timestamp);
257 257
258struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, 258struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
259 struct ip_options *opt)
260{ 259{
260 struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt;
261 struct tcp_options_received tcp_opt; 261 struct tcp_options_received tcp_opt;
262 struct inet_request_sock *ireq; 262 struct inet_request_sock *ireq;
263 struct tcp_request_sock *treq; 263 struct tcp_request_sock *treq;
@@ -336,7 +336,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
336 flowi4_init_output(&fl4, sk->sk_bound_dev_if, ireq->ir_mark, 336 flowi4_init_output(&fl4, sk->sk_bound_dev_if, ireq->ir_mark,
337 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE, IPPROTO_TCP, 337 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE, IPPROTO_TCP,
338 inet_sk_flowi_flags(sk), 338 inet_sk_flowi_flags(sk),
339 (opt && opt->srr) ? opt->faddr : ireq->ir_rmt_addr, 339 opt->srr ? opt->faddr : ireq->ir_rmt_addr,
340 ireq->ir_loc_addr, th->source, th->dest); 340 ireq->ir_loc_addr, th->source, th->dest);
341 security_req_classify_flow(req, flowi4_to_flowi(&fl4)); 341 security_req_classify_flow(req, flowi4_to_flowi(&fl4));
342 rt = ip_route_output_key(sock_net(sk), &fl4); 342 rt = ip_route_output_key(sock_net(sk), &fl4);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6a2a7d659a7a..94d1a7757ff7 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1408,7 +1408,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
1408 1408
1409#ifdef CONFIG_SYN_COOKIES 1409#ifdef CONFIG_SYN_COOKIES
1410 if (!th->syn) 1410 if (!th->syn)
1411 sk = cookie_v4_check(sk, skb, &TCP_SKB_CB(skb)->header.h4.opt); 1411 sk = cookie_v4_check(sk, skb);
1412#endif 1412#endif
1413 return sk; 1413 return sk;
1414} 1414}