On Mon, Apr 19, 2010 at 02:34:55PM +0300, Gregory Edigarov wrote:

> Hello,
> 
> This diff adds possibility for the network interfaces to have an arbitrary 
> names.
> this is done via ifconfig <oldname> name <newname>
> 
> Please test. 
> Thank you.
> 
> 
> --- /usr/src/sys/net/if.c.orig        Sat Apr 17 12:42:06 2010
> +++ /usr/src/sys/net/if.c     Sat Apr 17 13:27:12 2010
> @@ -1416,6 +1416,17 @@
>                       strlcpy(ifp->if_description, ifdescrbuf, IFDESCRSIZE);
>               }
>               break;
> +     
> +     case SIOCSIFNAME:
> +             if ((error = suser (p,0)) != 0)
> +                     return (error);
> +             error = copyinstr(ifr->ifr_data, ifnamebuf, 
> +                     IFNAMSIZ,&bytesdone);
> +             if (error == 0) {
> +                     (void)memset (ifp->if_xname, 0, IFNAMSIZ);
> +                     strlcpy(ifp->if_xname, ifnamebuf,IFNAMSIZ); 
> +             }
> +             break;
>  
>       case SIOCGIFRTLABEL:
>               if (ifp->if_rtlabelid &&
> --- /usr/src/sbin/ifconfig/ifconfig.c.orig    Sat Apr 17 13:43:47 2010
> +++ /usr/src/sbin/ifconfig/ifconfig.c Sat Apr 17 14:34:15 2010
> @@ -149,6 +149,7 @@
>  void setifbroadaddr(const char *, int);
>  void setifdesc(const char *, int);
>  void unsetifdesc(const char *, int);
> +void setifname(const char *, int);
>  void setifipdst(const char *, int);
>  void setifmetric(const char *, int);
>  void setifmtu(const char *, int);
> @@ -465,6 +466,7 @@
>       { "descr",      NEXTARG,        0,              setifdesc },
>       { "-description", 1,            0,              unsetifdesc },
>       { "-descr",     1,              0,              unsetifdesc },
> +     { "name",       1,              0,              setifname},     
>       { NULL, /*src*/ 0,              0,              setifaddr },
>       { NULL, /*dst*/ 0,              0,              setifdstaddr },
>       { NULL, /*illegal*/0,           0,              NULL },
> @@ -1118,6 +1120,14 @@
>  
>  /* ARGSUSED */
>  void
> +setifname(const char *val, int ignored)
> +{
> +     ifr.ifr_data = (caddr_t)val;
> +     if (ioctl(s, SIOCSIFNAME, &ifr) < 0)
> +             warn("SIOCSIFNAME");
> +} 
> +/* ARGSUSED */
> +void
>  setifipdst(const char *addr, int ignored)
>  {
>       in_getaddr(addr, DSTADDR);
> --- /usr/include/sys/sockio.h.orig    Sat Apr 17 14:33:11 2010
> +++ /usr/include/sys/sockio.h Sat Apr 17 14:32:41 2010
> @@ -179,6 +179,8 @@
>  #define      SIOCSLIFPHYRTABLEID _IOW('i', 161, struct ifreq) /* set tunnel 
> VRF id */
>  #define      SIOCGLIFPHYRTABLEID _IOWR('i', 162, struct ifreq) /* get tunnel 
> id */
>  
> +#define SIOCSIFNAME   _IOW('i', 163, struct ifreq) /* set interface name */
> +
>  #define      SIOCSVH         _IOWR('i', 245, struct ifreq)   /* set carp 
> param */
>  #define      SIOCGVH         _IOWR('i', 246, struct ifreq)   /* get carp 
> param */
>  
> 
> -- 
> With best regards,
>       Gregory Edigarov

This enables you to have two interfaces with the same name, afaiks, or
have funny names that might confused tools.  Sounds fishy to me. I'd
say we have a 'decription' field, use that to distinguish interfaces. 

        -Otto

Reply via email to