From: Rostislav Lisovy Date: Wed, 10 Aug 2011 09:44:43 +0000 (+0200) Subject: Added attribute for inverse rules logic. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lisovros/linux_canprio.git/commitdiff_plain/27de21caed76e86b1e7f595e8376419ab0e221e1?ds=sidebyside Added attribute for inverse rules logic. --- diff --git a/net/sched/cls_canprio.c b/net/sched/cls_canprio.c index b375d474173..0adb2ae00e7 100644 --- a/net/sched/cls_canprio.c +++ b/net/sched/cls_canprio.c @@ -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);