[CALL FOR TESTING] PREFSRC Route Attribute Support
Date: Wed, 22 Jul 2026 18:32:33 UTC
Hi,
Feature TL;DR:
This attribute add the ability/fixes some problems with:
- IPv4 routes sourced from loopback
- IPv6 routes with explicit source
- IPv4-over-IPv6 nexthop cases
- PPPoE / unnumbered tunnel/interface cases
- Netlink consumers like BIRD passing krt_prefsrc
I've added support for the prefsrc (preferred source) route attribute in
FreeBSD's routing stack. This allows a route to specify the source IP
address used for outgoing packets, even when that address is configured
on a different interface.
This should help with "ip unnumbered" interface setups and
IPv4-over-IPv6 routing, where source selection has traditionally been
awkward. In particular, it avoids the need to duplicate the same address
across multiple interfaces just to influence source address selection.
Previously, FreeBSD often required a loopback address and per-interface
address assignments for traffic to route correctly. In some modern
setups, this led to 0.0.0.0 being selected unless an address was
manually duplicated on both lo0 and the egress interface. This is also
disallowed by multiple RFCs.
The implementation includes:
- D58294 netlink: Add RTA_PREFSRC support
- D58326 routing: Add tests for the prefsrc route attribute
- D58300 rtnetlink.4: Add RTA_PREFSRC documentation
I'm looking for feedback and testing across different scenarios.
Example:
```
ifconfig lo0 inet 172.23.1.101/32 alias
route -n4 add 172.23.1.0/24 -inet6 -gateway
fe80::5a9c:fcff:fe10:b89%vtnet0 -prefsrc 172.23.1.101
```
Verify with tcpdump that outgoing packets use `172.23.1.101` as source:
```
172.23.1.101 > 172.23.1.1: ICMP echo request, id 18696, seq 0, length 64
```
test suite (D58326):
```
kyua test -k /usr/tests/Kyuafile sys/net/routing/test_routing
```
Please also test these configurations, which are not covered by the kyua
tests if possible:
- PPPoE tunnels: test unnumbered PPPoE interfaces sourcing traffic from
loopback.
- Netlink integration: confirm routes created via netlink properly
exchange prefsrc via RTA_PREFSRC.
This can be tested manually with BIRD:
```
protocol static {
ipv6;
route 2001:db8::/32 via 2a00:1098:6b:401::11 {
krt_prefsrc = 2001:db8::10;
};
}
```
or
```
protocol ospf v3 testing_ospf {
ipv6 {
import filter {
krt_prefsrc = 2001:db8:abc::1;
...
```
Thanks for testing!
--
Pouria