]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
It is possible to pass multiple rules for one instance of a filter.
authorRostislav Lisovy <lisovy@gmail.com>
Wed, 10 Aug 2011 09:31:00 +0000 (11:31 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Wed, 23 May 2012 08:45:12 +0000 (10:45 +0200)
include/linux/pkt_cls.h
tc/f_canprio.c
tc/setcanprio.sh

index f37b88b805e5e9ffef59c497575df72ba5ffbb53..4bd2eb9dc349e0172c96ad1255e5d7f39662b2e7 100644 (file)
@@ -380,8 +380,7 @@ enum {
 enum {
        TCA_CANPRIO_UNSPEC,
        TCA_CANPRIO_CLASSID,
-       TCA_CANPRIO_MATCH,
-       TCA_CANPRIO_MATCH_MASK,
+       TCA_CANPRIO_RULES,
        __TCA_CANPRIO_MAX
 };
 
index 18c9294fe285995ed3549698add1f838fe953d13..e202b55e67f99fd2c26b7bc5ecf5902d0e30d088 100644 (file)
 #include "utils.h"
 #include "tc_util.h"
 
+struct canprio_rule {
+       __u32 canid;
+       __u32 canid_mask;
+};
+
+struct canprio_rule canprio_rules[32];
 
 static void explain(void)
 {
@@ -29,7 +35,7 @@ static int canprio_parse_opt(struct filter_util *qu, char *handle,
        struct rtattr *tail;
        long h = 0;
        __u32 canid, canid_mask;
-
+       int rules_count = 0;
 
        if (argc == 0)
                return 0;
@@ -61,8 +67,9 @@ static int canprio_parse_opt(struct filter_util *qu, char *handle,
 
                        //printf("... 0x%x:0x%x]\n", canid, canid_mask);
                        if (canid > 0) {// FIXME boundary check
-                               addattr32(n, 4096, TCA_CANPRIO_MATCH, canid);
-                               addattr32(n, 4096, TCA_CANPRIO_MATCH_MASK, canid_mask);
+                               canprio_rules[rules_count].canid = canid;
+                               canprio_rules[rules_count].canid_mask = canid_mask;
+                               rules_count++;
                        }
 
                } else if (matches(*argv, "classid") == 0 ||
@@ -88,7 +95,9 @@ static int canprio_parse_opt(struct filter_util *qu, char *handle,
                argc--; argv++;
        }
 
-
+       
+       addattr_l(n, MAX_MSG, TCA_CANPRIO_RULES, &canprio_rules, 
+               sizeof(struct canprio_rule) * rules_count);
 
        tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
        return 0;
@@ -114,12 +123,10 @@ static int canprio_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt
                        sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_BASIC_CLASSID]), b1));
        }
 
-       if (tb[TCA_CANPRIO_MATCH])
-               fprintf(f, "Canid 0x%x ",
-                               *(__u32 *)RTA_DATA(tb[TCA_CANPRIO_MATCH]));
-       if (tb[TCA_CANPRIO_MATCH_MASK])
-               fprintf(f, "Canid mask %x ",
-                               *(__u32 *)RTA_DATA(tb[TCA_CANPRIO_MATCH_MASK]));
+       //FIXME
+       //if (tb[TCA_CANPRIO_RULES])
+       //      fprintf(f, "Canid 0x%x ",
+       //                      *(__u32 *)RTA_DATA(tb[TCA_CANPRIO_MATCH]));
 
 
        return 0;
index 7b60f3fe0789bad47759572fbbd1a7a5eb21fb7d..e320030085de94775293691a0de7a279325e9d1c 100755 (executable)
@@ -8,9 +8,9 @@ elif [ "$1" =  "stat" ]; then # show statistics
 
 else # create Prio qdiscs and configure canprio filter
        sudo ./tc qdisc add dev can0 root handle 1: prio
-       sudo ./tc filter add dev can0 parent 1:0 prio 1 canprio match 0x123:0xffff flowid 1:1
+       sudo ./tc filter add dev can0 parent 1:0 prio 1 canprio match 0x123:0xffff match 0x124:0xffff flowid 1:1
        sudo ./tc filter add dev can0 parent 1:0 prio 2 canprio match 0x223:0xffff flowid 1:2
-       sudo ./tc filter add dev can0 parent 1:0 prio 3 canprio match 0x323:0xffff flowid 1:3
+       sudo ./tc filter add dev can0 parent 1:0 prio 3 canprio match 0x1:0x1 flowid 1:3
 
        sudo ./tc qdisc show dev can0