> On 22 Feb 2018, at 5:00 pm, Ayaka Koshibe <akosh...@openbsd.org> wrote:
> 
> On Wed, Feb 21, 2018 at 03:42:58PM +0100, Sebastian Benoit wrote:
>> Ayaka Koshibe(akosh...@openbsd.org) on 2018.02.20 21:20:20 -0800:
>>> On Tue, Feb 20, 2018 at 4:48 AM, Reyk Floeter <r...@openbsd.org> wrote:
>>>> 
>>>>> Am 20.02.2018 um 11:15 schrieb Klemens Nanni <k...@openbsd.org>:
>>>>> 
>>>>>> On Mon, Feb 19, 2018 at 05:09:58PM -0800, Ayaka Koshibe wrote:
>>>>>> This diff would allow saying 'ifconfig foo -rdomain' instead of 
>>>>>> 'ifconfig foo rdomain 0'.
>>>>> I can see where you're coming from but this breaks semantics: `-option'
>>>>> clears an optional parameter or deconfigures functionality whereas
>>>>> `rdomain' is mandatory (defaulting to 0), every interface is attached
>>>>> to exactly one routing domain all the time.
>>>>> 
>>>> 
>>>> I would rather say that -option resets it to the default non-specific 
>>>> option. For example, -mode doesn???t remove all wireless modes.
>>> 
>>> This was also my interpretation of -option -- a way to reset to the
>>> default, which happens to be a value of 0 for this case.
>>> 
>>>> I think -rdomain is a good addition and the diff looks fine.
>>>> 
>>>> Reyk
>> 
>> i'm ok with the diff as well, but i want to remind you that rdomain is
>> special, because it also removes all ip configuration from the interface.
>> I.e. -rdomain does more than the other -options.
> 
> Ah, right. I hope I can just update the man page to explicitly mention
> this. I've also made it a bit more concise as jmc had suggested.

you should probably do a similar change for tunneldomain, just to be consistent.

cheers,
dlg

> 
> 
> Index: sbin/ifconfig/ifconfig.8
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
> retrieving revision 1.303
> diff -u -p -u -p -r1.303 ifconfig.8
> --- sbin/ifconfig/ifconfig.8  20 Feb 2018 07:34:28 -0000      1.303
> +++ sbin/ifconfig/ifconfig.8  22 Feb 2018 06:06:00 -0000
> @@ -439,6 +439,10 @@ domains.
> If the specified rdomain does not yet exist it will be created, including
> a routing table with the same id.
> By default all interfaces belong to routing domain 0.
> +.It Cm -rdomain
> +Remove the interface from the routing domain and return it to routing
> +domain 0.
> +Any inet and inet6 addresses on the interface will also be removed.
> .It Cm rtlabel Ar route-label
> (inet)
> Attach
> Index: sbin/ifconfig/ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.360
> diff -u -p -u -p -r1.360 ifconfig.c
> --- sbin/ifconfig/ifconfig.c  20 Feb 2018 15:33:16 -0000      1.360
> +++ sbin/ifconfig/ifconfig.c  22 Feb 2018 06:06:01 -0000
> @@ -237,6 +237,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);
> @@ -421,6 +422,7 @@ const struct      cmd {
>       { "rtlabel",    NEXTARG,        0,              setifrtlabel },
>       { "-rtlabel",   -1,             0,              setifrtlabel },
>       { "rdomain",    NEXTARG,        0,              setrdomain },
> +     { "-rdomain",   0,              0,              unsetrdomain },
>       { "staticarp",  IFF_STATICARP,  0,              setifflags },
>       { "-staticarp", -IFF_STATICARP, 0,              setifflags },
>       { "mpls",       IFXF_MPLS,      0,              setifxflags },
> @@ -5665,6 +5667,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