mirror of
https://git.FreeBSD.org/src.git
synced 2026-06-02 11:24:32 +00:00
netlink/route: extend pre-2.6.19 Linux compat shim to del/getroute
Commit f34aca55ad ("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
This commit is contained in:
+11
-3
@@ -978,6 +978,14 @@ create_nexthop_from_attrs(struct nl_parsed_route *attrs,
|
|||||||
return (nh);
|
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
|
static int
|
||||||
rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
|
rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
|
||||||
struct nl_pstate *npt)
|
struct nl_pstate *npt)
|
||||||
@@ -997,9 +1005,7 @@ rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
|
|||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pre-2.6.19 Linux API compatibility */
|
old_linux_compat(&attrs);
|
||||||
if (attrs.rtm_table > 0 && attrs.rta_table == 0)
|
|
||||||
attrs.rta_table = attrs.rtm_table;
|
|
||||||
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
|
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
|
||||||
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
|
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
@@ -1066,6 +1072,7 @@ rtnl_handle_delroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
|
|||||||
return (ESRCH);
|
return (ESRCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
old_linux_compat(&attrs);
|
||||||
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
|
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
|
||||||
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
|
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
@@ -1089,6 +1096,7 @@ rtnl_handle_getroute(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *
|
|||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
old_linux_compat(&attrs);
|
||||||
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
|
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
|
||||||
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
|
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|||||||
Reference in New Issue
Block a user