diff mbox series

[RFC,iproute2,3/5] act_ct: add support for commit flag

Message ID 874e2d7dcf83c28d7630c2aa21905e7a90f912e5.1548287070.git.mleitner@redhat.com
State RFC
Delegated to: David Ahern
Headers show
Series Initial, PoC implementation of sw datapath of tc+CT | expand

Commit Message

Marcelo Ricardo Leitner Jan. 25, 2019, 2:33 a.m. UTC
Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>
---
 include/uapi/linux/tc_act/tc_ct.h |  6 ++++++
 tc/m_ct.c                         | 14 ++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/uapi/linux/tc_act/tc_ct.h b/include/uapi/linux/tc_act/tc_ct.h
index d08a5afdc4b453c5388ad2ae63a00fd3b48457f0..37b95cda1dedd283b0244a03a20860ba22966dfa 100644
--- a/include/uapi/linux/tc_act/tc_ct.h
+++ b/include/uapi/linux/tc_act/tc_ct.h
@@ -23,6 +23,12 @@  enum {
 };
 #define TCA_CT_MAX (__TCA_CT_MAX - 1)
 
+enum {
+	TC_CT_COMMIT,
+	__TC_CT_MAX
+};
+#define TC_CT_MAX (__TC_CT_MAX - 1)
+
 struct tc_ct {
 	tc_gen;
 };
diff --git a/tc/m_ct.c b/tc/m_ct.c
index e20837ba4f9c49d1603b14721cabca1fbeca0c74..0e9b20edab8c870f93657d43bb5e72c13e9b6bd4 100644
--- a/tc/m_ct.c
+++ b/tc/m_ct.c
@@ -27,7 +27,7 @@  static void
 explain(void)
 {
 	fprintf(stderr,
-		"Usage: ct [mark <mark>] [zone <zone>] [label <label>] [chain <chain>]\n"
+		"Usage: ct [mark <mark>] [zone <zone>] [label <label>] [chain <chain>] [commit]\n"
 		"where:\n");
 }
 
@@ -181,6 +181,7 @@  parse_ct(struct action_util *a, int *argc_p, char ***argv_p,
 	char **argv = *argv_p;
 	struct tc_ct p = {};
 	struct rtattr *tail;
+	__u32 flags = 0;
 
 	if (argc <= 0) {
 		fprintf(stderr, "ct bad argument count %d\n", argc);
@@ -198,6 +199,8 @@  parse_ct(struct action_util *a, int *argc_p, char ***argv_p,
 
 again:
 	if (argc <= 0) {
+out:
+		addattr32(n, MAX_MSG, TCA_CT_FLAGS, flags);
 		addattr_l(n, MAX_MSG, TCA_CT_PARMS, &p, sizeof(p));
 		addattr_nest_end(n, tail);
 
@@ -224,6 +227,11 @@  again:
 		NEXT_ARG_FWD();
 		goto again;
 	}
+	if (!matches(*argv, "commit")) {
+		NEXT_ARG_FWD();
+		flags |= BIT(TC_CT_COMMIT);
+		goto again;
+	}
 /*	if (!matches(*argv, "state")) {
 		NEXT_ARG();
 		ct_parse_u8(*argv,
@@ -242,7 +250,9 @@  again:
 		goto again;
 	}*/
 
-	if (!matches(*argv, "help") == 0) {
+	if (!matches(*argv, "action"))
+		goto out;
+	if (!matches(*argv, "help")) {
 		usage();
 	} else {
 		fprintf(stderr, "ct option not supported %s\n", *argv);