rt_ifa_add() and rt_ifa_del() have a major confusion when it comes to
rtlabelid (as in labels on a route) vs rtableid (as in routing table id).
Because of this 'ifconfig <if> rtlabel XYZ' fails to add route labels to
the routing table.
The following diff fixes this issue.
To test:
ifconfig tap1001 rtlabel TEST
ifconfig tap1001 192.0.2.6/24
route -n get 192.0.2.1
--
:wq Claudio
Index: route.c
===================================================================
RCS file: /cvs/src/sys/net/route.c,v
retrieving revision 1.387
diff -u -p -r1.387 route.c
--- route.c 24 Jun 2019 22:26:25 -0000 1.387
+++ route.c 14 Aug 2019 17:57:07 -0000
@@ -1101,6 +1101,8 @@ rt_ifa_add(struct ifaddr *ifa, int flags
uint8_t prio = ifp->if_priority + RTP_STATIC;
int error;
+ KASSERT(rdomain == rtable_l2(rdomain));
+
memset(&info, 0, sizeof(info));
info.rti_ifa = ifa;
info.rti_flags = flags;
@@ -1109,12 +1111,7 @@ rt_ifa_add(struct ifaddr *ifa, int flags
info.rti_info[RTAX_GATEWAY] = sdltosa(ifp->if_sadl);
else
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
-
- KASSERT(rdomain == rtable_l2(rdomain));
- if (rdomain == rtable_l2(ifp->if_rtlabelid)) {
- info.rti_info[RTAX_LABEL] =
- rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
- }
+ info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
#ifdef MPLS
if ((flags & RTF_MPLS) == RTF_MPLS)
@@ -1158,6 +1155,8 @@ rt_ifa_del(struct ifaddr *ifa, int flags
uint8_t prio = ifp->if_priority + RTP_STATIC;
int error;
+ KASSERT(rdomain == rtable_l2(rdomain));
+
if ((flags & RTF_HOST) == 0 && ifa->ifa_netmask) {
m = m_get(M_DONTWAIT, MT_SONAME);
if (m == NULL)
@@ -1173,11 +1172,7 @@ rt_ifa_del(struct ifaddr *ifa, int flags
info.rti_info[RTAX_DST] = dst;
if ((flags & RTF_LLINFO) == 0)
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
-
- if (rdomain == rtable_l2(ifp->if_rtlabelid)) {
- info.rti_info[RTAX_LABEL] =
- rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
- }
+ info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
if ((flags & RTF_HOST) == 0)
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;