git: e492ad08fc34 - main - netlink/route: extend pre-2.6.19 Linux compat shim to del/getroute
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 29 May 2026 23:24:32 UTC
The branch main has been updated by olivier:
URL: https://cgit.FreeBSD.org/src/commit/?id=e492ad08fc347ebf40979d3a6baa9d7b8917c76b
commit e492ad08fc347ebf40979d3a6baa9d7b8917c76b
Author: Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-05-29 23:17:28 +0000
Commit: Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-05-29 23:23:12 +0000
netlink/route: extend pre-2.6.19 Linux compat shim to del/getroute
Commit f34aca55adef ("netlink/route: provide pre-2.6.19 Linux compat shim",
2024-06) fixed the partial fix for net/bird2 on the netlink path by mapping the
legacy 8-bit struct rtmsg::rtm_table field onto the modern 32-bit RTA_TABLE
attribute when the latter is absent.
That fix, however, was only applied to rtnl_handle_newroute. The two sibling
handlers: rtnl_handle_delroute and rtnl_handle_getroute were left looking at
attrs.rta_table directly. They are reachable from exactly the same client
(bird, in its netlink scan path), so any FIB number that fits in 8 bits
silently maps to RT_TABLE_UNSPEC in those handlers.
Reviewed by: melifaro (previous version)
Approved by: emaste
MFC after: 1 week
Sponsored by: Netflix
---
sys/netlink/route/rt.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c
index 17aae399c10a..39ecb537d365 100644
--- a/sys/netlink/route/rt.c
+++ b/sys/netlink/route/rt.c
@@ -978,6 +978,14 @@ create_nexthop_from_attrs(struct nl_parsed_route *attrs,
return (nh);
}
+/* pre-2.6.19 Linux API compatibility: prefer RTA_TABLE, fall back to rtm_table */
+static inline void
+old_linux_compat(struct nl_parsed_route *attrs)
+{
+ if (attrs->rtm_table > 0 && attrs->rta_table == 0)
+ attrs->rta_table = attrs->rtm_table;
+}
+
static int
rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
struct nl_pstate *npt)
@@ -997,9 +1005,7 @@ rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
return (EINVAL);
}
- /* pre-2.6.19 Linux API compatibility */
- if (attrs.rtm_table > 0 && attrs.rta_table == 0)
- attrs.rta_table = attrs.rtm_table;
+ old_linux_compat(&attrs);
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
@@ -1066,6 +1072,7 @@ rtnl_handle_delroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
return (ESRCH);
}
+ old_linux_compat(&attrs);
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
@@ -1089,6 +1096,7 @@ rtnl_handle_getroute(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *
if (error != 0)
return (error);
+ old_linux_compat(&attrs);
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);