[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <HE1PR0502MB3899B86687E2E229FAB7D026D1D30@HE1PR0502MB3899.eurprd05.prod.outlook.com>
Date: Fri, 30 Nov 2018 07:32:55 +0000
From: Maxim Mikityanskiy <maximmi@...lanox.com>
To: Saeed Mahameed <saeedm@....mellanox.co.il>
CC: Saeed Mahameed <saeedm@...lanox.com>,
Linux Netdev List <netdev@...r.kernel.org>,
"jasowang@...hat.com" <jasowang@...hat.com>,
Eric Dumazet <edumazet@...gle.com>,
"David S. Miller" <davem@...emloft.net>,
Eran Ben Elisha <eranbe@...lanox.com>,
Willem de Bruijn <willemb@...gle.com>,
Tariq Toukan <tariqt@...lanox.com>
Subject: RE: Invalid transport_offset with AF_PACKET socket
> > > So it should return at least 18 and not 14.
> >
> > Yes, the function does its best to return at least 18, but it silently
> expects
> > skb_transport_offset to exceed 18. In normal conditions, it will be more
> that
> > 18, because it will be at least 14 + 20. But in my case, when I send a
> packet
> > via an AF_PACKET socket, skb_transport_offset returns 14 (which is
> nonsense),
> > and the driver uses this value, causing the hardware to fail, because it's
> less
> > than 18.
> >
>
> Got it, so even if you copy 18 it is not sufficient ! if the packet is
> ipv4 or ipv6
> and the inline mode is set to MLX5_INLINE_MODE_IP in the vport
> context you must copy the IP headers as well !
Yes, I know that. That's why the driver uses skb_transport_offset - to include
the network header, but as skb_transport_offset returns a wrong offset, the IP
header doesn't get included. The thing is that with 14 bytes the driver even
fails to send a packet, and with 18 bytes and missing L3 header it seems to send
it, but it doesn't matter much, of course, we should pass the L3 header as well.
> but what do you expect from AF_PACKET socket ? to parse each and every
> packet and set skb_transport_offset ?
Not exactly.
First, AF_PACKET already parses each packet, and it even sets the transport
offset correctly if I specify the protocol in the third parameter of the
socket() call:
socket(AF_PACKET, SOCK_RAW, htons(0x0800));
So, if called in a specific way, the AF_SOCKET does exactly that - it parses
each packet and sets the transport offset, but if the protocol is not specified
(0) in the third parameter, it fails to parse correctly.
Second, I don't expect that. It's absolutely OK if AF_PACKET tells the driver
that it failed to parse the packet, then the driver can guess the network
protocol and restart parsing itself. The driver knows the format of its L2
header and can look at the necessary field.
However, if AF_PACKET could ask the driver to guess the protocol, it would be a
little bit faster, because this way skb_probe_transport_header is only called
once, and the field lookup in the L2 header is O(1).
Powered by blists - more mailing lists