mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants
@ 2016-01-02  2:18 Kylie McClain
  2016-01-02 19:15 ` Shiz
  0 siblings, 1 reply; 6+ messages in thread
From: Kylie McClain @ 2016-01-02  2:18 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 780 bytes --]

Hi, this is a patch to add TCPOPT and TCPOLEN constants to
netinet/tcp.h.

This was discussed in IRC a little, but upon me finishing it
it seemed to get lost in the noise. As such I've submitted it
here so that it won't get lost.

These constants are used by programs such as iptables and are
expected to be defined in the libc's tcp.h; glibc and BSD libcs
all have them exposed by default. However, they are not part of
tcp.h's reserved namespace, therefore it has been hidden behind
_BSD_SOURCE (which is the same as _DEFAULT_SOURCE internally)
so that the behavior is the same across other C libraries and
doesn't require patches to programs, but still manages to be
standards conforming if need be.

I've attached it since I don't trust gmail to not mess up patch
formatting.

[-- Attachment #2: 0001-netinet-tcp-Add-TCPOPT-TCPOLEN-constants.patch --]
[-- Type: application/octet-stream, Size: 1324 bytes --]

From dcbbbe36ba5046effd2e475a3e54b89623d0f6f7 Mon Sep 17 00:00:00 2001
From: Kylie McClain <somasis@exherbo.org>
Date: Wed, 30 Dec 2015 17:24:02 -0500
Subject: [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants

Programs such as iptables depend on these constants, which can also
be found defined in other libcs.

Since only TCP_* is reserved as part of tcp.h's namespace, we hide
them behind _BSD_SOURCE (and therefore _DEFAULT_SOURCE) to expose
them by default, but keep it standard conforming.
---
 include/netinet/tcp.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h
index 52358c7..1eb2449 100644
--- a/include/netinet/tcp.h
+++ b/include/netinet/tcp.h
@@ -28,6 +28,20 @@
 #define TCP_TIMESTAMP    24
 #define TCP_NOTSENT_LOWAT 25
 
+#ifdef defined(_BSD_SOURCE)
+#define TCPOPT_EOL              0
+#define TCPOPT_NOP              1
+#define TCPOPT_MAXSEG           2
+#define TCPOPT_WINDOW           3
+#define TCPOPT_SACK_PERMITTED   4
+#define TCPOPT_SACK             5
+#define TCPOPT_TIMESTAMP        8
+#define TCPOLEN_SACK_PERMITTED  2
+#define TCPOLEN_WINDOW          3
+#define TCPOLEN_MAXSEG          4
+#define TCPOLEN_TIMESTAMP       10
+#endif
+
 #define TCP_ESTABLISHED  1
 #define TCP_SYN_SENT     2
 #define TCP_SYN_RECV     3
-- 
2.6.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants
  2016-01-02  2:18 [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants Kylie McClain
@ 2016-01-02 19:15 ` Shiz
  2016-01-03  4:24   ` Rich Felker
  0 siblings, 1 reply; 6+ messages in thread
From: Shiz @ 2016-01-02 19:15 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]


> On 02 Jan 2016, at 03:18, Kylie McClain <somasissounds@gmail.com> wrote:
> 
> I've attached it since I don't trust gmail to not mess up patch
> formatting.

This seems off:

>+#ifdef defined(_BSD_SOURCE)

I think you either want #ifdef _BSD_SOURCE or #if defined(_BSD_SOURCE) here.

- Shiz

[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants
  2016-01-02 19:15 ` Shiz
@ 2016-01-03  4:24   ` Rich Felker
  2016-01-03  6:18     ` Kylie McClain
  0 siblings, 1 reply; 6+ messages in thread
From: Rich Felker @ 2016-01-03  4:24 UTC (permalink / raw)
  To: musl

On Sat, Jan 02, 2016 at 08:15:16PM +0100, Shiz wrote:
> 
> > On 02 Jan 2016, at 03:18, Kylie McClain <somasissounds@gmail.com> wrote:
> > 
> > I've attached it since I don't trust gmail to not mess up patch
> > formatting.
> 
> This seems off:
> 
> >+#ifdef defined(_BSD_SOURCE)
> 
> I think you either want #ifdef _BSD_SOURCE or #if defined(_BSD_SOURCE) here.

Yes. Also, due to the way things currently work, I think it's
necessary to test defined(_BSD_SOURCE) || defined(_GNU_SOURCE). I
don't like that and want to fix it at the features.h level, but this
is an overhaul fix that should be made all at once rather than with
incremental inconsistency, so for now it's best to just test both
here, I think.

Also, it seems there's already a section later in the file that's
conditional on BSD||GNU, so unless there's a good conceptual reason
not to I'd probably rather add the new constants there. Does this
sound okay?

Rich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants
  2016-01-03  4:24   ` Rich Felker
@ 2016-01-03  6:18     ` Kylie McClain
  0 siblings, 0 replies; 6+ messages in thread
From: Kylie McClain @ 2016-01-03  6:18 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

On Jan 2, 2016 11:25 PM, "Rich Felker" <dalias@libc.org> wrote:
> Also, it seems there's already a section later in the file that's
> conditional on BSD||GNU, so unless there's a good conceptual reason
> not to I'd probably rather add the new constants there. Does this
> sound okay?
>
> Rich

Sounds just fine to me.

[-- Attachment #2: Type: text/html, Size: 462 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants
  2016-01-04  2:48 Kylie McClain
@ 2016-01-17 22:37 ` Rich Felker
  0 siblings, 0 replies; 6+ messages in thread
From: Rich Felker @ 2016-01-17 22:37 UTC (permalink / raw)
  To: musl

On Sun, Jan 03, 2016 at 09:48:54PM -0500, Kylie McClain wrote:
> On Sun, Jan 3, 2016 at 1:18 AM, Kylie McClain <somasissounds@gmail.com> wrote:
> > On Jan 2, 2016 11:25 PM, "Rich Felker" <dalias@libc.org> wrote:
> >> Also, it seems there's already a section later in the file that's
> >> conditional on BSD||GNU, so unless there's a good conceptual reason
> >> not to I'd probably rather add the new constants there. Does this
> >> sound okay?
> >>
> >> Rich
> >
> > Sounds just fine to me.
> 
> Oh, and here's the updated patch by the way :)

Thanks! Committed.

Rich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants
@ 2016-01-04  2:48 Kylie McClain
  2016-01-17 22:37 ` Rich Felker
  0 siblings, 1 reply; 6+ messages in thread
From: Kylie McClain @ 2016-01-04  2:48 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]

On Sun, Jan 3, 2016 at 1:18 AM, Kylie McClain <somasissounds@gmail.com> wrote:
> On Jan 2, 2016 11:25 PM, "Rich Felker" <dalias@libc.org> wrote:
>> Also, it seems there's already a section later in the file that's
>> conditional on BSD||GNU, so unless there's a good conceptual reason
>> not to I'd probably rather add the new constants there. Does this
>> sound okay?
>>
>> Rich
>
> Sounds just fine to me.

Oh, and here's the updated patch by the way :)

[-- Attachment #2: 0001-netinet-tcp-Add-TCPOPT-TCPOLEN-constants.patch --]
[-- Type: application/octet-stream, Size: 1313 bytes --]

From 98628a1de1fe2c4d19bdeb3a7343dd04e6aef4bf Mon Sep 17 00:00:00 2001
From: Kylie McClain <somasis@exherbo.org>
Date: Wed, 30 Dec 2015 17:24:02 -0500
Subject: [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants

Programs such as iptables depend on these constants, which can also
be found defined in other libcs.

Since only TCP_* is reserved as part of tcp.h's namespace, we hide
them behind _BSD_SOURCE (and therefore _DEFAULT_SOURCE) to expose
them by default, but keep it standard conforming.
---
 include/netinet/tcp.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h
index 52358c7..f9b8464 100644
--- a/include/netinet/tcp.h
+++ b/include/netinet/tcp.h
@@ -41,7 +41,20 @@
 #define TCP_CLOSING      11
 
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define TCPOPT_EOL              0
+#define TCPOPT_NOP              1
+#define TCPOPT_MAXSEG           2
+#define TCPOPT_WINDOW           3
+#define TCPOPT_SACK_PERMITTED   4
+#define TCPOPT_SACK             5
+#define TCPOPT_TIMESTAMP        8
+#define TCPOLEN_SACK_PERMITTED  2
+#define TCPOLEN_WINDOW          3
+#define TCPOLEN_MAXSEG          4
+#define TCPOLEN_TIMESTAMP       10
+
 #define SOL_TCP 6
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <stdint.h>
-- 
2.6.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-01-17 22:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-02  2:18 [PATCH] netinet/tcp: Add TCPOPT, TCPOLEN constants Kylie McClain
2016-01-02 19:15 ` Shiz
2016-01-03  4:24   ` Rich Felker
2016-01-03  6:18     ` Kylie McClain
2016-01-04  2:48 Kylie McClain
2016-01-17 22:37 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).