• K
    bpf: cpumap: Implement generic cpumap · 11941f8a
    Kumar Kartikeya Dwivedi 提交于
    This change implements CPUMAP redirect support for generic XDP programs.
    The idea is to reuse the cpu map entry's queue that is used to push
    native xdp frames for redirecting skb to a different CPU. This will
    match native XDP behavior (in that RPS is invoked again for packet
    reinjected into networking stack).
    
    To be able to determine whether the incoming skb is from the driver or
    cpumap, we reuse skb->redirected bit that skips generic XDP processing
    when it is set. To always make use of this, CONFIG_NET_REDIRECT guard on
    it has been lifted and it is always available.
    
    >From the redirect side, we add the skb to ptr_ring with its lowest bit
    set to 1.  This should be safe as skb is not 1-byte aligned. This allows
    kthread to discern between xdp_frames and sk_buff. On consumption of the
    ptr_ring item, the lowest bit is unset.
    
    In the end, the skb is simply added to the list that kthread is anyway
    going to maintain for xdp_frames converted to skb, and then received
    again by using netif_receive_skb_list.
    
    Bulking optimization for generic cpumap is left as an exercise for a
    future patch for now.
    
    Since cpumap entry progs are now supported, also remove check in
    generic_xdp_install for the cpumap.
    Signed-off-by: NKumar Kartikeya Dwivedi <memxor@gmail.com>
    Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
    Reviewed-by: NToke Høiland-Jørgensen <toke@redhat.com>
    Acked-by: NJesper Dangaard Brouer <brouer@redhat.com>
    Link: https://lore.kernel.org/bpf/20210702111825.491065-4-memxor@gmail.com
    11941f8a
skbuff.h 133.1 KB