]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tcp: use sk_skb_reason_drop to free rx packets
authorYan Zhai <yan@cloudflare.com>
Mon, 17 Jun 2024 18:09:20 +0000 (11:09 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Jun 2024 11:44:22 +0000 (12:44 +0100)
Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving
socket to the tracepoint.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202406011539.jhwBd7DX-lkp@intel.com/
Signed-off-by: Yan Zhai <yan@cloudflare.com>
Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/syncookies.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c

index b61d36810fe3fd62b1e5c5885bbaf20185f1abf0..1948d15f1f281b0c9dc6ee237ff805bc288766e1 100644 (file)
@@ -496,6 +496,6 @@ out:
 out_free:
        reqsk_free(req);
 out_drop:
-       kfree_skb_reason(skb, reason);
+       sk_skb_reason_drop(sk, skb, reason);
        return NULL;
 }
index d0a1e34d69f691eb35b90a8c016451fb13f7393d..f513d1f927ad656697ca373984f5183981bd7494 100644 (file)
@@ -4860,7 +4860,7 @@ static void tcp_drop_reason(struct sock *sk, struct sk_buff *skb,
                            enum skb_drop_reason reason)
 {
        sk_drops_add(sk, skb);
-       kfree_skb_reason(skb, reason);
+       sk_skb_reason_drop(sk, skb, reason);
 }
 
 /* This one checks to see if we can put data from the
index de0c8f43448ab68ee45ad5bd30e952575c113979..8e49d69279d5749645991f1295a237a23add6f81 100644 (file)
@@ -1932,7 +1932,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
 reset:
        tcp_v4_send_reset(rsk, skb, sk_rst_convert_drop_reason(reason));
 discard:
-       kfree_skb_reason(skb, reason);
+       sk_skb_reason_drop(sk, skb, reason);
        /* Be careful here. If this function gets more complicated and
         * gcc suffers from register pressure on the x86, sk (in %ebx)
         * might be destroyed here. This current version compiles correctly,
@@ -2168,8 +2168,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
        int dif = inet_iif(skb);
        const struct iphdr *iph;
        const struct tcphdr *th;
+       struct sock *sk = NULL;
        bool refcounted;
-       struct sock *sk;
        int ret;
        u32 isn;
 
@@ -2368,7 +2368,7 @@ bad_packet:
 discard_it:
        SKB_DR_OR(drop_reason, NOT_SPECIFIED);
        /* Discard frame. */
-       kfree_skb_reason(skb, drop_reason);
+       sk_skb_reason_drop(sk, skb, drop_reason);
        return 0;
 
 discard_and_relse:
index bfad1e89b6a6bb99c28b9ef14c142a6c4aeae54b..9d83eadd308b0cb35026db0ab0216c936464cc33 100644 (file)
@@ -275,6 +275,6 @@ out:
 out_free:
        reqsk_free(req);
 out_drop:
-       kfree_skb_reason(skb, reason);
+       sk_skb_reason_drop(sk, skb, reason);
        return NULL;
 }
index 223b71790e44a36bff6189754aee0f3c2ea4586d..200fea92f12fc99617c64ca817ff1c44d4262085 100644 (file)
@@ -1674,7 +1674,7 @@ reset:
 discard:
        if (opt_skb)
                __kfree_skb(opt_skb);
-       kfree_skb_reason(skb, reason);
+       sk_skb_reason_drop(sk, skb, reason);
        return 0;
 csum_err:
        reason = SKB_DROP_REASON_TCP_CSUM;
@@ -1747,8 +1747,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
        int dif = inet6_iif(skb);
        const struct tcphdr *th;
        const struct ipv6hdr *hdr;
+       struct sock *sk = NULL;
        bool refcounted;
-       struct sock *sk;
        int ret;
        u32 isn;
        struct net *net = dev_net(skb->dev);
@@ -1940,7 +1940,7 @@ bad_packet:
 
 discard_it:
        SKB_DR_OR(drop_reason, NOT_SPECIFIED);
-       kfree_skb_reason(skb, drop_reason);
+       sk_skb_reason_drop(sk, skb, drop_reason);
        return 0;
 
 discard_and_relse: