[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <3ed04b5d061b87d2310ac394284dbd88c2014b5a.1585954968.git.petrm@mellanox.com>
Date: Sat, 4 Apr 2020 02:05:29 +0300
From: Petr Machata <petrm@...lanox.com>
To: netdev@...r.kernel.org
Cc: Petr Machata <petrm@...lanox.com>,
Stephen Hemminger <stephen@...workplumber.org>,
David Ahern <dsahern@...il.com>
Subject: [PATCH iproute2-next v2 1/3] tc: p_ip6: Support pedit of IPv6 dsfield
Support keywords dsfield, traffic_class and tos in the IPv6 context.
Signed-off-by: Petr Machata <petrm@...lanox.com>
---
Notes:
v2:
- Only accept 'traffic_class'.
- Move the if-branch that matches it to the end of the list.
- man: Drop the untrue statement that the traffic_class field needs
to be sandwiched between two 4-bit zeroes.
man/man8/tc-pedit.8 | 6 ++++--
tc/p_ip6.c | 15 +++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/man/man8/tc-pedit.8 b/man/man8/tc-pedit.8
index bbd725c4..3f6baa3d 100644
--- a/man/man8/tc-pedit.8
+++ b/man/man8/tc-pedit.8
@@ -60,8 +60,8 @@ pedit - generic packet editor action
.ti -8
.IR IP6HDR_FIELD " := { "
-.BR src " | " dst " | " flow_lbl " | " payload_len " | " nexthdr " |"
-.BR hoplimit " }"
+.BR src " | " dst " | " traffic_class " | " flow_lbl " | " payload_len " | "
+.BR nexthdr " | " hoplimit " }"
.ti -8
.IR TCPHDR_FIELD " := { "
@@ -229,6 +229,8 @@ are:
.TQ
.B dst
.TQ
+.B traffic_class
+.TQ
.B flow_lbl
.TQ
.B payload_len
diff --git a/tc/p_ip6.c b/tc/p_ip6.c
index 7cc7997b..71660c61 100644
--- a/tc/p_ip6.c
+++ b/tc/p_ip6.c
@@ -74,6 +74,21 @@ parse_ip6(int *argc_p, char ***argv_p,
res = parse_cmd(&argc, &argv, 1, TU32, RU8, sel, tkey);
goto done;
}
+ if (strcmp(*argv, "traffic_class") == 0) {
+ NEXT_ARG();
+ tkey->off = 1;
+ res = parse_cmd(&argc, &argv, 1, TU32, RU8, sel, tkey);
+
+ /* Shift the field by 4 bits on success. */
+ if (!res) {
+ int nkeys = sel->sel.nkeys;
+ struct tc_pedit_key *key = &sel->sel.keys[nkeys - 1];
+
+ key->mask = htonl(ntohl(key->mask) << 4 | 0xf);
+ key->val = htonl(ntohl(key->val) << 4);
+ }
+ goto done;
+ }
return -1;
--
2.20.1
Powered by blists - more mailing lists