Benjamin Cabé

Zephyr Weekly Update – Packet Filtering, UUIDs & More

Zephyr Weekly Update - Apr. 18, 2025

Zephyr Weekly Update - Apr. 18, 2025

Another week, another batch of updates and improvement being made to Zephyr, with over 140 merged pull requests!

Before diving into some of the highlights, I would encourage you to add the video recordings of the recent Zephyr Meetup Grenoble to your watchlist as there were quite a few interesting topics covered!

Network Packet Filtering Updates

It’s no secret that Zephyr’s networking stack is one of its great strengths. This week, some neat improvements to packet filtering have been introduced (PR #88544), including support for VLAN, statistics collection for number of packets affected by filters, a shell module, and more.

A new code sample is available and a great showcase for how you can leverage the Network Packet Filtering API (including the aforementioned improvements) to setup some filtering rules for e.g. implementing firewall functionality, network traffic control, etc.

For example, installing a filtering rule dropping any incoming packet larger than 200 bytes is as simple as:

static NPF_SIZE_MAX(maxsize_200, 200);
static NPF_ETH_TYPE_MATCH(ip_packet, NET_ETH_PTYPE_IP);

static NPF_RULE(small_ip_pkt, NET_OK, ip_packet, maxsize_200);

void install_my_filter(void)
{
    npf_insert_recv_rule(&npf_default_drop);
    npf_insert_recv_rule(&small_ip_pkt);
}

The code sample actually creates multiple VLAN networks, giving an opportunity to showcase rules that only apply to some interfaces. The net filter shell command also conveniently shows you a snapshot of which rules are in place.

uart:~$ net filter
Rule  Type        Verdict  Tests
[ 1]  recv        OK       3    eth vlan type[0x0800],size max[200],iface[2]
[ 2]  recv        OK       3    eth vlan type[0x0800],size min[100],iface[3]
[ 3]  recv        OK       1    iface[1]
[ 4]  recv        OK       2    eth vlan type[0x0806],iface[2]
[ 5]  recv        OK       2    eth vlan type[0x0806],iface[3]
[ 6]  recv        DROP     0

New UUID library

Generating and managing unique identifiers is crucial in many applications, and can be really useful to e.g. tag sensor data samples, generate session identifiers, etc. Thanks to @sorru94‘s work in PR #77884, Zephyr now includes a Universally Unique Identifier (UUID) utility library implemeting RFC 4122.

It provides functions for generating UUIDs (both v4 -random- and v5 -deterministic-), comparing them, and converting UUIDs between string and binary representations.

Check out the dedicated code sample for some code snippets.

New boards and SoCs

Drivers

Miscellaneous


A big thank you to the 4 individuals who had their first pull request accepted this week, 💙 🙌: @tiennguyenzg, @apni2, @tpambor, and @dhanquna.

As always, I very much welcome your thoughts and feedback in the comments below!

If you enjoyed this article, don’t forget to subscribe to this blog to be notified of upcoming publications! And of course, you can also always find me on Twitter and Mastodon.

Catch up on all previous issues of the Zephyr Weekly Update:

Exit mobile version