[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <423dd8d6-6e84-01d4-c529-ce85d84fa24b@digitalocean.com>
Date: Thu, 27 Feb 2020 13:44:03 -0700
From: David Ahern <dahern@...italocean.com>
To: Jesper Dangaard Brouer <brouer@...hat.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
prashantbhole.linux@...il.com, jasowang@...hat.com,
toke@...hat.com, mst@...hat.com, toshiaki.makita1@...il.com,
daniel@...earbox.net, john.fastabend@...il.com, ast@...nel.org,
kafai@...com, songliubraving@...com, yhs@...com, andriin@...com,
David Ahern <dsahern@...nel.org>
Subject: Re: [PATCH RFC v4 bpf-next 03/11] xdp: Add xdp_txq_info to xdp_buff
On 2/27/20 1:00 AM, Jesper Dangaard Brouer wrote:
>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
>> index 7850f8683b81..5e3f8aefad41 100644
>> --- a/include/uapi/linux/bpf.h
>> +++ b/include/uapi/linux/bpf.h
>> @@ -3334,8 +3334,10 @@ struct xdp_md {
>> __u32 data;
>> __u32 data_end;
>> __u32 data_meta;
>> - /* Below access go through struct xdp_rxq_info */
>> - __u32 ingress_ifindex; /* rxq->dev->ifindex */
>> + union {
>> + __u32 ingress_ifindex; /* rxq->dev->ifindex */
>> + __u32 egress_ifindex; /* txq->dev->ifindex */
>> + };
>
> Are we sure it is wise to "union share" (struct) xdp_md as the
> XDP-context in the XDP programs, with different expected_attach_type?
> As this allows the XDP-programmer to code an EGRESS program that access
> ctx->ingress_ifindex, this will under the hood be translated to
> ctx->egress_ifindex, because from the compilers-PoV this will just be an
> offset.
>
> We are setting up the XDP-programmer for a long debugging session, as
> she will be expecting to read 'ingress_ifindex', but will be getting
> 'egress_ifindex'. (As the compiler cannot warn her, and it is also
> correct seen from the verifier).
It both cases it means the device handling the packet. ingress_ifindex
== device handling the Rx, egress_ifindex == device handling the Tx.
Really, it is syntactic sugar for program writers. It would have been
better had xdp_md only called it ifindex from the beginning.
>
>
>> __u32 rx_queue_index; /* rxq->queue_index */
>
> So, the TX program can still read 'rx_queue_index', is this wise?
> (It should be easy to catch below and reject).
See patch 2.
In time I expect rx_queue_index to be a union with tx_queue_index for
the same reasons as the ifindex.
Powered by blists - more mailing lists