On Fri, Mar 22, 2019 at 12:59:01PM -0700, Stanislav Fomichev wrote:
> When called without skb, gather all required data from the
> __skb_flow_dissect's arguments and use recently introduces
> no-skb mode of bpf flow dissector.
> 
> Note: WARN_ON_ONCE(!net) will now trigger for eth_get_headlen users.
> 
> Signed-off-by: Stanislav Fomichev <s...@google.com>
> +                     struct bpf_flow_keys flow_keys;
> +                     struct bpf_flow_dissector ctx = {
> +                             .flow_keys = &flow_keys,
> +                             .data = data,
> +                             .data_end = data + hlen,
> +                             .protocol = proto,
> +                     };
> +
> +                     if (skb) {
> +                             ctx.skb = skb;
> +                             ctx.protocol = skb->protocol;
> +                             ctx.vlan_tci = skb->vlan_tci;
> +                             ctx.vlan_proto = skb->vlan_proto;
> +                             ctx.vlan_present = skb->vlan_present;
> +                     }

are you suggesting to have vlan* fields that only work properly for skb case?
It means that progs/bpf_flow.c would not work as-is for eth_get_headlen.
And to have unified program that works in both cases the program would need to 
rely
on above internal implementation detail, like checking that ctx->protocol == 0 ?
imo that is worse than having two different flow dissector program types.

May be remove protocol and vlan* from ctx ?
Then the only thing program can do is look at the packet data which is
eth_get_headlen use case. For skb case the existence of vlan can be retrofitted 
into
dissector results by the kernel after the program finished.

Reply via email to