diff options
author | Phil Blundell <philb@gnu.org> | 2000-05-27 17:36:16 +0000 |
---|---|---|
committer | Phil Blundell <philb@gnu.org> | 2000-05-27 17:36:16 +0000 |
commit | ff42d595ccb7442d369c07b2bb3198e1a405f4ed (patch) | |
tree | c2df39678487d18fcda3b2cb9adabc1987e89eff /ifconfig.c | |
parent | Make `route -A inet6 add default ...' work. (diff) | |
download | net-tools-ff42d595ccb7442d369c07b2bb3198e1a405f4ed.tar.gz net-tools-ff42d595ccb7442d369c07b2bb3198e1a405f4ed.tar.bz2 net-tools-ff42d595ccb7442d369c07b2bb3198e1a405f4ed.zip |
Check /proc before opening ECONET sockets.
Try to fix the problem with alias interfaces and non INET sockets.
Diffstat (limited to 'ifconfig.c')
-rw-r--r-- | ifconfig.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -3,7 +3,7 @@ * that either displays or sets the characteristics of * one or more of the system's networking interfaces. * - * Version: $Id: ifconfig.c,v 1.37 2000/05/21 19:35:34 pb Exp $ + * Version: $Id: ifconfig.c,v 1.38 2000/05/27 17:36:16 pb Exp $ * * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> * and others. Copyright 1993 MicroWalt Corporation @@ -144,16 +144,28 @@ static int set_flag(char *ifname, short flag) static int clr_flag(char *ifname, short flag) { struct ifreq ifr; + int fd; + + if (strchr(ifname, ':')) { + /* This is a v4 alias interface. Downing it via a socket for + another AF may have bad consequences. */ + fd = get_socket_for_af(AF_INET); + if (fd < 0) { + fprintf(stderr, _("No support for INET on this system.\n")); + return -1; + } + } else + fd = skfd; strcpy(ifr.ifr_name, ifname); - if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) { + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { fprintf(stderr, _("%s: unknown interface: %s\n"), ifname, strerror(errno)); return -1; } strcpy(ifr.ifr_name, ifname); ifr.ifr_flags &= ~flag; - if (ioctl(skfd, SIOCSIFFLAGS, &ifr) < 0) { + if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { perror("SIOCSIFFLAGS"); return -1; } |