Re: [PATCH bpf-next v2 5/8] selftests/bpf: Verify xdp_metadata xdp->af_xdp path

Anton Protopopov
2022-11-29T10:06:17Z

On 22/11/21 10:25, Stanislav Fomichev wrote:
>
> [...]
>
> +
> + if (bpf_xdp_metadata_rx_timestamp_supported(ctx))
> + meta->rx_timestamp = bpf_xdp_metadata_rx_timestamp(ctx);
> +
> + if (bpf_xdp_metadata_rx_hash_supported(ctx))
> + meta->rx_hash = bpf_xdp_metadata_rx_hash(ctx);

Is there a case when F_supported and F are not called in a sequence? If not,
then you can join them:

bool (*ndo_xdp_rx_timestamp)(const struct xdp_md *ctx, u64 *timestamp);

so that a calling XDP program does one indirect call instead of two for one
field

if (bpf_xdp_metadata_rx_timestamp(ctx, &meta->rx_timestamp)) {
/* ... couldn't get the timestamp */
}