Merge ~smb/ubuntu/+source/iproute2:merge-xenial into ubuntu/+source/iproute2:ubuntu/xenial-proposed

Proposed by Stefan Bader
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: 9c9e5f06de2ebf7397fa20cc0a7719502b09ec71
Merged at revision: 9c9e5f06de2ebf7397fa20cc0a7719502b09ec71
Proposed branch: ~smb/ubuntu/+source/iproute2:merge-xenial
Merge into: ubuntu/+source/iproute2:ubuntu/xenial-proposed
Diff against target: 260 lines (+238/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/1011-tc-Add-support-for-the-matchall-traffic-classifier.patch (+230/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
git-ubuntu developers Pending
Review via email: mp+365865@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Minor lack of dep3 headers, the rest LGTM

review: Needs Fixing
Revision history for this message
Stefan Bader (smb) wrote :

> Minor lack of dep3 headers, the rest LGTM

Refreshed branch with updated patch. I mimicked the additional fields done in the previous patch.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Now it looks good, thanks

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Tagged and Sponsored into -unapproved.
Please track SRU handling and proposed migration later on.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index 6a65658..e2297c3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1iproute2 (4.3.0-1ubuntu3.16.04.5) xenial; urgency=medium
2
3 * sched: Match-all classifier is missing in xenial (LP: #1642514)
4 - d/p/1011-tc-Add-support-for-the-matchall-traffic-classifier.patch
5
6 -- Stefan Bader <stefan.bader@canonical.com> Thu, 04 Apr 2019 15:47:07 +0200
7
1iproute2 (4.3.0-1ubuntu3.16.04.4) xenial; urgency=medium8iproute2 (4.3.0-1ubuntu3.16.04.4) xenial; urgency=medium
29
3 * Add support for VF Trust (LP: #1800877)10 * Add support for VF Trust (LP: #1800877)
diff --git a/debian/patches/1011-tc-Add-support-for-the-matchall-traffic-classifier.patch b/debian/patches/1011-tc-Add-support-for-the-matchall-traffic-classifier.patch
4new file mode 10064411new file mode 100644
index 0000000..7c2fef2
--- /dev/null
+++ b/debian/patches/1011-tc-Add-support-for-the-matchall-traffic-classifier.patch
@@ -0,0 +1,230 @@
1Origin: upstream, https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=d5cbf3ff0561b6c8158c3538c7fe1946add9dec3
2Bug-Ubuntu: https://bugs.launchpad.net/bugs/1642514
3From: Yotam Gigi <yotamg@mellanox.com>
4Date: Wed, 31 Aug 2016 09:28:26 +0200
5Subject: [PATCH] tc: Add support for the matchall traffic classifier.
6
7The matchall classifier matches every packet and allows the user to apply
8actions on it. In addition, it supports the skip_sw and skip_hw (as can
9be found on u32 and flower filter) that direct the kernel to skip the
10software/hardware processing of the actions.
11
12This filter is very useful in usecases where every packet should be
13matched. For example, packet mirroring (SPAN) can be setup very easily
14using that filter.
15
16Signed-off-by: Yotam Gigi <yotamg@mellanox.com>
17Signed-off-by: Jiri Pirko <jiri@mellanox.com>
18
19(backported from commit d5cbf3ff0561b6c8158c3538c7fe1946add9dec3 iproute2)
20[smb: Add kernel definitions and merged printing skip flags]
21Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
22---
23 tc/Makefile | 1 +
24 tc/f_matchall.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++
25 2 files changed, 144 insertions(+)
26 create mode 100644 tc/f_matchall.c
27
28Index: iproute2/tc/Makefile
29===================================================================
30--- iproute2.orig/tc/Makefile
31+++ iproute2/tc/Makefile
32@@ -65,6 +65,7 @@ TCMODULES += q_fq.o
33 TCMODULES += q_pie.o
34 TCMODULES += q_hhf.o
35 TCMODULES += e_bpf.o
36+TCMODULES += f_matchall.o
37
38 ifeq ($(TC_CONFIG_IPSET), y)
39 ifeq ($(TC_CONFIG_XT), y)
40Index: iproute2/tc/f_matchall.c
41===================================================================
42--- /dev/null
43+++ iproute2/tc/f_matchall.c
44@@ -0,0 +1,152 @@
45+/*
46+ * f_matchall.c Match-all Classifier
47+ *
48+ * This program is free software; you can distribute it and/or
49+ * modify it under the terms of the GNU General Public License
50+ * as published by the Free Software Foundation; either version
51+ * 2 of the License, or (at your option) any later version.
52+ *
53+ * Authors: Jiri Pirko <jiri@mellanox.com>, Yotam Gigi <yotamg@mellanox.com>
54+ *
55+ */
56+
57+#include <stdio.h>
58+#include <stdlib.h>
59+#include <unistd.h>
60+#include <syslog.h>
61+#include <fcntl.h>
62+#include <sys/socket.h>
63+#include <netinet/in.h>
64+#include <arpa/inet.h>
65+#include <string.h>
66+#include <linux/if.h>
67+
68+#include "utils.h"
69+#include "tc_util.h"
70+
71+static void explain(void)
72+{
73+ fprintf(stderr, "Usage: ... matchall [skip_sw | skip_hw]\n");
74+ fprintf(stderr, " [ action ACTION_SPEC ] [ classid CLASSID ]\n");
75+ fprintf(stderr, "\n");
76+ fprintf(stderr, "Where: SELECTOR := SAMPLE SAMPLE ...\n");
77+ fprintf(stderr, " FILTERID := X:Y:Z\n");
78+ fprintf(stderr, " ACTION_SPEC := ... look at individual actions\n");
79+ fprintf(stderr, "\nNOTE: CLASSID is parsed as hexadecimal input.\n");
80+}
81+
82+static int matchall_parse_opt(struct filter_util *qu, char *handle,
83+ int argc, char **argv, struct nlmsghdr *n)
84+{
85+ struct tcmsg *t = NLMSG_DATA(n);
86+ struct rtattr *tail;
87+ __u32 flags = 0;
88+ long h = 0;
89+
90+ if (handle) {
91+ h = strtol(handle, NULL, 0);
92+ if (h == LONG_MIN || h == LONG_MAX) {
93+ fprintf(stderr, "Illegal handle \"%s\", must be numeric.\n",
94+ handle);
95+ return -1;
96+ }
97+ }
98+ t->tcm_handle = h;
99+
100+ if (argc == 0)
101+ return 0;
102+
103+ tail = (struct rtattr *)(((void *)n)+NLMSG_ALIGN(n->nlmsg_len));
104+ addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);
105+
106+ while (argc > 0) {
107+ if (matches(*argv, "classid") == 0 ||
108+ strcmp(*argv, "flowid") == 0) {
109+ unsigned int handle;
110+
111+ NEXT_ARG();
112+ if (get_tc_classid(&handle, *argv)) {
113+ fprintf(stderr, "Illegal \"classid\"\n");
114+ return -1;
115+ }
116+ addattr_l(n, MAX_MSG, TCA_MATCHALL_CLASSID, &handle, 4);
117+ } else if (matches(*argv, "action") == 0) {
118+ NEXT_ARG();
119+ if (parse_action(&argc, &argv, TCA_MATCHALL_ACT, n)) {
120+ fprintf(stderr, "Illegal \"action\"\n");
121+ return -1;
122+ }
123+ continue;
124+
125+ } else if (strcmp(*argv, "skip_hw") == 0) {
126+ NEXT_ARG();
127+ flags |= TCA_CLS_FLAGS_SKIP_HW;
128+ continue;
129+ } else if (strcmp(*argv, "skip_sw") == 0) {
130+ NEXT_ARG();
131+ flags |= TCA_CLS_FLAGS_SKIP_SW;
132+ continue;
133+ } else if (strcmp(*argv, "help") == 0) {
134+ explain();
135+ return -1;
136+ } else {
137+ fprintf(stderr, "What is \"%s\"?\n", *argv);
138+ explain();
139+ return -1;
140+ }
141+ argc--; argv++;
142+ }
143+
144+ if (flags) {
145+ if (!(flags ^ (TCA_CLS_FLAGS_SKIP_HW |
146+ TCA_CLS_FLAGS_SKIP_SW))) {
147+ fprintf(stderr,
148+ "skip_hw and skip_sw are mutually exclusive\n");
149+ return -1;
150+ }
151+ addattr_l(n, MAX_MSG, TCA_MATCHALL_FLAGS, &flags, 4);
152+ }
153+
154+ tail->rta_len = (((void *)n)+n->nlmsg_len) - (void *)tail;
155+ return 0;
156+}
157+
158+static int matchall_print_opt(struct filter_util *qu, FILE *f,
159+ struct rtattr *opt, __u32 handle)
160+{
161+ struct rtattr *tb[TCA_MATCHALL_MAX+1];
162+
163+ if (opt == NULL)
164+ return 0;
165+
166+ parse_rtattr_nested(tb, TCA_MATCHALL_MAX, opt);
167+
168+ if (handle)
169+ fprintf(f, "handle 0x%x ", handle);
170+
171+ if (tb[TCA_MATCHALL_CLASSID]) {
172+ SPRINT_BUF(b1);
173+ fprintf(f, "flowid %s ",
174+ sprint_tc_classid(rta_getattr_u32(tb[TCA_MATCHALL_CLASSID]), b1));
175+ }
176+
177+ if (tb[TCA_MATCHALL_FLAGS]) {
178+ __u32 flags = rta_getattr_u32(tb[TCA_MATCHALL_FLAGS]);
179+
180+ if (flags & TCA_CLS_FLAGS_SKIP_HW)
181+ fprintf(f, "\n skip_hw");
182+ if (flags & TCA_CLS_FLAGS_SKIP_SW)
183+ fprintf(f, "\n skip_sw");
184+ }
185+
186+ if (tb[TCA_MATCHALL_ACT])
187+ tc_print_action(f, tb[TCA_MATCHALL_ACT]);
188+
189+ return 0;
190+}
191+
192+struct filter_util matchall_filter_util = {
193+ .id = "matchall",
194+ .parse_fopt = matchall_parse_opt,
195+ .print_fopt = matchall_print_opt,
196+};
197Index: iproute2/include/linux/pkt_cls.h
198===================================================================
199--- iproute2.orig/include/linux/pkt_cls.h
200+++ iproute2/include/linux/pkt_cls.h
201@@ -95,6 +95,10 @@ enum {
202
203 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
204
205+/* tca flags definitions */
206+#define TCA_CLS_FLAGS_SKIP_HW (1 << 0) /* don't offload filter to HW */
207+#define TCA_CLS_FLAGS_SKIP_SW (1 << 1) /* don't use filter in SW */
208+
209 /* U32 filters */
210
211 #define TC_U32_HTID(h) ((h)&0xFFF00000)
212@@ -363,6 +367,18 @@ enum {
213
214 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
215
216+/* Match-all classifier */
217+
218+enum {
219+ TCA_MATCHALL_UNSPEC,
220+ TCA_MATCHALL_CLASSID,
221+ TCA_MATCHALL_ACT,
222+ TCA_MATCHALL_FLAGS,
223+ __TCA_MATCHALL_MAX,
224+};
225+
226+#define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
227+
228 /* Extended Matches */
229
230 struct tcf_ematch_tree_hdr {
diff --git a/debian/patches/series b/debian/patches/series
index 09a3842..d65e150 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -12,3 +12,4 @@
121008-vf_trust_dddf1b44126e.patch121008-vf_trust_dddf1b44126e.patch
131009-vf_trust_b6d77d9ee312.patch131009-vf_trust_b6d77d9ee312.patch
141010-vf_trust_fe9322781e63.patch141010-vf_trust_fe9322781e63.patch
151011-tc-Add-support-for-the-matchall-traffic-classifier.patch

Subscribers

People subscribed via source and target branches