On Mon, Feb 19, 2018 at 05:09:58PM -0800, Ayaka Koshibe wrote:
> Index: sbin/ifconfig/ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.353
> diff -u -p -u -p -r1.353 ifconfig.c
> --- sbin/ifconfig/ifconfig.c  16 Jan 2018 10:33:55 -0000      1.353
> +++ sbin/ifconfig/ifconfig.c  20 Feb 2018 00:02:48 -0000
> @@ -220,6 +220,7 @@ void      unsetvlandev(const char *, int);
>  void mpe_status(void);
>  void mpw_status(void);
>  void setrdomain(const char *, int);
> +void unsetrdomain(const char *, int);
>  int  prefix(void *val, int);
>  void getifgroups(void);
>  void setifgroup(const char *, int);
> @@ -397,6 +398,7 @@ const struct      cmd {
>       { "rtlabel",    NEXTARG,        0,              setifrtlabel },
>       { "-rtlabel",   -1,             0,              setifrtlabel },
>       { "rdomain",    NEXTARG,        0,              setrdomain },
> +     { "-rdomain",   0,              0,              unsetrdomain },

I don't have an opinion about whether -rdomain is a necessary
addition or not. I could live fine with either.

But that question aside:

I doubt the new function 'unsetrdomain' is really needed.
It seems that instead of adding unsetrdomain() we could make
the -rdomain option invoke setrdomain() with rdomain id 0.

I haven't tested this idea, though.
Does your change work without the new function unsetrdomain?
I.e. a diff which only adds this to ifconfig.c:

 +      { "-rdomain",   0,              0,              setrdomain },


>       { "staticarp",  IFF_STATICARP,  0,              setifflags },
>       { "-staticarp", -IFF_STATICARP, 0,              setifflags },
>       { "mpls",       IFXF_MPLS,      0,              setifxflags },
> @@ -5578,6 +5580,15 @@ setrdomain(const char *id, int param)
>       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
>       ifr.ifr_rdomainid = rdomainid;
>       if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) < 0)
> +             warn("SIOCSIFRDOMAIN");
> +}
> +
> +void
> +unsetrdomain(const char *ignored, int alsoignored)
> +{
> +     strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
> +     ifr.ifr_rdomainid = 0;
> +     if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) < 0)        
>               warn("SIOCSIFRDOMAIN");
>  }
>  #endif
> 

Reply via email to