From: akoshibe Date: Thu, 9 Aug 2018 03:35:19 +0000 (+0000) Subject: Currently, attempting to move an immovable lo(4) to a new rdomain will fail X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=060157415d5f0558d2a599bcd4ad9c3bcfe5d570;p=openbsd Currently, attempting to move an immovable lo(4) to a new rdomain will fail with an EPERM, but the target rdomain will still be created. Move the check for an lo(4)'s if_index/if_rdomain to before the creation of a nonexisting target routing table. ok benno@ claudio@ mpi@ --- diff --git a/sys/net/if.c b/sys/net/if.c index e6546dff224..7097eb278ef 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.558 2018/07/11 09:08:21 henning Exp $ */ +/* $OpenBSD: if.c,v 1.559 2018/08/09 03:35:19 akoshibe Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1743,6 +1743,10 @@ if_setrdomain(struct ifnet *ifp, int rdomain) 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 rdomain) 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.