netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] uapi: linux: restore IPPROTO_MAX to 256
@ 2023-01-11 21:47 Pablo Neira Ayuso
  2023-01-12 10:54 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Pablo Neira Ayuso @ 2023-01-11 21:47 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet

IPPROTO_MAX used to be 256, but with the introduction of IPPROTO_MPTCP
definition, IPPROTO_MAX was bumped to 263.

IPPROTO_MPTCP definition is used for the socket interface from
userspace. It is never used in the layer 4 protocol field of
IP headers.

IPPROTO_* definitions are used anywhere in the kernel as well as in
userspace to set the layer 4 protocol field in IP headers.

At least in Netfilter, there is code in userspace that relies on
IPPROTO_MAX (not inclusive) to check for the maximum layer 4 protocol.

This patch restores IPPROTO_MAX to 256.

Fixes: faf391c3826c ("tcp: Define IPPROTO_MPTCP")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
Alternatively, I can also define an internal __IPPROTO_MAX to 256 in
userspace.  I understand an update on uapi at this stage might be
complicated. Another possibility is to add a new definition
IPPROTO_FIELD_MAX to uapi and set it to 256 that userspace could start
using.

 include/uapi/linux/in.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index 07a4cb149305..0600b03b49ee 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -80,10 +80,10 @@ enum {
   IPPROTO_ETHERNET = 143,	/* Ethernet-within-IPv6 Encapsulation	*/
 #define IPPROTO_ETHERNET	IPPROTO_ETHERNET
   IPPROTO_RAW = 255,		/* Raw IP packets			*/
+  IPPROTO_MAX = 256,
 #define IPPROTO_RAW		IPPROTO_RAW
   IPPROTO_MPTCP = 262,		/* Multipath TCP connection		*/
 #define IPPROTO_MPTCP		IPPROTO_MPTCP
-  IPPROTO_MAX
 };
 #endif
 
-- 
2.30.2


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

* Re: [PATCH net] uapi: linux: restore IPPROTO_MAX to 256
  2023-01-11 21:47 [PATCH net] uapi: linux: restore IPPROTO_MAX to 256 Pablo Neira Ayuso
@ 2023-01-12 10:54 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2023-01-12 10:54 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet

On Wed, Jan 11, 2023 at 10:47:19PM +0100, Pablo Neira Ayuso wrote:
> IPPROTO_MAX used to be 256, but with the introduction of IPPROTO_MPTCP
> definition, IPPROTO_MAX was bumped to 263.
> 
> IPPROTO_MPTCP definition is used for the socket interface from
> userspace. It is never used in the layer 4 protocol field of
> IP headers.
> 
> IPPROTO_* definitions are used anywhere in the kernel as well as in
> userspace to set the layer 4 protocol field in IP headers.
> 
> At least in Netfilter, there is code in userspace that relies on
> IPPROTO_MAX (not inclusive) to check for the maximum layer 4 protocol.
> 
> This patch restores IPPROTO_MAX to 256.
> 
> Fixes: faf391c3826c ("tcp: Define IPPROTO_MPTCP")
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> Alternatively, I can also define an internal __IPPROTO_MAX to 256 in
> userspace.  I understand an update on uapi at this stage might be
> complicated. Another possibility is to add a new definition
> IPPROTO_FIELD_MAX to uapi and set it to 256 that userspace could start
> using.

Scratch this.

This breaks inet_create() and inet6_create() which is going to break
MP-TCP with socket().

I'll post a v2 adding a new IPPROTO_FIELD_MAX definition 256.

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

end of thread, other threads:[~2023-01-12 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 21:47 [PATCH net] uapi: linux: restore IPPROTO_MAX to 256 Pablo Neira Ayuso
2023-01-12 10:54 ` Pablo Neira Ayuso

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).