From e6acf64859fc1b4cc125608604cf38ae77c85367 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 9 Jul 2020 05:32:07 +0200 Subject: [PATCH] libnm-core: support 'clsact' qdisc The 'clsact' qdisc is similar to 'ingress' but supports both ingress and egress [1]. It uses the same handle as 'ingress' and has two child classes :fff2 (ingress) and :fff3 (egress) on which filters can be attached. With clsact, for example, it becomes possible to do port mirroring with a single qdisc: nmcli connection modify mirror +tc.qdisc "clsact" nmcli connection modify mirror +tc.tfilter "parent ffff:fff3 matchall action mirred egress mirror dev dummy1" nmcli connection modify mirror +tc.tfilter "parent ffff:fff2 matchall action mirred egress mirror dev dummy1" instead of two (ingress + i.e. prio). We don't support yet the symbolic names 'ingress' and 'egress' for :fff2 and :fff3 in the filter. See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1436535 [1] https://lwn.net/Articles/671458/ --- libnm-core/nm-utils.c | 4 ++-- libnm-core/tests/test-setting.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index b633a5099..c0913eea9 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -2375,7 +2375,7 @@ _nm_utils_string_append_tc_qdisc_rest (GString *string, NMTCQdisc *qdisc) gs_free char *str = NULL; if ( handle != TC_H_UNSPEC - && !nm_streq (kind, "ingress")) { + && !NM_IN_STRSET (kind, "ingress", "clsact")) { g_string_append (string, "handle "); _string_append_tc_handle (string, handle); g_string_append_c (string, ' '); @@ -2467,7 +2467,7 @@ _tc_read_common_opts (const char *str, variant = g_hash_table_lookup (ht, "kind"); if (variant) { *kind = g_variant_dup_string (variant, NULL); - if (nm_streq (*kind, "ingress")) { + if (NM_IN_STRSET (*kind, "ingress", "clsact")) { if (*parent == TC_H_UNSPEC) *parent = TC_H_INGRESS; if (*handle == TC_H_UNSPEC) diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c index 1b53baeda..6bf1fdb1e 100644 --- a/libnm-core/tests/test-setting.c +++ b/libnm-core/tests/test-setting.c @@ -2308,6 +2308,14 @@ test_tc_config_qdisc (void) nm_tc_qdisc_unref (qdisc1); nm_tc_qdisc_unref (qdisc2); + qdisc1 = nm_utils_tc_qdisc_from_str ("clsact", &error); + nmtst_assert_success (qdisc1, error); + str = nm_utils_tc_qdisc_to_str (qdisc1, &error); + nmtst_assert_success (str, error); + g_assert_cmpstr (str, ==, "clsact"); + nm_tc_qdisc_unref (qdisc1); + g_free (str); + #define CHECK_ATTRIBUTE(qdisc, name, vtype, type, value) \ variant = nm_tc_qdisc_get_attribute (qdisc, name); \ g_assert (variant); \