liberps

Linux

erpsd on Linux bridges

erpsd runs one or more ERP instances on Linux software bridges. erpsctl sends it commands over a Unix socket.

Dataplane model

FunctionHow erpsd does it
Ring portsTwo ports of the same bridge, which must have vlan_filtering enabled (checked over rtnetlink)
Blocking a port (§9.4)Remove the instance's protected VIDs from the port's bridge VLAN membership; unblocking adds them back as tagged members
R-APS (§9.5)The R-APS VLAN is not configured on the bridge. A packet socket per ring port with a BPF filter for 01-19-A7-00-00-xx receives R-APS, recovering the VLAN tag from PACKET_AUXDATA; the core forwards it between ring ports in software
FDB flush (§9.6)Netlink bulk delete of dynamic entries per ring port and protected VID (kernel 6.0 and later), with a dump-and-delete fallback
Signal failThe port is down or has no carrier (IFF_UP and IFF_LOWER_UP), tracked through rtnetlink link events
Event loopepoll over the packet sockets, rtnetlink, a timerfd armed to the earliest deadline, a signalfd and the control socket

It needs CAP_NET_RAW for the packet sockets and CAP_NET_ADMIN for VLAN and FDB changes.

Set up a node

ip link add name br0 type bridge vlan_filtering 1
ip link set ring0 master br0
ip link set ring1 master br0
bridge vlan add dev ring0 vid 10
bridge vlan add dev ring1 vid 10
ip link set br0 up; ip link set ring0 up; ip link set ring1 up

Add each protected VID as a tagged member on both ring ports, and remove VLAN 1 from them if it is not protected. Use the same ring ID and R-APS VID on every node of a ring, and a distinct node ID on each node. Do not give the same protected VID to two instances on the same port.

Configure and run

# /etc/erpsd.conf: one command per line
erps ring R1 ring-id 1 raps-vid 100 port0 ring0 port1 ring1
erps ring R1 node-id 02:00:00:00:00:01
erps ring R1 protected-vlans 10
erps ring R1 role owner rpl-port 1
erps ring R1 enable
erpsd -c /etc/erpsd.conf -s /run/erpsd.sock -l notice
erpsctl -s /run/erpsd.sock show erps summary json
erpsctl -s /run/erpsd.sock erps ring R1 force-switch port 0
erpsctl -s /run/erpsd.sock            # interactive, or a script on stdin
Options
-c configuration script (a failing line is reported by number), -s control socket (default /run/erpsd.sock, mode 0660), -l log level, -n leave VLAN membership as it is on exit.
Shutdown
On SIGINT or SIGTERM, erpsd removes protected VLANs from enabled ring ports by default, so no unprotected loop is left forwarding.
Node ID
Set it explicitly. With node-id auto the daemon uses the bridge's MAC when it can identify the bridge, otherwise the first non-loopback Ethernet MAC.

Control protocol

The control socket is a Unix stream socket. A client writes one command per line; the daemon replies with the command output followed by a trailer line made of the ASCII record separator (0x1E), the decimal result code and a newline. A connection may carry several commands. Requests are limited to 2048 bytes, and a client's pending output to 128 KiB.

Limits

End-to-end test

make e2e needs no root. It runs tests/linux/ring4.sh in a user, network and mount namespace with sysfs remounted, builds four VLAN-filtering bridges joined by veth pairs into a ring, and starts one erpsd per bridge. It then checks:

  1. Idle convergence, with VLAN 10 removed only at the two RPL ends
  2. Broadcast traffic crosses the ring without a storm
  3. A link failure leads to Protection with the RPL opened
  4. Recovery leads, after WTR, back to Idle
  5. No platform error on any node, and FDB flushes performed
  6. Every daemon exits 0 on SIGTERM, reports nothing under AddressSanitizer, and leaves its ring ports blocked