Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp800961lqh; Fri, 31 May 2024 18:44:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9eGYtuOXDbV9zayoco2pIkEjhv6ujo4u2OKbDapj5M9BLARH+L0HRqgAOZgB0ZvSip1RuDqDwLz9DEKCcVGsN/nDHVgKA3Ib5T6Cq7w== X-Google-Smtp-Source: AGHT+IEl/DSUttlij7lbUCL+Sl1Wo4AGpPdnc3RVvrJ7M5r6wB5kriuTScJwmrFr8z9fEGmIMtQl X-Received: by 2002:a05:6214:310c:b0:6a0:a7c6:436f with SMTP id 6a1803df08f44-6aecd6b9262mr40159156d6.38.1717206288042; Fri, 31 May 2024 18:44:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717206288; cv=pass; d=google.com; s=arc-20160816; b=bGpTBYw5vo9CXIGZ4FQ9rdxEc9ch0Aj8ToITNqCUOHlZxNdwt08D3VbbhIAE3TEEha ZGCmDFAAepRTv30dMi2x/e3yOTm+Ob035LV6d+KFemZXYz2Hdlto2fG33A5lmDwA26xY kbovsNrORSio8LKLoUwosoTiOPaIX7N54NAKd+zyXJjVbRfjW5DQGqBStdr5j0HNNQJD cFskwgbWAl+woAr03Qqi2Xhp1v/70gT0I0GkZHQADLdpS7sb3Ld5xv0phBUaq+GHYFIi DikC4siqNvPj68s0ynqdq/A27tfon7/jaFuFrhEQ3YWHBD6fVWLpO6taSX2hrD9SQpr8 1L3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dYA4sm5ZJWs2eGhWm2n7K+ofN7tUeRmWPht1RYEuz58=; fh=mJ0mrBqGfR8ATrlPsRnMRzr3ipWFRhiSkLkFYpOYaN4=; b=u5Fdpc5TDPSYibYfDKxPyNCiWuZDxRwETKvhrYMXtIpfns2+kKCvOR8V9gceyuq5Lm RLOfhlZsZHZpU2nPca4ttwT4mUpx9WpXaODZ+/cSL+xR+xKutkxY4vUJ1gSmfg/5ZGPO AU7FWzqiwNmLBbe09IbPm0sqToM4+EHU5Av78kyCzD0eN1oWdEWkw5NxY6fIndIspAgj zlPftScm+eIfr6rtJO8X+JXtMleyCPPyoMCkykZUsqLtzWPG/F1kaR9OG+TkATHkITnT pYx4xCB3W8WtlVjn+SFASGlD/wp/sxjFlJ8WJ+qcYXvbzzT6Hy3lLA4PQw0WCtmM6rE1 yX0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=Xv0WToc1; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-197638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b402380si35200086d6.241.2024.05.31.18.44.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:44:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=Xv0WToc1; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-197638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 85C211C217C2 for ; Sat, 1 Jun 2024 01:44:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 612EF1E4AF; Sat, 1 Jun 2024 01:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="Xv0WToc1" Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA6916FBE for ; Sat, 1 Jun 2024 01:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206180; cv=none; b=chxKeXcR7eoGHCReCo0mm6GEtQoUbEJsd+KhN0e00ISrHTcSS5AH00ylSNb3kAzJGZzAljugSRa1EFT6rEf7/TL/COoh5QNvFts2bDU5yNIF/vNMq8UDliCZC8jFziqp5qf3y6qKNUxB8ArpZ/Bed7AAyStAHEhH1sm7loKViBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206180; c=relaxed/simple; bh=1LVHRhrSMWEwJpOY/aznILauVa0NivSWY+f+CAqnbvA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q7NLfKaenEbkrpFMsZph99/OXis2NJDBHAPv99w0LeczSHB/xNPSdlwVq+D0hcmLwzvGWiHvcBwPmgxiXJmPb4ehbsR+lyU71ctFX+CN+QMP09WJSoQajP0GgjS35bXiRtw54oVJLmo0FiSdKZXaWwtYQZ7kB5e4sLI2czPudUg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=Xv0WToc1; arc=none smtp.client-ip=209.85.219.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-dfa48f505dfso2630917276.3 for ; Fri, 31 May 2024 18:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717206178; x=1717810978; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dYA4sm5ZJWs2eGhWm2n7K+ofN7tUeRmWPht1RYEuz58=; b=Xv0WToc1MxZYkw9/ypiCWj7FEmuwkczmpehZ0DufYqltgqrX7JDaeZDrOki/09xyvU AQy2YzDMP3ScLeqgyv09ZDPSpzyJA7rx8qQjEHXbzfOmdoTdGAPGmMEakDJERmsm0nDU fSKeMYiBDcrkM0BqpZBshezHRoxsiPNrsSstqML0tnyfPd0qSrBLGAMOty84sVnyrgg7 CluutMd5s+Hzbe2tSE4h9+NbGiv9u27k7ndjaxH/unCEjxkwsbYhQmeS3u3ItcAdUcXf jsK2geImaHkqYeTUgaIa/lUOjECIu1rPaj92vc8aFL7+QlEHJVQCzxpqy8g5Kjy4o4UJ SKzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717206178; x=1717810978; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dYA4sm5ZJWs2eGhWm2n7K+ofN7tUeRmWPht1RYEuz58=; b=Wr9Jre7dARn5dHKiMnWza4z6OSvCo5dock0/bonZfGDHSVAkHenjTOISCIGW9g2z2M kUDbuPR/pSrGzliJEDjP4HamfQUKq43pg9VBpmCbdKoI4b3SeCBwZMvEi0nUmMHfzmrs yzkSrcoMm19z+wF/F6yUjBNDOfxkPBIFx9pTZRvn2em6itKAgC26QaCd/VaJcTbpd1Pc 9Gx5wQnhX9W6rDsKMDvm0HxwJMB54eL5E8GyvGmXKG/LOm89EAZOeqyB38CezyMasGNA feGTxOLk0MBJkeDFd4u6PaZR+0d506lHrDl0E5VuZpdArz8r42uetpI2m6/fm4m6aC70 inSA== X-Forwarded-Encrypted: i=1; AJvYcCWUUVNr7POlnu1rpvg7N1cm0FSgTdjedxU7UDMjtDLFPthBDWeNLHXI+d66oVoxmqARg40vyOulEdoHDfYoDYszGYlS6+G4JX5+oCCf X-Gm-Message-State: AOJu0YyzQn+olFgqkfb70Bn81cLMNktMROHmBuLHgGe1PLVyBnJh01uK F6cN3Od/VN4Esy/FiYiBZOpDiwKGBUBAK2YaJwyh8VUP98ncASNUDJ+XVWLv94g= X-Received: by 2002:a25:1387:0:b0:df4:d7e2:aa2f with SMTP id 3f1490d57ef6-dfa73dbfb85mr3516117276.59.1717206177923; Fri, 31 May 2024 18:42:57 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-dfa6f150099sm555136276.60.2024.05.31.18.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:42:57 -0700 (PDT) Date: Fri, 31 May 2024 18:42:55 -0700 From: Yan Zhai To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , David Ahern , Abhishek Chauhan , Mina Almasry , Florian Westphal , Alexander Lobakin , David Howells , Jiri Pirko , Daniel Borkmann , Sebastian Andrzej Siewior , Lorenzo Bianconi , Pavel Begunkov , linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Jesper Dangaard Brouer Subject: [RFC v2 net-next 5/7] tcp: use sk_skb_reason_drop to free rx packets Message-ID: <40d89398347be8d269f49f604bf82bdb9855d00d.1717206060.git.yan@cloudflare.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving socket to the tracepoint. Signed-off-by: Yan Zhai --- net/ipv4/syncookies.c | 2 +- net/ipv4/tcp_input.c | 2 +- net/ipv4/tcp_ipv4.c | 6 +++--- net/ipv6/syncookies.c | 2 +- net/ipv6/tcp_ipv6.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index b61d36810fe3..1948d15f1f28 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -496,6 +496,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) out_free: reqsk_free(req); out_drop: - kfree_skb_reason(skb, reason); + sk_skb_reason_drop(sk, skb, reason); return NULL; } diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5aadf64e554d..bedb079de1f0 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4859,7 +4859,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 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 041c7eda9abe..f7a046bc4b27 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1939,7 +1939,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, @@ -2176,8 +2176,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; @@ -2376,7 +2376,7 @@ int tcp_v4_rcv(struct sk_buff *skb) 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: diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index bfad1e89b6a6..9d83eadd308b 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c @@ -275,6 +275,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) out_free: reqsk_free(req); out_drop: - kfree_skb_reason(skb, reason); + sk_skb_reason_drop(sk, skb, reason); return NULL; } diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 1ac7502e1bf5..93967accc35d 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1678,7 +1678,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) 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; @@ -1751,8 +1751,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); @@ -1944,7 +1944,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) 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: -- 2.30.2