summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryasuoka <yasuoka@openbsd.org>2017-02-28 15:35:02 +0000
committeryasuoka <yasuoka@openbsd.org>2017-02-28 15:35:02 +0000
commit70d12234cdfdc4e6a2f7c1a4061e1ca06fc3c886 (patch)
treea5531c1f8087010b17d17e729b72a4729f7aee17
parentsync (diff)
downloadwireguard-openbsd-70d12234cdfdc4e6a2f7c1a4061e1ca06fc3c886.tar.xz
wireguard-openbsd-70d12234cdfdc4e6a2f7c1a4061e1ca06fc3c886.zip
Don't change the up status of the interface when changing its rdomain.
Diff from nagasaka@iij. ok mpi
-rw-r--r--sys/net/if.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index fca93c28534..6a5d41f7a93 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.487 2017/02/16 10:15:12 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.488 2017/02/28 15:35:02 yasuoka Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -1707,7 +1707,7 @@ int
if_setrdomain(struct ifnet *ifp, int rdomain)
{
struct ifreq ifr;
- int error;
+ int error, up = 0, s;
if (rdomain < 0 || rdomain > RT_TABLEID_MAX)
return (EINVAL);
@@ -1748,8 +1748,6 @@ if_setrdomain(struct ifnet *ifp, int rdomain)
/* remove all routing entries when switching domains */
/* XXX this is a bit ugly */
if (rdomain != ifp->if_rdomain) {
- int s;
-
s = splnet();
/*
* We are tearing down the world.
@@ -1757,8 +1755,10 @@ if_setrdomain(struct ifnet *ifp, int rdomain)
* 1. everything that cares gets a message
* 2. the automagic IPv6 bits are recreated
*/
- if (ifp->if_flags & IFF_UP)
+ if (ifp->if_flags & IFF_UP) {
+ up = 1;
if_down(ifp);
+ }
rti_delete(ifp);
#ifdef MROUTING
vif_delete(ifp);
@@ -1780,6 +1780,13 @@ if_setrdomain(struct ifnet *ifp, int rdomain)
/* Add interface to the specified rdomain */
ifp->if_rdomain = rdomain;
+ /* If we took down the IF, bring it back */
+ if (up) {
+ s = splnet();
+ if_up(ifp);
+ splx(s);
+ }
+
return (0);
}