Index: route.c =================================================================== RCS file: /cvs/src/sys/net/route.c,v retrieving revision 1.379 diff -u -p -r1.379 route.c --- route.c 23 Nov 2018 16:24:11 -0000 1.379 +++ route.c 31 Jan 2019 03:00:37 -0000 @@ -1032,17 +1032,24 @@ rt_maskedcopy(struct sockaddr *src, stru int rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst) { + return (rt_ifa_add_rdomain(ifa, flags | RTF_MPATH, dst, + ifa->ifa_ifp->if_rdomain)); +} + +int +rt_ifa_add_rdomain(struct ifaddr *ifa, int flags, struct sockaddr *dst, + unsigned int rtableid) +{ struct ifnet *ifp = ifa->ifa_ifp; struct rtentry *rt; struct sockaddr_rtlabel sa_rl; struct rt_addrinfo info; - unsigned int rtableid = ifp->if_rdomain; uint8_t prio = ifp->if_priority + RTP_STATIC; int error; memset(&info, 0, sizeof(info)); info.rti_ifa = ifa; - info.rti_flags = flags | RTF_MPATH; + info.rti_flags = flags; info.rti_info[RTAX_DST] = dst; if (flags & RTF_LLINFO) info.rti_info[RTAX_GATEWAY] = sdltosa(ifp->if_sadl); @@ -1051,11 +1058,8 @@ rt_ifa_add(struct ifaddr *ifa, int flags info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl); #ifdef MPLS - if ((flags & RTF_MPLS) == RTF_MPLS) { + if ((flags & RTF_MPLS) == RTF_MPLS) info.rti_mpls = MPLS_OP_POP; - /* MPLS routes only exist in rdomain 0 */ - rtableid = 0; - } #endif /* MPLS */ if ((flags & RTF_HOST) == 0) @@ -1085,21 +1089,22 @@ rt_ifa_add(struct ifaddr *ifa, int flags int rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst) { + return (rt_ifa_del_rdomain(ifa, flags, dst, + ifa->ifa_ifp->if_rdomain)); +} + +int +rt_ifa_del_rdomain(struct ifaddr *ifa, int flags, struct sockaddr *dst, + unsigned int rtableid) +{ struct ifnet *ifp = ifa->ifa_ifp; struct rtentry *rt; struct mbuf *m = NULL; struct sockaddr *deldst; struct rt_addrinfo info; struct sockaddr_rtlabel sa_rl; - unsigned int rtableid = ifp->if_rdomain; uint8_t prio = ifp->if_priority + RTP_STATIC; int error; - -#ifdef MPLS - if ((flags & RTF_MPLS) == RTF_MPLS) - /* MPLS routes only exist in rdomain 0 */ - rtableid = 0; -#endif /* MPLS */ if ((flags & RTF_HOST) == 0 && ifa->ifa_netmask) { m = m_get(M_DONTWAIT, MT_SONAME); Index: route.h =================================================================== RCS file: /cvs/src/sys/net/route.h,v retrieving revision 1.173 diff -u -p -r1.173 route.h --- route.h 12 Nov 2018 16:36:54 -0000 1.173 +++ route.h 31 Jan 2019 03:00:37 -0000 @@ -456,7 +456,11 @@ void rtref(struct rtentry *); void rtfree(struct rtentry *); int rt_ifa_add(struct ifaddr *, int, struct sockaddr *); +int rt_ifa_add_rdomain(struct ifaddr *, int, struct sockaddr *, + unsigned int); int rt_ifa_del(struct ifaddr *, int, struct sockaddr *); +int rt_ifa_del_rdomain(struct ifaddr *, int, struct sockaddr *, + unsigned int); void rt_ifa_purge(struct ifaddr *); int rt_ifa_addlocal(struct ifaddr *); int rt_ifa_dellocal(struct ifaddr *); Index: if_mpe.c =================================================================== RCS file: /cvs/src/sys/net/if_mpe.c,v retrieving revision 1.77 diff -u -p -r1.77 if_mpe.c --- if_mpe.c 31 Jan 2019 02:00:27 -0000 1.77 +++ if_mpe.c 31 Jan 2019 03:00:37 -0000 @@ -133,8 +133,8 @@ mpe_clone_destroy(struct ifnet *ifp) LIST_REMOVE(sc, sc_list); if (sc->sc_smpls.smpls_label) { - rt_ifa_del(&sc->sc_ifa, RTF_MPLS, - smplstosa(&sc->sc_smpls)); + rt_ifa_del_rdomain(&sc->sc_ifa, RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); } if_detach(ifp); @@ -329,13 +329,13 @@ mpe_ioctl(struct ifnet *ifp, u_long cmd, break; if (sc->sc_smpls.smpls_label) { /* remove old MPLS route */ - rt_ifa_del(&sc->sc_ifa, RTF_MPLS, - smplstosa(&sc->sc_smpls)); + rt_ifa_del_rdomain(&sc->sc_ifa, RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); } /* add new MPLS route */ sc->sc_smpls.smpls_label = shim.shim_label; - error = rt_ifa_add(&sc->sc_ifa, RTF_MPLS|RTF_LOCAL, - smplstosa(&sc->sc_smpls)); + error = rt_ifa_add_rdomain(&sc->sc_ifa, RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); if (error) { sc->sc_smpls.smpls_label = 0; break; @@ -346,8 +346,9 @@ mpe_ioctl(struct ifnet *ifp, u_long cmd, /* XXX does not make sense, the MPLS route is on rtable 0 */ if (ifr->ifr_rdomainid != ifp->if_rdomain) { if (sc->sc_smpls.smpls_label) { - rt_ifa_add(&sc->sc_ifa, RTF_MPLS, - smplstosa(&sc->sc_smpls)); + rt_ifa_add_rdomain(&sc->sc_ifa, + RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); } } /* return with ENOTTY so that the parent handler finishes */ Index: if_mpw.c =================================================================== RCS file: /cvs/src/sys/net/if_mpw.c,v retrieving revision 1.31 diff -u -p -r1.31 if_mpw.c --- if_mpw.c 30 Jan 2019 01:09:36 -0000 1.31 +++ if_mpw.c 31 Jan 2019 03:00:37 -0000 @@ -116,8 +116,8 @@ mpw_clone_destroy(struct ifnet *ifp) ifp->if_flags &= ~IFF_RUNNING; if (sc->sc_smpls.smpls_label) { - rt_ifa_del(&sc->sc_ifa, RTF_MPLS, - smplstosa(&sc->sc_smpls)); + rt_ifa_del_rdomain(&sc->sc_ifa, RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); } ether_ifdetach(ifp); @@ -162,9 +162,9 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd, /* Teardown all configuration if got no nexthop */ sin = (struct sockaddr_in *) &imr.imr_nexthop; if (sin->sin_addr.s_addr == 0) { - if (rt_ifa_del(&sc->sc_ifa, RTF_MPLS, - smplstosa(&sc->sc_smpls)) == 0) - sc->sc_smpls.smpls_label = 0; + rt_ifa_del_rdomain(&sc->sc_ifa, RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); + sc->sc_smpls.smpls_label = 0; memset(&sc->sc_rshim, 0, sizeof(sc->sc_rshim)); memset(&sc->sc_nexthop, 0, sizeof(sc->sc_nexthop)); @@ -190,13 +190,16 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd, MPLS_LABEL2SHIM(imr.imr_rshim.shim_label); if (sc->sc_smpls.smpls_label != imr.imr_lshim.shim_label) { - if (sc->sc_smpls.smpls_label) - rt_ifa_del(&sc->sc_ifa, RTF_MPLS, - smplstosa(&sc->sc_smpls)); + if (sc->sc_smpls.smpls_label) { + rt_ifa_del_rdomain(&sc->sc_ifa, + RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); + } sc->sc_smpls.smpls_label = imr.imr_lshim.shim_label; - error = rt_ifa_add(&sc->sc_ifa, RTF_MPLS|RTF_LOCAL, - smplstosa(&sc->sc_smpls)); + error = rt_ifa_add_rdomain(&sc->sc_ifa, + RTF_MPLS | RTF_LOCAL, + smplstosa(&sc->sc_smpls), 0); if (error != 0) { sc->sc_smpls.smpls_label = 0; break;