Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp390400lqb; Tue, 4 Jun 2024 14:48:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOAfdQ1RD+zNtLRyGBYcyqY8Q7LCWAgioZ1J1Dsuh2wYgj4YNDg/kxOCDPnY+Pj8qgMV5XzHAmBM+p4t5ILZ9zBsRvdrOaL4C8mqluNw== X-Google-Smtp-Source: AGHT+IGOH8A2i+KweP+CVv7PMBObW8El8NKudY4eNAAp9biTSMuXVfGABkWdP8TnREgfmON60gF3 X-Received: by 2002:a05:6358:98a7:b0:19c:2542:da2b with SMTP id e5c5f4694b2df-19c6c68a36bmr84565755d.10.1717537688468; Tue, 04 Jun 2024 14:48:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717537688; cv=pass; d=google.com; s=arc-20160816; b=WOG8IRlBHy3PSPeGu3UBV1CfCLyH9Fv1bsbJ3tfz9tnQcZFRCLKyJYvtaGSR+DcJw4 Nnp6u/h5uH1vHbb2mE5pRz7KLmEeMVP2eGSShTdiTaSS7Ojwv4ptOdAcqvLeH7VrikXk GFzjuKR6fn1Jmoeaix7ZTRHQPmgzMxUxKQxmmC47YMwygX1s2t3ukMiGffrnvkbZW9Dj bF/tKJIi8av2YortsdvBABjKh0N9QQFi9OWY5LTOfi9IB4/kHWrIs/vziJ599+wZ5jsp nIfuBf3pKFd33Qboprm6L/AT4MBD8T6R9/BgXpgidDJspJBjowxFpCoNjARYkBea/HgK A5jQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Xi5+LcSX/bATxH1bP5/g0ND+UBH3qoQYjHtyB8LNLkE=; fh=sXpaJURUAXwh0qfsDAu4g3yP3m+0x5vJ0x9vzFOKorY=; b=N0Fdqf6ttfnif6GtlwWxwmYGHfZeHqo2FYIsagqM4yKZcHkV4TCQvXsd3aYEZ6b8Hj wnE7/RL6uCqIM8B4QkkNeaLIwNvXa5N2ha7W9NycO7Sq/EzFYBJiejB20LwbWdPlVqxZ 61WrfAgyv9NRmFUPi7sZlPJahlqlb+UJsNFVnO+kh+M0tH7BIGMhMzWguMxT5BMMLmql ZomksxDDm59+xnjjRx7jI3sw0l5DKThhurnIWdD29JOJ7nCB25QsHDbqDgDvmnCDdWUj ClKPmjMhf+F9+63QSCvVy/K1pY/z7y7xcGsfYscftiufu7MvtpCPJRlzXlAPpbI/PZ3e la4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=HbNJ9QXT; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-201420-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3540fb432si1998228a12.132.2024.06.04.14.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201420-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=HbNJ9QXT; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-201420-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0EE8F286F5F for ; Tue, 4 Jun 2024 21:48:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87C4014D2BC; Tue, 4 Jun 2024 21:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="HbNJ9QXT" Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (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 F284414C5AE for ; Tue, 4 Jun 2024 21:47:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717537664; cv=none; b=f81RAL/YmAAUfQD78+O95OY+lXFe0JozY1OU9UAalSm1cG2EV/Yyp9TCu1reJy8INXo3XpC4W2J24sGy9VfIwlvllwKKhMAKc1h4pTH0vRuKBu5XhAsJJYDTidTdgRfo4dvuaUHfDdRENP/TeRzQwI9olpl7ljd5k1NGryEBp+g= 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.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6ae84d171fcso26922306d6.2 for ; Tue, 04 Jun 2024 14:47:42 -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=oZXuDlT38mnK7swAP6FbcLVqKdJhqhS7U3bJRGECsXYFezVdA3GuCZ+N3Lup7yDCUa Onw/HnjlAKAQ7tnHzGwNRP9mq+GPxV1sOfN85R93rJ2DDmmjBxZ2vWCYAsFtN5iKcBsQ x1dLz4M4LDdQkfKpZlPmRA/eyhiQB47+34EaLO8ZnHWtfjvY4tqKK+eprXCnmbCzmJpK tR3Bzkrsa9VeA1km/xDJ9YG0IE2k8jghn0ic6MngwhJaRBQn5+qyQqBxZoy9hPrgRko0 xj0C8ppqHZXgFgFpVTqg7TjWyFEWJ3Lyw/+3/BmMCP+WmZPjBeUHw8NsPHQ1GlUk0Fg6 oXxA== X-Forwarded-Encrypted: i=1; AJvYcCUo6JYtmX6MlgYZc6pprgPsoBe33S8bZ+eOpY2lDejLyBVPCY+AHzKZsJcGLAcS+Kg+GyWCPf6McpcbrNUJSWJ80TnhMmPKHwKXmRDE X-Gm-Message-State: AOJu0YxVTU3keBTZS+ztgpke9/iOnJVD5gJcwxmclZE9x17xzo2BgTCv dVVvNbBAT+B3ZW9TIjnQwcJZHux0GXz+BcxnDNYE+9hu+bTr4Ib0tDAKd20SFZA= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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; } -- 2.30.2