From: akoshibe Date: Fri, 23 Feb 2018 05:17:39 +0000 (+0000) Subject: Add unsetrdomain() and option -rdomain to return an interface to routing X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=34c76ae096d1f35aca2a2f618bb58bfa5218c427;p=openbsd Add unsetrdomain() and option -rdomain to return an interface to routing domain 0. OK phessler, henning, deraadt, stsp, benno --- diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 63cc1edb88f..cdb24ead6c2 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.303 2018/02/20 07:34:28 jmc Exp $ +.\" $OpenBSD: ifconfig.8,v 1.304 2018/02/23 05:17:39 akoshibe Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: February 20 2018 $ +.Dd $Mdocdate: February 23 2018 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -439,6 +439,10 @@ domains. If the specified rdomain does not yet exist it will be created, including a routing table with the same id. By default all interfaces belong to routing domain 0. +.It Cm -rdomain +Remove the interface from the routing domain and return it to routing +domain 0. +Any inet and inet6 addresses on the interface will also be removed. .It Cm rtlabel Ar route-label (inet) Attach diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index a91173b08a5..5b041e08021 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.360 2018/02/20 15:33:16 tb Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.361 2018/02/23 05:17:39 akoshibe Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -237,6 +237,7 @@ void unsetvlandev(const char *, int); void mpe_status(void); void mpw_status(void); void setrdomain(const char *, int); +void unsetrdomain(const char *, int); int prefix(void *val, int); void getifgroups(void); void setifgroup(const char *, int); @@ -421,6 +422,7 @@ const struct cmd { { "rtlabel", NEXTARG, 0, setifrtlabel }, { "-rtlabel", -1, 0, setifrtlabel }, { "rdomain", NEXTARG, 0, setrdomain }, + { "-rdomain", 0, 0, unsetrdomain }, { "staticarp", IFF_STATICARP, 0, setifflags }, { "-staticarp", -IFF_STATICARP, 0, setifflags }, { "mpls", IFXF_MPLS, 0, setifxflags }, @@ -5667,6 +5669,15 @@ setrdomain(const char *id, int param) if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) < 0) warn("SIOCSIFRDOMAIN"); } + +void +unsetrdomain(const char *ignored, int alsoignored) +{ + strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + ifr.ifr_rdomainid = 0; + if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) < 0) + warn("SIOCSIFRDOMAIN"); +} #endif #ifndef SMALL