[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <80752de6-d18e-4ed9-9d5a-e6ab4954c3bf@redhat.com>
Date: Wed, 3 Sep 2025 11:01:48 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Daniel Zahka <daniel.zahka@...il.com>,
Donald Hunter <donald.hunter@...il.com>, Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Simon Horman <horms@...nel.org>, Jonathan Corbet <corbet@....net>,
Andrew Lunn <andrew+netdev@...n.ch>
Cc: Saeed Mahameed <saeedm@...dia.com>, Leon Romanovsky <leon@...nel.org>,
Tariq Toukan <tariqt@...dia.com>, Boris Pismenny <borisp@...dia.com>,
Kuniyuki Iwashima <kuniyu@...gle.com>, Willem de Bruijn
<willemb@...gle.com>, David Ahern <dsahern@...nel.org>,
Neal Cardwell <ncardwell@...gle.com>, Patrisious Haddad
<phaddad@...dia.com>, Raed Salem <raeds@...dia.com>,
Jianbo Liu <jianbol@...dia.com>, Dragos Tatulea <dtatulea@...dia.com>,
Rahul Rameshbabu <rrameshbabu@...dia.com>,
Stanislav Fomichev <sdf@...ichev.me>,
Toke Høiland-Jørgensen <toke@...hat.com>,
Alexander Lobakin <aleksander.lobakin@...el.com>,
Kiran Kella <kiran.kella@...adcom.com>,
Jacob Keller <jacob.e.keller@...el.com>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v10 17/19] psp: provide decapsulation and receive
helper for drivers
On 9/3/25 5:10 AM, Daniel Zahka wrote:
> On 9/2/25 6:28 AM, Paolo Abeni wrote:
>> On 8/28/25 6:29 PM, Daniel Zahka wrote:
>>> +/* Receive handler for PSP packets.
>>> + *
>>> + * Presently it accepts only already-authenticated packets and does not
>>> + * support optional fields, such as virtualization cookies.
>>> + */
>>> +int psp_dev_rcv(struct sk_buff *skb, u16 dev_id, u8 generation, bool strip_icv)
>>> +{
>>> + const struct psphdr *psph;
>>> + int depth = 0, end_depth;
>>> + struct psp_skb_ext *pse;
>>> + struct ipv6hdr *ipv6h;
>>> + struct ethhdr *eth;
>>> + int encap_bytes;
>>> + __be16 proto;
>>> +
>>> + eth = (struct ethhdr *)(skb->data);
>>> + proto = __vlan_get_protocol(skb, eth->h_proto, &depth);
>>> + if (proto != htons(ETH_P_IPV6))
>>> + return -EINVAL;
>>> +
>>> + ipv6h = (struct ipv6hdr *)(skb->data + depth);
>>> + depth += sizeof(*ipv6h);
>>> + end_depth = depth + sizeof(struct udphdr) + sizeof(struct psphdr);
>> Why aren't you checking the next hdr being UDP? This could potentially
>> match unrelated packets.
>
> This assumes the caller knows the packet is psp transport mode packet,
> which I think could be a reasonable API given that all psp
> implementations probably involve parsing packets in hw. I will update
> this patch to properly support IPv4, though.
Since you are already reading the header cacheline, I guess validating
the transport will not make any difference performance wise, and better
safe than sorry.
>> Also I guess you need pskb_may_pull() above.
>
> we check for: end_depth > skb_headlen(skb). If you prefer
> pskb_may_pull(), I can change it.
It's not a matter of personal preference: different NICs could cook the
skbs with different layouts. It's legit to process here valid PSP skbs
with headlen() less than end_depth - with some/all the headers in the
skb frags.
/P
Powered by blists - more mailing lists