]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/blobdiff - tc/f_flow.c
Convert to use rta_getattr_ functions
[lisovros/iproute2_canprio.git] / tc / f_flow.c
index 1537ade826e11ad3e940082462d843e69f96202a..7d4bb7aff65dee96c008650bb1c353f5257e6dd9 100644 (file)
@@ -24,7 +24,7 @@ static void explain(void)
 "Usage: ... flow ...\n"
 "\n"
 " [mapping mode]: map key KEY [ OPS ] ...\n"
-" [hashing mode]: hash keys KEY-LIST ...\n"
+" [hashing mode]: hash keys KEY-LIST ... [ perturb SECS ]\n"
 "\n"
 "                 [ divisor NUM ] [ baseclass ID ] [ match EMATCH_TREE ]\n"
 "                 [ police POLICE_SPEC ] [ action ACTION_SPEC ]\n"
@@ -33,7 +33,7 @@ static void explain(void)
 "KEY      := [ src | dst | proto | proto-src | proto-dst | iif | priority | \n"
 "              mark | nfct | nfct-src | nfct-dst | nfct-proto-src | \n"
 "              nfct-proto-dst | rt-classid | sk-uid | sk-gid |\n"
-"              vlan-tag ]\n"
+"              vlan-tag | rxhash ]\n"
 "OPS      := [ or NUM | and NUM | xor NUM | rshift NUM | addend NUM ]\n"
 "ID       := X:Y\n"
        );
@@ -57,6 +57,7 @@ static const char *flow_keys[FLOW_KEY_MAX+1] = {
        [FLOW_KEY_SKUID]                = "sk-uid",
        [FLOW_KEY_SKGID]                = "sk-gid",
        [FLOW_KEY_VLAN_TAG]             = "vlan-tag",
+       [FLOW_KEY_RXHASH]               = "rxhash",
 };
 
 static int flow_parse_keys(__u32 *keys, __u32 *nkeys, char *argv)
@@ -211,6 +212,13 @@ static int flow_parse_opt(struct filter_util *fu, char *handle,
                                return -1;
                        }
                        addattr32(n, 4096, TCA_FLOW_BASECLASS, tmp);
+               } else if (matches(*argv, "perturb") == 0) {
+                       NEXT_ARG();
+                       if (get_u32(&tmp, *argv, 0)) {
+                               fprintf(stderr, "Illegal \"perturb\"\n");
+                               return -1;
+                       }
+                       addattr32(n, 4096, TCA_FLOW_PERTURB, tmp);
                } else if (matches(*argv, "police") == 0) {
                        NEXT_ARG();
                        if (parse_police(&argc, &argv, TCA_FLOW_POLICE, n)) {
@@ -274,7 +282,7 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
        fprintf(f, "handle 0x%x ", handle);
 
        if (tb[TCA_FLOW_MODE]) {
-               __u32 mode = *(__u32 *)RTA_DATA(tb[TCA_FLOW_MODE]);
+               __u32 mode = rta_getattr_u32(tb[TCA_FLOW_MODE]);
 
                switch (mode) {
                case FLOW_MODE_MAP:
@@ -287,7 +295,7 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
        }
 
        if (tb[TCA_FLOW_KEYS]) {
-               __u32 keymask = *(__u32 *)RTA_DATA(tb[TCA_FLOW_KEYS]);
+               __u32 keymask = rta_getattr_u32(tb[TCA_FLOW_KEYS]);
                char *sep = "";
 
                fprintf(f, "keys ");
@@ -301,9 +309,9 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
        }
 
        if (tb[TCA_FLOW_MASK])
-               mask = *(__u32 *)RTA_DATA(tb[TCA_FLOW_MASK]);
+               mask = rta_getattr_u32(tb[TCA_FLOW_MASK]);
        if (tb[TCA_FLOW_XOR])
-               val = *(__u32 *)RTA_DATA(tb[TCA_FLOW_XOR]);
+               val = rta_getattr_u32(tb[TCA_FLOW_XOR]);
 
        if (mask != ~0 || val != 0) {
                __u32 or = (mask & val) ^ val;
@@ -319,17 +327,21 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
 
        if (tb[TCA_FLOW_RSHIFT])
                fprintf(f, "rshift %u ",
-                       *(__u32 *)RTA_DATA(tb[TCA_FLOW_RSHIFT]));
+                       rta_getattr_u32(tb[TCA_FLOW_RSHIFT]));
        if (tb[TCA_FLOW_ADDEND])
                fprintf(f, "addend 0x%x ",
-                       *(__u32 *)RTA_DATA(tb[TCA_FLOW_ADDEND]));
+                       rta_getattr_u32(tb[TCA_FLOW_ADDEND]));
 
        if (tb[TCA_FLOW_DIVISOR])
                fprintf(f, "divisor %u ",
-                       *(__u32 *)RTA_DATA(tb[TCA_FLOW_DIVISOR]));
+                       rta_getattr_u32(tb[TCA_FLOW_DIVISOR]));
        if (tb[TCA_FLOW_BASECLASS])
                fprintf(f, "baseclass %s ",
-                       sprint_tc_classid(*(__u32 *)RTA_DATA(tb[TCA_FLOW_BASECLASS]), b1));
+                       sprint_tc_classid(rta_getattr_u32(tb[TCA_FLOW_BASECLASS]), b1));
+
+       if (tb[TCA_FLOW_PERTURB])
+               fprintf(f, "perturb %usec ",
+                       rta_getattr_u32(tb[TCA_FLOW_PERTURB]));
 
        if (tb[TCA_FLOW_EMATCHES])
                print_ematch(f, tb[TCA_FLOW_EMATCHES]);