tcp: Clean up reverse xmas tree in cookie_v[46]_check().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 29 Nov 2023 02:29:17 +0000 (18:29 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Nov 2023 04:15:32 +0000 (20:15 -0800)
We will grow and cut the xmas tree in cookie_v[46]_check().
This patch cleans it up to make later patches tidy.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20231129022924.96156-2-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/syncookies.c
net/ipv6/syncookies.c

index d37282c06e3da05fd36c48e6b4236d74ac2b7fe2..a0118ea76734ff6d11c9def23124d32692f59cac 100644 (file)
@@ -331,18 +331,18 @@ EXPORT_SYMBOL_GPL(cookie_tcp_reqsk_alloc);
 struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
 {
        struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt;
+       const struct tcphdr *th = tcp_hdr(skb);
+       __u32 cookie = ntohl(th->ack_seq) - 1;
        struct tcp_options_received tcp_opt;
+       struct tcp_sock *tp = tcp_sk(sk);
        struct inet_request_sock *ireq;
        struct tcp_request_sock *treq;
-       struct tcp_sock *tp = tcp_sk(sk);
-       const struct tcphdr *th = tcp_hdr(skb);
-       __u32 cookie = ntohl(th->ack_seq) - 1;
-       struct sock *ret = sk;
        struct request_sock *req;
+       struct sock *ret = sk;
        int full_space, mss;
+       struct flowi4 fl4;
        struct rtable *rt;
        __u8 rcv_wscale;
-       struct flowi4 fl4;
        u32 tsoff = 0;
        int l3index;
 
index 12eedc6ca2ccae602985e5b96402b13f258f9589..aa5fb5486cde901bffa161f834ec960268cc8da9 100644 (file)
@@ -127,17 +127,17 @@ EXPORT_SYMBOL_GPL(__cookie_v6_check);
 
 struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
 {
+       const struct tcphdr *th = tcp_hdr(skb);
+       __u32 cookie = ntohl(th->ack_seq) - 1;
+       struct ipv6_pinfo *np = inet6_sk(sk);
        struct tcp_options_received tcp_opt;
+       struct tcp_sock *tp = tcp_sk(sk);
        struct inet_request_sock *ireq;
        struct tcp_request_sock *treq;
-       struct ipv6_pinfo *np = inet6_sk(sk);
-       struct tcp_sock *tp = tcp_sk(sk);
-       const struct tcphdr *th = tcp_hdr(skb);
-       __u32 cookie = ntohl(th->ack_seq) - 1;
-       struct sock *ret = sk;
        struct request_sock *req;
-       int full_space, mss;
        struct dst_entry *dst;
+       struct sock *ret = sk;
+       int full_space, mss;
        __u8 rcv_wscale;
        u32 tsoff = 0;
        int l3index;