From owner-svn-src-head@FreeBSD.ORG Wed Jun 24 18:21:37 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E8421065670; Wed, 24 Jun 2009 18:21:37 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C1E98FC1A; Wed, 24 Jun 2009 18:21:37 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5OILbTF023620; Wed, 24 Jun 2009 18:21:37 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5OILbtL023615; Wed, 24 Jun 2009 18:21:37 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <200906241821.n5OILbtL023615@svn.freebsd.org> From: Jamie Gritton Date: Wed, 24 Jun 2009 18:21:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194871 - in head: rescue/rescue sbin/ifconfig X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jun 2009 18:21:38 -0000 Author: jamie Date: Wed Jun 24 18:21:37 2009 New Revision: 194871 URL: http://svn.freebsd.org/changeset/base/194871 Log: Add the "vnet" and "-vnet" options, to allow moving interfaces between jails with VIMAGE. Approved by: bz (mentor) Modified: head/rescue/rescue/Makefile head/sbin/ifconfig/Makefile head/sbin/ifconfig/ifconfig.8 head/sbin/ifconfig/ifconfig.c Modified: head/rescue/rescue/Makefile ============================================================================== --- head/rescue/rescue/Makefile Wed Jun 24 18:19:55 2009 (r194870) +++ head/rescue/rescue/Makefile Wed Jun 24 18:21:37 2009 (r194871) @@ -143,7 +143,7 @@ CRUNCH_LIBS+= -lipx .if ${MK_ZFS} != "no" CRUNCH_LIBS+= -lzfs -lnvpair -luutil -lavl .endif -CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv -lmd -lreadline -lsbuf -lufs -lz +CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lreadline -lsbuf -lufs -lz .if ${MACHINE_ARCH} == "i386" CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk Modified: head/sbin/ifconfig/Makefile ============================================================================== --- head/sbin/ifconfig/Makefile Wed Jun 24 18:19:55 2009 (r194870) +++ head/sbin/ifconfig/Makefile Wed Jun 24 18:21:37 2009 (r194871) @@ -27,8 +27,8 @@ SRCS+= ifgre.c # GRE keys etc SRCS+= ifgif.c # GIF reversed header workaround SRCS+= ifieee80211.c regdomain.c # SIOC[GS]IEEE80211 support -DPADD+= ${LIBBSDXML} ${LIBSBUF} -LDADD+= -lbsdxml -lsbuf +DPADD+= ${LIBBSDXML} ${LIBSBUF} ${LIBJAIL} +LDADD+= -lbsdxml -ljail -lsbuf SRCS+= ifcarp.c # SIOC[GS]VH support SRCS+= ifgroup.c # ... Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Wed Jun 24 18:19:55 2009 (r194870) +++ head/sbin/ifconfig/ifconfig.8 Wed Jun 24 18:21:37 2009 (r194871) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd January 7, 2009 +.Dd June 24, 2009 .Dt IFCONFIG 8 .Os .Sh NAME @@ -417,6 +417,18 @@ If the driver offers user-configurable V reception of extended frames, tag processing in hardware, or frame filtering in hardware, respectively. +.It Cm vnet Ar jail +Move the interface to the +.Xr jail 8 , +specified by name or JID. +If the jail has a virtual network stack, the interface will disappear +from the current environment and become visible to the jail. +.It Fl vnet Ar jail +Reclaim the interface from the +.Xr jail 8 , +specified by name or JID. +If the jail has a virtual network stack, the interface will disappear +from the jail, and become visible to the current network environment. .It Cm polling Turn on .Xr polling 4 @@ -2367,6 +2379,7 @@ tried to alter an interface's configurat .\" .Xr eon 5 , .Xr rc 8 , .Xr routed 8 , +.Xr jail 8 , .Xr sysctl 8 .Sh HISTORY The Modified: head/sbin/ifconfig/ifconfig.c ============================================================================== --- head/sbin/ifconfig/ifconfig.c Wed Jun 24 18:19:55 2009 (r194870) +++ head/sbin/ifconfig/ifconfig.c Wed Jun 24 18:21:37 2009 (r194871) @@ -67,6 +67,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -629,6 +630,34 @@ deletetunnel(const char *vname, int para } static void +setifvnet(const char *jname, int dummy __unused, int s, + const struct afswtch *afp) +{ + struct ifreq my_ifr; + + memcpy(&my_ifr, &ifr, sizeof(my_ifr)); + ifr.ifr_jid = jail_getid(jname); + if (ifr.ifr_jid < 0) + errx(1, "%s", jail_errmsg); + if (ioctl(s, SIOCSIFVNET, &ifr) < 0) + err(1, "SIOCSIFVNET"); +} + +static void +setifrvnet(const char *jname, int dummy __unused, int s, + const struct afswtch *afp) +{ + struct ifreq my_ifr; + + memcpy(&my_ifr, &ifr, sizeof(my_ifr)); + ifr.ifr_jid = jail_getid(jname); + if (ifr.ifr_jid < 0) + errx(1, "%s", jail_errmsg); + if (ioctl(s, SIOCSIFRVNET, &ifr) < 0) + err(1, "SIOCSIFRVNET"); +} + +static void setifnetmask(const char *addr, int dummy __unused, int s, const struct afswtch *afp) { @@ -1012,6 +1041,8 @@ static struct cmd basic_cmds[] = { DEF_CMD_ARG2("tunnel", settunnel), DEF_CMD("-tunnel", 0, deletetunnel), DEF_CMD("deletetunnel", 0, deletetunnel), + DEF_CMD_ARG("vnet", setifvnet), + DEF_CMD_ARG("-vnet", setifrvnet), DEF_CMD("link0", IFF_LINK0, setifflags), DEF_CMD("-link0", -IFF_LINK0, setifflags), DEF_CMD("link1", IFF_LINK1, setifflags),