Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp802814lqh; Fri, 31 May 2024 18:51:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUD+QZ7pBKcqRj4K6GPm//HnpafP+OjR3/ZiFcET5aqv5X66AfzktIukCJyssumIHrEEIToADpbp0nh46S9yZPJjst+ABCejZk0BZFbxg== X-Google-Smtp-Source: AGHT+IGLR0BJqN1YQ1wQQOY8AE+5wGUKge7vO366rlqcM5SW56AucHyZgWrCpRfrJ/2VMnV0fkLq X-Received: by 2002:a05:6870:5489:b0:24f:cfbd:70ad with SMTP id 586e51a60fabf-2508b7883f0mr4168456fac.9.1717206697725; Fri, 31 May 2024 18:51:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717206697; cv=pass; d=google.com; s=arc-20160816; b=ZFcUUhmSEQLyhgXOlsIApOMmPO5RbVUyLgG9dVTwY2it3wsEEZOvjtpioKFsXNBeQ/ /YxiideKVnAF/kcDJK8tP5joodpIAoNdiQbwJnb7ljpTRxSgMSIrhbULRRg0I/8WFlkO kvA/NrkOMoHfYVLXMjcVZcAOuWc06jNPl0Et6WFxqv3rffTNAyJJUw09v21D9cJqsCIg 7LEH0jviw+4Jqd4oaKXpFIXe+FdnzPyHiQwrADX/p2m0HfOVyEEEtDFP7qz6y8mUEEpl hCQan0VJ68C8207nzrvG4RXu3Yavlq6tfL0G6ThWwfpICvJ8848RL9truazS4qvdzobP 74Tw== 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=cundJu+cYnxxw8687bE9Xl3Y+llWE0GOh77B0ua/CNI=; fh=GSZhjmOQIQGRwabtWeXdEU/FP0duS33dcfiv64j/yRc=; b=vocpAYdCqJXwzthMauwixhxAWXaV6KDrlvg/LrbprGZhpdYoWlDqGDP3+ggJxsw6+G m+PdmCzXM9Ow0gLRs0hcH8z0ET0IPsn96guIb3xTkiThLU5jIuDzMHcxfpnIlMOXjzMF fZesAA52KpgpIM5eUALLvJcs7eCmKBLFX8Amf7GAeHm984X4LdluYaWlWuPUNUy8UeF6 /dnz1f9gk0eiEcKMlHWw/vZQVKe1jYrzCWK3m86DjXhdCeh2nEs4v046R+Hheg96JWg4 1CknDiv8WiyOzAHY/ADynBlh/sew1Di7i9UWSbTr75y+F9J0CLO7m9HDFOqWIq71f4S1 4IhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=EZEulQPL; 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-197634-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197634-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35b40c704si2421934a12.434.2024.05.31.18.51.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:51:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197634-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=EZEulQPL; 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-197634-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197634-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 F37A7282253 for ; Sat, 1 Jun 2024 01:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 200DFE54C; Sat, 1 Jun 2024 01:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="EZEulQPL" Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (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 B20FC6FB6 for ; Sat, 1 Jun 2024 01:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206169; cv=none; b=OzGoZ7cg1WCFtt7Xh7AYrwl7hyOPOxw9YZgj+TgCM6kvWTXENCrn2A6wO+lkwNzv3Z9seLHlZv3q1JpTAN4RrDI7N0hSq653LUyXqsmzR0aKY8CIh2ZclrriwdMdIoeqOfeaSoNzBkIleyI9NNGbtqVaqdAiW52YFmmDdvBVTq4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206169; 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=kVcSGxeRTtvXQuxJ+apGnTSRYFqUB0cf0U+3D9K69LKYoMk6WaroGoatIJeZ2mx6zHrtuqNt8UTlnirw21D94THMMfczqHwU0CTUSWlUtGIwdssaFEbs8osip7ZeGtu66M8o4SZa/RZRTNYc4cCLZHmp/oK0kzlVfybzV5Pa6EY= 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.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-dfa79233c48so1147377276.1 for ; Fri, 31 May 2024 18:42:47 -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=X3GI2x3RQQbM42qtkKLLPjB4q2HCVwd/QqYUdMr59XTsWymkcGJ1r3evVevhmn/Qu9 Cb6U59dFITkQBIM1zaTV2nbrH4h7mf/rZTsQqiYcD2hfLohcwKMp3yvz/+IA34GOpv9d Rgn0c34y03XXT6cQUKt/diWIjYkwjuWm+nZ0REi0gMRdXv4p4w/JPJ38a0TWGGWlGkmL dNHINBE37kuZpb+0k7ShG+TYFPIJ7e2DPFS5Wm2mZyThS+Z0JXremSVAHqWZxgwukevn W84RW0nlsEaSiNGFSL/6ejO4EqiR/R5ngXCDuudPrYRU2ASFrzuFsHDH1HOfF4fBqtuk 5qUw== X-Forwarded-Encrypted: i=1; AJvYcCXnJTlgkTBpapsL5UG8xg0eSmu5LrvUnTJXky09zGfrFicKC42m6ge8XIwsPraLrLynjMHV+PyFm/4EVVWn8O52NLipc/BGhr6Wz87j X-Gm-Message-State: AOJu0Yw+x4g8QWO5KcE7fnGr4Y3Xn+4hj2zL8ne/PDkkiRjA0av5tyYQ /Csrl8R5BxkgABVz+xtvxL/oxoS/C91tEiICndiM23U2l2ptC32DUrMG6ad3DPs= 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: 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 --- 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; } -- 2.30.2