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/
This commit is contained in:
Beniamino Galvani 2020-07-09 05:32:07 +02:00
parent 2a1bac6b8a
commit e6acf64859
2 changed files with 10 additions and 2 deletions

View file

@ -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)

View file

@ -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); \