# Xdp\_filter - suricata

**URL:** <https://forum.suricata.io/t/xdp-filter-suricata/3137>\
**Category:** Help\
**Tags:** suricata, xdp\
**Created:** [January 17, 2023, 11:18am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137 "2023-01-17T11:18:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozgur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/ozgur/32/1977_2.png) [@ozgur](https://forum.suricata.io/u/ozgur)\
**Post date:** [January 17, 2023, 11:18am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/1 "2023-01-17T11:18:13Z")

</div>

Hi everyone,  
I am working xdp\_filter with suricata. I added rule about to drop icmp packets. This is af-packet section in suricata.yaml:  
af-packet:

- interface: wlp0s20f3  
#Number of receive threads. “auto” uses the number of cores  
#threads: auto  
#Default clusterid. AF\_PACKET will load balance packets based on flow.  
cluster-id: 99  
cluster-type: cluster\_cpu  
defrag: yes  
xdp-mode: soft  
xdp-filter-file: /home/ozgurkeskin/Projects/suricata/ebpf/xdp\_filter.bpf  
xdp-cpu-redirect: [“all”]  
bypass: yes  
use-mmap: yes  
ring-size: 200000

When I started ping to 8.8.8.8 suricata can not drop icmp packets. Any help would be great!  
Best regards,

---

<div class="post-metadata">

**Author:** ![pevma](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/pevma/32/29_2.png) [@pevma](https://forum.suricata.io/u/pevma)\
**Post date:** [January 17, 2023, 2:00pm UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/2 "2023-01-17T14:00:34Z")

</div>

Hi,  
Any error during Suricata start? What does the filter bpf do actually?

---

<div class="post-metadata">

**Author:** ![ozgur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/ozgur/32/1977_2.png) [@ozgur](https://forum.suricata.io/u/ozgur)\
**Post date:** [January 18, 2023, 7:19am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/3 "2023-01-18T07:19:26Z")

</div>

Hi Peter,  
I didn’t face any error message during Suricata start. I checked logs it seem fine.  
xdp\_filter aims “XDP bypass allows Suricata to tell the kernel that packets for some flows have to be dropped via the XDP mechanism. This is an early drop that occurs before the datagram reaches the Linux kernel network stack.”

---

<div class="post-metadata">

**Author:** ![Andreas\_Herz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/andreas_herz/32/52_2.png) [@Andreas\_Herz](https://forum.suricata.io/u/Andreas_Herz)\
**Post date:** [January 18, 2023, 2:28pm UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/4 "2023-01-18T14:28:24Z")

</div>

What version are you running?  
How does your suricata.yaml look like?  
How do you start suricata?

---

<div class="post-metadata">

**Author:** ![ozgur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/ozgur/32/1977_2.png) [@ozgur](https://forum.suricata.io/u/ozgur)\
**Post date:** [January 19, 2023, 7:33am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/5 "2023-01-19T07:33:17Z")

</div>

Hi Andreas,  
This is Suricata version 7.0.0-rc1-dev (4c7ca2c36 2022-12-22)  
Run command  
/usr/bin/suricata -c /home/ozgurkeskin/Projects/suricata/suricata.yaml --pidfile /var/run/suricata.pid --af-packet=wlp0s20f3 -vvv  
And I attached suricata.yaml.  
[suricata.yaml](https://forum.suricata.io/uploads/short-url/bNM1GzIikrMlxYCeUlnbEcc6jh5.yaml) (79.7 KB)

---

<div class="post-metadata">

**Author:** ![Andreas\_Herz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/andreas_herz/32/52_2.png) [@Andreas\_Herz](https://forum.suricata.io/u/Andreas_Herz)\
**Post date:** [January 24, 2023, 2:51pm UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/6 "2023-01-24T14:51:58Z")

</div>

Did you update the `xdp_filter.bpf` file or did you use a shipped one?

---

<div class="post-metadata">

**Author:** ![ozgur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/ozgur/32/1977_2.png) [@ozgur](https://forum.suricata.io/u/ozgur)\
**Post date:** [January 25, 2023, 6:30am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/7 "2023-01-25T06:30:59Z")

</div>

I used shipped one but I have to update maps declaration.Here is the link about problem.

> **[Libbpf: the road to v1.0](https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#drop-support-for-legacy-bpf-map-declaration-syntax)**
>
> Automated upstream mirror for libbpf stand-alone build. - libbpf/libbpf

---

<div class="post-metadata">

**Author:** ![ozgur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/ozgur/32/1977_2.png) [@ozgur](https://forum.suricata.io/u/ozgur)\
**Post date:** [May 31, 2023, 10:38am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/8 "2023-05-31T10:38:42Z")

</div>

Hi Andreas, is there any update about my issue?

---

<div class="post-metadata">

**Author:** ![Andreas\_Herz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/andreas_herz/32/52_2.png) [@Andreas\_Herz](https://forum.suricata.io/u/Andreas_Herz)\
**Post date:** [May 31, 2023, 11:33am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/9 "2023-05-31T11:33:54Z")

</div>

Yes see [Libbpf 1.x with Suricata 6 doesn't support XDP - #6 by Loathe](https://forum.suricata.io/t/libbpf-1-x-with-suricata-6-doesnt-support-xdp/3526/6) and also [Bug #6088: xdp/ebpf: updated shipped bpf files to be supported by libbpf v1.0 and higher - Suricata - Open Information Security Foundation](https://redmine.openinfosecfoundation.org/issues/6088) so it needs to be updated to make it work, which is not done yet

---

<div class="post-metadata">

**Author:** ![ozgur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/ozgur/32/1977_2.png) [@ozgur](https://forum.suricata.io/u/ozgur)\
**Post date:** [May 31, 2023, 12:15pm UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/10 "2023-05-31T12:15:15Z")

</div>

Hi Andreas

I did this refactor about legacy map definitions and then builded ebpf files again. Start suricata with no error. When I entered drop rule in suritaca.rules file in order to drop all icmp trafic it is not working.

---

<div class="post-metadata">

**Author:** ![Loathe](https://avatars.discourse-cdn.com/v4/letter/l/aca169/32.png) [@Loathe](https://forum.suricata.io/u/Loathe)\
**Post date:** [June 1, 2023, 7:00am UTC](https://forum.suricata.io/t/xdp-filter-suricata/3137/11 "2023-06-01T07:00:07Z")

</div>

Hello, it seems you are using Suricata as IPS. In this mode official docs tells you should use 2 interfaces like router or firewall, one for incoming traffic and one for outgoing. To make this work you should also set ipv[4 or 6].ip\_forward to 1 in your system (sysctl -a | grep forward can help to find it). And then add symmetric parameters in your af-packet section for both interfaces:  
af-packet:

- interface: eth0  
copy-mode: ips  
copy-iface: eth1

- interface: eth1  
copy-mode: ips  
copy-iface: eth0  
I have not tested it myself, cause we use Suricata as IDS, but official docs says it ([13. Setting up IPS/inline for Linux — Suricata 6.0.12 documentation](https://docs.suricata.io/en/suricata-6.0.12/setting-up-ipsinline-for-linux.html#settings-up-ips-at-layer-2))
