From owner-svn-src-all@FreeBSD.ORG Mon Mar 23 12:07:30 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F222710658BB; Mon, 23 Mar 2009 12:07:29 +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 BBC6E8FC12; Mon, 23 Mar 2009 12:07:29 +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 n2NC7TIC008833; Mon, 23 Mar 2009 12:07:29 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2NC7Tl8008829; Mon, 23 Mar 2009 12:07:29 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <200903231207.n2NC7Tl8008829@svn.freebsd.org> From: Jamie Gritton Date: Mon, 23 Mar 2009 12:07:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190318 - in stable/7: sbin/ifconfig sys sys/contrib/pf sys/dev/ath/ath_hal sys/dev/cxgb sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2009 12:08:03 -0000 Author: jamie Date: Mon Mar 23 12:07:29 2009 New Revision: 190318 URL: http://svn.freebsd.org/changeset/base/190318 Log: MFC: r189864: Default to AF_LOCAL instead of AF_INET sockets for non-family-specific operations. This allows the query operations to work in non-IPv4 jails, and will be necessary in a future of possible non-INET networking. (reprise r189970) r190151: Call the interface's if_ioctl from ifioctl(), if the protocol didn't handle the ioctl. There are other paths that already call it, but this allows for a non-interface socket (like AF_LOCAL which ifconfig now uses) to use a broader class of interface ioctls. Approved by: bz (mentor) Modified: stable/7/sbin/ifconfig/ (props changed) stable/7/sbin/ifconfig/ifclone.c stable/7/sbin/ifconfig/ifconfig.c stable/7/sbin/ifconfig/ifgroup.c stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/net/if.c Modified: stable/7/sbin/ifconfig/ifclone.c ============================================================================== --- stable/7/sbin/ifconfig/ifclone.c Mon Mar 23 11:07:34 2009 (r190317) +++ stable/7/sbin/ifconfig/ifclone.c Mon Mar 23 12:07:29 2009 (r190318) @@ -53,9 +53,9 @@ list_cloners(void) int idx; int s; - s = socket(AF_INET, SOCK_DGRAM, 0); + s = socket(AF_LOCAL, SOCK_DGRAM, 0); if (s == -1) - err(1, "socket(AF_INET,SOCK_DGRAM)"); + err(1, "socket(AF_LOCAL,SOCK_DGRAM)"); memset(&ifcr, 0, sizeof(ifcr)); Modified: stable/7/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/7/sbin/ifconfig/ifconfig.c Mon Mar 23 11:07:34 2009 (r190317) +++ stable/7/sbin/ifconfig/ifconfig.c Mon Mar 23 12:07:29 2009 (r190318) @@ -434,21 +434,22 @@ static const struct cmd setifdstaddr_cmd DEF_CMD("ifdstaddr", 0, setifdstaddr); static int -ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *afp) +ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp) { - const struct afswtch *nafp; + const struct afswtch *afp, *nafp; struct callback *cb; int s; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); + afp = uafp != NULL ? uafp : af_getbyname("inet"); top: - if (afp == NULL) - afp = af_getbyname("inet"); ifr.ifr_addr.sa_family = afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ? - AF_INET : afp->af_af; + AF_LOCAL : afp->af_af; - if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) + if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0 && + (uafp != NULL || errno != EPROTONOSUPPORT || + (s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0)) err(1, "socket(family %u,SOCK_DGRAM", ifr.ifr_addr.sa_family); while (argc > 0) { @@ -792,11 +793,12 @@ status(const struct afswtch *afp, const if (afp == NULL) { allfamilies = 1; - afp = af_getbyname("inet"); - } else + ifr.ifr_addr.sa_family = AF_LOCAL; + } else { allfamilies = 0; - - ifr.ifr_addr.sa_family = afp->af_af == AF_LINK ? AF_INET : afp->af_af; + ifr.ifr_addr.sa_family = + afp->af_af == AF_LINK ? AF_LOCAL : afp->af_af; + } strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0); Modified: stable/7/sbin/ifconfig/ifgroup.c ============================================================================== --- stable/7/sbin/ifconfig/ifgroup.c Mon Mar 23 11:07:34 2009 (r190317) +++ stable/7/sbin/ifconfig/ifgroup.c Mon Mar 23 12:07:29 2009 (r190318) @@ -131,9 +131,9 @@ printgroup(const char *groupname) int len, cnt = 0; int s; - s = socket(AF_INET, SOCK_DGRAM, 0); + s = socket(AF_LOCAL, SOCK_DGRAM, 0); if (s == -1) - err(1, "socket(AF_INET,SOCK_DGRAM)"); + err(1, "socket(AF_LOCAL,SOCK_DGRAM)"); bzero(&ifgr, sizeof(ifgr)); strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name)); if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) { Modified: stable/7/sys/net/if.c ============================================================================== --- stable/7/sys/net/if.c Mon Mar 23 11:07:34 2009 (r190317) +++ stable/7/sys/net/if.c Mon Mar 23 12:07:29 2009 (r190318) @@ -1968,6 +1968,8 @@ ifioctl(struct socket *so, u_long cmd, c error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, ifp, td)); + if (error == EOPNOTSUPP && ifp != NULL && ifp->if_ioctl != NULL) + error = (*ifp->if_ioctl)(ifp, cmd, data); #else { int ocmd = cmd; @@ -2009,6 +2011,9 @@ ifioctl(struct socket *so, u_long cmd, c cmd, data, ifp, td)); + if (error == EOPNOTSUPP && ifp != NULL && + ifp->if_ioctl != NULL) + error = (*ifp->if_ioctl)(ifp, cmd, data); switch (ocmd) { case OSIOCGIFADDR: