sys/socket.h: fix SO_PEERSEC value on MIPS

Submitted by Matthias Schiffer on June 24, 2018, 3:18 p.m.

Details

Message ID 4e0877a604bad684be020f68e96a05156131fd44.1529853403.git.mschiffer@universe-factory.net
State New
Series "sys/socket.h: fix SO_PEERSEC value on MIPS"
Headers show

Commit Message

Matthias Schiffer June 24, 2018, 3:18 p.m.
Differing from all other archs supported by musl, MIPS defines SO_PEERSEC
to 30 instead of 31.

Reported-by: Andrey Jr. Mlenikov <temnota.am@gmail.com>
---
 arch/mips/bits/socket.h    | 2 ++
 arch/mips64/bits/socket.h  | 2 ++
 arch/mipsn32/bits/socket.h | 2 ++
 include/sys/socket.h       | 3 +++
 4 files changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
index 191ebdb5a418..39c42b822ac3 100644
--- a/arch/mips/bits/socket.h
+++ b/arch/mips/bits/socket.h
@@ -48,5 +48,7 @@  struct cmsghdr {
 #define SO_SNDBUFFORCE  31
 #define SO_RCVBUFFORCE  33
 
+#define SO_PEERSEC      30
+
 #define SOCK_NONBLOCK     0200
 #define SOCK_CLOEXEC  02000000
diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
index cf801797beb0..39b764df4c62 100644
--- a/arch/mips64/bits/socket.h
+++ b/arch/mips64/bits/socket.h
@@ -64,5 +64,7 @@  struct cmsghdr {
 #define SO_SNDBUFFORCE  31
 #define SO_RCVBUFFORCE  33
 
+#define SO_PEERSEC      30
+
 #define SOCK_NONBLOCK     0200
 #define SOCK_CLOEXEC  02000000
diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
index 191ebdb5a418..39c42b822ac3 100644
--- a/arch/mipsn32/bits/socket.h
+++ b/arch/mipsn32/bits/socket.h
@@ -48,5 +48,7 @@  struct cmsghdr {
 #define SO_SNDBUFFORCE  31
 #define SO_RCVBUFFORCE  33
 
+#define SO_PEERSEC      30
+
 #define SOCK_NONBLOCK     0200
 #define SOCK_CLOEXEC  02000000
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 507da5cc2a40..6b6cf2fc3988 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -203,7 +203,10 @@  struct linger {
 #define SO_TIMESTAMP            29
 #define SCM_TIMESTAMP           SO_TIMESTAMP
 
+#ifndef SO_PEERSEC
 #define SO_PEERSEC              31
+#endif
+
 #define SO_PASSSEC              34
 #define SO_TIMESTAMPNS          35
 #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS

Comments

Rich Felker June 24, 2018, 3:30 p.m.
On Sun, Jun 24, 2018 at 05:18:39PM +0200, Matthias Schiffer wrote:
> Differing from all other archs supported by musl, MIPS defines SO_PEERSEC
> to 30 instead of 31.
> 
> Reported-by: Andrey Jr. Mlenikov <temnota.am@gmail.com>
> ---
>  arch/mips/bits/socket.h    | 2 ++
>  arch/mips64/bits/socket.h  | 2 ++
>  arch/mipsn32/bits/socket.h | 2 ++
>  include/sys/socket.h       | 3 +++
>  4 files changed, 9 insertions(+)
> 
> diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
> index 191ebdb5a418..39c42b822ac3 100644
> --- a/arch/mips/bits/socket.h
> +++ b/arch/mips/bits/socket.h
> @@ -48,5 +48,7 @@ struct cmsghdr {
>  #define SO_SNDBUFFORCE  31
>  #define SO_RCVBUFFORCE  33
>  
> +#define SO_PEERSEC      30
> +
>  #define SOCK_NONBLOCK     0200
>  #define SOCK_CLOEXEC  02000000
> diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
> index cf801797beb0..39b764df4c62 100644
> --- a/arch/mips64/bits/socket.h
> +++ b/arch/mips64/bits/socket.h
> @@ -64,5 +64,7 @@ struct cmsghdr {
>  #define SO_SNDBUFFORCE  31
>  #define SO_RCVBUFFORCE  33
>  
> +#define SO_PEERSEC      30
> +
>  #define SOCK_NONBLOCK     0200
>  #define SOCK_CLOEXEC  02000000
> diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
> index 191ebdb5a418..39c42b822ac3 100644
> --- a/arch/mipsn32/bits/socket.h
> +++ b/arch/mipsn32/bits/socket.h
> @@ -48,5 +48,7 @@ struct cmsghdr {
>  #define SO_SNDBUFFORCE  31
>  #define SO_RCVBUFFORCE  33
>  
> +#define SO_PEERSEC      30
> +
>  #define SOCK_NONBLOCK     0200
>  #define SOCK_CLOEXEC  02000000
> diff --git a/include/sys/socket.h b/include/sys/socket.h
> index 507da5cc2a40..6b6cf2fc3988 100644
> --- a/include/sys/socket.h
> +++ b/include/sys/socket.h
> @@ -203,7 +203,10 @@ struct linger {
>  #define SO_TIMESTAMP            29
>  #define SCM_TIMESTAMP           SO_TIMESTAMP
>  
> +#ifndef SO_PEERSEC
>  #define SO_PEERSEC              31
> +#endif
> +
>  #define SO_PASSSEC              34
>  #define SO_TIMESTAMPNS          35
>  #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
> -- 
> 2.18.0

Should we perhaps do this under the SO_DEBUG conditional like all the
other SO_* that vary by arch? Doing so would require adding
definitions to the other weird archs (ibm ones) but might be cleaner
in the top-level header -- I'm not sure.

Rich
Matthias Schiffer June 25, 2018, 5:52 p.m.
On 06/24/2018 05:30 PM, Rich Felker wrote:
> On Sun, Jun 24, 2018 at 05:18:39PM +0200, Matthias Schiffer wrote:
>> Differing from all other archs supported by musl, MIPS defines SO_PEERSEC
>> to 30 instead of 31.
>>
>> Reported-by: Andrey Jr. Mlenikov <temnota.am@gmail.com>
>> ---
>>  arch/mips/bits/socket.h    | 2 ++
>>  arch/mips64/bits/socket.h  | 2 ++
>>  arch/mipsn32/bits/socket.h | 2 ++
>>  include/sys/socket.h       | 3 +++
>>  4 files changed, 9 insertions(+)
>>
>> diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
>> index 191ebdb5a418..39c42b822ac3 100644
>> --- a/arch/mips/bits/socket.h
>> +++ b/arch/mips/bits/socket.h
>> @@ -48,5 +48,7 @@ struct cmsghdr {
>>  #define SO_SNDBUFFORCE  31
>>  #define SO_RCVBUFFORCE  33
>>  
>> +#define SO_PEERSEC      30
>> +
>>  #define SOCK_NONBLOCK     0200
>>  #define SOCK_CLOEXEC  02000000
>> diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
>> index cf801797beb0..39b764df4c62 100644
>> --- a/arch/mips64/bits/socket.h
>> +++ b/arch/mips64/bits/socket.h
>> @@ -64,5 +64,7 @@ struct cmsghdr {
>>  #define SO_SNDBUFFORCE  31
>>  #define SO_RCVBUFFORCE  33
>>  
>> +#define SO_PEERSEC      30
>> +
>>  #define SOCK_NONBLOCK     0200
>>  #define SOCK_CLOEXEC  02000000
>> diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
>> index 191ebdb5a418..39c42b822ac3 100644
>> --- a/arch/mipsn32/bits/socket.h
>> +++ b/arch/mipsn32/bits/socket.h
>> @@ -48,5 +48,7 @@ struct cmsghdr {
>>  #define SO_SNDBUFFORCE  31
>>  #define SO_RCVBUFFORCE  33
>>  
>> +#define SO_PEERSEC      30
>> +
>>  #define SOCK_NONBLOCK     0200
>>  #define SOCK_CLOEXEC  02000000
>> diff --git a/include/sys/socket.h b/include/sys/socket.h
>> index 507da5cc2a40..6b6cf2fc3988 100644
>> --- a/include/sys/socket.h
>> +++ b/include/sys/socket.h
>> @@ -203,7 +203,10 @@ struct linger {
>>  #define SO_TIMESTAMP            29
>>  #define SCM_TIMESTAMP           SO_TIMESTAMP
>>  
>> +#ifndef SO_PEERSEC
>>  #define SO_PEERSEC              31
>> +#endif
>> +
>>  #define SO_PASSSEC              34
>>  #define SO_TIMESTAMPNS          35
>>  #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
>> -- 
>> 2.18.0
> 
> Should we perhaps do this under the SO_DEBUG conditional like all the
> other SO_* that vary by arch? Doing so would require adding
> definitions to the other weird archs (ibm ones) but might be cleaner
> in the top-level header -- I'm not sure.
> 
> Rich
> 


That would actually make sense. I did not research what SO_PEERSEC even is
before I sent the patch; only know I noticed that both the constants
defined under SO_DEBUG and the others below the #endif are SOL_SOCKET, so
it would be more consistent to move it under SO_DEBUG as well.

Matthias
Matthias Schiffer June 26, 2018, 6:21 p.m.
On 06/25/2018 07:52 PM, Matthias Schiffer wrote:
> On 06/24/2018 05:30 PM, Rich Felker wrote:
>> On Sun, Jun 24, 2018 at 05:18:39PM +0200, Matthias Schiffer wrote:
>>> Differing from all other archs supported by musl, MIPS defines SO_PEERSEC
>>> to 30 instead of 31.
>>>
>>> Reported-by: Andrey Jr. Mlenikov <temnota.am@gmail.com>
>>> ---
>>>  arch/mips/bits/socket.h    | 2 ++
>>>  arch/mips64/bits/socket.h  | 2 ++
>>>  arch/mipsn32/bits/socket.h | 2 ++
>>>  include/sys/socket.h       | 3 +++
>>>  4 files changed, 9 insertions(+)
>>>
>>> diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
>>> index 191ebdb5a418..39c42b822ac3 100644
>>> --- a/arch/mips/bits/socket.h
>>> +++ b/arch/mips/bits/socket.h
>>> @@ -48,5 +48,7 @@ struct cmsghdr {
>>>  #define SO_SNDBUFFORCE  31
>>>  #define SO_RCVBUFFORCE  33
>>>  
>>> +#define SO_PEERSEC      30
>>> +
>>>  #define SOCK_NONBLOCK     0200
>>>  #define SOCK_CLOEXEC  02000000
>>> diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
>>> index cf801797beb0..39b764df4c62 100644
>>> --- a/arch/mips64/bits/socket.h
>>> +++ b/arch/mips64/bits/socket.h
>>> @@ -64,5 +64,7 @@ struct cmsghdr {
>>>  #define SO_SNDBUFFORCE  31
>>>  #define SO_RCVBUFFORCE  33
>>>  
>>> +#define SO_PEERSEC      30
>>> +
>>>  #define SOCK_NONBLOCK     0200
>>>  #define SOCK_CLOEXEC  02000000
>>> diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
>>> index 191ebdb5a418..39c42b822ac3 100644
>>> --- a/arch/mipsn32/bits/socket.h
>>> +++ b/arch/mipsn32/bits/socket.h
>>> @@ -48,5 +48,7 @@ struct cmsghdr {
>>>  #define SO_SNDBUFFORCE  31
>>>  #define SO_RCVBUFFORCE  33
>>>  
>>> +#define SO_PEERSEC      30
>>> +
>>>  #define SOCK_NONBLOCK     0200
>>>  #define SOCK_CLOEXEC  02000000
>>> diff --git a/include/sys/socket.h b/include/sys/socket.h
>>> index 507da5cc2a40..6b6cf2fc3988 100644
>>> --- a/include/sys/socket.h
>>> +++ b/include/sys/socket.h
>>> @@ -203,7 +203,10 @@ struct linger {
>>>  #define SO_TIMESTAMP            29
>>>  #define SCM_TIMESTAMP           SO_TIMESTAMP
>>>  
>>> +#ifndef SO_PEERSEC
>>>  #define SO_PEERSEC              31
>>> +#endif
>>> +
>>>  #define SO_PASSSEC              34
>>>  #define SO_TIMESTAMPNS          35
>>>  #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
>>> -- 
>>> 2.18.0
>>
>> Should we perhaps do this under the SO_DEBUG conditional like all the
>> other SO_* that vary by arch? Doing so would require adding
>> definitions to the other weird archs (ibm ones) but might be cleaner
>> in the top-level header -- I'm not sure.
>>
>> Rich
>>
> 
> 
> That would actually make sense. I did not research what SO_PEERSEC even is
> before I sent the patch; only know I noticed that both the constants
> defined under SO_DEBUG and the others below the #endif are SOL_SOCKET, so
> it would be more consistent to move it under SO_DEBUG as well.
> 
> Matthias
> 

Should I send an updated patch, or are you going to fix it up yourself?

Matthias
Rich Felker June 26, 2018, 8:05 p.m.
On Tue, Jun 26, 2018 at 08:21:38PM +0200, Matthias Schiffer wrote:
> On 06/25/2018 07:52 PM, Matthias Schiffer wrote:
> > On 06/24/2018 05:30 PM, Rich Felker wrote:
> >> On Sun, Jun 24, 2018 at 05:18:39PM +0200, Matthias Schiffer wrote:
> >>> Differing from all other archs supported by musl, MIPS defines SO_PEERSEC
> >>> to 30 instead of 31.
> >>>
> >>> Reported-by: Andrey Jr. Mlenikov <temnota.am@gmail.com>
> >>> ---
> >>>  arch/mips/bits/socket.h    | 2 ++
> >>>  arch/mips64/bits/socket.h  | 2 ++
> >>>  arch/mipsn32/bits/socket.h | 2 ++
> >>>  include/sys/socket.h       | 3 +++
> >>>  4 files changed, 9 insertions(+)
> >>>
> >>> diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
> >>> index 191ebdb5a418..39c42b822ac3 100644
> >>> --- a/arch/mips/bits/socket.h
> >>> +++ b/arch/mips/bits/socket.h
> >>> @@ -48,5 +48,7 @@ struct cmsghdr {
> >>>  #define SO_SNDBUFFORCE  31
> >>>  #define SO_RCVBUFFORCE  33
> >>>  
> >>> +#define SO_PEERSEC      30
> >>> +
> >>>  #define SOCK_NONBLOCK     0200
> >>>  #define SOCK_CLOEXEC  02000000
> >>> diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
> >>> index cf801797beb0..39b764df4c62 100644
> >>> --- a/arch/mips64/bits/socket.h
> >>> +++ b/arch/mips64/bits/socket.h
> >>> @@ -64,5 +64,7 @@ struct cmsghdr {
> >>>  #define SO_SNDBUFFORCE  31
> >>>  #define SO_RCVBUFFORCE  33
> >>>  
> >>> +#define SO_PEERSEC      30
> >>> +
> >>>  #define SOCK_NONBLOCK     0200
> >>>  #define SOCK_CLOEXEC  02000000
> >>> diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
> >>> index 191ebdb5a418..39c42b822ac3 100644
> >>> --- a/arch/mipsn32/bits/socket.h
> >>> +++ b/arch/mipsn32/bits/socket.h
> >>> @@ -48,5 +48,7 @@ struct cmsghdr {
> >>>  #define SO_SNDBUFFORCE  31
> >>>  #define SO_RCVBUFFORCE  33
> >>>  
> >>> +#define SO_PEERSEC      30
> >>> +
> >>>  #define SOCK_NONBLOCK     0200
> >>>  #define SOCK_CLOEXEC  02000000
> >>> diff --git a/include/sys/socket.h b/include/sys/socket.h
> >>> index 507da5cc2a40..6b6cf2fc3988 100644
> >>> --- a/include/sys/socket.h
> >>> +++ b/include/sys/socket.h
> >>> @@ -203,7 +203,10 @@ struct linger {
> >>>  #define SO_TIMESTAMP            29
> >>>  #define SCM_TIMESTAMP           SO_TIMESTAMP
> >>>  
> >>> +#ifndef SO_PEERSEC
> >>>  #define SO_PEERSEC              31
> >>> +#endif
> >>> +
> >>>  #define SO_PASSSEC              34
> >>>  #define SO_TIMESTAMPNS          35
> >>>  #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
> >>> -- 
> >>> 2.18.0
> >>
> >> Should we perhaps do this under the SO_DEBUG conditional like all the
> >> other SO_* that vary by arch? Doing so would require adding
> >> definitions to the other weird archs (ibm ones) but might be cleaner
> >> in the top-level header -- I'm not sure.
> >>
> >> Rich
> >>
> > 
> > 
> > That would actually make sense. I did not research what SO_PEERSEC even is
> > before I sent the patch; only know I noticed that both the constants
> > defined under SO_DEBUG and the others below the #endif are SOL_SOCKET, so
> > it would be more consistent to move it under SO_DEBUG as well.
> 
> Should I send an updated patch, or are you going to fix it up yourself?

I'm doing it now. Thanks. I think we're going to find that there are
more SO_* that might vary by arch, especially if we ever add sparc.

What I'd kind of like to eventually do is get rid of the definitions
in sys/socket.h itself and always have them all in bits, with most
archs sharing the arch/generic version of the bits header. However
that doesn't work with the current bits/socket.h since the generic
definitions of msghdr and cmsghdr don't work on 64-bit. Perhaps we
should introduce a new bits/sockopt.h (but this imposes an extra file
open/parse for every #include <sys/socket.h>) or find some way to
avoid the gratuitous difference (maybe alltypes.h could somehow
provide padding definitions for a generic definition of [c]msghdr to
use).

Anyway I won't delay the immediate bugfix with what-ifs about future
direction.

Rich
Matthias Schiffer June 26, 2018, 8:20 p.m.
On 06/26/2018 10:05 PM, Rich Felker wrote:
> On Tue, Jun 26, 2018 at 08:21:38PM +0200, Matthias Schiffer wrote:
>> On 06/25/2018 07:52 PM, Matthias Schiffer wrote:
>>> On 06/24/2018 05:30 PM, Rich Felker wrote:
>>>> On Sun, Jun 24, 2018 at 05:18:39PM +0200, Matthias Schiffer wrote:
>>>>> Differing from all other archs supported by musl, MIPS defines SO_PEERSEC
>>>>> to 30 instead of 31.
>>>>>
>>>>> Reported-by: Andrey Jr. Mlenikov <temnota.am@gmail.com>
>>>>> ---
>>>>>  arch/mips/bits/socket.h    | 2 ++
>>>>>  arch/mips64/bits/socket.h  | 2 ++
>>>>>  arch/mipsn32/bits/socket.h | 2 ++
>>>>>  include/sys/socket.h       | 3 +++
>>>>>  4 files changed, 9 insertions(+)
>>>>>
>>>>> diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
>>>>> index 191ebdb5a418..39c42b822ac3 100644
>>>>> --- a/arch/mips/bits/socket.h
>>>>> +++ b/arch/mips/bits/socket.h
>>>>> @@ -48,5 +48,7 @@ struct cmsghdr {
>>>>>  #define SO_SNDBUFFORCE  31
>>>>>  #define SO_RCVBUFFORCE  33
>>>>>  
>>>>> +#define SO_PEERSEC      30
>>>>> +
>>>>>  #define SOCK_NONBLOCK     0200
>>>>>  #define SOCK_CLOEXEC  02000000
>>>>> diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
>>>>> index cf801797beb0..39b764df4c62 100644
>>>>> --- a/arch/mips64/bits/socket.h
>>>>> +++ b/arch/mips64/bits/socket.h
>>>>> @@ -64,5 +64,7 @@ struct cmsghdr {
>>>>>  #define SO_SNDBUFFORCE  31
>>>>>  #define SO_RCVBUFFORCE  33
>>>>>  
>>>>> +#define SO_PEERSEC      30
>>>>> +
>>>>>  #define SOCK_NONBLOCK     0200
>>>>>  #define SOCK_CLOEXEC  02000000
>>>>> diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
>>>>> index 191ebdb5a418..39c42b822ac3 100644
>>>>> --- a/arch/mipsn32/bits/socket.h
>>>>> +++ b/arch/mipsn32/bits/socket.h
>>>>> @@ -48,5 +48,7 @@ struct cmsghdr {
>>>>>  #define SO_SNDBUFFORCE  31
>>>>>  #define SO_RCVBUFFORCE  33
>>>>>  
>>>>> +#define SO_PEERSEC      30
>>>>> +
>>>>>  #define SOCK_NONBLOCK     0200
>>>>>  #define SOCK_CLOEXEC  02000000
>>>>> diff --git a/include/sys/socket.h b/include/sys/socket.h
>>>>> index 507da5cc2a40..6b6cf2fc3988 100644
>>>>> --- a/include/sys/socket.h
>>>>> +++ b/include/sys/socket.h
>>>>> @@ -203,7 +203,10 @@ struct linger {
>>>>>  #define SO_TIMESTAMP            29
>>>>>  #define SCM_TIMESTAMP           SO_TIMESTAMP
>>>>>  
>>>>> +#ifndef SO_PEERSEC
>>>>>  #define SO_PEERSEC              31
>>>>> +#endif
>>>>> +
>>>>>  #define SO_PASSSEC              34
>>>>>  #define SO_TIMESTAMPNS          35
>>>>>  #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
>>>>> -- 
>>>>> 2.18.0
>>>>
>>>> Should we perhaps do this under the SO_DEBUG conditional like all the
>>>> other SO_* that vary by arch? Doing so would require adding
>>>> definitions to the other weird archs (ibm ones) but might be cleaner
>>>> in the top-level header -- I'm not sure.
>>>>
>>>> Rich
>>>>
>>>
>>>
>>> That would actually make sense. I did not research what SO_PEERSEC even is
>>> before I sent the patch; only know I noticed that both the constants
>>> defined under SO_DEBUG and the others below the #endif are SOL_SOCKET, so
>>> it would be more consistent to move it under SO_DEBUG as well.
>>
>> Should I send an updated patch, or are you going to fix it up yourself?
> 
> I'm doing it now. Thanks. I think we're going to find that there are
> more SO_* that might vary by arch, especially if we ever add sparc.
> 
> What I'd kind of like to eventually do is get rid of the definitions
> in sys/socket.h itself and always have them all in bits, with most
> archs sharing the arch/generic version of the bits header. However
> that doesn't work with the current bits/socket.h since the generic
> definitions of msghdr and cmsghdr don't work on 64-bit. Perhaps we
> should introduce a new bits/sockopt.h (but this imposes an extra file
> open/parse for every #include <sys/socket.h>) or find some way to
> avoid the gratuitous difference (maybe alltypes.h could somehow
> provide padding definitions for a generic definition of [c]msghdr to
> use).
> 
> Anyway I won't delay the immediate bugfix with what-ifs about future
> direction.
> 
> Rich
> 

Thanks. It seems you missed to add SO_PEERSEC to powerpc{,64} and s390x
though, which also define SO_DEBUG.

Matthias
Rich Felker June 26, 2018, 8:28 p.m.
On Tue, Jun 26, 2018 at 10:20:53PM +0200, Matthias Schiffer wrote:
> On 06/26/2018 10:05 PM, Rich Felker wrote:
> > On Tue, Jun 26, 2018 at 08:21:38PM +0200, Matthias Schiffer wrote:
> >> On 06/25/2018 07:52 PM, Matthias Schiffer wrote:
> >>> On 06/24/2018 05:30 PM, Rich Felker wrote:
> >>>> On Sun, Jun 24, 2018 at 05:18:39PM +0200, Matthias Schiffer wrote:
> >>>>> Differing from all other archs supported by musl, MIPS defines SO_PEERSEC
> >>>>> to 30 instead of 31.
> >>>>>
> >>>>> Reported-by: Andrey Jr. Mlenikov <temnota.am@gmail.com>
> >>>>> ---
> >>>>>  arch/mips/bits/socket.h    | 2 ++
> >>>>>  arch/mips64/bits/socket.h  | 2 ++
> >>>>>  arch/mipsn32/bits/socket.h | 2 ++
> >>>>>  include/sys/socket.h       | 3 +++
> >>>>>  4 files changed, 9 insertions(+)
> >>>>>
> >>>>> diff --git a/arch/mips/bits/socket.h b/arch/mips/bits/socket.h
> >>>>> index 191ebdb5a418..39c42b822ac3 100644
> >>>>> --- a/arch/mips/bits/socket.h
> >>>>> +++ b/arch/mips/bits/socket.h
> >>>>> @@ -48,5 +48,7 @@ struct cmsghdr {
> >>>>>  #define SO_SNDBUFFORCE  31
> >>>>>  #define SO_RCVBUFFORCE  33
> >>>>>  
> >>>>> +#define SO_PEERSEC      30
> >>>>> +
> >>>>>  #define SOCK_NONBLOCK     0200
> >>>>>  #define SOCK_CLOEXEC  02000000
> >>>>> diff --git a/arch/mips64/bits/socket.h b/arch/mips64/bits/socket.h
> >>>>> index cf801797beb0..39b764df4c62 100644
> >>>>> --- a/arch/mips64/bits/socket.h
> >>>>> +++ b/arch/mips64/bits/socket.h
> >>>>> @@ -64,5 +64,7 @@ struct cmsghdr {
> >>>>>  #define SO_SNDBUFFORCE  31
> >>>>>  #define SO_RCVBUFFORCE  33
> >>>>>  
> >>>>> +#define SO_PEERSEC      30
> >>>>> +
> >>>>>  #define SOCK_NONBLOCK     0200
> >>>>>  #define SOCK_CLOEXEC  02000000
> >>>>> diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
> >>>>> index 191ebdb5a418..39c42b822ac3 100644
> >>>>> --- a/arch/mipsn32/bits/socket.h
> >>>>> +++ b/arch/mipsn32/bits/socket.h
> >>>>> @@ -48,5 +48,7 @@ struct cmsghdr {
> >>>>>  #define SO_SNDBUFFORCE  31
> >>>>>  #define SO_RCVBUFFORCE  33
> >>>>>  
> >>>>> +#define SO_PEERSEC      30
> >>>>> +
> >>>>>  #define SOCK_NONBLOCK     0200
> >>>>>  #define SOCK_CLOEXEC  02000000
> >>>>> diff --git a/include/sys/socket.h b/include/sys/socket.h
> >>>>> index 507da5cc2a40..6b6cf2fc3988 100644
> >>>>> --- a/include/sys/socket.h
> >>>>> +++ b/include/sys/socket.h
> >>>>> @@ -203,7 +203,10 @@ struct linger {
> >>>>>  #define SO_TIMESTAMP            29
> >>>>>  #define SCM_TIMESTAMP           SO_TIMESTAMP
> >>>>>  
> >>>>> +#ifndef SO_PEERSEC
> >>>>>  #define SO_PEERSEC              31
> >>>>> +#endif
> >>>>> +
> >>>>>  #define SO_PASSSEC              34
> >>>>>  #define SO_TIMESTAMPNS          35
> >>>>>  #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
> >>>>> -- 
> >>>>> 2.18.0
> >>>>
> >>>> Should we perhaps do this under the SO_DEBUG conditional like all the
> >>>> other SO_* that vary by arch? Doing so would require adding
> >>>> definitions to the other weird archs (ibm ones) but might be cleaner
> >>>> in the top-level header -- I'm not sure.
> >>>>
> >>>> Rich
> >>>>
> >>>
> >>>
> >>> That would actually make sense. I did not research what SO_PEERSEC even is
> >>> before I sent the patch; only know I noticed that both the constants
> >>> defined under SO_DEBUG and the others below the #endif are SOL_SOCKET, so
> >>> it would be more consistent to move it under SO_DEBUG as well.
> >>
> >> Should I send an updated patch, or are you going to fix it up yourself?
> > 
> > I'm doing it now. Thanks. I think we're going to find that there are
> > more SO_* that might vary by arch, especially if we ever add sparc.
> > 
> > What I'd kind of like to eventually do is get rid of the definitions
> > in sys/socket.h itself and always have them all in bits, with most
> > archs sharing the arch/generic version of the bits header. However
> > that doesn't work with the current bits/socket.h since the generic
> > definitions of msghdr and cmsghdr don't work on 64-bit. Perhaps we
> > should introduce a new bits/sockopt.h (but this imposes an extra file
> > open/parse for every #include <sys/socket.h>) or find some way to
> > avoid the gratuitous difference (maybe alltypes.h could somehow
> > provide padding definitions for a generic definition of [c]msghdr to
> > use).
> > 
> > Anyway I won't delay the immediate bugfix with what-ifs about future
> > direction.
> > 
> > Rich
> > 
> 
> Thanks. It seems you missed to add SO_PEERSEC to powerpc{,64} and s390x
> though, which also define SO_DEBUG.

Oops, will fix right away.

Rich