From nobody Sun Dec 14 19:26:22 2025 Received: from spam.asrmicro.com (asrmicro.com [210.13.118.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D011335BA; Thu, 17 Apr 2025 09:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.13.118.86 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744882576; cv=none; b=tjUrVyT13+t+lT9+W5jovnXEV3nOZGNnfrkyTSLdd4fPru/lR5KrEKBThEgeLerCWx0XHRLSWCf2pFOpMS5gvYmo/o5Xl6tz+GkzfSruwQMrGfxLgNZj4/UP4OZX4iDES5ahdro0u4VXax1WsuAysyJKn5Z3ZGu3Su0JH+qqucE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744882576; c=relaxed/simple; bh=/3cgy1tOPVmp/GwqXQ5b09Rm9iK7C5DYKc0OMkdAHUc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=AhUQAnP01iwT1wAlelbRcGkD5dm84w7oR3xvwk0NO+Vx5RKYmbTStWNusivUbdM+IvSbyUoGiICW3leZyfa51cxlvOzvcNJe/Q2m6S38eHwjWREPP/WfFighMjIJ1Xc/0KmFtVm4wNVpft9Y6WPqlaPqP9bR7QT73pRngIgqOmQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=asrmicro.com; spf=pass smtp.mailfrom=asrmicro.com; arc=none smtp.client-ip=210.13.118.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=asrmicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asrmicro.com Received: from exch03.asrmicro.com (exch03.asrmicro.com [10.1.24.118]) by spam.asrmicro.com with ESMTPS id 53H9TuF3001085 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 17 Apr 2025 17:29:56 +0800 (GMT-8) (envelope-from huajianyang@asrmicro.com) Received: from localhost (10.26.128.141) by exch03.asrmicro.com (10.1.24.118) with Microsoft SMTP Server (TLS) id 15.0.847.32; Thu, 17 Apr 2025 17:29:59 +0800 From: Huajian Yang To: , CC: , , , , , , , , , , , , , , Huajian Yang Subject: [PATCH] net: Move specific fragmented packet to slow_path instead of dropping it Date: Thu, 17 Apr 2025 17:29:53 +0800 Message-ID: <20250417092953.8275-1-huajianyang@asrmicro.com> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: exch02.asrmicro.com (10.1.24.122) To exch03.asrmicro.com (10.1.24.118) X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: spam.asrmicro.com 53H9TuF3001085 Content-Type: text/plain; charset="utf-8" The config NF_CONNTRACK_BRIDGE will change the bridge forwarding for fragmented packets. The original bridge does not know that it is a fragmented packet and forwards it directly, after NF_CONNTRACK_BRIDGE is enabled, function nf_br_ip_fragment and br_ip6_fragment will check the headroom. In original br_forward, insufficient headroom of skb may indeed exist, but there's still a way to save the skb in the device driver after dev_queue_xmit.So droping the skb will change the original bridge forwarding in some cases. Signed-off-by: Huajian Yang Reviewed-by: Florian Westphal --- net/bridge/netfilter/nf_conntrack_bridge.c | 12 ++++++------ net/ipv6/netfilter.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfil= ter/nf_conntrack_bridge.c index 816bb0fde718..6482de4d8750 100644 --- a/net/bridge/netfilter/nf_conntrack_bridge.c +++ b/net/bridge/netfilter/nf_conntrack_bridge.c @@ -60,19 +60,19 @@ static int nf_br_ip_fragment(struct net *net, struct so= ck *sk, struct ip_fraglist_iter iter; struct sk_buff *frag; =20 - if (first_len - hlen > mtu || - skb_headroom(skb) < ll_rs) + if (first_len - hlen > mtu) goto blackhole; =20 - if (skb_cloned(skb)) + if (skb_cloned(skb) || + skb_headroom(skb) < ll_rs) goto slow_path; =20 skb_walk_frags(skb, frag) { - if (frag->len > mtu || - skb_headroom(frag) < hlen + ll_rs) + if (frag->len > mtu) goto blackhole; =20 - if (skb_shared(frag)) + if (skb_shared(frag) || + skb_headroom(frag) < hlen + ll_rs) goto slow_path; } =20 diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c index 581ce055bf52..4541836ee3da 100644 --- a/net/ipv6/netfilter.c +++ b/net/ipv6/netfilter.c @@ -164,20 +164,20 @@ int br_ip6_fragment(struct net *net, struct sock *sk,= struct sk_buff *skb, struct ip6_fraglist_iter iter; struct sk_buff *frag2; =20 - if (first_len - hlen > mtu || - skb_headroom(skb) < (hroom + sizeof(struct frag_hdr))) + if (first_len - hlen > mtu) goto blackhole; =20 - if (skb_cloned(skb)) + if (skb_cloned(skb) || + skb_headroom(skb) < (hroom + sizeof(struct frag_hdr))) goto slow_path; =20 skb_walk_frags(skb, frag2) { - if (frag2->len > mtu || - skb_headroom(frag2) < (hlen + hroom + sizeof(struct frag_hdr))) + if (frag2->len > mtu) goto blackhole; =20 /* Partially cloned skb? */ - if (skb_shared(frag2)) + if (skb_shared(frag2) || + skb_headroom(frag2) < (hlen + hroom + sizeof(struct frag_hdr))) goto slow_path; } =20 --=20 2.48.1