[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aH5CvbR6zD7ENreo@lore-desk>
Date: Mon, 21 Jul 2025 15:38:05 +0200
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Florian Westphal <fw@...len.de>
Cc: "David S. Miller" <davem@...emloft.net>,
David Ahern <dsahern@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>,
Pablo Neira Ayuso <pablo@...filter.org>,
Jozsef Kadlecsik <kadlec@...filter.org>,
Shuah Khan <shuah@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>,
netdev@...r.kernel.org, netfilter-devel@...r.kernel.org,
coreteam@...filter.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH nf-next v4 1/2] net: netfilter: Add IPIP flowtable SW
acceleration
> Lorenzo Bianconi <lorenzo@...nel.org> wrote:
> > > Lorenzo Bianconi <lorenzo@...nel.org> wrote:
> > > > +static bool nf_flow_ip4_encap_proto(struct sk_buff *skb, u16 *size)
> > > > +{
> > > > + struct iphdr *iph;
> > > > +
> > > > + if (!pskb_may_pull(skb, sizeof(*iph)))
> > > > + return false;
> > >
> > > Nit: I think this could be 2 * sizeof() and a comment that we will
> > > also need the inner ip header later, might save one reallocation.
> >
> > nf_flow_ip4_encap_proto() is used even for plain IP traffic but I guess we can
> > assume the IP payload is at least 20B, right?
>
> Oh, right, I missed that. But even if we have a.g. ip header with icmp
> header, then the postconditions are the same, no?
>
> as-is:
> pskb_may_pull -> ok, then iph->protocol == IPPROTO_IPIP -> return false
>
> with 2*iph:
> pskb_may_pull -> return false
>
> ... but I'll leave it up to you, if you prefer pskb_may_pull(skb, sizeof(*iph)))
> for clarity then lets keep it as-is.
I guess the point is we run nf_flow_skb_encap_protocol() not only for IPIP
traffic but even for plain IP traffic (e.g. IP+UDP) in nf_flow_offload_lookup().
In particular, we run the following check in nf_flow_tuple_ip() for IP+UDP
traffic:
pskb_may_pull(, 28)
That is less restrictive with respect to
pskb_may_pull(, 40)
I guess it is better to keep the original check in
nf_flow_skb_encap_protocol(). What do you think?
Regards,
Lorenzo
>
> > > > + iph = (struct iphdr *)skb_network_header(skb);
> > > > + *size = iph->ihl << 2;
> > >
> > > I think this should be sanity tested vs. sizeof(iph).
> >
> > I guess this is already done in ip_has_options(), agree?
>
> Indeed it is! Nevermind then :-)
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists