net: tcp: add skb drop reasons to tcp_v4_rcv()
authorMenglong Dong <imagedong@tencent.com>
Sun, 20 Feb 2022 07:06:30 +0000 (15:06 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 20 Feb 2022 13:55:31 +0000 (13:55 +0000)
Use kfree_skb_reason() for some path in tcp_v4_rcv() that missed before,
including:

SKB_DROP_REASON_SOCKET_FILTER
SKB_DROP_REASON_XFRM_POLICY

Reviewed-by: Mengen Sun <mengensun@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_ipv4.c

index 6873f46..a3beab0 100644 (file)
@@ -2057,6 +2057,8 @@ process:
                        iph = ip_hdr(skb);
                        tcp_v4_fill_cb(skb, iph, th);
                        nsk = tcp_check_req(sk, skb, req, false, &req_stolen);
+               } else {
+                       drop_reason = SKB_DROP_REASON_SOCKET_FILTER;
                }
                if (!nsk) {
                        reqsk_put(req);
@@ -2092,8 +2094,10 @@ process:
                }
        }
 
-       if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
+       if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
+               drop_reason = SKB_DROP_REASON_XFRM_POLICY;
                goto discard_and_relse;
+       }
 
        if (tcp_v4_inbound_md5_hash(sk, skb, dif, sdif))
                goto discard_and_relse;
@@ -2166,6 +2170,7 @@ discard_and_relse:
 
 do_time_wait:
        if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+               drop_reason = SKB_DROP_REASON_XFRM_POLICY;
                inet_twsk_put(inet_twsk(sk));
                goto discard_it;
        }