diff mbox series

[net-next,1/2] net: add IP_DSCP_MASK

Message ID 20200803080217.391850-2-liuhangbin@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series Add IP_DSCP_MASK and fix vxlan tos value before xmit | expand

Commit Message

Hangbin Liu Aug. 3, 2020, 8:02 a.m. UTC
In RFC1349 it defined TOS field like

       0     1     2     3     4     5     6     7
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |   PRECEDENCE    |          TOS          | MBZ |
    +-----+-----+-----+-----+-----+-----+-----+-----+

But this has been obsoleted by RFC2474, and updated by RFC3168 later.
Now the DS Field should be like

       0     1     2     3     4     5     6     7
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |          DS FIELD, DSCP           | ECN FIELD |
    +-----+-----+-----+-----+-----+-----+-----+-----+

      DSCP: differentiated services codepoint
      ECN:  Explicit Congestion Notification

So the old IPTOS_TOS_MASK 0x1E should be updated. But since
changed the value will break UAPI, let's add a new value
IP_DSCP_MASK 0xFC as a replacement.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 include/uapi/linux/in_route.h | 1 +
 include/uapi/linux/ip.h       | 2 ++
 2 files changed, 3 insertions(+)

Comments

Guillaume Nault Aug. 3, 2020, 9:26 a.m. UTC | #1
On Mon, Aug 03, 2020 at 04:02:16PM +0800, Hangbin Liu wrote:
> In RFC1349 it defined TOS field like
> 
>        0     1     2     3     4     5     6     7
>     +-----+-----+-----+-----+-----+-----+-----+-----+
>     |   PRECEDENCE    |          TOS          | MBZ |
>     +-----+-----+-----+-----+-----+-----+-----+-----+
> 
> But this has been obsoleted by RFC2474, and updated by RFC3168 later.
> Now the DS Field should be like
> 
>        0     1     2     3     4     5     6     7
>     +-----+-----+-----+-----+-----+-----+-----+-----+
>     |          DS FIELD, DSCP           | ECN FIELD |
>     +-----+-----+-----+-----+-----+-----+-----+-----+
> 
>       DSCP: differentiated services codepoint
>       ECN:  Explicit Congestion Notification
> 
> So the old IPTOS_TOS_MASK 0x1E should be updated. But since
> changed the value will break UAPI, let's add a new value
> IP_DSCP_MASK 0xFC as a replacement.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  include/uapi/linux/in_route.h | 1 +
>  include/uapi/linux/ip.h       | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/include/uapi/linux/in_route.h b/include/uapi/linux/in_route.h
> index 0cc2c23b47f8..26ba4efb054d 100644
> --- a/include/uapi/linux/in_route.h
> +++ b/include/uapi/linux/in_route.h
> @@ -29,5 +29,6 @@
>  #define RTCF_NAT	(RTCF_DNAT|RTCF_SNAT)
>  
>  #define RT_TOS(tos)	((tos)&IPTOS_TOS_MASK)
> +#define RT_DSCP(tos)	((tos)&IP_DSCP_MASK)
>  
>  #endif /* _LINUX_IN_ROUTE_H */
> diff --git a/include/uapi/linux/ip.h b/include/uapi/linux/ip.h
> index e42d13b55cf3..62e4169277eb 100644
> --- a/include/uapi/linux/ip.h
> +++ b/include/uapi/linux/ip.h
> @@ -22,6 +22,8 @@
>  
>  #define IPTOS_TOS_MASK		0x1E
>  #define IPTOS_TOS(tos)		((tos)&IPTOS_TOS_MASK)
> +#define IP_DSCP_MASK		0xFC
> +#define IP_DSCP(tos)		((tos)&IP_DSCP_MASK)

What's the use of IP_DSCP()? It's the same as RT_DSCP().

I guess it's supposed to be the equivalent of IPTOS_TOS(), but that
macro is only used once in the tree, where it could be replaced with
RT_TOS().

I can't see a reason to copy this pattern.
diff mbox series

Patch

diff --git a/include/uapi/linux/in_route.h b/include/uapi/linux/in_route.h
index 0cc2c23b47f8..26ba4efb054d 100644
--- a/include/uapi/linux/in_route.h
+++ b/include/uapi/linux/in_route.h
@@ -29,5 +29,6 @@ 
 #define RTCF_NAT	(RTCF_DNAT|RTCF_SNAT)
 
 #define RT_TOS(tos)	((tos)&IPTOS_TOS_MASK)
+#define RT_DSCP(tos)	((tos)&IP_DSCP_MASK)
 
 #endif /* _LINUX_IN_ROUTE_H */
diff --git a/include/uapi/linux/ip.h b/include/uapi/linux/ip.h
index e42d13b55cf3..62e4169277eb 100644
--- a/include/uapi/linux/ip.h
+++ b/include/uapi/linux/ip.h
@@ -22,6 +22,8 @@ 
 
 #define IPTOS_TOS_MASK		0x1E
 #define IPTOS_TOS(tos)		((tos)&IPTOS_TOS_MASK)
+#define IP_DSCP_MASK		0xFC
+#define IP_DSCP(tos)		((tos)&IP_DSCP_MASK)
 #define	IPTOS_LOWDELAY		0x10
 #define	IPTOS_THROUGHPUT	0x08
 #define	IPTOS_RELIABILITY	0x04