1 From a7cd7badedcb643dc1adb41edeb4cf8e4d9ec063 Mon Sep 17 00:00:00 2001
2 From: Stephen Hemminger <stephen@networkplumber.org>
3 Date: Tue, 19 Mar 2019 10:36:56 -0700
4 Subject: uapi: add CAKE FWMARK
6 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
8 include/uapi/linux/pkt_sched.h | 1 +
9 1 file changed, 1 insertion(+)
11 diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
12 index 1eb572e..7ee74c3 100644
13 --- a/include/uapi/linux/pkt_sched.h
14 +++ b/include/uapi/linux/pkt_sched.h
15 @@ -1021,6 +1021,7 @@ enum {
22 #define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1)
24 From 5ebfe1f6fea2bb3bfccf4cf93829516caaa0233d Mon Sep 17 00:00:00 2001
25 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
26 Date: Mon, 18 Mar 2019 01:30:45 +0100
27 Subject: [PATCH] q_cake: Add support for setting the fwmark option
29 Content-Type: text/plain; charset=UTF-8
30 Content-Transfer-Encoding: 8bit
32 This adds support for the newly added fwmark option to CAKE, which allows
33 overriding the tin selection from the per-packet firewall marks. The fwmark
34 field is a bitmask that is applied to the fwmark to select the tin.
36 Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
38 man/man8/tc-cake.8 | 16 ++++++++++++++++
39 tc/q_cake.c | 24 ++++++++++++++++++++++++
40 2 files changed, 40 insertions(+)
42 diff --git a/man/man8/tc-cake.8 b/man/man8/tc-cake.8
43 index eda436e1..8c57eadd 100644
44 --- a/man/man8/tc-cake.8
45 +++ b/man/man8/tc-cake.8
46 @@ -91,6 +91,10 @@ TIME |
57 @@ -524,6 +528,18 @@ preset on the modern Internet is firmly discouraged.
59 Voice (CS7, CS6, EF, VA, TOS4), 25% threshold, reduced Codel interval.
65 + This options turns on fwmark-based overriding of CAKE's tin selection.
66 +If set, the option specifies a bitmask that will be applied to the fwmark
67 +associated with each packet. If the result of this masking is non-zero, the
68 +result will be right-shifted by the number of least-significant unset bits in
69 +the mask value, and the result will be used as a the tin number for that packet.
70 +This can be used to set policies in a firewall script that will override CAKE's
71 +built-in tin selection.
76 diff --git a/tc/q_cake.c b/tc/q_cake.c
77 index e827e3f1..307a12c0 100644
80 @@ -82,6 +82,7 @@ static void explain(void)
81 " [ split-gso* | no-split-gso ]\n"
82 " [ ack-filter | ack-filter-aggressive | no-ack-filter* ]\n"
83 " [ memlimit LIMIT ]\n"
85 " [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
86 " [ mpu N ] [ ingress | egress* ]\n"
87 " (* marks defaults)\n");
88 @@ -106,6 +107,7 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
96 @@ -332,6 +334,16 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
97 "Illegal value for \"memlimit\": \"%s\"\n", *argv);
100 + } else if (strcmp(*argv, "fwmark") == 0) {
104 + if (get_u32(&fwm, *argv, 0)) {
106 + "Illegal value for \"fwmark\": \"%s\"\n", *argv);
110 } else if (strcmp(*argv, "help") == 0) {
113 @@ -376,6 +388,9 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
115 addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit,
118 + addattr_l(n, 1024, TCA_CAKE_FWMARK, &fwmark,
121 addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
123 @@ -409,6 +424,7 @@ static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
124 struct rtattr *tb[TCA_CAKE_MAX + 1];
125 unsigned int interval = 0;
126 unsigned int memlimit = 0;
127 + unsigned int fwmark = 0;
131 @@ -507,6 +523,10 @@ static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
132 RTA_PAYLOAD(tb[TCA_CAKE_RTT]) >= sizeof(__u32)) {
133 interval = rta_getattr_u32(tb[TCA_CAKE_RTT]);
135 + if (tb[TCA_CAKE_FWMARK] &&
136 + RTA_PAYLOAD(tb[TCA_CAKE_FWMARK]) >= sizeof(__u32)) {
137 + fwmark = rta_getattr_u32(tb[TCA_CAKE_FWMARK]);
141 print_string(PRINT_FP, NULL, "wash ", NULL);
142 @@ -559,6 +579,10 @@ static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
143 sprint_size(memlimit, b1));
147 + print_uint(PRINT_FP, NULL, "fwmark 0x%x ", fwmark);
148 + print_0xhex(PRINT_JSON, "fwmark", NULL, fwmark);