All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: DSCP in IPv4 routing
@ 2020-11-13  2:06 Russell Strong
  2020-11-13  3:36 ` Stephen Hemminger
  0 siblings, 1 reply; 8+ messages in thread
From: Russell Strong @ 2020-11-13  2:06 UTC (permalink / raw)
  To: netdev

TOS handling in ipv4 routing does not support using dscp.
This change widens masks to use the 6 DSCP bits in routing.

Tested with

ip rule add dsfield EF lookup main
ip rule
0:	from all lookup local
32765:	from all tos EF lookup main
32766:	from all lookup main
32767:	from all lookup default

and verified that lookups are indeed performed from the
correct table.

This now works instead of failing with "Error: Invalid tos."

Signed-off-by: Russell Strong <russell@strong.id.au>
---
 include/net/route.h           | 2 +-
 include/uapi/linux/in_route.h | 2 +-
 include/uapi/linux/ip.h       | 2 ++
 net/ipv4/fib_rules.c          | 2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/net/route.h b/include/net/route.h
index ff021cab657e..519448ad37d0 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -255,7 +255,7 @@ static inline void ip_rt_put(struct rtable *rt)
 	dst_release(&rt->dst);
 }
 
-#define IPTOS_RT_MASK	(IPTOS_TOS_MASK & ~3)
+#define IPTOS_RT_MASK	(IPTOS_DS_MASK & ~3)
 
 extern const __u8 ip_tos2prio[16];
 
diff --git a/include/uapi/linux/in_route.h
b/include/uapi/linux/in_route.h index 0cc2c23b47f8..db5d236b9c50 100644
--- a/include/uapi/linux/in_route.h
+++ b/include/uapi/linux/in_route.h
@@ -28,6 +28,6 @@
 
 #define RTCF_NAT	(RTCF_DNAT|RTCF_SNAT)
 
-#define RT_TOS(tos)	((tos)&IPTOS_TOS_MASK)
+#define RT_TOS(tos)	((tos)&IPTOS_DS_MASK)
 
 #endif /* _LINUX_IN_ROUTE_H */
diff --git a/include/uapi/linux/ip.h b/include/uapi/linux/ip.h
index e42d13b55cf3..fafd9470ae78 100644
--- a/include/uapi/linux/ip.h
+++ b/include/uapi/linux/ip.h
@@ -20,6 +20,8 @@
 #include <linux/types.h>
 #include <asm/byteorder.h>
 
+#define IPTOS_DS_MASK		0xfc
+#define IPTOS_DS(tos)		((tos)&IPTOS_DS_MASK)
 #define IPTOS_TOS_MASK		0x1E
 #define IPTOS_TOS(tos)		((tos)&IPTOS_TOS_MASK)
 #define	IPTOS_LOWDELAY		0x10
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index ce54a30c2ef1..1499105d1efd 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -229,7 +229,7 @@ static int fib4_rule_configure(struct fib_rule
*rule, struct sk_buff *skb, int err = -EINVAL;
 	struct fib4_rule *rule4 = (struct fib4_rule *) rule;
 
-	if (frh->tos & ~IPTOS_TOS_MASK) {
+	if (frh->tos & ~IPTOS_RT_MASK) {
 		NL_SET_ERR_MSG(extack, "Invalid tos");
 		goto errout;
 	}
-- 
2.26.2


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

end of thread, other threads:[~2020-11-17  0:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13  2:06 [PATCH net-next] net: DSCP in IPv4 routing Russell Strong
2020-11-13  3:36 ` Stephen Hemminger
2020-11-13  9:02   ` Guillaume Nault
2020-11-14 23:03     ` Russell Strong
2020-11-14 23:09     ` Russell Strong
2020-11-14 23:10     ` Russell Strong
2020-11-17  0:21       ` kernel test robot
2020-11-17  0:21         ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.