From patchwork Mon Jun 17 18:09:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13701185 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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 D1FE219923D for ; Mon, 17 Jun 2024 18:09:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718647767; cv=none; b=aCXwMs6X27K0UqC9U3D5UCuIcHx86SCBKzWc7rwI4rNi27eNU+T0be+M7Vm1yajQGof+oBajyOkRQj1dVueh9qkoZ8tLj6595bO9+zL51E8Qhu3o3fTVvxfM3ldmBgc1bbdDcrUGXYKkofo0+rFS+b5PA86V369bSo7H0wrOAvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718647767; c=relaxed/simple; bh=deJZMXGB4u9IlWilhC165qOhNKSkcsd0Cq2qS5gJdV8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mxYs1arax5HPh3zbhN1jFSTZPy7y5eQCxEJYnUUdjXuWXKCXmIvfeHdVHEq6g1eW+q+IyTLWU0ILnhv6+orqumE4YyaqIs1w+sCCNx5FpWjR1qu1OeJxee788xwbVbjgNaKitMMobY6NCcbT5//OV4gBpQfGR+qpuIop8N5wMnQ= 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=IBcDneUW; arc=none smtp.client-ip=209.85.219.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="IBcDneUW" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-6b063047958so25414686d6.3 for ; Mon, 17 Jun 2024 11:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1718647764; x=1719252564; 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=J+g79hCGPCQt1VIhgByLxRis8HiHyiHDdOiniWzs6eI=; b=IBcDneUWqEFtafrOY1ZzctM7R4odKc98HMCi9B6YoG2ucYetsPsp8iloXG6r/7Q/B8 DZSL6+jcmMikHyhIgPga3bZ1gAGaMNoQkwpdWR4PDz9LYFX01eQZ8+zWZENhWMdOpohe U67wiMWEA37x/ojkrX3iszcRUhpFVqebtdAyg26n75PqhmIrvta2F5yuKV/i/ta9913t g/y3uP7T52a0PRAGp+RRj+5R9gF3Tp+KtOgVhrs/QHrkPDVxeWpMt47Lw/SO52IBs0zt HErOl1lHHUcMW2QPoqZC6tXxmcYRqKP46xtVfZa63HcjtC3wYuqx+34KrgwX9ERs1Fz0 MCHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718647764; x=1719252564; 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=J+g79hCGPCQt1VIhgByLxRis8HiHyiHDdOiniWzs6eI=; b=CKaXpcXjTOWKnREudeaECkhXPLcN1H8hgO67Wgs+EeF4eTfODTAnivDY2pJbsfTR+c Ptu6830e4mn+IrC1YAkemRS/tzN7l4KFBDkjko83uR95Avoo4MkCm4Eih5cGgB0KyEA3 +5Ra+bafbne+gOT/4TpeOX68WViJSO+kztazeONIXYnvyLXl3FviqUE/pnLHsrZuTM6/ eqJiizuIHUNJigyKBK2We7+/1ZrHszlTefoyQ2eUcViuJ+SWQGc7zZskmfN4UE7o1QIv +nuWOGVR0sbBnnRTg2uvtlRdEpr/NGSffDbVLxXNYoEsrdLiiOCAwobBEnJBiOE21pEO Dniw== X-Gm-Message-State: AOJu0YwqZWLra/bOtir0xoIng1JSUZiXXP97AF0ykJlbDyocWXYJESlm ztCqxd2FD1xt9kvvZwc1Ck5oYhMCrIw0eOTXS+a7NBdc1hTalQt3xcCDZAG9m1dcrAUvlLpxP/B nsQc= X-Google-Smtp-Source: AGHT+IEMPqHaANmszkkMQXD5A2+Zm8agC4VHhJZqDTiCbUYQGKA8ftZzrDZUOCGNXCLjLvAhNCFwnQ== X-Received: by 2002:a0c:f3cd:0:b0:6b0:72c7:88d8 with SMTP id 6a1803df08f44-6b2afce6bf9mr106926546d6.35.1718647764012; Mon, 17 Jun 2024 11:09:24 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:164]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5eca9c1sm58246746d6.39.2024.06.17.11.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 11:09:23 -0700 (PDT) Date: Mon, 17 Jun 2024 11:09:20 -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 , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Neil Horman , linux-trace-kernel@vger.kernel.org, Dan Carpenter Subject: [PATCH net-next v5 5/7] tcp: use sk_skb_reason_drop to free rx packets Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving socket to the tracepoint. Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202406011539.jhwBd7DX-lkp@intel.com/ Signed-off-by: Yan Zhai Acked-by: Jesper Dangaard Brouer --- v2->v3: added missing report tags --- 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: