Search code examples
linux-kernelxdp-bpf

Xdp how to determine traffic direction?


How do I know inside the xdp function whether a packet is incoming or outgoing? I want to handle only outgoing packets, but I can't find how to identify them.

Command example:

ip link set eth1 xdpgeneric obj ebpf.o sec entry

Solution

  • XDP does not support outgoing packets at this time, so your program will only get incoming packets.

    If you want to process outgoing packets with eBPF, you may want to look into attaching programs to a TC classifier instead of the XDP hook.