From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.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 BF6F484039 for ; Sun, 5 Jul 2026 02:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783218992; cv=none; b=Yi3AmXFceWtiddBnKiLrl/Br2MsH9IAce5Wl+d1qdeCxuT5jSPmSh1ObQ4J2Kq6+5q/EOO18AXi9tr4MFJcdPLB95p/q+STlKTV1JRnebOzZrcvWa7fkQXMtsJyptjm0hE+fmBZ2P/2OTl5SS90Evetz93AAQ/TClQEDDS7KEss= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783218992; c=relaxed/simple; bh=+BArqPRi/HGb47SvX7vALOEV+D05PN6gJxn6aT+kPjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MVkKW7StHHQ8sfBP3PNyNMyTGN2a/lpQxa22jeEGO1fbzPC2K2IuMRLASp48cu8HuRRkg4B6gyziHe+nlNrlwwIZ7losyNhZ5YNEYfLdh03bYLzE+Fbb+qaiEbahTRm+kLRaKSGKnBcJwbaHqa1ZNjfkln3R8EhmmnQJY3U/X64= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RSDdMEq9; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RSDdMEq9" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-698ae09e356so2482470a12.2 for ; Sat, 04 Jul 2026 19:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783218989; x=1783823789; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AG88zQ4/Ea5c59EGNnHF8fES6bswAggUNG/bJaKr2q0=; b=RSDdMEq9O1Af+FRa24JBPvCQPIOZcdZkdI9j8xhWEwFcpMSH5FhXtHMIwgKSZBBPh8 73lsH5IsMMxnmROKTSaNrwZmz852wu8QfOBwPh7jMnGroZxbtAIO7vKA5KvHpodKumIR ctxhfV0yzIWCFJlToXosdo4gmxr7kPyq5vadQinp2qV1UMFMTlQU7XqA/DLFH75eKa/+ k6HLZZ07bQwOu+H8R7dfv6a9unVQNiXq0J0DjZiPCYj0PzgP2BrvC950sgGDsSZHojKF UE7SXzuHdvLlIQU65TVUeVJtvkFMkfb69QA9mf3UEhYFNRHgqVham8ZWniztsCrgPqbD tdwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783218989; x=1783823789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AG88zQ4/Ea5c59EGNnHF8fES6bswAggUNG/bJaKr2q0=; b=D6Wx9nCHjiz/VmwqCp3Q3LTCZj2UDFSqllLEixWrl8fQ4nOURn+VhYpVEtoV31iER8 1z7Epqo6wOqAfQnGxTfWl/nsYFArLKwq2s2z4WSfomhFxL/4hLGDC8P0KQUkKdch4Rr1 JkrsTuZ9v7P1Px4rkMEuIKt8CZHZDqHlSKqBD5RgrK81sq3MwNZYaQUV7fBqlxWnq8jx 0hxOPf/O72OIhUO4MXOxAAi60xI5PnrCgCxtOZ+dKC3Eg6V5mNkDSbmfs9xWArm/eqjG SakHeqhLFu3+MyvHiIpOxhdOMLd2wOxykXsuMERLMzc7uosHwPqdDOADBJX5PaccqXbC +3Rw== X-Gm-Message-State: AOJu0YxNYbzWp6VlxlBc+G4S3MlmxT/V6fzZPbMkfUUZjIX9Yfs7iWi9 jYDr8pnnD0i2r62Qw4SwnIXeJ/AMkHKKJ7CGtifvd1dKiams012/I3DEp7aSjw0E X-Gm-Gg: AfdE7cmqyk3+3ePyZV5uf2zXDaE+pDEUV4cT5wsmEPlIBu//NjJhFmxhVYO4y3ORT/m Cnm9dVkUKWKXyYBfb/GKO3j9XOfgEmaWI7CP3Nxw7a8PwGa4G0mRlzszbtEHtkuFrhi6FCScw47 g25XKv5o+fv7Ogo+LIb//MK6PrtThe/orWbeGgNbTEpZQn5TFXp+aXAYTuEtsN5KMYy78GPnwVf U1PBofalQkCLCq3/0q5fYYz84NeEtRVrPZUzV8Mak8yHBVQ1LyAJwpb1YikAjS5WQm9nVdeWk4M 3p5gM2qPOSeMsqdM4GRrwtA1IQCvMvNqC0einr40WGpnny46/6UGDred8rbSus6mcItNlpkVjFN Gfk0TueRNLYpOidWBMc0FnsI9fDusLn0620sJ9UrLbR44ouFwpwoozv5bAmo8+H1DhLIJp4hi8D 9pFozr3sYsyr9oKey/z+hOQF0RhEDWa9hWZiCNnWTwglnd3LIUGHPRcRL+Ow== X-Received: by 2002:a17:907:969f:b0:c12:34f0:49b4 with SMTP id a640c23a62f3a-c12e6bf61b6mr148343466b.55.1783218988698; Sat, 04 Jul 2026 19:36:28 -0700 (PDT) Received: from dau-home-pc.. ([95.164.115.35]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c12bc53e065sm463082166b.46.2026.07.04.19.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2026 19:36:27 -0700 (PDT) From: Anton Danilov To: netdev@vger.kernel.org Cc: Willem de Bruijn , "David S . Miller" , David Ahern , Eric Dumazet , Kuniyuki Iwashima , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , linux-kselftest@vger.kernel.org Subject: [PATCH net-next v5 1/2] udp: fix encapsulation packet resubmit in multicast deliver Date: Sun, 5 Jul 2026 05:36:03 +0300 Message-ID: X-Mailer: git-send-email 2.47.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When a UDP encapsulation socket (e.g., FOU) receives a multicast packet, __udp4_lib_mcast_deliver() and __udp6_lib_mcast_deliver() call consume_skb() when udp_queue_rcv_skb() returns a positive value. A positive return value from udp_queue_rcv_skb() indicates that the encap_rcv handler (e.g., fou_udp_recv) has consumed the UDP header and wants the packet to be resubmitted to the IP protocol handler for further processing (e.g., as a GRE packet). The unicast paths handle this correctly by propagating the return value up to ip_protocol_deliver_rcu() / ip6_protocol_deliver_rcu() for resubmission. However, the multicast paths destroy the packet via consume_skb() instead of resubmitting it, causing silent packet loss. This affects any UDP encapsulation (FOU, GUE) combined with multicast destination addresses. Fix this by returning the value from udp_queue_rcv_skb() when it is positive, matching the behavior of the corresponding unicast paths. Note the sign difference between IPv4 and IPv6: - IPv4: udp_unicast_rcv_skb() returns -ret, and ip_protocol_deliver_rcu() resubmits when ret < 0 (using -ret as the protocol number). - IPv6: udp6_unicast_rcv_skb() returns ret, and ip6_protocol_deliver_rcu() resubmits when ret > 0 (using ret as the nexthdr). Both mcast paths now follow the same convention as their respective unicast paths. Suggested-by: Willem de Bruijn Suggested-by: Kuniyuki Iwashima Signed-off-by: Anton Danilov Assisted-by: Claude:claude-opus-4-6 --- net/ipv4/udp.c | 6 ++++-- net/ipv6/udp.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 59248a59358c..d3ddcbfc8477 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2476,6 +2476,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb, struct udp_hslot *hslot; struct sk_buff *nskb; bool use_hash2; + int ret; hash2_any = 0; hash2 = 0; @@ -2520,8 +2521,9 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb, } if (first) { - if (udp_queue_rcv_skb(first, skb) > 0) - consume_skb(skb); + ret = udp_queue_rcv_skb(first, skb); + if (ret > 0) + return -ret; } else { kfree_skb(skb); __UDP_INC_STATS(net, UDP_MIB_IGNOREDMULTI); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 392e18b97045..0910cc171776 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -949,6 +949,7 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb, struct udp_hslot *hslot; struct sk_buff *nskb; bool use_hash2; + int ret; hash2_any = 0; hash2 = 0; @@ -998,8 +999,9 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb, } if (first) { - if (udpv6_queue_rcv_skb(first, skb) > 0) - consume_skb(skb); + ret = udpv6_queue_rcv_skb(first, skb); + if (ret > 0) + return ret; } else { kfree_skb(skb); __UDP6_INC_STATS(net, UDP_MIB_IGNOREDMULTI); -- 2.47.3