Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp802753lqh; Fri, 31 May 2024 18:51:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyvi39HsNNua252kEIQmhrZbjI+V/GJ/UXnXJYV1FasUoejn2n+Fz0hY6Q380hKh0YCYxWrIcY67vslX6Y91NvSOd8zzBOo5kklXunkA== X-Google-Smtp-Source: AGHT+IHw7ePxU+hrstSAGg42I7Gtye2zH7WvuI6K0zmoLTzVPp7OiaVD/EXcfs1Ahzc6pDTUBzfu X-Received: by 2002:a05:6870:84c9:b0:24f:e284:407e with SMTP id 586e51a60fabf-2508ba13e29mr4035265fac.25.1717206681518; Fri, 31 May 2024 18:51:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717206681; cv=pass; d=google.com; s=arc-20160816; b=xnzVypAkmKNn+8trj1wBvhMtlcKYKmR9lYXJCEVCLjViAVk9+7WhKRVb1xvIX8nIuh y/4HKVMPxMANsk5eGWU3O8PcMfao2bQ3I99irPnBwkJSn/YhSKAfWq7Ixng3ukibCQIg Yc1YYuUA/YmDPYhqTJiGkoNnL5WQQPvaaBv9liYWRZf/3IV/35s3cwXBXgsBbobjK+F9 ly1Jq2z3BlQuhCjRtIGKulc5aOxSYNAqWioATJ1KQ9aIO7wjwIdTq4afG/Y+bFGQaQQo YtmW4KMNjW0m/Jr4XT0FUqjxAh78DGz11n5OnJCM79KsK2w++OkmmKf5VQAZ20h4UoZu stbg== 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=y2xdFUxWobdQwEfx7YLKH85Utfki6HaKV/+RpyucODI=; fh=PpMk+9ap0X9qKHl5gLlJTAQLDnSnL8+qsk2SheRFg9o=; b=wn4Lr7rmeTVf4b7Baux8ff26DmQNM9R+SMku13Ss/YPeiESd+YN6zY8VBOulRMFb+5 4W0ODHtm/7WgCk31Z6p1zh+iVdKBDBUOGPyVbDz/Zzfac/9vocsGh1l1RaAYMdQEqeOv znaTWJgsld2qrBk92aiL4Av/0dkN2p/hxGgNK9OXC/UVFspicojNSpoOaRKPpUkLCArx bbjtWdXc1VQ9NDidIP8nsu11x6Vr6Q5yunkEO1gQX8bMBBKzDfkD1yIxdk8v3HBgXpyh cD+AOq5SBTd9R7eQNSv7jU/IZWrRYAaPQq2dKPhj5E9MH2Rc7wh91TWUo0sKzzIIjlek 75sA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b="RILy/egF"; 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-197639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197639-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-6c35af46011si1704723a12.482.2024.05.31.18.51.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 18:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197639-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="RILy/egF"; 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-197639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197639-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 9251C2892D9 for ; Sat, 1 Jun 2024 01:45:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F8E5224CF; Sat, 1 Jun 2024 01:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="RILy/egF" Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.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 BD7791F934 for ; Sat, 1 Jun 2024 01:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206183; cv=none; b=KvgOnXu5QYZozVH1OFBIhTb82sDOWftOpug5IuiKSDR8WF5KIt78O/bDPYHk8F01qyPxVVzIHglavl12ihSLU41PpVJjb6TCF6c0kVAEqMF3dCPJLkGMzhm57xJkfyC8H4UYEE0gTAMDmAQYl18DG+1BbYlM7v28uxXIqv7BGn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717206183; c=relaxed/simple; bh=8vUlbvEH7gTZvH1D61OBJNrvJ28CeUyHOjmFolkGer4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JNAy8BPLlRMEljg3Kutl7r7Wc+hG4HFQcya6eDoo2lHhWuf/Zml8wxSBekfdDYE9CjxOUXtzuLeUSYlTe6ePo982VlZWDb5tDlzebtVX+3kPsmBZrST2d5Z/COWmH5oZ5dD7YLpCzza9LHCjfFrv9bUPTSc7SWTv6j9J0p4Cu88= 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.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 Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-62a2424ed01so27975597b3.1 for ; Fri, 31 May 2024 18:43:01 -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=ivBu0OQCiCBkvXkkLJxnVJg5vbP4qIy2FhlPGR4NMB1orqEybPYR2lC9SkDzo1aQfx 7yaiyEF7rdE9J9ztezN5gAPFaz66vzU7AbzEEss1UZ7OwZudFlYNuNaOpLr4drFE9wXM ySewUJORcdqC42oPKjbTdsy5socgPzhqw0uWrowRk/NuDKnLm1Y+Tjbo43J4e+5sVJW+ RZi9XeLsHZhCqwPZg72yJP6wHksuQJXVUVT9vrvnzu8sKwN5qzpTV0Jc7FYsnvoF5wur Vvi0UwLZ912Ra3TNW3cEAAPuPk4HqmXCEq9+w8vetUPOU3bD30r86vYc/y3OBnvKZQRX eY6g== X-Forwarded-Encrypted: i=1; AJvYcCVvylluPyQakuCYML3T2cqcpvL91a5fWfOcdyyxAadeJkl8S3bE6icdUmZBw4yf10gNqZjexpvwXaVxxIz99BT00dWa3Z7A0UGv6qQd X-Gm-Message-State: AOJu0YwcZyyFoVLRAYvXalaw4XQm7vwzQsreyCFFoJJjFDOyBZTfm8U9 dq542i+k+srcjMVSX7bBkk8jEXzRZI67LTYVCpyMDni73AfvOLx5wSDMLMGqF/0= 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: 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: 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; } -- 2.30.2