Hi,
I noticed that if you try to move an immovable lo(4) to a nonexistent rdomain,
a new routing table will be created despite the operation failing with an
EPERM.
The following moves the rdomain/index check for lo(4) to before the creation
of a nonexisting target routing table.
OK?
Thanks,
Ayaka
Index: if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.558
diff -u -p -u -r1.558 if.c
--- if.c 11 Jul 2018 09:08:21 -0000 1.558
+++ if.c 6 Aug 2018 00:06:34 -0000
@@ -1743,6 +1743,10 @@ if_setrdomain(struct ifnet *ifp, int rdo
if (rdomain < 0 || rdomain > RT_TABLEID_MAX)
return (EINVAL);
+ if ((ifp->if_flags & IFF_LOOPBACK) &&
+ (ifp->if_index == rtable_loindex(ifp->if_rdomain)))
+ return (EPERM);
+
/*
* Create the routing table if it does not exist, including its
* loopback interface with unit == rdomain.
@@ -1777,10 +1781,6 @@ if_setrdomain(struct ifnet *ifp, int rdo
return (EINVAL);
if (rdomain != ifp->if_rdomain) {
- if ((ifp->if_flags & IFF_LOOPBACK) &&
- (ifp->if_index == rtable_loindex(ifp->if_rdomain)))
- return (EPERM);
-
s = splnet();
/*
* We are tearing down the world.