Netdev List
 help / color / mirror / Atom feed
* [PATCH v2] ipv4: make DSCP values works with ip rules
@ 2018-11-20 13:29 Pavel Balaev
  2018-11-20 14:12 ` Sabrina Dubroca
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Balaev @ 2018-11-20 13:29 UTC (permalink / raw)
  To: davem; +Cc: netdev

This patch adds ability to set DSCP values in ip rules.                                                                                          
Values presented in /etc/iproute3/rt_dsfield and now can be used in rules.

Example:
$ ip ru add from 10.88.0.2 tos AF23 lookup dscp.
Result:
---
32762:	from 10.88.0.2 tos AF43 lookup dscp
---

Patch was tested with such configuration:

+-----------+
| 10.88.0.2 | -> ping 172.16.0.1 -Q 0x58 ->
|   host0   |
+-----------+

   +-------------------------------------+
   | router with patched kernel          |
   |                                     |
-> | from 10.88.0.2 tos AF43 lookup dscp |->
   | table dscp:                         |
   |   172.16.0.0/24 via 10.200.0.2      |
   +-------------------------------------+

	 +------------------+
-> | eth0: 10.200.0.2 |
   | eth1: 172.16.0.1 |
   |      host1       |
   +------------------+

Signed-off-by: Pavel Balaev <mail@void.so>
---
 include/net/route.h     | 2 +-
 include/uapi/linux/ip.h | 2 ++
 net/ipv4/fib_rules.c    | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/net/route.h b/include/net/route.h
index bb53cdba..b984ecff 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -239,7 +239,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_DSCP_MASK & ~3)
 
 extern const __u8 ip_tos2prio[16];
 
diff --git a/include/uapi/linux/ip.h b/include/uapi/linux/ip.h
index e42d13b5..307ce2b1 100644
--- a/include/uapi/linux/ip.h
+++ b/include/uapi/linux/ip.h
@@ -38,6 +38,8 @@
 #define IPTOS_PREC_PRIORITY             0x20
 #define IPTOS_PREC_ROUTINE              0x00
 
+#define IPTOS_DSCP_MASK		(IPTOS_TOS_MASK | IPTOS_PREC_MASK)
+#define IPTOS_DSCP(tos)		((tos)&IPTOS_DSCP_MASK)
 
 /* IP options */
 #define IPOPT_COPY		0x80
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index f8eb78d0..9ba91ef0 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -220,7 +220,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_DSCP_MASK) {
 		NL_SET_ERR_MSG(extack, "Invalid tos");
 		goto errout;
 	}
-- 
2.18.1

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

* Re: [PATCH v2] ipv4: make DSCP values works with ip rules
  2018-11-20 13:29 [PATCH v2] ipv4: make DSCP values works with ip rules Pavel Balaev
@ 2018-11-20 14:12 ` Sabrina Dubroca
  2018-11-20 14:36   ` Pavel Balaev
  0 siblings, 1 reply; 3+ messages in thread
From: Sabrina Dubroca @ 2018-11-20 14:12 UTC (permalink / raw)
  To: Pavel Balaev; +Cc: davem, netdev

Hi Pavel,

2018-11-20, 16:29:36 +0300, Pavel Balaev wrote:
> This patch adds ability to set DSCP values in ip rules.

You dropped the RFC reference that you had in v1.

> Values presented in /etc/iproute3/rt_dsfield and now can be used in rules.

iproute3?

> 
> Example:
> $ ip ru add from 10.88.0.2 tos AF23 lookup dscp.
> Result:
> ---

Be careful when you write commit messages. "git am" is going to cut
out everything that comes after the first ^---$ line it sees, so the
rest of those explanations, as well as your sign-off, will be dropped.

> 32762:	from 10.88.0.2 tos AF43 lookup dscp
> ---
> 
> Patch was tested with such configuration:
> 
> +-----------+
> | 10.88.0.2 | -> ping 172.16.0.1 -Q 0x58 ->
> |   host0   |
> +-----------+
> 
>    +-------------------------------------+
>    | router with patched kernel          |
>    |                                     |
> -> | from 10.88.0.2 tos AF43 lookup dscp |->
>    | table dscp:                         |
>    |   172.16.0.0/24 via 10.200.0.2      |
>    +-------------------------------------+
> 
> 	 +------------------+
> -> | eth0: 10.200.0.2 |
>    | eth1: 172.16.0.1 |
>    |      host1       |
>    +------------------+
> 
> Signed-off-by: Pavel Balaev <mail@void.so>

-- 
Sabrina

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

* Re: [PATCH v2] ipv4: make DSCP values works with ip rules
  2018-11-20 14:12 ` Sabrina Dubroca
@ 2018-11-20 14:36   ` Pavel Balaev
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Balaev @ 2018-11-20 14:36 UTC (permalink / raw)
  To: Sabrina Dubroca; +Cc: netdev

On Tue, Nov 20, 2018 at 03:12:18PM +0100, Sabrina Dubroca wrote:
> Hi Pavel,
> 
> 2018-11-20, 16:29:36 +0300, Pavel Balaev wrote:
> > This patch adds ability to set DSCP values in ip rules.
> 
> You dropped the RFC reference that you had in v1.
> 
RFC2474 and RFC2597 values.
> > Values presented in /etc/iproute3/rt_dsfield and now can be used in rules.
> 
> iproute3?
> 
That was a typo, iproute2.
> > 
> > Example:
> > $ ip ru add from 10.88.0.2 tos AF23 lookup dscp.
> > Result:
> > ---
> 
> Be careful when you write commit messages. "git am" is going to cut
> out everything that comes after the first ^---$ line it sees, so the
> rest of those explanations, as well as your sign-off, will be dropped.
> 
> > 32762:	from 10.88.0.2 tos AF43 lookup dscp
> > ---
> > 
> > Patch was tested with such configuration:
> > 
> > +-----------+
> > | 10.88.0.2 | -> ping 172.16.0.1 -Q 0x58 ->
> > |   host0   |
> > +-----------+
> > 
> >    +-------------------------------------+
> >    | router with patched kernel          |
> >    |                                     |
> > -> | from 10.88.0.2 tos AF43 lookup dscp |->
> >    | table dscp:                         |
> >    |   172.16.0.0/24 via 10.200.0.2      |
> >    +-------------------------------------+
> > 
> > 	 +------------------+
> > -> | eth0: 10.200.0.2 |
> >    | eth1: 172.16.0.1 |
> >    |      host1       |
> >    +------------------+
> > 
> > Signed-off-by: Pavel Balaev <mail@void.so>
> 
> -- 
> Sabrina
Ok. Got it. Tnx.

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

end of thread, other threads:[~2018-11-21  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-20 13:29 [PATCH v2] ipv4: make DSCP values works with ip rules Pavel Balaev
2018-11-20 14:12 ` Sabrina Dubroca
2018-11-20 14:36   ` Pavel Balaev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox