• Paul Chaignon's avatar
    selftests/bpf: Don't assign outer source IP to host · 1115169f
    Paul Chaignon authored
    The previous commit fixed a bug in the bpf_skb_set_tunnel_key helper to
    avoid dropping packets whose outer source IP address isn't assigned to a
    host interface. This commit changes the corresponding selftest to not
    assign the outer source IP address to an interface.
    
    Not assigning the source IP to an interface causes two issues in the
    existing test:
    
    1. The ARP requests will fail for that IP address so we need to add the
       ARP entry manually.
    2. The encapsulated ICMP echo reply traffic will not reach the VXLAN
       device. It will be dropped by the stack before, because the
       outer destination IP is unknown.
    
    To solve 2., we have two choices. Either we perform decapsulation
    ourselves in a BPF program attached at veth1 (the base device for the
    VXLAN device), or we switch the outer destination address when we
    receive the packet at veth1, such that the stack properly demultiplexes
    it to the VXLAN device afterward.
    
    This commit implements the second approach, where we switch the outer
    destination address from the unassigned IP address to the assigned one,
    only for VXLAN traffic ingressing veth1.
    
    Then, at the vxlan device, the BPF program that checks the output of
    bpf_skb_get_tunnel_key needs to be updated as the expected local IP
    address is now the unassigned one.
    Signed-off-by: default avatarPaul Chaignon <paul@isovalent.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/4addde76eaf3477a58975bef15ed2788c44e5f55.1658759380.git.paul@isovalent.com
    1115169f
test_tunnel.c 13 KB