From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (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 5E15F3A1DB for ; Wed, 24 Jun 2026 00:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782259799; cv=none; b=gReleWg9fvvD4F6/RxVeO3rHC7tDgRZdOc3oCOvBxQBcojAQFpvuCFObN+R6mj0rQPI/bJFUXEMlioA6RLsOwCm05bkxBntRn/VQ0AVexbEKUWHGQArWI+075bpjQjC82s2PlN4lE8LT1vIu/BSy9uVR5HzxwQ9zIIBJNv5RZfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782259799; c=relaxed/simple; bh=0XYbSaKDOoQduMhTFPk0faWObl2M7CF+88yrRNTkwwc=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=ORX7rDo8wsOcHcQegy6Tui+8tWZNtKvqrrOkEr38kmrcEE2zIpMvGhiaCXHQbF+2FXiGq2lQkduxwChxRjQCUzNr2bcMhzhPfjpQan4vC457lJq8c6TdK+nMIBqWcl0rMG3sLGatM72qu9LmzoTTdmsnRgk1vV8gP2G6vOT+sDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=yPdDeSi/; arc=none smtp.client-ip=74.125.82.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="yPdDeSi/" Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-30c6c8d7503so294970eec.0 for ; Tue, 23 Jun 2026 17:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1782259797; x=1782864597; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=G8oF7gaI866b4fh2rX0QoDVma7OKpRu/EkO3XgX53kE=; b=yPdDeSi/Tr2gqG/UpLxRu4RJ50CYw3+LqV6ACLBjLE1IOtJtXqrpVP3/DdMdC+B94H kD7KHfaSURNiYzFNnGLcmk8gNKTJj/LInMItHkrFVqwxKijDy5UIRubGoh4l8so+C93o LfXAQrquRhj8tu/uTtxh2IrFOKVSPbexuHKP/ZZI2JnT0kdGhYeKmDpV23JvOBFud9QH gifvsRKPxhCum00TvuENKCiPO5fkPeSu6wce/9EagyD6A8a0Ol3tRc0szeTJ/8fL4Qgb KNvBfkoQQ7B3o8fX+PFSDuxif6j6tKUwApS1Io2XmWxzrY4Teh/EabxvXppwXEUjPJAx 87SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782259797; x=1782864597; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=G8oF7gaI866b4fh2rX0QoDVma7OKpRu/EkO3XgX53kE=; b=b8KImu3p+mm6ra+JhSAWpUN0+9kO9Wr0BgSdssZKztXi3x9u+1LnWA0fkbI9aygZya vYFKFNucyPOzyot97QJrN0Ic6Tku2QL68wTGThSQDB90wz1mWGnwy/j/CsvUhRbG7uom ORMj/hapHov45HkJNuSAvSsj7/6ND7lUXXyXkC67HqGXyoQEneqN0/TmRJKwgxSvAMfi uyiqsiUbAEmj01nHziX8ZTEQzOqiRx+Y6P6FUlxAdqsUds5U8a/oVFWFZBPSd/GWwNup BSvHnXfR7xM4fNbxs68jf1lwmKuNwFJZIv0luszPihf9Pwlgce58jRSWFzc/dpSuppMc Hmaw== X-Forwarded-Encrypted: i=1; AHgh+RqsgVA1Pz20FjRkMtGLeCn9wVWM7zPkRZVTCQEd5udDHnRSnY1AEIuBoEZp9BV77kSUVcI=@vger.kernel.org X-Gm-Message-State: AOJu0YyUda0oFM6Sg74xV6Tnv0xIYcrTR5ijUhrHqHeOU5XUU0R9W+l2 hVdUMXlroGpAPaxsud9MOF/Thgv+Pkk2q7nyxo84Zw4S7LS+U+ODPz0bIKrzJSIBb48= X-Gm-Gg: AfdE7cmr4zhkiiqckOIn4e5R9NuxnBOBEbWekjun8NhNPZ/7FFyD7gb2hIkDemTYX93 1Ky0vg76OEatQmXTv7YsU/I+gBR5P+v6Jf/mpvnxol7fPSm63mNr53XIrmnahypnZUlnJ1ORI4f r36FWJeqZJh0FUJN63sGufgOB9gAQuZ9IlyFzP29Wjmh2CUo3bTPMK4AEGlXZSCitrTapgMhktw gS1ej6r0G4OupmCp8Z7yIBHOiHvtG6Vl3hcUvoyUYm9y3777ZjcT4G7f9cSz8tuFOYR+jvi6PSi b+8k3atescbLv10WVacHSYDoftiSb3fL519uM0R+zrQBNgthLvLKI/35WgFhLHGH7uiavVWnUaQ 25oh/5JT0J2kUNUUpOTXbBQlNFmw77CZXHbLElI6XU9sQGdIOXeCz/6inx0Jx8+A3OShMBUDjX7 G6qlGS X-Received: by 2002:a05:7300:4304:b0:304:d14b:b706 with SMTP id 5a478bee46e88-30c6937271bmr1341249eec.27.1782259797305; Tue, 23 Jun 2026 17:09:57 -0700 (PDT) Received: from localhost ([2620:10d:c090:600::2526]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c52daf89dsm9570073eec.31.2026.06.23.17.09.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2026 17:09:56 -0700 (PDT) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 23 Jun 2026 20:09:54 -0400 Message-Id: Cc: , , , , , , , , , , , Subject: Re: [PATCH bpf-next v8 1/7] net: move netfilter nf_reject_fill_skb_dst to core ipv4 From: "Emil Tsalapatis" To: "Mahe Tardy" , X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260622120515.137082-1-mahe.tardy@gmail.com> <20260622120515.137082-2-mahe.tardy@gmail.com> In-Reply-To: <20260622120515.137082-2-mahe.tardy@gmail.com> On Mon Jun 22, 2026 at 8:05 AM EDT, Mahe Tardy wrote: > Move and rename nf_reject_fill_skb_dst from > ipv4/netfilter/nf_reject_ipv4 to ip_route_reply_fill_dst in ipv4/route.c > so that it can be reused in the following patches by BPF kfuncs. > > Netfilter uses nf_ip_route that is almost a transparent wrapper around > ip_route_output_key so this patch inlines it. > > Reviewed-by: Jordan Rife > Signed-off-by: Mahe Tardy Reviewed-by: Emil Tsalapatis > --- > include/net/route.h | 1 + > net/ipv4/netfilter/nf_reject_ipv4.c | 19 ++----------------- > net/ipv4/route.c | 15 +++++++++++++++ > 3 files changed, 18 insertions(+), 17 deletions(-) > > diff --git a/include/net/route.h b/include/net/route.h > index f90106f383c5..300d292cd9a1 100644 > --- a/include/net/route.h > +++ b/include/net/route.h > @@ -173,6 +173,7 @@ struct rtable *ip_route_output_flow(struct net *, str= uct flowi4 *flp, > const struct sock *sk); > struct dst_entry *ipv4_blackhole_route(struct net *net, > struct dst_entry *dst_orig); > +int ip_route_reply_fill_dst(struct sk_buff *skb); > > static inline struct rtable *ip_route_output_key(struct net *net, struct= flowi4 *flp) > { > diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_= reject_ipv4.c > index fecf6621f679..c1c0724e4d4d 100644 > --- a/net/ipv4/netfilter/nf_reject_ipv4.c > +++ b/net/ipv4/netfilter/nf_reject_ipv4.c > @@ -252,21 +252,6 @@ static void nf_reject_ip_tcphdr_put(struct sk_buff *= nskb, const struct sk_buff * > nskb->csum_offset =3D offsetof(struct tcphdr, check); > } > > -static int nf_reject_fill_skb_dst(struct sk_buff *skb_in) > -{ > - struct dst_entry *dst =3D NULL; > - struct flowi fl; > - > - memset(&fl, 0, sizeof(struct flowi)); > - fl.u.ip4.daddr =3D ip_hdr(skb_in)->saddr; > - nf_ip_route(dev_net(skb_in->dev), &dst, &fl, false); > - if (!dst) > - return -1; > - > - skb_dst_set(skb_in, dst); > - return 0; > -} > - > /* Send RST reply */ > void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *old= skb, > int hook) > @@ -279,7 +264,7 @@ void nf_send_reset(struct net *net, struct sock *sk, = struct sk_buff *oldskb, > if (!oth) > return; > > - if (!skb_dst(oldskb) && nf_reject_fill_skb_dst(oldskb) < 0) > + if (!skb_dst(oldskb) && ip_route_reply_fill_dst(oldskb) < 0) > return; > > if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) > @@ -352,7 +337,7 @@ void nf_send_unreach(struct sk_buff *skb_in, int code= , int hook) > if (iph->frag_off & htons(IP_OFFSET)) > return; > > - if (!skb_dst(skb_in) && nf_reject_fill_skb_dst(skb_in) < 0) > + if (!skb_dst(skb_in) && ip_route_reply_fill_dst(skb_in) < 0) > return; > > if (skb_csum_unnecessary(skb_in) || > diff --git a/net/ipv4/route.c b/net/ipv4/route.c > index 3f3de5164d6e..f24609933fbe 100644 > --- a/net/ipv4/route.c > +++ b/net/ipv4/route.c > @@ -2942,6 +2942,21 @@ struct rtable *ip_route_output_flow(struct net *ne= t, struct flowi4 *flp4, > } > EXPORT_SYMBOL_GPL(ip_route_output_flow); > > +int ip_route_reply_fill_dst(struct sk_buff *skb) > +{ > + struct rtable *rt; > + struct flowi4 fl4 =3D { > + .daddr =3D ip_hdr(skb)->saddr > + }; > + > + rt =3D ip_route_output_key(dev_net(skb->dev), &fl4); > + if (IS_ERR(rt)) > + return PTR_ERR(rt); > + skb_dst_set(skb, &rt->dst); > + return 0; > +} > +EXPORT_SYMBOL_GPL(ip_route_reply_fill_dst); > + > /* called with rcu_read_lock held */ > static int rt_fill_info(struct net *net, __be32 dst, __be32 src, > struct rtable *rt, u32 table_id, dscp_t dscp, > -- > 2.34.1