]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
Added attribute for inverse rules logic.
authorRostislav Lisovy <lisovy@gmail.com>
Wed, 10 Aug 2011 09:44:43 +0000 (11:44 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Wed, 10 Aug 2011 09:44:43 +0000 (11:44 +0200)
net/sched/cls_canprio.c

index b375d4741733fe39a7f82dc6f5ff7a75faa4053a..0adb2ae00e738a446baf8f71c62d34b5d995f7af 100644 (file)
@@ -29,7 +29,7 @@ struct canprio_rule {
 
 struct canprio_rule *canprio_rules;
 int canprio_rules_count = 0;
-int canprio_inv_en;
+int canprio_inv_en = 0;
 //--------------------------------------
 
 /* Definition of Netlink messages */
@@ -37,6 +37,7 @@ enum {
        TCA_CANPRIO_A_UNSPEC,
        TCA_CANPRIO_CLASSID,
        TCA_CANPRIO_RULES,
+       TCA_CANPRIO_INV_EN, /* enable inverse rules */
        __TCA_CANPRIO_MAX,
 };
 #define TCA_CANPRIO_MAX (__TCA_CANPRIO_MAX - 1)
@@ -45,6 +46,7 @@ static const struct nla_policy canprio_policy[TCA_CANPRIO_MAX + 1] = {
        [TCA_CANPRIO_CLASSID]    = { .type = NLA_U32 },
        //FIXME Be aware of possible problems with 64bit kernel and 32bit userspace etc.
        [TCA_CANPRIO_RULES]      = { .len = sizeof(canprio_rules) }, 
+       [TCA_CANPRIO_INV_EN]     = { .type = NLA_U32 },
 };
 
 struct canprio_head {
@@ -126,7 +128,7 @@ static int canprio_classify(struct sk_buff *skb, struct tcf_proto *tp,
                if (canid & CAN_EFF_FLAG) {
 
                } else {
-                       if(test_bit(canid, f->match)) {
+                       if(test_bit(canid, f->match) ^ canprio_inv_en) {
                                printk( "   canprio_classify() match ok: ID 0x%x\n", canid);
                                *res = f->res;
                                return TC_POLICE_OK;
@@ -278,6 +280,8 @@ static int canprio_change(struct tcf_proto *tp, unsigned long base, u32 handle,
                        canprio_rules[i].canid, canprio_rules[i].canid_mask);
        }
 
+       canprio_inv_en = nla_get_u32(tb[TCA_CANPRIO_INV_EN]);
+
        //Add newly created filter to list of all filters
        tcf_tree_lock(tp);
        list_add(&f->link, &head->flist);