summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2009-03-15 22:33:18 +0000
committerjamie <jamie@FreeBSD.org>2009-03-15 22:33:18 +0000
commit172e53d32b65f2bac0f0d0d4080969bb14d3f8e8 (patch)
treefb3561f9c80f3461985c074fe9601a6739c3f462 /sbin
parent4fc2f82f67bc08664b8ed7df98cea3f48013160d (diff)
downloadFreeBSD-src-172e53d32b65f2bac0f0d0d4080969bb14d3f8e8.zip
FreeBSD-src-172e53d32b65f2bac0f0d0d4080969bb14d3f8e8.tar.gz
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. Approved by: bz (mentor)
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ifconfig/ifclone.c4
-rw-r--r--sbin/ifconfig/ifconfig.c22
-rw-r--r--sbin/ifconfig/ifgroup.c4
3 files changed, 16 insertions, 14 deletions
diff --git a/sbin/ifconfig/ifclone.c b/sbin/ifconfig/ifclone.c
index 8fba9ff..aba974e 100644
--- a/sbin/ifconfig/ifclone.c
+++ b/sbin/ifconfig/ifclone.c
@@ -54,9 +54,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));
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 3b6138d..73c8025 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -441,22 +441,23 @@ 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;
const struct cmd *p;
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) {
@@ -803,11 +804,12 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
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);
diff --git a/sbin/ifconfig/ifgroup.c b/sbin/ifconfig/ifgroup.c
index 88774a6..9eaac3b 100644
--- a/sbin/ifconfig/ifgroup.c
+++ b/sbin/ifconfig/ifgroup.c
@@ -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) {
OpenPOWER on IntegriCloud