*
* Some function descriptions are heavily inspired by article "Linux Network
* Traffic Control -- Implementation Overview" by Werner Almesberger
- *
- *
- * Implementation notes;
- * parameter of functions named "base" is pointer to some parent element
*/
#include <linux/module.h>
#endif
#define SFF_BITMAP 1
-#undef SFF_BITMAP
+
/* Definition of Netlink messages */
enum {
{
int i;
- pr_debug("%s() invoked\n", __FUNCTION__);
/* Limit can_mask and can_id to SFF range to protect against write after end of array */
can_mask &= CAN_SFF_MASK;
can_id &= can_mask;
u32 can_id;
int i;
- pr_debug(" canprio_classify() invoked\n");
can_id = (u32)canprio_get_id(skb);
rcu_read_lock();
#endif
}
- //if (r->inv_match_en)
- // match = !match;
-
if (match) {
*res = f->res;
- pr_debug( " canprio_classify() match ok: ID 0x%x\n", can_id);
rcu_read_unlock();
return TC_POLICE_OK;
}
struct canprio_rules *rules_tmp;
int err;
int i;
- pr_debug("%s() invoked\n", __FUNCTION__);
rules_tmp = kzalloc(sizeof(*rules_tmp), GFP_KERNEL);
if (rules_tmp == NULL)
canprio_nl_rules = nla_data(tb[TCA_CANPRIO_RULES]);
rules_tmp->sff_rules_count = 0;
rules_tmp->eff_rules_count = 0;
- rules_tmp->rules_count = (nla_len(tb[TCA_CANPRIO_RULES]) / sizeof(struct can_filter));
- pr_debug(" rules_count = %u\n", rules_tmp->rules_count);
+ rules_tmp->rules_count =
+ (nla_len(tb[TCA_CANPRIO_RULES]) / sizeof(struct can_filter));
- rules_tmp->rules_raw = kzalloc(sizeof(struct can_filter) * rules_tmp->rules_count, GFP_KERNEL);
+ rules_tmp->rules_raw =
+ kzalloc(sizeof(struct can_filter) * rules_tmp->rules_count, GFP_KERNEL);
err = -ENOMEM;
if (rules_tmp->rules_raw == NULL)
goto errout;
memcpy(rules_tmp->rules_raw + rules_tmp->eff_rules_count,
&canprio_nl_rules[i], sizeof(struct can_filter));
rules_tmp->eff_rules_count ++;
-
- pr_debug(" can ID to match = 0x%x with mask 0x%x\n",
- canprio_nl_rules[i].can_id, canprio_nl_rules[i].can_mask);
} else {
continue;
}
canprio_sff_match_add(rules_tmp, canprio_nl_rules[i].can_id,
canprio_nl_rules[i].can_mask);
#endif
-
- pr_debug(" can ID to match = 0x%x with mask 0x%x\n",
- canprio_nl_rules[i].can_id, canprio_nl_rules[i].can_mask);
}
}
}
if (tb[TCA_CANPRIO_INV_EN] != NULL)
rules_tmp->inv_match_en = nla_get_u32(tb[TCA_CANPRIO_INV_EN]);
- if (f->rules == NULL) { // Setting parameters for newly created filter
+ if (f->rules == NULL) { /* Setting parameters for newly created filter */
rcu_assign_pointer(f->rules, rules_tmp);
- } else { // Changing existing filter
+ } else { /* Changing existing filter */
struct canprio_rules *rules_old;
rules_old = xchg(&f->rules, rules_tmp);
* @base:
* @handle:
* @tca: Messages passed through the Netlink from userspace.
- * @arg: ??? FIXME
+ * @arg:
*/
static int canprio_change(struct tcf_proto *tp, unsigned long base, u32 handle,
struct nlattr **tca, unsigned long *arg)
struct nlattr *tb[TCA_CANPRIO_MAX + 1];
int err;
- pr_debug("%s() invoked\n", __FUNCTION__);
-
if (tca[TCA_OPTIONS] == NULL)
return -EINVAL;
if (handle && f->handle != handle)
return -EINVAL;
- pr_debug("[change existing filter]\n");
return canprio_set_parms(tp, f, base, tb, tca[TCA_RATE]);
}
f->handle = canprio_gen_handle(tp);
}
- //Configure filter
+ /* Configure filter */
err = canprio_set_parms(tp, f, base, tb, tca[TCA_RATE]);
if (err < 0)
goto errout;
- //Add newly created filter to list of all filters
+ /* Add newly created filter to list of all filters */
tcf_tree_lock(tp);
list_add(&f->link, &head->flist);
tcf_tree_unlock(tp);
static int canprio_init(struct tcf_proto *tp)
{
struct canprio_head *head;
- pr_debug(" canprio_init invoked\n");
head = kzalloc(sizeof(*head), GFP_KERNEL);
if (head == NULL)
struct canprio_head *head = (struct canprio_head *) tp->root;
struct canprio_filter *f;
- pr_debug("%s() invoked\n", __FUNCTION__);
-
list_for_each_entry(f, &head->flist, link) {
if (arg->count < arg->skip)
goto skip;
struct canprio_filter *f = (struct canprio_filter *) fh;
struct nlattr *nest;
struct canprio_rules *r;
- pr_debug("%s() invoked\n", __FUNCTION__);
if (f == NULL)
return skb->len;