diff options
author | Cong Wang <cwang@twopensource.com> | 2014-10-15 23:33:21 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-17 18:02:57 +0200 |
commit | e25f866fbc8a4bf387b5dbe8e25aa5b07e55c74f (patch) | |
tree | df2c77e0b95e195dc496bba98155e2c62b9a80cd /include | |
parent | ipv4: call __ip_options_echo() in cookie_v4_check() (diff) | |
download | linux-e25f866fbc8a4bf387b5dbe8e25aa5b07e55c74f.tar.xz linux-e25f866fbc8a4bf387b5dbe8e25aa5b07e55c74f.zip |
ipv4: share tcp_v4_save_options() with cookie_v4_check()
cookie_v4_check() allocates ip_options_rcu in the same way
with tcp_v4_save_options(), we can just make it a helper function.
Cc: Krzysztof Kolasa <kkolasa@winsoft.pl>
Cc: Eric Dumazet <edumazet@google.com>
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/tcp.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 74efeda994b3..869637a7caf7 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1666,4 +1666,24 @@ int tcpv4_offload_init(void); void tcp_v4_init(void); void tcp_init(void); +/* + * Save and compile IPv4 options, return a pointer to it + */ +static inline struct ip_options_rcu *tcp_v4_save_options(struct sk_buff *skb) +{ + const struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt; + struct ip_options_rcu *dopt = NULL; + + if (opt && opt->optlen) { + int opt_size = sizeof(*dopt) + opt->optlen; + + dopt = kmalloc(opt_size, GFP_ATOMIC); + if (dopt && __ip_options_echo(&dopt->opt, skb, opt)) { + kfree(dopt); + dopt = NULL; + } + } + return dopt; +} + #endif /* _TCP_H */ |