gamemann / XDP-Firewall

A firewall that utilizes the Linux kernel's XDP hook. The XDP hook allows for very fast network processing on Linux systems. This is great for dropping malicious traffic from a (D)DoS attack. IPv6 is supported with this firewall! I hope this helps network engineers/programmers interested in utilizing XDP!
https://deaconn.net/
MIT License
545 stars 92 forks source link

How to check for stats #31

Closed ReshiramZekrom1 closed 1 year ago

ReshiramZekrom1 commented 1 year ago

Hello, thank you really much for this great work.

I'm sorry for the newbie question, but I was wondering how could I display how many packets the firewall either dropped or accepted.

Tried to run cat /proc/<pID>/fd/1 but it returns "No such device or address"

Do you have any drifts? Thanks

gamemann commented 1 year ago

Hey!

The program should output stats in stdout by default unless if you specify the --nostats argument. I'm not sure why the stdout file descriptor is invalid.

If you want to find stats on the file system, you may look at the /sys/class/net/<interface name>/statistics/ directory (e.g. rx_dropped for incoming dropped packets). You may also use ethtool -S <interface> as well if ethtool is installed. The following is an example from my VM.

➜  build git:(main) sudo ethtool -S enp1s0 
NIC statistics:
     rx_queue_0_packets: 8436611
     rx_queue_0_bytes: 4476286219
     rx_queue_0_drops: 0
     rx_queue_0_xdp_packets: 2480
     rx_queue_0_xdp_tx: 0
     rx_queue_0_xdp_redirects: 0
     rx_queue_0_xdp_drops: 0
     rx_queue_0_kicks: 134
     tx_queue_0_packets: 5272491
     tx_queue_0_bytes: 5331752464
     tx_queue_0_xdp_tx: 0
     tx_queue_0_xdp_tx_drops: 0
     tx_queue_0_kicks: 5030536

You can see XDP-specific stats here.

I hope this helps :smiley:

ReshiramZekrom1 commented 1 year ago

That's great! Thank you really much for the detailed comment!

gamemann commented 1 year ago

You're welcome and glad that helped! :smiley:

I'm going to close this issue for now, but if you have any other questions, feel free to reopen it.