Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jan 2013 00:02:34 +1100
From:      Lawrence Stewart <lstewart@freebsd.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-net@freebsd.org
Subject:   Re: [PATCH] Don't imply TCP and UDP socket options are bitmasks
Message-ID:  <510130EA.4020700@freebsd.org>
In-Reply-To: <201301221528.18388.jhb@freebsd.org>
References:  <201301141550.13577.jhb@freebsd.org> <201301151416.07231.jhb@freebsd.org> <50FE5473.7000807@freebsd.org> <201301221528.18388.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 01/23/13 07:28, John Baldwin wrote:
> On Tuesday, January 22, 2013 3:57:23 am Lawrence Stewart wrote:
>> On 01/16/13 06:16, John Baldwin wrote:
>>> On Tuesday, January 15, 2013 3:49:33 am Lawrence Stewart wrote:
>>>> On 01/15/13 07:50, John Baldwin wrote:
>>>>> The constants used for TCP and UDP socket options (TCP_NODELAY, etc.) are 
>>>>> currently defined as hex values that are individual bits.  However, socket 
>>>>> options are never masked together, they are used as a simple enumeration of 
>>>>> discrete values.  Using a bitmask forces us to run out of bits and makes it 
>>>>> harder for vendors to try to use a high range of values for local custom 
>>>>> options (hoping that they never conflict with a new option value added in 
>>>>> stock FreeBSD).
>>>>
>>>> Yup. Should we be explicitly #defining the boundary between "bits
>>>> reserved for FreeBSD" and "bits for private vendor use"?
>>>
>>> Oh, we could if you wanted.  I'm using 0x1000 locally for both TCP and UDP,
>>> but those are completely arbitrary values.  Saner ones might be 0x8000000 if
>>> we want to do that explicitly.  We could perhaps just say that is true for all
>>> socket option levels (that is, just define one SO_VENDOR constant or some such
>>> but say it applies to all levels)?
>>
>> A single SO_VENDOR applied to all levels sounds good to me.
> 
> Ok, how about this for wording:
> 
> Index: sys/socket.h
> ===================================================================
> --- socket.h	(revision 245742)
> +++ socket.h	(working copy)
> @@ -143,6 +143,15 @@ typedef	__uid_t		uid_t;
>  #endif
>  
>  /*
> + * Space reserved for new socket options added by third-party vendors.
> + * This range applies to all socket option levels.  New socket options
> + * in FreeBSD should always use an option value less than SO_VENDOR.
> + */
> +#if __BSD_VISIBLE
> +#define	SO_VENDOR	0x80000000
> +#endif
> +
> +/*
>   * Structure used for manipulating linger option.
>   */
>  struct linger {

Two thumbs up from me.

We might also want to

#define	TCP_VENDOR SO_VENDOR /* FreeBSD TCP socket options must be
numerically less than this. */

and so on in each file that defines option levels to provide some hint
to people that SO_VENDOR exists? Maybe we don't need the define and just
need to put the one line comment at the end of each set of options in
each file where a particular level's options are specified.

Cheers,
Lawrence



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?510130EA.4020700>