Re: [PATCH bpf-next 1/2] bpf: Add ifindex to bpf_sk_lookup

From: John Fastabend
Date: Thu Oct 21 2021 - 15:08:09 EST


Alexei Starovoitov wrote:
> On Fri, Oct 15, 2021 at 4:24 AM Mark Pashmfouroush
> <markpash@xxxxxxxxxxxxxx> wrote:
> >
> > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> > index 6fc59d61937a..9bd3e8b8a659 100644
> > --- a/include/uapi/linux/bpf.h
> > +++ b/include/uapi/linux/bpf.h
> > @@ -6262,6 +6262,7 @@ struct bpf_sk_lookup {
> > __u32 local_ip4; /* Network byte order */
> > __u32 local_ip6[4]; /* Network byte order */
> > __u32 local_port; /* Host byte order */
> > + __u32 ifindex; /* Maps to skb->dev->ifindex */
>
> Is the comment accurate?
> The bpf_sk_lookup_kern ifindex is populated with inet_iif(skb).
> Which is skb->skb_iif at this point (I think).
> skb->dev->ifindex would typically mean destination or egress ifindex.
> In __sk_buff we have 'ifindex' and 'ingress_ifindex' to differentiate them.
> If it's really dev->ifindex than keeping 'ifindex' name here would be correct,
> but looking at how it's populated in inet/udp_lookup makes me wonder
> whether it should be named 'ingress_ifindex' instead and comment clarified.
>
> If/when you resubmit please trim cc list to a minimum.

At least in the tcp cases its coming from inet_iif which is either
the rtable or skb->skb_iif. Agree would be nice to fixup the comment.

Thanks.