xdp-project / xdp-tutorial

XDP tutorial
2.44k stars 576 forks source link

packet03-assignment-04: packet have been redirect, xdp_stats have recored the redirect action, but the statistics of ethtool is wrong #424

Open daiminglong opened 4 months ago

daiminglong commented 4 months ago

case1: redirect to outside veth0(10.11.1.2) <----> test(10.11.1.1) <--xdp_route_fib_lookup_redirect--> eth1(9.134.119.213) <---> internet

case2: redirect to another namespace veth0(10.11.1.2) <----> test(10.11.1.1) <--xdp_route_fib_lookup_redirect--> test1(10.11.2.1) <---> veth0(10.11.2.2)

result: case2 ping 10.11.2.2 is success case1 ping 183.2.172.42(i'm sure about that the route is reachable and can be ping successful from outside ns)failed with stats like below: [root@xxxxx]# ./xdp_stats -d test XDP-action XDP_ABORTED 0 pkts ( 0 pps) 0 Kbytes ( 0 Mbits/s) period:0.250111 XDP_DROP 0 pkts ( 0 pps) 0 Kbytes ( 0 Mbits/s) period:0.250084 XDP_PASS 0 pkts ( 0 pps) 0 Kbytes ( 0 Mbits/s) period:0.250084 XDP_TX 0 pkts ( 0 pps) 0 Kbytes ( 0 Mbits/s) period:0.250084 XDP_REDIRECT 26 pkts ( 0 pps) 2 Kbytes ( 0 Mbits/s) period:0.250084

[root@xxx]# ethtool -S test NIC statistics: peer_ifindex: 2 rx_queue_0_xdp_packets: 207 rx_queue_0_xdp_bytes: 17388 rx_queue_0_xdp_drops: 146 ???????

the xdp_stats record my pkt is redirect successed, but the interface statistics showed that the packet is dropped by xdp? can anybody help with this, thankyou :) @aspsk

ncshy commented 2 months ago

Can you verify if your redirected packet has the correct MAC addresses, by verifying that fib_params.dmac and fib_params.smac correspond to your gateway (route -n) and ARP table entry for your gateway device(arp -n).