• Gokul Sivakumar's avatar
    samples: bpf: Convert ARP table network order fields into readable format · cf8980a3
    Gokul Sivakumar authored
    The ARP table that is dumped when the xdp_router_ipv4 process is launched
    has the IP address & MAC address in non-readable network byte order format,
    also the alignment is off when printing the table.
    
    Address HwAddress
    160000e0                1600005e0001
    ff96a8c0                ffffffffffff
    faffffef                faff7f5e0001
    196a8c0		9607871293ea
    fb0000e0                fb00005e0001
    0               0
    196a8c0		9607871293ea
    ffff11ac                ffffffffffff
    faffffef                faff7f5e0001
    fb0000e0                fb00005e0001
    160000e0                1600005e0001
    160000e0                1600005e0001
    faffffef                faff7f5e0001
    fb0000e0                fb00005e0001
    40011ac         40011ac4202
    
    Fix this by converting the "Address" field from network byte order Hex into
    dotted decimal notation IPv4 format and "HwAddress" field from network byte
    order Hex into Colon separated Hex format. Also fix the aligntment of the
    fields in the ARP table.
    
    Address         HwAddress
    224.0.0.22      01:00:5e:00:00:16
    192.168.150.255 ff:ff:ff:ff:ff:ff
    239.255.255.250 01:00:5e:7f:ff:fa
    192.168.150.1	ea:93:12:87:07:96
    224.0.0.251     01:00:5e:00:00:fb
    0.0.0.0         00:00:00:00:00:00
    192.168.150.1	ea:93:12:87:07:96
    172.17.255.255  ff:ff:ff:ff:ff:ff
    239.255.255.250 01:00:5e:7f:ff:fa
    224.0.0.251     01:00:5e:00:00:fb
    224.0.0.22      01:00:5e:00:00:16
    224.0.0.22      01:00:5e:00:00:16
    239.255.255.250 01:00:5e:7f:ff:fa
    224.0.0.251     01:00:5e:00:00:fb
    172.17.0.4      02:42:ac:11:00:04
    Signed-off-by: default avatarGokul Sivakumar <gokulkumar792@gmail.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20210919080305.173588-2-gokulkumar792@gmail.com
    cf8980a3
xdp_router_ipv4_user.c 18.6 KB