From patchwork Sat Jun 1 01:42:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13682295 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (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 C7CA2AD4C for ; Sat, 1 Jun 2024 01:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206170; cv=none; b=puuQNpjkQrqXziSb/lA72SYVEElZNDkPkpIADqI2WP3m5yYJcr4hbloLKRMcUnPan/1Dk1ot9GNkJvl3LiPialRtINiBGgKC26UoOcDeNr4DWSPQOQyqzjEetuMTWjF22QIhiVJH8WeDP84cXBz8TseARiSSjFxvV7Hr84Wj4IE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206170; c=relaxed/simple; bh=fMhS89j65J/ioJctAsELK69LYt7rCRTJv5kJAJc12O8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fZnFCET23DlqtcX9JLe9Sg/Dqhk14rHN/NLl6WVGyyMmg5OW2QWCWg3TH0de1Drbk/ufymOUd/hdnFMEYV/7YWIYqytL1nUW1OMzQqBElw9S8umqqZ11pcKb6G/f4vhKiuwr0Gxpkq+qsbJQzdZhEc9ufgb1sVv+jO/cRJkwpqo= 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=EZEulQPL; arc=none smtp.client-ip=209.85.219.169 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="EZEulQPL" Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-dfa79233c48so1147381276.1 for ; Fri, 31 May 2024 18:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717206167; x=1717810967; 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=cundJu+cYnxxw8687bE9Xl3Y+llWE0GOh77B0ua/CNI=; b=EZEulQPLbNS0NM15eeqKtV9wFeLGCPEme9p9MxydLAhDWvxVpmc43mkyJD3lgqbHXR gwMG7e7eAxQzsVvz+brmbu/uZvfH4D9aGhPFlMVBWYSGaab5kn9Ggb31RKkT+KsCEi3i cq5R+J6SZUrwaQASzn05t6gmqiUXEaHfkdWYFjeBDHen/QBz4ceYUl1NPZQKNwlV0T29 8GZA9YUVTndFYXQNs+shzcvBN4qeekaOAbLmE9UZ9fDETaKxmGaBEvtW5AIDI9Ghz0Lo HNGw0ZwI6wU3YOysfGBIVn4mYqwExGOnSgqSIctwuFR2oqhfRGQCh8tuNyuvdBIONmJH M91Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717206167; x=1717810967; 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=cundJu+cYnxxw8687bE9Xl3Y+llWE0GOh77B0ua/CNI=; b=ZIxha1SudtNz1el8KjqwLHqOg6/Wry7gGFxdZp5Fr1xAfEI8+O5plYDNa9dijoQYpu RfCKl0NreXw2WnCMqq7EDRd2ANCK8KUSc9qffWOIVm9gheBqhmeO65YWMvFGZWRG+521 kz0uULVHPmaZF+KOlh3evO3o9KQ9Qi47aAzhjn32WTUvHhXqibf/ZEqjnypzBxJwYpmg pptxTjzKEnU0MolitsJP6tfURplNLB6+4n1tb2HymD77N/p6sAFJ36P3wVNdX6H3XMgA AM2fCF51wkCvOv438Ndc3vtm+CufsNlsdkb9/9jH/NcFtxDWLvZZvV534RJTZDjAwKtD qAUQ== X-Gm-Message-State: AOJu0Yy+6QhNKCKnRnMVjH+V63r9XpZLvZ2a03tWEfBXvdWAR7dhT64x fqu8M9dtB0DgH/J/3he8K0os6dUeNTvNtSEDIili+4bOh+dClEsdWwmagVWNEMqIwyurXKamE1r SZYQ= X-Google-Smtp-Source: AGHT+IF8/QXX/W3z+6+bPU1EZTN+wOS5BbuypuBo+0m5XNlSWCNf1UxNrXiBYmUihxaQr4gR5LJW8w== X-Received: by 2002:a25:abd1:0:b0:df4:dcb6:75bd with SMTP id 3f1490d57ef6-dfa73bc31f9mr4195161276.9.1717206166653; Fri, 31 May 2024 18:42:46 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-dfa6f011334sm561875276.4.2024.05.31.18.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:42:45 -0700 (PDT) Date: Fri, 31 May 2024 18:42:43 -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 1/7] net: add rx_sk to trace_kfree_skb Message-ID: <451ae2a5c2ddb3c127cfddaf4a6579d6e85791f3.1717206060.git.yan@cloudflare.com> 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 X-Patchwork-State: RFC skb does not include enough information to find out receiving sockets/services and netns/containers on packet drops. In theory skb->dev tells about netns, but it can get cleared/reused, e.g. by TCP stack for OOO packet lookup. Similarly, skb->sk often identifies a local sender, and tells nothing about a receiver. Allow passing an extra receiving socket to the tracepoint to improve the visibility on receiving drops. Signed-off-by: Yan Zhai --- include/trace/events/skb.h | 11 +++++++---- net/core/dev.c | 2 +- net/core/skbuff.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 07e0715628ec..aa6b46b6172c 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -24,15 +24,16 @@ DEFINE_DROP_REASON(FN, FN) TRACE_EVENT(kfree_skb, TP_PROTO(struct sk_buff *skb, void *location, - enum skb_drop_reason reason), + enum skb_drop_reason reason, struct sock *rx_sk), - TP_ARGS(skb, location, reason), + TP_ARGS(skb, location, reason, rx_sk), TP_STRUCT__entry( __field(void *, skbaddr) __field(void *, location) __field(unsigned short, protocol) __field(enum skb_drop_reason, reason) + __field(void *, rx_skaddr) ), TP_fast_assign( @@ -40,12 +41,14 @@ TRACE_EVENT(kfree_skb, __entry->location = location; __entry->protocol = ntohs(skb->protocol); __entry->reason = reason; + __entry->rx_skaddr = rx_sk; ), - TP_printk("skbaddr=%p protocol=%u location=%pS reason: %s", + TP_printk("skbaddr=%p protocol=%u location=%pS reason: %s rx_skaddr=%p", __entry->skbaddr, __entry->protocol, __entry->location, __print_symbolic(__entry->reason, - DEFINE_DROP_REASON(FN, FNe))) + DEFINE_DROP_REASON(FN, FNe)), + __entry->rx_skaddr) ); #undef FN diff --git a/net/core/dev.c b/net/core/dev.c index 85fe8138f3e4..7844227ecbfd 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5233,7 +5233,7 @@ static __latent_entropy void net_tx_action(struct softirq_action *h) trace_consume_skb(skb, net_tx_action); else trace_kfree_skb(skb, net_tx_action, - get_kfree_skb_cb(skb)->reason); + get_kfree_skb_cb(skb)->reason, NULL); if (skb->fclone != SKB_FCLONE_UNAVAILABLE) __kfree_skb(skb); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 466999a7515e..2854afdd713f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1203,7 +1203,7 @@ bool __kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) if (reason == SKB_CONSUMED) trace_consume_skb(skb, __builtin_return_address(0)); else - trace_kfree_skb(skb, __builtin_return_address(0), reason); + trace_kfree_skb(skb, __builtin_return_address(0), reason, NULL); return true; } From patchwork Sat Jun 1 01:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13682296 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 ACCE3111AA for ; Sat, 1 Jun 2024 01:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206173; cv=none; b=P+jRnIqN0MyoMgfSLthmdiqYrumfaUDG8XV/VntOKSJe8X7xt4i9DcDwvXhn6ipKDJqPRYppP9G8tLPB/+Yi5+ijzuiiVdQAhGtlP+CA8ibyAQEASw5Msk05B+cjU7u9e2uKem9557CXFZE4VzmCEWN9hESBcwlJY6tfQgsUHn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206173; c=relaxed/simple; bh=Gs30pldD4IYhwgM9Z2RPF0lE51iD4CooDjoR4sEXvh0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dgi0JSBS22l6WyWA00jTl/mselFxvxGgSVMq6icGrEHLtaW6wgECQGF6y0xxlVtZeHexOgeBq5NznCVaXhPvqv3hQIdrE5aDGNudzxyMCwZgmPyV63ib7LSjQBEAx3dEHUbSTgnSWEd8ob9nosmSd/+XU8i8wiFoWlsfHxFkNEw= 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=XQ15/Q1X; arc=none smtp.client-ip=209.85.128.173 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="XQ15/Q1X" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-62027fcf9b1so21929457b3.0 for ; Fri, 31 May 2024 18:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717206169; x=1717810969; 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=8Z9GdxrPO2MLCd8f731wHDlufWSwkyCPNseSHb6h3wQ=; b=XQ15/Q1XETdGOTRLWhBTT3gErcVCeO0uprAAVCdu9YptwBW9E4SMhhg5H0RaJoLh1f 6/v7f6XrurPJGgL6kJDcPJLKhY9IbbUEIgpe+uJb88cwcweR3/JIJOLCVA/HHPFcnhYc gFNIj0uV7OWHxaT2utpa0gYWNRfd3i5G7CvDWX6RBe0Y8m2KDBWhVa1jNbd/6hiXxWjj E8uEUk1645Zwv1sHPhuUcE+O+xaijnVYoBGqoiTsuDnKlrC2+YMwtmsOIxFLeEXCQuBO 8liIhGRJNiJXL5zMEdbkrgVI+KFvAyMpLxE4sgvHCEwQRNrTpR8t9n8442O6m+3oQEot 1psQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717206169; x=1717810969; 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=8Z9GdxrPO2MLCd8f731wHDlufWSwkyCPNseSHb6h3wQ=; b=FUY64fcJRaDX5taPKBmW5dZxhpA4gixASDSkDZQxWZIVFLMV/uqWjhl3xT/Fl047AW leL2VulEjUadTeM+Z/zxyneW+2uJrHEGuFWynbrw3uk88g327GO4/ac7dUKOQav5b5NU GoFmJLbMiGWgx3JVG945WcTQy88w6ii1zu1dy8jDRNier3Gt84N7pkGbS5CKg4UI6NzV v2OoM3BYm7DZbKQDS6wXQEASmdGuucwzcuSR7wd2vt47wGH727nYddtttPZGH4j+I4ET WzL3rDILaO57nTwu50CMCdNLSQ+/nqf0pR5fkJ27IhqOupheytZRefHbdD3l20Nkx2lr z/ZA== X-Gm-Message-State: AOJu0YzqRmCsoc+yqtLwDt8gDGftip5zlzY0HkUBM+dkdUC6ll5eLzg0 YA443JBWYB7HnFa1fWhzQdZx3D7TVvTv5bOEpZyMO5rPepit6expT1OQ+pXBRctYok8yvzQF+d2 PcPA= X-Google-Smtp-Source: AGHT+IG/p7TPTItF3rbnoq/hG8AoVbSWCKhcw+n9wi696EyChGLv7ahUjI/js3/etNq+svJTYAOu4w== X-Received: by 2002:a05:690c:d17:b0:61b:e694:2225 with SMTP id 00721157ae682-62c6cc6ba10mr53472687b3.5.1717206169542; Fri, 31 May 2024 18:42:49 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-62c766c8db1sm5386287b3.138.2024.05.31.18.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:42:48 -0700 (PDT) Date: Fri, 31 May 2024 18:42:46 -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 2/7] net: introduce sk_skb_reason_drop function Message-ID: <0cb76a7cc4fc9967ea901d5cb638d8c0e118e7bd.1717206060.git.yan@cloudflare.com> 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 X-Patchwork-State: RFC Long used destructors kfree_skb and kfree_skb_reason do not pass receiving socket to packet drop tracepoints trace_kfree_skb. This makes it hard to track packet drops of a certain netns (container) or a socket (user application). The naming of these destructors are also not consistent with most sk/skb operating functions, i.e. functions named "sk_xxx" or "skb_xxx". Introduce a new functions sk_skb_reason_drop as drop-in replacement for kfree_skb_reason on local receiving path. Callers can now pass receiving sockets to the tracepoints. kfree_skb and kfree_skb_reason are still usable but they are now just inline helpers that call sk_skb_reason_drop. Note it is not feasible to do the same to consume_skb. Packets not dropped can flow through multiple receive handlers, and have multiple receiving sockets. Leave it untouched for now. Suggested-by: Eric Dumazet Signed-off-by: Yan Zhai --- v1->v2: changes function names to be more consistent with common sk/skb operations --- include/linux/skbuff.h | 10 ++++++++-- net/core/skbuff.c | 22 ++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index fe7d8dbef77e..c479a2515a62 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1251,8 +1251,14 @@ static inline bool skb_data_unref(const struct sk_buff *skb, return true; } -void __fix_address -kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason); +void __fix_address sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb, + enum skb_drop_reason reason); + +static inline void +kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) +{ + sk_skb_reason_drop(NULL, skb, reason); +} /** * kfree_skb - free an sk_buff with 'NOT_SPECIFIED' reason diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 2854afdd713f..9def11fe42c4 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1190,7 +1190,8 @@ void __kfree_skb(struct sk_buff *skb) EXPORT_SYMBOL(__kfree_skb); static __always_inline -bool __kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) +bool __sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb, + enum skb_drop_reason reason) { if (unlikely(!skb_unref(skb))) return false; @@ -1203,26 +1204,27 @@ bool __kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) if (reason == SKB_CONSUMED) trace_consume_skb(skb, __builtin_return_address(0)); else - trace_kfree_skb(skb, __builtin_return_address(0), reason, NULL); + trace_kfree_skb(skb, __builtin_return_address(0), reason, sk); return true; } /** - * kfree_skb_reason - free an sk_buff with special reason + * sk_skb_reason_drop - free an sk_buff with special reason + * @sk: the socket to receive @skb, or NULL if not applicable * @skb: buffer to free * @reason: reason why this skb is dropped * - * Drop a reference to the buffer and free it if the usage count has - * hit zero. Meanwhile, pass the drop reason to 'kfree_skb' - * tracepoint. + * Drop a reference to the buffer and free it if the usage count has hit + * zero. Meanwhile, pass the receiving socket and drop reason to + * 'kfree_skb' tracepoint. */ void __fix_address -kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) +sk_skb_reason_drop(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason reason) { - if (__kfree_skb_reason(skb, reason)) + if (__sk_skb_reason_drop(sk, skb, reason)) __kfree_skb(skb); } -EXPORT_SYMBOL(kfree_skb_reason); +EXPORT_SYMBOL(sk_skb_reason_drop); #define KFREE_SKB_BULK_SIZE 16 @@ -1261,7 +1263,7 @@ kfree_skb_list_reason(struct sk_buff *segs, enum skb_drop_reason reason) while (segs) { struct sk_buff *next = segs->next; - if (__kfree_skb_reason(segs, reason)) { + if (__sk_skb_reason_drop(NULL, segs, reason)) { skb_poison_list(segs); kfree_skb_add_bulk(segs, &sa, reason); } From patchwork Sat Jun 1 01:42:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13682297 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.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 4C1C514287 for ; Sat, 1 Jun 2024 01:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206175; cv=none; b=J0kLrdZxVbgugQbvuiCduLjS/97Qrio+wYRRNBUF7o7Ucw7pwtgxYY0e8hQsAdfpWNIfXuWBg4+Iit5wAgLBbF5TEGLv7AzF/AoW3ingvbqYP3JUzW2wWgDDtZR6mxwy/yOJXS3o64tn3/nlw6AWR2wk3lo1mwGR+Fx0SfTqHcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206175; c=relaxed/simple; bh=jkzjDY7vnEB8DqdbcGuw7ABHpoGpOOOicO2KkYgqYYM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XeXD749pArD8PZ/4BxHkjtXb7jOOCIrypIWbfsIak00NIvKhX3sBwsfnSOoe6RSiIAq6nuhcqvlCrVnUfi0d8OH16O6/LIEGrTdHZgMW8OkEhf+nLV1eGP/wGT1HEeSPbiZsDQo6U8ys9R7EUFWzFTMJs4ivzFKK4vipCk0tx2U= 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=P6BCgOqj; arc=none smtp.client-ip=209.85.128.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="P6BCgOqj" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-62a08092c4dso25275967b3.0 for ; Fri, 31 May 2024 18:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717206172; x=1717810972; 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=ZokBvFXzTLhgVv1PaHNF9XfQX0m9YCf5c4LTRhvqEjE=; b=P6BCgOqjCwEYkeAdeHdpygNBK/qpkaaRTAoG3Srt734tzOsdCer3T7xSEb8QjSZy+2 DCoioOQojDkxUysL/G2PvHNUmDcM9YU0jKUERh8K1jpIt9kQeOALk4V4WaR4rY09speE G8eYlu48+epL/jS9HWmK4Mwy3V/c8H1IUyxUa4QZPFozfnxFTRt+JOAoG+omCPo7jKvf SXG8vFVQNcv+v827gegNe/z6fkWaphPaYenKBwVSr2bdW9LD4MAnTwdcTLbZz/MJ6Q02 RaQWwT3nLZUhqYff2Rgqi9BlDjPOep9vpDxbzDUuReLbDtM9aOyYCDlY5ngsA+6yQyre D+kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717206172; x=1717810972; 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=ZokBvFXzTLhgVv1PaHNF9XfQX0m9YCf5c4LTRhvqEjE=; b=Ba75hhym/YgRiZ26/unnew+x0qSOb5fU5tNyTWbb5eqDrRyKFp/atN4VaZLQmLy5sJ 36L5GV3/5V6yjbmPhuhQIox2DzqYyMGZ4nMbHIExWyg93lO7iwdqVS/Zm5u3L87sVQsJ V8J+S+l4dZ+/+0HIHgZ7gRavqB4j9Dj7tz4OH7e4vEFJYapyHAENuExp5RZCMGPWxmQF 3EQf1QCBmWGSwKnm21dnmcRIYWhnyFlSSkpb2rT4RZXm4guKZYbmvmG2WWPIsDLltHw6 gEpfvsjhwbh1RzhPXRqX8xyt1pSvjbroSZrpkDZuGcDgWqQLcmpehCll7zin+QmrXCec upBw== X-Gm-Message-State: AOJu0YwQU1XN239CDD+iQO2WpK+RE4V1GJBBEyTL/2EkVbrJjqL7AHcS +81PE42gPmKf0GBoCgFHXKH9A7tWPuVtGFZeaU5sM4HpFdN/qPEhK/JG3WADfQN0GE4Rqm44qcG TKsE= X-Google-Smtp-Source: AGHT+IHxVHyrr3VrYHe1OY427vM5xOxlLkkCH+3te1HypqOSqMSXO5Gncg6Y43GhkUSd/fqXGDmlUw== X-Received: by 2002:a81:e302:0:b0:61a:cd65:3010 with SMTP id 00721157ae682-62c7971cf21mr35315987b3.30.1717206172275; Fri, 31 May 2024 18:42:52 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-62c765b8c28sm5377187b3.28.2024.05.31.18.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:42:51 -0700 (PDT) Date: Fri, 31 May 2024 18:42:49 -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 3/7] ping: use sk_skb_reason_drop to free rx packets Message-ID: <71a5ce50c3a2657bc9b28d5030e33bef112e74cc.1717206060.git.yan@cloudflare.com> 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 X-Patchwork-State: RFC Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving socket to the tracepoint. Signed-off-by: Yan Zhai --- net/ipv4/ping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 823306487a82..619ddc087957 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -946,7 +946,7 @@ static enum skb_drop_reason __ping_queue_rcv_skb(struct sock *sk, pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", inet_sk(sk), inet_sk(sk)->inet_num, skb); if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) { - kfree_skb_reason(skb, reason); + sk_skb_reason_drop(sk, skb, reason); pr_debug("ping_queue_rcv_skb -> failed\n"); return reason; } From patchwork Sat Jun 1 01:42:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13682298 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 C786D14287 for ; Sat, 1 Jun 2024 01:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206179; cv=none; b=QD+kjCM5GFTKJc3WJGq0thogqfz43QH5MVJ7LIMPopURiU0/MZumV/l94UnUf4Tq1fy+Db1S/GAAI4SjVwCVay39tB0+eZ8kAL4bhf2ZzJ5k9Krlh1szbNMQ7bIMENx3JpFfb7YADlXhlyyWVpl6CPsWZayukMm5muqBfsi5Cwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206179; c=relaxed/simple; bh=kSyvuVmoawm0A1229Z9cjCnSswrtkKHtT2WgaP8HoEM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oLjCtPdTnXma5CebD6GQe+r+2DNnC9BqoytSqmN3ZrrO7egIZCnz2kQrCxK7p++/oHY7TC+IeUBy3RDYjRjx/rhZyF3vhFzOQ8YrF95vRRzNKccEHxYKbTTAjoEuTW/Vpvy4v2s6u2yKBYmlJGhpbIt7gDb2iDuiLgnI00Ljo4Y= 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=YD4BtylA; arc=none smtp.client-ip=209.85.128.178 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="YD4BtylA" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-62a08b250a2so26622937b3.3 for ; Fri, 31 May 2024 18:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717206176; x=1717810976; 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=GJDm6iwovalgWz0sxMpvGD5PNxGmSKas+lavj2Qq0ow=; b=YD4BtylARo6CiEtgUKYej8A3xKc7kvOxKEg7U2CcUZeVW/+6hz6E6WEAJkuzo9hnQl Bn25RhH4kyt0BUK9NirWMskx1dcIZvxAmB+iiime/jhO4R2ibp1nWjNsb9xu2R3niQRo v4OnhKU3uzkd9vasOojq8uwWvXB5PHwx2LQiIcMdrkf30TunowZoeJe2c746vO08gagK /38xK/4ya0qqXp4DSd7vYVSGKgGHzDoZ8E+Dzv8HRQKpbY4fXjRsWj/qRxgD5TSZfMZ8 yxUbC0oOV3nifgyUtsVJZHJ+9RW9LksglHg63o83I0M1r4vymnprh/+E091i3PIkVLOP wPNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717206176; x=1717810976; 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=GJDm6iwovalgWz0sxMpvGD5PNxGmSKas+lavj2Qq0ow=; b=gedX/9moBGIJkaO2dAx/siuiTfZCxhdxm6Xw0xwr3ApG5PCmc3AtJYq6y4Wl3/edDz rhwkG1zCab2R60y9vByoPfk2ETW0qYwQ7Io6U8uNYhKDFqd2ODDD/QUwEvd4g6tQ9++U sXucSqaFQTIgpjDY9YsJ539vvJgTK+TuBlv/N8wM4LAXq3bf/qJnjreLeiDVIeDOTD7+ beD+AqaS8xHX03PgtOGCJBcidqGTvJfU/V0WVLJ0pRFhTPBnojOkALaXak/XIxf7OJPh +d+fekulwT7OeH2CNcXJr8PVHPy7QtATq9Q7pSrO0WoTFv8fXTyT+gVyWVxChPn5sAby UqRw== X-Gm-Message-State: AOJu0YyXb+acPyqMGA9kvR8HVXQhNdSWthXDOKvFjm7WtqBwa4/3sSLp Txjka7aczu3FH2LDyfc/vUJIX4UplXWc+xxa+PSJVps1nQ2uKJkR1pd/6NaaeI9isQQfnFQF3cQ W4aI= X-Google-Smtp-Source: AGHT+IH/j2vzJwaTlUPRMs2EMQDMQa6P7RZLullnU/Y5B7uu39vSuoijNLKOBF04J9MmRcLjvexeoQ== X-Received: by 2002:a81:ce03:0:b0:618:8e76:af45 with SMTP id 00721157ae682-62c797ef694mr32229037b3.52.1717206174989; Fri, 31 May 2024 18:42:54 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-62c765e6efesm5424497b3.42.2024.05.31.18.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:42:54 -0700 (PDT) Date: Fri, 31 May 2024 18:42:52 -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 4/7] net: raw: use sk_skb_reason_drop to free rx packets Message-ID: <0ecd499cd2e43560f22997b3aed0b72eb585dd7a.1717206060.git.yan@cloudflare.com> 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 X-Patchwork-State: RFC Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving socket to the tracepoint. Signed-off-by: Yan Zhai --- net/ipv4/raw.c | 4 ++-- net/ipv6/raw.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 1a0953650356..474dfd263c8b 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -301,7 +301,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb) ipv4_pktinfo_prepare(sk, skb, true); if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) { - kfree_skb_reason(skb, reason); + sk_skb_reason_drop(sk, skb, reason); return NET_RX_DROP; } @@ -312,7 +312,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb) { if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { atomic_inc(&sk->sk_drops); - kfree_skb_reason(skb, SKB_DROP_REASON_XFRM_POLICY); + sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_XFRM_POLICY); return NET_RX_DROP; } nf_reset_ct(skb); diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index f838366e8256..608fa9d05b55 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -362,14 +362,14 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb) if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) && skb_checksum_complete(skb)) { atomic_inc(&sk->sk_drops); - kfree_skb_reason(skb, SKB_DROP_REASON_SKB_CSUM); + sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_SKB_CSUM); return NET_RX_DROP; } /* Charge it to the socket. */ skb_dst_drop(skb); if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) { - kfree_skb_reason(skb, reason); + sk_skb_reason_drop(sk, skb, reason); return NET_RX_DROP; } @@ -390,7 +390,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb) if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { atomic_inc(&sk->sk_drops); - kfree_skb_reason(skb, SKB_DROP_REASON_XFRM_POLICY); + sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_XFRM_POLICY); return NET_RX_DROP; } nf_reset_ct(skb); @@ -415,7 +415,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb) if (inet_test_bit(HDRINCL, sk)) { if (skb_checksum_complete(skb)) { atomic_inc(&sk->sk_drops); - kfree_skb_reason(skb, SKB_DROP_REASON_SKB_CSUM); + sk_skb_reason_drop(sk, skb, SKB_DROP_REASON_SKB_CSUM); return NET_RX_DROP; } } From patchwork Sat Jun 1 01:42:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13682299 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 7B0B01B5A4 for ; Sat, 1 Jun 2024 01:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206180; cv=none; b=eTIa7RlP507wtTAYCY4H72BVfrGkjyXkp0h7ZRnZbN2ekI77YNjyfPsJX5YZzpTGC9W9ghkF5qhTa7sypsaq0BaHzUxhmoHx63VCa4nRem0zB6c+VBt95ZTgQ0NR91K+vQjsHT9qA95MqALlVgAoBp4KNwGdFpPscZCpicXgD30= 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.128.181 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="Xv0WToc1" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-627ea4e0becso25694887b3.0 for ; Fri, 31 May 2024 18:42:59 -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=ugpAprJniTAlBOAum5XQsEgo/4QVEg3WtUZsIxVNygVE5e24kuuf9y2nXCf2mDmtDe WeYI1XjTLTyY2E/aFeTc9TgPtjaYz9p++pP6p4lIr4bsa/yIJVkkWac9blaqFc5SXqVs R8yKvl3CW9R1cnQJtluhTdbWBpo0rr5H4F1fzSW3BuiClk9z3NIOenmPDZpxldZpH1Mm zADoFf8faLCKQdiGPyvEg18eCdrZlUOhA/zgudlQVbZGRtog16MkZtKnvhuhQL3snuTJ /zIW3yAWkKiKbk/APSHtPdGKJOElLxq9Xgj8XLlJkL34X3oK3liiMJDu3LDay3x3GQoU yfwA== X-Gm-Message-State: AOJu0Yzv7YgN/Rjdi1j3E6rargVI/TR1d9tEtM6cDEY+QnW0q5G8Rivy t4spDAZpO8/zhZb+lpz2KCEbS/ncn6BtpRP+8oUdxJM0jSbWugoQEsw8I9HeXv4hyk1kz8jZ6pk /qk0= X-Google-Smtp-Source: AGHT+IHFKpM9VUj5fPdAjZri6ASqCbW12U8KkE2PQMXK9hGY4p9KtRo4Ib8XzSacGGYo3hFMh5BQkg== 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: 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 X-Patchwork-State: RFC 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: From patchwork Sat Jun 1 01:42:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13682300 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 0479221362 for ; Sat, 1 Jun 2024 01:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206184; cv=none; b=HOvpi5UP7cN6YXkr/NH6U7kWJ1JsiwoLMb4DWvfWvV0fEo3n1RBIKPJwbdS1yRSOXLyNjwVO62nPleAxpYYijWdriCqTmPEdl4x8La0EaEbxRHvcg67yBqFCBXngr1M88g+pGlVENVap0/XlWRVPuyRu9OovpJolEqTIS6ey3QI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206184; c=relaxed/simple; bh=8vUlbvEH7gTZvH1D61OBJNrvJ28CeUyHOjmFolkGer4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s5DnyJ1GRk4AWha6VVIwMONBbw+JVyBn4DjQ0xrj0JBwFDIC9JEUweQONwlg/wfTonq9iYyjbO/dyXAC3d32arP3yGjeNrvGM2w+P9aFzrVi9bOPaqXtu6O/X/V7bIAOnZYpKJUFBeid7/6ChAR9NxMa7P/dcbmxgIRvVGJj54U= 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=RILy/egF; arc=none smtp.client-ip=209.85.128.175 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="RILy/egF" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-62a2424ed01so27975757b3.1 for ; Fri, 31 May 2024 18:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717206181; x=1717810981; 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=y2xdFUxWobdQwEfx7YLKH85Utfki6HaKV/+RpyucODI=; b=RILy/egFZdUJ5NO8K+QHWKFHGDB9ns+IJtwcOqMfJCHojQo8GWz6eereq+V3ZdX7n/ VzyJ1nkcFK37h085zjQomjfjsnchbiREb2IknrJMRwHcctmrbbk7rYwV78yO9QcF+Gf9 /LK8Ap9Pl4eCthhlRVdrbrH2tBT9njfgJYePH5Yr6frADthoxyW13zUFL7Xkd0rsoNEg cibX84nrINkVH1JYpeJLuNKN3XVgYWm9kHZjxXsywhImWa94zRBiwkCMMCmf2hbzmvS5 w04hC3eB3QeHWL6ODMD00ltPOwrnuivceOsPXHQ93LO9ullid1CAY7uik0T0UM3rF2vg Pu4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717206181; x=1717810981; 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=y2xdFUxWobdQwEfx7YLKH85Utfki6HaKV/+RpyucODI=; b=i9uqxO8+urbT8JsCMlUEApmRnl0xappgZrusKi/fVLSCW5bqoTTYWBFrAK5iv7x8sI cWr0TWtan9C4/x5WEKH77YBZH8jV2R0+r7ZLqkjHnkkGioM6+MkDOv9nLG4aJ7Bl0aK/ ZssWJ7LepAExR4aCKpW89wLiPZisJXk+Hy6Ti8V0U4flu2uxX75IZ2vjsH72iI/QSNzl DJRV4hnLeBiXHVLcVrl2B++L2O4vXXOk9rvzSQ1p7jxSRIp3D/Fobi+DtvEsImxm2n7l G2Qw+pwcdBSfPqjCJ9sKw+pNBdRW1R3PVZKMFkAh20CA5GYkiaEsypV2NrAhlf6dWhXc r47w== X-Gm-Message-State: AOJu0YzdvPir075fCvXMURX1EQxpcvDMpC49xJ7W+u2Fe5IHjVAdjEl4 evRforqA2KOkAwn884JHYwcQE2TjFELRZJDka9rYjQC2vmsq/yMMszcTiFFe5At8SKvaFh+e9x5 gO8I= X-Google-Smtp-Source: AGHT+IEjR0Ljn4HhOxXhAh7n33Q2xIPS6LzvX1WnMQFcShl7OzOwraUD/JRB815GeeImrjbnCz0LRg== X-Received: by 2002:a0d:cb81:0:b0:622:cc0d:62c3 with SMTP id 00721157ae682-62c7971cbcemr36155437b3.28.1717206180717; Fri, 31 May 2024 18:43:00 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-62c7667cad3sm5394697b3.87.2024.05.31.18.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:43:00 -0700 (PDT) Date: Fri, 31 May 2024 18:42:58 -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 6/7] udp: use sk_skb_reason_drop to free rx packets Message-ID: <76cb47137dc232e88a0707d1d863749c5f35ec89.1717206060.git.yan@cloudflare.com> 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 X-Patchwork-State: RFC Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving socket to the tracepoint. Signed-off-by: Yan Zhai --- net/ipv4/udp.c | 10 +++++----- net/ipv6/udp.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 189c9113fe9a..ecafb1695999 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2074,7 +2074,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) } UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); trace_udp_fail_queue_rcv_skb(rc, sk, skb); - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return -1; } @@ -2196,7 +2196,7 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) drop: __UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); atomic_inc(&sk->sk_drops); - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return -1; } @@ -2383,7 +2383,7 @@ static int udp_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb, int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, int proto) { - struct sock *sk; + struct sock *sk = NULL; struct udphdr *uh; unsigned short ulen; struct rtable *rt = skb_rtable(skb); @@ -2460,7 +2460,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, * Hmm. We got an UDP packet to a port to which we * don't wanna listen. Ignore it. */ - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return 0; short_packet: @@ -2485,7 +2485,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, __UDP_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE); drop: __UDP_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return 0; } diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index c81a07ac0463..b56f0b9f4307 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -673,7 +673,7 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) } UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); trace_udp_fail_queue_rcv_skb(rc, sk, skb); - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return -1; } @@ -776,7 +776,7 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) drop: __UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); atomic_inc(&sk->sk_drops); - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return -1; } @@ -940,8 +940,8 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED; const struct in6_addr *saddr, *daddr; struct net *net = dev_net(skb->dev); + struct sock *sk = NULL; struct udphdr *uh; - struct sock *sk; bool refcounted; u32 ulen = 0; @@ -1033,7 +1033,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, __UDP6_INC_STATS(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE); icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0); - kfree_skb_reason(skb, reason); + sk_skb_reason_drop(sk, skb, reason); return 0; short_packet: @@ -1054,7 +1054,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, __UDP6_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE); discard: __UDP6_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); - kfree_skb_reason(skb, reason); + sk_skb_reason_drop(sk, skb, reason); return 0; } From patchwork Sat Jun 1 01:43:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13682301 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 0CF102773C for ; Sat, 1 Jun 2024 01:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206187; cv=none; b=M2MuqOygk7G+Bb04Yigq2tylyxM1OsSY3ZZzV99zNwhUBzgLm2xy5VNC2TRlLnC9w3XTMbGaEFygF1eWvbaBo7fWimia8dZ0Pk05VUCeQlFWVTe6rNu6s6Gyo+SnMJxe4tx9cvFGNwtsiAmRjUlusBPWy1/HCFnBYCHgv6NjkbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206187; c=relaxed/simple; bh=S72Ki5HHkpC2an6q78XTrK7f5rHLvP6MDa6qVibaFlc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IVinm6YY7471b3wLmkabdSCaRNYLsExF1iGbeMkGibH3W0QN95255GCb9DM1AnqnCXy8J06uPp5eOOkNWvCcASAs7JyRi1uLIA9OFCR/FQEP2iMg36Zuj6oRSpxdCulCV+O478goOxYjygk9HZO9JGXOpNKLkwM5bMrx5r/w4sM= 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=Nqtbt4To; arc=none smtp.client-ip=209.85.128.175 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="Nqtbt4To" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-62a0849f8e5so25307167b3.2 for ; Fri, 31 May 2024 18:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717206184; x=1717810984; 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=D/La4XSUTmNeuu9YRTxpONiBsYW4Mtyght862Rg0qE8=; b=Nqtbt4To/8w3O533vKLdhzuG6bV8QHLsQcNSVonu1qpDl5SgF/4KYfk29909tebBhi WVxQBeiOpIj4hSnG4N3SbvbvAP09w43N2AA4msyptg1qlsnL3X8bG4BXiwmNPX9+Wi27 OUoiiwavqaF0wLRjpXWp2t7cMbielEuSFKVwS859mtQ7VSCjJ0+NC0k3rLlpy/xifv8k vMzETkn8EPC06xlFzAmorGs0zsZ4nyD/V0xPaq8tmHX/YUsye/PteJfGctczQougjzbu PiGyMPt5FzR5UQ420aqx4rlCvIOFZmoaSD8/SuyzTqu/8pkQc0SSvUmZhbVSKa9L5EMT /bOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717206184; x=1717810984; 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=D/La4XSUTmNeuu9YRTxpONiBsYW4Mtyght862Rg0qE8=; b=sF52myZaTKwIoPkODeDZzKY1Jk3P2nQI6Q2dtt7kDad9B0n7CjxA1BgQYi5lXagT3g phZZb+Pzz3EBu1rbc7RMRMhh+Au4cOX27Bk8PxpjsLZKKJkGEdJfDBoxQJutOeEWjziO GoxGVfPP7fGkViw/56FBUF/B40tc32034ELx583/+FjPGUikB9WpzjOsv89fWBILZiCT 2E8SUqYzcsb0XPZC+PzDMr62y3AHqj2A1BtiAuBAMMpOJYuu9bsxTx7GhedQL+G5ldo5 XVjdOBxxD7bTsy21/UoHATJqfyfaPDQe5kkU9QgSYQuFAh6NAVkJwmmZLtTMPbU4Q9wc 0Onw== X-Gm-Message-State: AOJu0YxMiX2hLEGbpebSqkFZcXDr4aTgM+KMTR/DI2ydTjXAsE4jJPve Zj0TbuJAIDvU27iZw9DpB5l8bUVGlVD4Lfrjndb7DD5FoHS4UKTcSLNQe2dRVDtXZiQVpZanERt dC0s= X-Google-Smtp-Source: AGHT+IEua05S7PDRoCJza0EQl0jMFsfegyLK1tQ6xf+usXIX97QNBaJMtekX4NLQSbhGYbhg72SnZg== X-Received: by 2002:a81:4520:0:b0:61b:3364:32db with SMTP id 00721157ae682-62c797fac84mr38162817b3.36.1717206183488; Fri, 31 May 2024 18:43:03 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-62c7667dc7esm5397227b3.81.2024.05.31.18.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:43:02 -0700 (PDT) Date: Fri, 31 May 2024 18:43:00 -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 7/7] af_packet: 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 X-Patchwork-State: RFC Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving socket to the tracepoint. Signed-off-by: Yan Zhai --- net/packet/af_packet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index fce390887591..3133d4eb4a1b 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2226,7 +2226,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, skb->len = skb_len; } drop: - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return 0; } @@ -2494,7 +2494,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, skb->len = skb_len; } drop: - kfree_skb_reason(skb, drop_reason); + sk_skb_reason_drop(sk, skb, drop_reason); return 0; drop_n_account: @@ -2503,7 +2503,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, drop_reason = SKB_DROP_REASON_PACKET_SOCK_ERROR; sk->sk_data_ready(sk); - kfree_skb_reason(copy_skb, drop_reason); + sk_skb_reason_drop(sk, copy_skb, drop_reason); goto drop_n_restore; }