]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: implement support for action flags
authorVlad Buslov <vladbu@mellanox.com>
Wed, 30 Oct 2019 14:20:40 +0000 (16:20 +0200)
committerDavid Ahern <dsahern@gmail.com>
Sat, 2 Nov 2019 14:44:23 +0000 (07:44 -0700)
Implement setting and printing of action flags with single available flag
value "no_percpu" that translates to kernel UAPI TCA_ACT_FLAGS value
TCA_ACT_FLAGS_NO_PERCPU_STATS. Update man page with information regarding
usage of action flags.

Example usage:

 # tc actions add action gact drop no_percpu
 # sudo tc actions list action gact
 total acts 1

        action order 0: gact action drop
         random type none pass val 0
         index 1 ref 1 bind 0
        no_percpu

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
man/man8/tc-actions.8
tc/m_action.c

index f46166e3f685940e04e1efafdf30f7834651ed4a..bee59f7247faed3710d23f0565e2100b806d3e50 100644 (file)
@@ -47,6 +47,8 @@ actions \- independently defined actions in tc
 ] [
 .I COOKIESPEC
 ] [
+.I FLAGS
+] [
 .I CONTROL
 ]
 
@@ -71,6 +73,10 @@ ACTNAME
 :=
 .BI cookie " COOKIE"
 
+.I FLAGS
+:=
+.I no_percpu
+
 .I ACTDETAIL
 :=
 .I ACTNAME ACTPARAMS
@@ -186,6 +192,14 @@ As such, it can be used as a correlating value for maintaining user state.
 The value to be stored is completely arbitrary and does not require a specific
 format. It is stored inside the action structure itself.
 
+.TP
+.I FLAGS
+Action-specific flags. Currently, the only supported flag is
+.I no_percpu
+which indicates that action is expected to have minimal software data-path
+traffic and doesn't need to allocate stat counters with percpu allocator.
+This option is intended to be used by hardware-offloaded actions.
+
 .TP
 .BI since " MSTIME"
 When dumping large number of actions, a millisecond time-filter can be
index 36c744bbe374515dcca04706f46a3de7d3e89e9a..4da810c8c0aa769a5fd7c3992977b9dc31723d93 100644 (file)
@@ -250,6 +250,16 @@ done0:
                                addattr_l(n, MAX_MSG, TCA_ACT_COOKIE,
                                          &act_ck, act_ck_len);
 
+                       if (*argv && strcmp(*argv, "no_percpu") == 0) {
+                               struct nla_bitfield32 flags =
+                                       { TCA_ACT_FLAGS_NO_PERCPU_STATS,
+                                         TCA_ACT_FLAGS_NO_PERCPU_STATS };
+
+                               addattr_l(n, MAX_MSG, TCA_ACT_FLAGS, &flags,
+                                         sizeof(struct nla_bitfield32));
+                               NEXT_ARG_FWD();
+                       }
+
                        addattr_nest_end(n, tail);
                        ok++;
                }
@@ -318,6 +328,15 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
                                           strsz, b1, sizeof(b1)));
                print_string(PRINT_FP, NULL, "%s", _SL_);
        }
+       if (tb[TCA_ACT_FLAGS]) {
+               struct nla_bitfield32 *flags = RTA_DATA(tb[TCA_ACT_FLAGS]);
+
+               if (flags->selector & TCA_ACT_FLAGS_NO_PERCPU_STATS)
+                       print_bool(PRINT_ANY, "no_percpu", "\tno_percpu",
+                                  flags->value &
+                                  TCA_ACT_FLAGS_NO_PERCPU_STATS);
+               print_string(PRINT_FP, NULL, "%s", _SL_);
+       }
 
        return 0;
 }