iproute2: update to 5.0.0
[openwrt/.git] / package / network / utils / iproute2 / patches / 010-cake-fwmark.patch
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
5
6 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
7 ---
8  include/uapi/linux/pkt_sched.h | 1 +
9  1 file changed, 1 insertion(+)
10
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 {
16         TCA_CAKE_INGRESS,
17         TCA_CAKE_ACK_FILTER,
18         TCA_CAKE_SPLIT_GSO,
19 +       TCA_CAKE_FWMARK,
20         __TCA_CAKE_MAX
21  };
22  #define TCA_CAKE_MAX   (__TCA_CAKE_MAX - 1)
23
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
28 MIME-Version: 1.0
29 Content-Type: text/plain; charset=UTF-8
30 Content-Transfer-Encoding: 8bit
31
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.
35
36 Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
37 ---
38  man/man8/tc-cake.8 | 16 ++++++++++++++++
39  tc/q_cake.c        | 24 ++++++++++++++++++++++++
40  2 files changed, 40 insertions(+)
41
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 |
47  LIMIT ]
48  .br
49  [
50 +.BR fwmark
51 +MASK ]
52 +.br
53 +[
54  .BR ptm
55  |
56  .BR atm
57 @@ -524,6 +528,18 @@ preset on the modern Internet is firmly discouraged.
58  .br
59                 Voice (CS7, CS6, EF, VA, TOS4), 25% threshold, reduced Codel interval.
60  
61 +.PP
62 +.B fwmark
63 +MASK
64 +.br
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.
72 +
73  .SH OTHER PARAMETERS
74  .B memlimit
75  LIMIT
76 diff --git a/tc/q_cake.c b/tc/q_cake.c
77 index e827e3f1..307a12c0 100644
78 --- a/tc/q_cake.c
79 +++ b/tc/q_cake.c
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"
84 +"                [ fwmark MASK ]\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,
89         int autorate = -1;
90         int ingress = -1;
91         int overhead = 0;
92 +       int fwmark = -1;
93         int wash = -1;
94         int nat = -1;
95         int atm = -1;
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);
98                                 return -1;
99                         }
100 +               } else if (strcmp(*argv, "fwmark") == 0) {
101 +                       unsigned int fwm;
102 +
103 +                       NEXT_ARG();
104 +                       if (get_u32(&fwm, *argv, 0)) {
105 +                               fprintf(stderr,
106 +                                       "Illegal value for \"fwmark\": \"%s\"\n", *argv);
107 +                               return -1;
108 +                       }
109 +                       fwmark = fwm;
110                 } else if (strcmp(*argv, "help") == 0) {
111                         explain();
112                         return -1;
113 @@ -376,6 +388,9 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
114         if (memlimit)
115                 addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit,
116                           sizeof(memlimit));
117 +       if (fwmark != -1)
118 +               addattr_l(n, 1024, TCA_CAKE_FWMARK, &fwmark,
119 +                         sizeof(fwmark));
120         if (nat != -1)
121                 addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
122         if (wash != -1)
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;
128         __u64 bandwidth = 0;
129         int ack_filter = 0;
130         int split_gso = 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]);
134         }
135 +       if (tb[TCA_CAKE_FWMARK] &&
136 +           RTA_PAYLOAD(tb[TCA_CAKE_FWMARK]) >= sizeof(__u32)) {
137 +               fwmark = rta_getattr_u32(tb[TCA_CAKE_FWMARK]);
138 +       }
139  
140         if (wash)
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));
144         }
145  
146 +       if (fwmark)
147 +               print_uint(PRINT_FP, NULL, "fwmark 0x%x ", fwmark);
148 +       print_0xhex(PRINT_JSON, "fwmark", NULL, fwmark);
149 +
150         return 0;
151  }
152