From patchwork Tue Jun 4 21:47:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13685874 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (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 476E614D280 for ; Tue, 4 Jun 2024 21:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537664; cv=none; b=kYI2KOSQYGkFDZBYY+ZI+sF4u4OnZEB7SSZN/tARp6Hx4zVpv+FST3bKxU9EP0gzjV/oMtEFGo85/YFRv0JmVpcDw7o6dYCEbynhl70nbziLlSKk0krx4HskESwfcQorZexjxsPVSB6Y7KTT3Q57g7e9XZGr3LYAkYlD2P94Z50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537664; c=relaxed/simple; bh=veQ5oIfiTUvENwX+KQoiXEtvqEcqUv4Rq16hqY4Km9E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kA1qeT5FmVu2x4vYCWgNOGvqv1a+DKcuwJciHd5XWiCYKSo3ZtWp2524POdMLbSSW5moy0z48bs3r/b0Kl1PtvsVo90AzyYFSJncdxVpY2LDnr0ZzJrBhJKCQmtCr3psQXNnRTy4fBWqqBT1hDOzsMMTwgid5m62jvGALwBoook= 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=HbNJ9QXT; arc=none smtp.client-ip=209.85.219.41 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="HbNJ9QXT" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-6ae84d171fcso26922326d6.2 for ; Tue, 04 Jun 2024 14:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717537662; x=1718142462; 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=Xi5+LcSX/bATxH1bP5/g0ND+UBH3qoQYjHtyB8LNLkE=; b=HbNJ9QXTw1kP/iOYD/zVm27UI2YfJa2P2I9CwiY9+fGhe0BRJQXUyHSqSkEWkgbVD5 7bgNgnCuKuwf3xfPF5ywp5g2W8XOP1i7h40xq29lmmVBx4uxe/4a/1kSYf//ow8bSlrI 6gGLUaXhyKjkEANT9bfLVKsqjw9cCkRA13VHbZoa1QaS5/AtgbblxuVDOTkwJi7WQ1tw TisbUTPQ5HUHRvGXhUr+hf3YpYEd9RN0UKXjfEqn6he72A9vEWxr8kUX29DXOFxJF8Ys ybHwB+ai9F/QshoS7P2osYz6J7UjGUgUsxSGLD8cdech1l940PLmjoh443EIfWO0wff2 oysQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717537662; x=1718142462; 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=Xi5+LcSX/bATxH1bP5/g0ND+UBH3qoQYjHtyB8LNLkE=; b=hYD24rvPJFFB7HOPbDQdKH1MqDcAThdehHT/T3k7eldBdvsOA3reIgC+c2fougmbiL Lc3m0wFyCHbPKFhgzSkvF7FIDdJHmzkH71k7LFIV2wsY1G/8XfoauMKjAAfTDGHqknSF 0e6us59K3Lf5PHIrUlnv8PFCRJm80MeV5iILWQX5WfSEPm5xLCxg9aJMiAvvjJbNgrWN Oc4Edle28/zumd553wLV4LPf/rZtku5AH7l34cMvsSqHBZztKOmTv4LqnTJnoBGmfoYH ABVTjtwGby7+fvjPtAQL2diADkSQNCtckRv86YZCmicOpCncii+tTpe0eYfnqTO2CgyL vwqQ== X-Gm-Message-State: AOJu0YyRcccawisQDa10p+M+xVl9q9EI3TUVhPQswTQ1gXNoJ0uk5Yvd NG34rrbMowiFLW0WXAIXvQfEAbrOyxhhyssTP9ZsqWbl++VTeYzXnq0KYQCrkzWwvPw2ldBJKtf bGPE= X-Google-Smtp-Source: AGHT+IGCqyUWLOmLdxsaYYhKUdgkQw3I4w6PUaZPCC47ZQJ4/1mMkcgZLWaDyGJ5cfuUWXcsXf9IPw== X-Received: by 2002:a05:6214:440b:b0:6af:c491:8cfe with SMTP id 6a1803df08f44-6b030a76552mr5722376d6.45.1717537661766; Tue, 04 Jun 2024 14:47:41 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6af5576960bsm28947326d6.3.2024.06.04.14.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:47:41 -0700 (PDT) Date: Tue, 4 Jun 2024 14:47:38 -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: [RFC v3 net-next 1/7] net: add rx_sk to trace_kfree_skb Message-ID: <983c54f98746bd42d778b99840435d0a93963cb3.1717529533.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 --- v2->v3: fixed drop_monitor function prototype --- include/trace/events/skb.h | 11 +++++++---- net/core/dev.c | 2 +- net/core/drop_monitor.c | 9 ++++++--- net/core/skbuff.c | 2 +- 4 files changed, 15 insertions(+), 9 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/drop_monitor.c b/net/core/drop_monitor.c index 430ed18f8584..2e0ae3328232 100644 --- a/net/core/drop_monitor.c +++ b/net/core/drop_monitor.c @@ -109,7 +109,8 @@ static u32 net_dm_queue_len = 1000; struct net_dm_alert_ops { void (*kfree_skb_probe)(void *ignore, struct sk_buff *skb, void *location, - enum skb_drop_reason reason); + enum skb_drop_reason reason, + struct sock *rx_sk); void (*napi_poll_probe)(void *ignore, struct napi_struct *napi, int work, int budget); void (*work_item_func)(struct work_struct *work); @@ -264,7 +265,8 @@ static void trace_drop_common(struct sk_buff *skb, void *location) static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb, void *location, - enum skb_drop_reason reason) + enum skb_drop_reason reason, + struct sock *rx_sk) { trace_drop_common(skb, location); } @@ -491,7 +493,8 @@ static const struct net_dm_alert_ops net_dm_alert_summary_ops = { static void net_dm_packet_trace_kfree_skb_hit(void *ignore, struct sk_buff *skb, void *location, - enum skb_drop_reason reason) + enum skb_drop_reason reason, + struct sock *rx_sk) { ktime_t tstamp = ktime_get_real(); struct per_cpu_dm_data *data; 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 Tue Jun 4 21:47:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13685875 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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 8968E14D43E for ; Tue, 4 Jun 2024 21:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537669; cv=none; b=TiK5zzEWyt1ehF6e6XGZAKBG2ahqJdUPGZYEPrkbZalTy/YGTPtJoheaOcaUCkORBsuXP2j7T9iKGJJAf62RNZf7PWoSd35HGU1SQl9lSKJqLJlNLaGs0wpuxLme6h/1oBXxfJ3hGFKtg+XLymox/MUx4HqRrlpWgHXlKFcp784= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537669; c=relaxed/simple; bh=Gs30pldD4IYhwgM9Z2RPF0lE51iD4CooDjoR4sEXvh0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QWDZ2RT+7XSUXHQdvzwgYhQMwtN9zmlzhu2QX5MkJAH/wU4wq9dvdLIrgZ8ovcN2rrEcMzdSfvAaMYDXfn1mMPlIXiXE2K+1B3uQKdrFUieRAmVKIp1/ziZYw/Q2najiDVzhS1lh5oGOL9by7/SwR/3rZkTLy+KltogyJ0soD6k= 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=VBZv5Nkc; arc=none smtp.client-ip=209.85.219.51 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="VBZv5Nkc" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6af27d0c9f8so19616076d6.2 for ; Tue, 04 Jun 2024 14:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717537665; x=1718142465; 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=VBZv5Nkc+jzD+6LJXbyKqEoUTOBdAphLvrGEU0Q+0jjmv6XL+72aBZXLQqLFY44gOO xN3A8JWRCvUsNptse5/1dipNTF7OO9ZV3h3iTHcz4hT8meHbNKRZRMrl0gbLsSppz58p HFThAJnGdamc+TkJaGBd0AZKicvuB1lo2M5keqrI+xrEiSnyE8qBN+uQkPxVK8M5FFbc N6LQAjFGZhlE0wo72YR6UX3PZnwHWYkh/93fIQhQbRT750VR7LTV41V/ZIWg1v6pKLN/ cE+i7fOTn64mgM466o4QJSGjvBvmEAZbCPxqEKYNr1t3YUOQAzH8ifuu64yFFBWiA8tU vsLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717537665; x=1718142465; 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=LqHubtUSlbbNTCFxYCZF916fPlnfrgaCYLv/OAjbRyVKfyyxBPYACWk8QkgxNP9Jl7 p8PaDkggg1BeKLfU5i6KOKwKE12SPmqY8OoaF2rTHxEHGiHaPZAYnveA3EH4HHSaa9b9 I8B5lcWc3GYizyCOWTJqfmVEG35QEXFn2pvonnOEhJ/+FhnLvCJxBizfZh5munlsTYXJ +Mqq1ADYF7cRDcFi9p9DiHgUrS5pmPIVk6Wg5x+pqJ1m6eqrWdLHyD5X31SdaZ9QNMsR 2BS8TrDY2EUrLH8YwHx/wJkbah2FiofABQsSR9A1ibH0G5+9NX3XCQX4ibGFwZp5EqcE PW9w== X-Gm-Message-State: AOJu0YwQHWW0a3OUcogdazlMYb0EZFeYcMELh53QTeyzGhu/QkqSZ+71 BYcw65WwEWuTvqND+3TNi04tISX+UnkWWn9R4LSw1UDkGMy6IqWctE0zswj9JdTCyXfzRXqD6Xc xbuw= X-Google-Smtp-Source: AGHT+IHyvwcOi3cOWpc996/wJwpxD7ii12QfBKK0r8HKrXffexIJSRh+ZwKVYne/HV7sJfE2h5DgCA== X-Received: by 2002:a05:6214:4347:b0:6af:4a1f:de64 with SMTP id 6a1803df08f44-6b030a59138mr6247126d6.44.1717537665179; Tue, 04 Jun 2024 14:47:45 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ae4b417b0bsm42203196d6.108.2024.06.04.14.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:47:44 -0700 (PDT) Date: Tue, 4 Jun 2024 14:47:41 -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: [RFC v3 net-next 2/7] net: introduce sk_skb_reason_drop function Message-ID: <1fec17924ebc0499b1f62b2af5bda216e4de00b4.1717529533.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 Tue Jun 4 21:47:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13685876 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 09AAA14C5A5 for ; Tue, 4 Jun 2024 21:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537671; cv=none; b=jqrXvEMUmpeajyQiiJAtUF1hRJyfKvfePm8GQNtOivG/ZCD5hzKHvmUhPoHMi2gOALDxLpzA3p3qL6YWTnT82YvP2LrCiaPDbFSYqr4M88/wnkeMAxFU7GxAAlfdorbWflDqEe6NUdY1+Z1RJUkmL76SQu8b6kL3KVd+ccy9iJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537671; c=relaxed/simple; bh=jkzjDY7vnEB8DqdbcGuw7ABHpoGpOOOicO2KkYgqYYM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X1FRqkiyBAAcXhE+Zp4bM8uwanLkBomHzIfXbG8X7OzPyv8oo+z12vkVKhjqzfnye8pNR946qnNhBtSe9afGBnVkSQivjnjz8GeWuiiMBPYYDYsxBltCE3EqohWN7KCI7ClVIOmokJOAc6GUSsW6TwsULu9V3OlPFcK8Xs/0wyQ= 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=Z2PNykFB; arc=none smtp.client-ip=209.85.167.176 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="Z2PNykFB" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3d1d35cdfc6so3591352b6e.3 for ; Tue, 04 Jun 2024 14:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717537669; x=1718142469; 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=Z2PNykFBGGMHFGchjXa/OmUdra2jHDOXI+VbW5tmKPM9o748EuEl3EoT3SSTcwWMGg LJ/vJGeOGay59QynmfMC/fgz9bPdmGyR5eWWUEX0XiCGrsJ0t98gUMi8vr2mQJn6vTvX +PjLlqClYuBFDQSZReLpacJbsfNsVr1UH2C6A4BpjSNi2UBR6E9b8VCioNJNbqWhazrI qErncViwqW4Touum7ORClyMtMFDoXDV6S6UgXNC5ysH6t9iPfaJ7YXV3Vlr/Y0suZgiL x4AoGkGEItIbHOGwaU0FcPCv65EL2aGIhDpdOxYzjYZZ6pqouyVx5rq8qa2sKpx/uSiw Th8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717537669; x=1718142469; 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=Ul1mH4tjEDTawgWFswONMX0EXLWiV3fetvYYtibdag+zsxX3uqZ4x2wCND1SgnHJlP US3ZEukPOepiPVx6B4+kHVuY0Q8JQZlmtZe73x1ktNZqwtd/66Mx1F4FjyIqhNObkLj8 Ha3njtJU+5vpjugREBExDIjfphi8/ps5E6yraP2lvyROG8361BQYEqdl7Ex9zRLdFMRL rkHeEByO/alhDYMe3Y57wT84elqGLF+lvrlbxi8OF0vfwir+6ZH/HUuujtfsjs7QpfaM 3Ta9/SOoYw+1l1YoRtZgNGkJcKypYHPPtr3HE97VYSqU9JASx+Wm3RvYJ74CZ1q7ESqF UV/w== X-Gm-Message-State: AOJu0Yz/5MfSFaHYEraPtBMi94mGIuSwhYPofX2zy63n1h6/tZAGjZck Nqwfcr0g1bkUJORVxkMM/jhHXwVcy7XDfpSTq194UY7qHnT5J2Xh2mnddyO3Uz1F6F/v9mfAF8a ApHw= X-Google-Smtp-Source: AGHT+IE/CcVqEmURDm+qAHOzuZAeWRfQfnebx+xrgKlGcKR6QHmLUh+u4nT5c3F0so32M1T4yr9MCQ== X-Received: by 2002:a54:4193:0:b0:3c9:94ab:e8e8 with SMTP id 5614622812f47-3d2043a7200mr644527b6e.33.1717537668593; Tue, 04 Jun 2024 14:47:48 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ae4a73e425sm42261866d6.24.2024.06.04.14.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:47:47 -0700 (PDT) Date: Tue, 4 Jun 2024 14:47:45 -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: [RFC v3 net-next 3/7] ping: use sk_skb_reason_drop to free rx packets Message-ID: <5e4263e09e784f8b32e261a0fb8ed7056da313a5.1717529533.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 Tue Jun 4 21:47:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13685877 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 1022614E2E4 for ; Tue, 4 Jun 2024 21:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537675; cv=none; b=nATkkwkm7n+KGiQJq6qQIUbtT8Afm/xiV3r4ZI+7UI7JQl1DQruGG2AX+47NjUbQZtVoeMGukMYGE4OmoSSe35l0YOGKWFkSRN7f5Xecy+b3yNs5bz64Zp09+k3Cy8g1Fj6mOxaQGOZRE3NQ3G+0r0CzuXqXreiQb3YDexRcZWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537675; c=relaxed/simple; bh=kSyvuVmoawm0A1229Z9cjCnSswrtkKHtT2WgaP8HoEM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a6QYRWBbojPmIunGH06S32LDzQ2Uwa4qD4PiH28DdA9zOVRUAXsPLnc+5cg8DdQu+QS0biKBjbHMwP/EROQEgzB/2HAK8jsK1gmF+pV/Zh30ZXDHESrxCFck5/8oAGDJLx1IZs4rbduxvrDUX7oomZAxdnur1HFiGMZTpaB1G+s= 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=ECNOhF4D; arc=none smtp.client-ip=209.85.160.182 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="ECNOhF4D" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-44025bb945dso5448161cf.0 for ; Tue, 04 Jun 2024 14:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717537672; x=1718142472; 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=ECNOhF4DhW2ck/MgMn1GFml8XgX8b+BjYujnwEMYcKdHODY0s8cx8aSIJ1Y1K1B+wc fWxZD4GHXFcZSBH5YsyaeEbm0AmPHfFrU4LrrDgr72TrjMXcDE9YiwuNGGtXWNkDRJwg zqYbNQ6YRjdRUGYDewv2hfnYC25Id6c+SOJ1rB/aoHgUEFWOR5NMMmf6ZTeLR49z9ZjX u2IZQ3sFjhQItraejhwuuBdRMiRqnRuKg3A3P24uM9Xv21/2LWZWwiMFVFOm0QKa4Wr0 cErmXR1vL/CG0CVG5oKDxRd7y2++TrFJHbgfIPoqgEa83AeIezy9cLfX6nUlgMPDjG0o vLcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717537672; x=1718142472; 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=jpF97HqU7OOutaVdjwi7Oh2bkHd3fCNfn06TEBGBTNc0QN8NippXiPR9iNs1Anlo2M tLifMZgPjYaeUnL+mxxm7cxNCM4doi6odmV8/oJF/cRExQmSz1/JsdkEulv1HevX4XRV DWLtLe/rtfQXoksOjtHNj+SVTvzB+d6obLBJ1/j+GpaGzY7TaEkbMifcpTBG6J1EKgwZ //M0pCZTTosjH1gbpe0BOE0Xr0YbIPOQWaZBQF370OV1jUZ8dcZa+GALOX8xxuGEhpH5 xjXsoG/TSff0l3lQjrKRPqrP8nRUEl91kXX/yMIuD1cYROc0sCFmPDYD5U/4BntxuC9v s1Ng== X-Gm-Message-State: AOJu0YzMCjL5Jys34R5hQ1g3xE9Sf0p5B7ZpO4DqriWNGHsmLf3zhlhl GkeLGmHTqL+SO3BDK7taK5D2gCyrRDFinETlOm0ueDZGSaeOSKXEzUonm9PYHpcsli8XVEnaqsH 3aWI= X-Google-Smtp-Source: AGHT+IGrjmW80tkDxovgZo69Xf5PbK5esJcY0OF5LniVh0HDjzfNjOgJwHal5f9dAzBVDUlBowbAnQ== X-Received: by 2002:ac8:5dd2:0:b0:43d:f989:edbc with SMTP id d75a77b69052e-4402b670b7emr5780621cf.52.1717537672021; Tue, 04 Jun 2024 14:47:52 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4402627e268sm6946441cf.61.2024.06.04.14.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:47:51 -0700 (PDT) Date: Tue, 4 Jun 2024 14:47:48 -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: [RFC v3 net-next 4/7] net: raw: use sk_skb_reason_drop to free rx packets Message-ID: <854cb997b5407fbc4d23014d895f7cef5df724a1.1717529533.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 Tue Jun 4 21:47: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: 13685878 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.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 1990714EC55 for ; Tue, 4 Jun 2024 21:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537678; cv=none; b=LFfNN6CeBcVmsAYafL4qbxAnRUE2zN43TqGQrWn43rs4FkPfXC+aZ+GKHzBaMYCWec6vWPs2qRvFgcP71rNp5Vw0PTRR12Wz2mo+bXxldHfVu3TkmVvF2diumWQuARQQFVkd80Rys7QRO0vQaabOUZ7ZDnbXnFv0eilg8/HGHiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537678; c=relaxed/simple; bh=deJZMXGB4u9IlWilhC165qOhNKSkcsd0Cq2qS5gJdV8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dSMcwrrXKsQjCGTsiU0NV0Ew9RErHWTEAvigH1JT8N+TDLPlJuAA62VhN8rFCiwRwdql8fZKgJg4GTu1vH22PfyrQWxX+wuuoAtYFpd77qKoHcgNSIEtEPQahd2pOpgNHAeO01iyTsMzAN+Sfw5BWIaaely9mb9UL42S286w/wU= 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=Wfjeidr3; arc=none smtp.client-ip=209.85.160.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="Wfjeidr3" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-440299bcf53so2257151cf.3 for ; Tue, 04 Jun 2024 14:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717537675; x=1718142475; 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=Wfjeidr3NAdkarc/ByAXIbSjDNtXTqCZgl112d02FVLYYsAVJd4Vy9UsYQAzyOpbPh 5xaJFSnAzThc/6Sziy6n7uemevbHYaY8V9jdL4CqVMANH3B21xKTihUGlSF1HDJiuHvn CAQXMvZ1uxNUrw8spiajZX+KMHCRadFJvUK1+7eHx/GzFzBLV0i19N13E7lu1BMOwmg0 Iv0fqzZExmP8BPu+JOMj/8BU/n5h28sngx3sh4eI6ycT3uEkdnV8ZixjMgq9S31WrpZl Upp1THSjnUFxOvJsRT0KovDyjkOwOh+BjX/d/pzVIAWA3Be/tOWUmcPP4zsnS3kaVk/o TK/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717537675; x=1718142475; 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=AHk6newJTHrZnmsbwcuoVPgqfqH9KM0gL/bI7UQvVPmaRgPt8cblQhpbjujP5iqEGe dTamVRuAok8A79UHO78+7J0Xk8vuKzujUZK/Yy2vMRTOMDM7myWAg7bUeNgA4Fvn/Tcg y9yUnlkdiW0cF5Rp4wsudPrvXHxj6aG5juYzO3UzEL405PYNGugJvXnYqnFgWcKtBGRx W8oDzW+BRl55tBkFs27tAj/ZDbu1rgpzWCB3/iwIzLyKCA5jJ0dEW4ePmGkrDzsvquLc BcVLvJc5hPu47QkXpdsBObClH67sBcTJUhgVUcYY86gAkMrm0b8nfIMiV0ZsfMjEqljD 0t0Q== X-Gm-Message-State: AOJu0YzLl5JOK6py4smxPNMDVvXgqh1or9ufiPyUihYy+KDZVOt8mcvl eC2GLpy77Z7Bg6wjP6KLBFjYiqzHJT/KRXhoAGKDGIBqAACYShPXrUej6veUnIL5wrgq4TpGeJz Uj2M= X-Google-Smtp-Source: AGHT+IF6wYK2vSs0tnZLGeGleWFepuv42H+1iOxWPaTWSUI1YgoUnJSfAYdRv3oVvyAhsuPNnOPBfQ== X-Received: by 2002:a05:622a:452:b0:43e:e6e:21dd with SMTP id d75a77b69052e-4402b58ac7emr6655911cf.12.1717537675459; Tue, 04 Jun 2024 14:47:55 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43ff35dfd56sm51508081cf.21.2024.06.04.14.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:47:54 -0700 (PDT) Date: Tue, 4 Jun 2024 14:47: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 , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Neil Horman , linux-trace-kernel@vger.kernel.org, Dan Carpenter Subject: [RFC v3 net-next 5/7] tcp: use sk_skb_reason_drop to free rx packets Message-ID: <350a9309892d44cf45eff3ba84df4cfe0fa7a5b6.1717529533.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. Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202406011539.jhwBd7DX-lkp@intel.com/ Signed-off-by: Yan Zhai --- 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: From patchwork Tue Jun 4 21:47: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: 13685879 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (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 8C97614D2A4 for ; Tue, 4 Jun 2024 21:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537682; cv=none; b=cicF2v75h51iZR6mVXYBcEUbO88QPB2VE1ZmuocKc0nH8M1ADAxZBN6uOdiXb7Eh/4H0eqh0yU5xobjqFk2vUDigbSwELXYpNyFlylUVHRxVE14bM7UyUv4mf30KS3Gl0ubSNmRbA/npaI1Ml5+/m2nc5PhocurZ0WGIpzP3pFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537682; c=relaxed/simple; bh=j0ydkIBK6v7Eeei6xO8sCTgU/f0LdUJsud2ZNVHdLms=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KAWNm1uXEJjTzmgFEiCGIebCRorxgzbFevOreaZCZ+2hLGhwMOdyeM1K1IdRb4YxQlxnS/dOKf4nRKqqQlHeCgyCXkFxNHkOyELdJNswD2IH1nIINrItAtX7gv9Mtw7Rl61sxVIw3jhgxD25iZnauaRNoNJh02R64/0fljDs2Po= 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=T5X1JEct; arc=none smtp.client-ip=209.85.222.174 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="T5X1JEct" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7951da82ea7so51286685a.1 for ; Tue, 04 Jun 2024 14:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717537679; x=1718142479; 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=rAchTAFhWTofDy57Shf/o1FtCjgXoHrGCl9Vam22s+I=; b=T5X1JEctGnbiLaXWA6giLtXwC1dEPb/3azd9MjhXYd0QJ46VYdU/3dT/a/VOKXi6FZ CPgKAczY1VMPTg/wO1CAkMaybsd0DH3gw0456Gsgn/+aR1x2HXlzh/ULrFOu03B0gzPk 9wmmd0rwtZaVwWWDkG9QdEKolKKZJZPDlqx9oDR/QORbR/PH09xr08qDpOcdfVSUSRd8 aYFKrfFPjT6yAU0pNbMBJxsdjRLSfPqkgJdzcDeY+pMYiShbPty/ogRDDdrrPHMMyw+9 5yAb2e4tH6ZAji28mc0jmbG3f7PBRlAef/+5IXpYAMKRMOP+5Hz0NHm4t560W0rffnFg CTJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717537679; x=1718142479; 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=rAchTAFhWTofDy57Shf/o1FtCjgXoHrGCl9Vam22s+I=; b=ExO2WQNnco5r3DU9oNPnW6jUeQO36a3jBCQLqQR99/IyddJjsp0qltOLTs3AVfR/NL U3VcFP7wWZ+jzgXU0op7z2z7RbQBe7G8VqmbcwyapgE0XLi/gbNfNutNmXuLvq66GbFb rCJ5elQE2g328sIOzjxpQBXeJ68KOnk7bohWshNh/BoBp1r62VsffTMDkc4eYmfL1ioN XOxUYrn/XSyGwQexrVw+KAWcVU2DfChXXLaHD8h+9L+ycl4zLuwXtVjJ+ASpjzzRf2eH AiLZArGVJDibA+JTpzmwAEfFAHNsWyj4mXqNwaUQqTU8Ge3H1ARc4+I8AwCu3DcRI+Ta paPg== X-Gm-Message-State: AOJu0YwMwQ+1K3JZDEjGHdzYsa4o1+8wzpJ8su+ziDQDmuI6nHfuY0aT e4zJgiGO7fSNz4E1rNZtIq3ZlZB7UrEqsd8m8FwzIikfORK7kgZz5Q4XY8lAmmiXUMYz/bQ1Yun 02ZU= X-Google-Smtp-Source: AGHT+IHNt3jn7WJz+jPbwIdxjTdsnrRgXiY2ppLki/PsmmyW/+qrqDLmLsFiCBczM03ovu0HJirHLA== X-Received: by 2002:a05:620a:2590:b0:792:ffab:75ef with SMTP id af79cd13be357-79523d3f13cmr63560485a.5.1717537679049; Tue, 04 Jun 2024 14:47:59 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7951a69940asm70746385a.35.2024.06.04.14.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:47:58 -0700 (PDT) Date: Tue, 4 Jun 2024 14:47: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 , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Neil Horman , linux-trace-kernel@vger.kernel.org, Dan Carpenter Subject: [RFC v3 net-next 6/7] udp: use sk_skb_reason_drop to free rx packets Message-ID: <449b5d073ebc49bb1350b46c56ada8469a96f8d8.1717529533.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. Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202406011751.NpVN0sSk-lkp@intel.com/ Signed-off-by: Yan Zhai --- v2->v3: added missing report tags --- 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 Tue Jun 4 21:47:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13685880 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (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 1AE6914F12D for ; Tue, 4 Jun 2024 21:48:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537686; cv=none; b=L2b6nezZEeFE/r5yPeusIUwEsvX4BzdPQpSi3F8v2ebfrNgfdTT4xmrxwN62EmzTTv4SnHt1DO+pJSL1g06Xuo4ZmMVP9ZSjdLSy2s9Zh4pP7wcEF8Wq/EuFg3QeqMmqkWUK/bHxMuvyLyNkQV/BJs8wbNnJ4U7oKF+eU8Js84k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537686; c=relaxed/simple; bh=uEGMHEFbMp0HLSU5Z7U4ENmeA4RvQ8IslnoZTeDpYIQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qoovlly3FjatkK+zXqpbEuPgBeb1OKTkAipy4U15NJ6Bz58tM6ZWBKIbHZYguoUEsDGPWwqansAFAyw+TqnjLagpNYOk0bU/nuvkDlUwCZ165+56AGsoJvJTgFRRbV+HkfwH751KACOwIEADRpBzTAV/+Ke2ktXeWQnesTqrb1U= 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=F0YGIPaM; arc=none smtp.client-ip=209.85.219.45 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="F0YGIPaM" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6afbf9c9bc0so13763786d6.3 for ; Tue, 04 Jun 2024 14:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1717537683; x=1718142483; 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=+04wpAGrgh0quqRhPOuIE9e5b5DYf6qkerlRm6e6uUE=; b=F0YGIPaM93k2hd8gAAMatCKDnEXoBJD0/kl28LTYZPwbQgJOaSlpNPIySbvb8tpCUb LTfyQlbFJr3uE6aIYr1Fq8awtTVe6uijQlzsui4kBZKgdzbmV2zXQ+LmdQM64i4qI7zC E1OrxBwneRq1oFhNE+7MBHsf9KC3l+/cXKf05bieZUjjW2rwlpDKV/KZTL+mLc+Hvfnr nfWKopr9oWoPaGjwmQa05zEOFBPlRTBQdKIQJGYfJ+TTPS9GPr/gHQFgPMPT16o3bne9 9OwXAv3qzfYebk6ycFiBxZgAvb/5OK/+sCuX+5IEor9DyYXVn6jGR1zM5+f9EZfkKp9f nHqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717537683; x=1718142483; 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=+04wpAGrgh0quqRhPOuIE9e5b5DYf6qkerlRm6e6uUE=; b=mQ9GnsNRundlJFUKOXkAQjFHNiJahif/kxETkNfwmOHQkQI8WdizhaXF3Yla8my9jT cxIy47atnaOIXu9UkLRKY37vIQYSRSWxrQQO+phPzG1iyqFcK7/p+Pvjuqfn0enxxPIp TsWEwL27EBI9X0Ef81xnkUpf7h9Ut4lbaw1enD0B8QnaYYPhiOK7l0f7cifqEN+tfGWN evz5deqzL13rELaWuRHT47tDw2KZEHjKkaPMHl5e1/lgQyAxqT6CbYABUImes0u7xzDG k6MaqP1BMNH9Te+anM55MdAOI6JSNj+74BbTWUPVRZzILNGMMLPfw8D5GLFgBTMa3sXw m/Kg== X-Gm-Message-State: AOJu0YytZFuKN90NZWU9asnnGN+UQGTPTA4Ym9x7IN7glvxE7ZE9D9/L KSyGnO7uB9BGvPSv0DDDxw6hFiHCLTDvrdypC5sRNrR0Db0rnJmXLZDMzdU0lpHiBt7GX9+F3S0 IxWg= X-Google-Smtp-Source: AGHT+IG6/GBC9sNG+exjZROqqV20El9+yth58LdwTrthEzSlb+iKsIQbqjd2bF6oWHOLCPDaM1c5tg== X-Received: by 2002:a05:6214:3902:b0:6af:cb9f:59dc with SMTP id 6a1803df08f44-6b020320c02mr6439866d6.1.1717537683041; Tue, 04 Jun 2024 14:48:03 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f9b::18e:1c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ae4b418d5csm42118766d6.106.2024.06.04.14.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:48:01 -0700 (PDT) Date: Tue, 4 Jun 2024 14:47:59 -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: [RFC v3 net-next 7/7] af_packet: use sk_skb_reason_drop to free rx packets Message-ID: <0fa6bd81ccb75b9fe28971a895bb7a700b30b81b.1717529533.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. Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202406011859.Aacus8GV-lkp@intel.com/ Signed-off-by: Yan Zhai --- v2->v3: fixed uninitialized sk, added missing report tags. --- net/packet/af_packet.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index fce390887591..42d29b8a84fc 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2121,7 +2121,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { enum skb_drop_reason drop_reason = SKB_CONSUMED; - struct sock *sk; + struct sock *sk = NULL; struct sockaddr_ll *sll; struct packet_sock *po; u8 *skb_head = skb->data; @@ -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; } @@ -2234,7 +2234,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { enum skb_drop_reason drop_reason = SKB_CONSUMED; - struct sock *sk; + struct sock *sk = NULL; struct packet_sock *po; struct sockaddr_ll *sll; union tpacket_uhdr h; @@ -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; }