Check /proc before opening ECONET sockets.
authorPhil Blundell <philb@gnu.org>
Sat, 27 May 2000 17:36:16 +0000 (17:36 +0000)
committerPhil Blundell <philb@gnu.org>
Sat, 27 May 2000 17:36:16 +0000 (17:36 +0000)
Try to fix the problem with alias interfaces and non INET sockets.

ifconfig.c
lib/econet.c

index 56ff46e..39ba6fa 100644 (file)
@@ -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;
     }
index ed6695a..1229a28 100644 (file)
@@ -3,7 +3,7 @@
  *              support functions for the net-tools.
  *              (NET-3 base distribution).
  *
- * Version:     $Id: econet.c,v 1.10 2000/05/20 13:38:10 pb Exp $
+ * Version:     $Id: econet.c,v 1.11 2000/05/27 17:36:16 pb Exp $
  *
  * Author:      Philip Blundell <philb@gnu.org>
  *
@@ -80,7 +80,7 @@ struct aftype ec_aftype =
     ec_print, ec_sprint, ec_input, NULL,
     NULL, NULL, NULL,
     -1,
-    NULL /*"/proc/sys/net/econet"*/
+    "/proc/sys/net/econet"
 };
 
 #endif                         /* HAVE_AFECONET */