From owner-svn-src-head@FreeBSD.ORG Sun Jul 26 11:25:58 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 27C75106564A; Sun, 26 Jul 2009 11:25:58 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EF1C58FC20; Sun, 26 Jul 2009 11:25:57 +0000 (UTC) (envelope-from bz@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 n6QBPvrx068912; Sun, 26 Jul 2009 11:25:57 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6QBPvJY068910; Sun, 26 Jul 2009 11:25:57 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200907261125.n6QBPvJY068910@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 26 Jul 2009 11:25:57 +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: r195890 - head/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: Sun, 26 Jul 2009 11:25:58 -0000 Author: bz Date: Sun Jul 26 11:25:57 2009 New Revision: 195890 URL: http://svn.freebsd.org/changeset/base/195890 Log: Make ifconfig ifN -vnet actually work: - fix ifconfig to ignore the non-existent interface in the current network stack in case of '-vnet'. - in ifconfig: actually use the local variables defined for the vnet functions rather than modifying the global. Reviewed by: rwatson Approved by: re (kib) Modified: head/sbin/ifconfig/ifconfig.c Modified: head/sbin/ifconfig/ifconfig.c ============================================================================== --- head/sbin/ifconfig/ifconfig.c Sun Jul 26 09:01:15 2009 (r195889) +++ head/sbin/ifconfig/ifconfig.c Sun Jul 26 11:25:57 2009 (r195890) @@ -252,6 +252,19 @@ main(int argc, char *argv[]) ifconfig(argc, argv, 1, NULL); exit(0); } + /* + * NOTE: We have to special-case the `-vnet' command + * right here as we would otherwise fail when trying + * to find the interface as it lives in another vnet. + */ + if (argc > 0 && (strcmp(argv[0], "-vnet") == 0)) { + iflen = strlcpy(name, ifname, sizeof(name)); + if (iflen >= sizeof(name)) + errx(1, "%s: interface name too long", + ifname); + ifconfig(argc, argv, 0, NULL); + exit(0); + } errx(1, "interface %s does not exist", ifname); } } @@ -636,10 +649,10 @@ setifvnet(const char *jname, int dummy _ struct ifreq my_ifr; memcpy(&my_ifr, &ifr, sizeof(my_ifr)); - ifr.ifr_jid = jail_getid(jname); - if (ifr.ifr_jid < 0) + my_ifr.ifr_jid = jail_getid(jname); + if (my_ifr.ifr_jid < 0) errx(1, "%s", jail_errmsg); - if (ioctl(s, SIOCSIFVNET, &ifr) < 0) + if (ioctl(s, SIOCSIFVNET, &my_ifr) < 0) err(1, "SIOCSIFVNET"); } @@ -650,11 +663,11 @@ setifrvnet(const char *jname, int dummy struct ifreq my_ifr; memcpy(&my_ifr, &ifr, sizeof(my_ifr)); - ifr.ifr_jid = jail_getid(jname); - if (ifr.ifr_jid < 0) + my_ifr.ifr_jid = jail_getid(jname); + if (my_ifr.ifr_jid < 0) errx(1, "%s", jail_errmsg); - if (ioctl(s, SIOCSIFRVNET, &ifr) < 0) - err(1, "SIOCSIFRVNET"); + if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0) + err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name); } static void