• D
    bpf: support for access to tunnel options · 14ca0751
    Daniel Borkmann 提交于
    After eBPF being able to programmatically access/manage tunnel key meta
    data via commit d3aa45ce ("bpf: add helpers to access tunnel metadata")
    and more recently also for IPv6 through c6c33454 ("bpf: support ipv6
    for bpf_skb_{set,get}_tunnel_key"), this work adds two complementary
    helpers to generically access their auxiliary tunnel options.
    
    Geneve and vxlan support this facility. For geneve, TLVs can be pushed,
    and for the vxlan case its GBP extension. I.e. setting tunnel key for geneve
    case only makes sense, if we can also read/write TLVs into it. In the GBP
    case, it provides the flexibility to easily map the group policy ID in
    combination with other helpers or maps.
    
    I chose to model this as two separate helpers, bpf_skb_{set,get}_tunnel_opt(),
    for a couple of reasons. bpf_skb_{set,get}_tunnel_key() is already rather
    complex by itself, and there may be cases for tunnel key backends where
    tunnel options are not always needed. If we would have integrated this
    into bpf_skb_{set,get}_tunnel_key() nevertheless, we are very limited with
    remaining helper arguments, so keeping compatibility on structs in case of
    passing in a flat buffer gets more cumbersome. Separating both also allows
    for more flexibility and future extensibility, f.e. options could be fed
    directly from a map, etc.
    
    Moreover, change geneve's xmit path to test only for info->options_len
    instead of TUNNEL_GENEVE_OPT flag. This makes it more consistent with vxlan's
    xmit path and allows for avoiding to specify a protocol flag in the API on
    xmit, so it can be protocol agnostic. Having info->options_len is enough
    information that is needed. Tested with vxlan and geneve.
    Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
    Acked-by: NAlexei Starovoitov <ast@kernel.org>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    14ca0751
bpf.h 10.5 KB