linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	Shuah Khan <shuah@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH nf-next v4 1/2] net: netfilter: Add IPIP flowtable SW acceleration
Date: Mon, 21 Jul 2025 11:49:42 +0200	[thread overview]
Message-ID: <aH4NNppbRppZojYO@lore-desk> (raw)
In-Reply-To: <aHpIuOiEaoewEQxm@strlen.de>

[-- Attachment #1: Type: text/plain, Size: 2659 bytes --]

> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> > +	path->type = DEV_PATH_IPENCAP;
> > +	path->dev = ctx->dev;
> > +	path->encap.proto = htons(ETH_P_IP);
> > +	path->encap.id = jhash_3words(ntohl(tiph->saddr), ntohl(tiph->daddr),
> > +				      IPPROTO_IPIP, 0);
> 
> I think it would be better to have a helper.  Else I think this needs a
> comment that explains it must be kept in sync with nf_flow_tuple_encap().
> 
> Or use __ipv4_addr_hash(tiph->saddr, (__force __u32)tiph->daddr).
> (loses IPPROTO_IPIP though).

ack, I will fix it in v5.

> 
> > @@ -165,6 +166,19 @@ static void nf_flow_tuple_encap(struct sk_buff *skb,
> >  		tuple->encap[i].id = ntohs(phdr->sid);
> >  		tuple->encap[i].proto = skb->protocol;
> >  		break;
> > +	case htons(ETH_P_IP):
> > +		if (!pskb_may_pull(skb, sizeof(*iph)))
> > +			break;
> 
> Is this needed?  Caller does:
> 
>         if (!pskb_may_pull(skb, thoff + ctx->hdrsize))
>                 return -1;
> 
> and then populates the inner header:
>         iph = (struct iphdr *)(skb_network_header(skb) + ctx->offset);
> 	tuple->src_v4.s_addr    = iph->saddr;
> 
> 
> .... so I think this can rely on the outer header being available
> via skb_network_header().

I agree, I will fix it in v5.

> 
> > +		tuple->encap[i].proto = htons(ETH_P_IP);
> > +		tuple->encap[i].id = jhash_3words(ntohl(iph->daddr),
> > +						  ntohl(iph->saddr),
> > +						  IPPROTO_IPIP, 0);
> 
> See above, I think this desevers a helper or a comment, or both.
> 
> > +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?

> 
> > +	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?

> 
> > +
> >  static bool nf_flow_skb_encap_protocol(struct sk_buff *skb, __be16 proto,
> >  				       u32 *offset)
> >  {
> >  	struct vlan_ethhdr *veth;
> >  	__be16 inner_proto;
> > +	u16 size;
> >  
> >  	switch (skb->protocol) {
> > +	case htons(ETH_P_IP):
> > +		if (nf_flow_ip4_encap_proto(skb, &size))
> > +			*offset += size;
> 
> Nit: return nf_flow_ip4_encap_proto(skb, &offset) ?

ack, I will fix it in v5.

Regards,
Lorenzo


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-07-21  9:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-18 10:31 [PATCH nf-next v4 0/2] Add IPIP flowtable SW acceleratio Lorenzo Bianconi
2025-07-18 10:31 ` [PATCH nf-next v4 1/2] net: netfilter: Add IPIP flowtable SW acceleration Lorenzo Bianconi
2025-07-18 13:14   ` Florian Westphal
2025-07-21  9:49     ` Lorenzo Bianconi [this message]
2025-07-21 11:51       ` Florian Westphal
2025-07-21 13:38         ` Lorenzo Bianconi
2025-07-21 13:57           ` Florian Westphal
2025-07-18 10:31 ` [PATCH nf-next v4 2/2] selftests: netfilter: nft_flowtable.sh: Add IPIP flowtable selftest Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aH4NNppbRppZojYO@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).