* ----------------------------------------------------------------------------
*/
-#ifdef SFF_BITMAP
static void canfltr_sff_match_add(struct canfltr_rules *rls, u32 can_id, u32 can_mask)
{
+#ifdef SFF_BITMAP
int i;
/* Limit can_mask and can_id to SFF range to protect against write after end of array */
if ((i & can_mask) == can_id)
set_bit(i, rls->match_sff);
}
-}
#endif
+}
/*
- * Extracts Can ID ot ouf the sk_buff structure.
+ * Extracts Can ID out of the sk_buff structure.
*/
static canid_t canfltr_get_id(struct sk_buff *skb)
{
}
/*
- * Performs the classification. Iterates over all instances of filter
- * checking for Can ID match.
+ * Performs the classification. Iterates over all instances of filter,
+ * checking for CAN ID match.
*
* @skb: Socket buffer
* @tp:
*
* Returns value relevant for policing. Used return values:
* TC_POLICE_OK if succesfully classified (without regard to policing rules)
- * TC_POLICE_UNSPEC if no matching filter was found
+ * TC_POLICE_UNSPEC if no matching rule was found
*/
static int canfltr_classify(struct sk_buff *skb, struct tcf_proto *tp,
struct tcf_result *res)
struct canfltr_head *head = (struct canfltr_head *)tp->root;
struct canfltr_state *f;
struct canfltr_rules *r;
- u32 can_id;
+ canid_t can_id;
int i;
- can_id = (u32)canfltr_get_id(skb);
+ can_id = canfltr_get_id(skb);
rcu_read_lock();
list_for_each_entry(f, &head->flist, link) {
can_id &= CAN_EFF_MASK;
for (i = 0; i < r->eff_rules_count; i++) {
- if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK) ==
- (can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK)) {
-
+ if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK) == /* XXX: Why aren't these & performed "off-line"? */
+ (can_id & r->rules_raw[i].can_mask & CAN_EFF_MASK)) {
match = true;
break;
}
match = test_bit(can_id, r->match_sff);
#else
for (i = r->eff_rules_count; i < r->eff_rules_count + r->sff_rules_count; i++) {
- if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK) ==
- (can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK)) {
-
+ if ((r->rules_raw[i].can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK) == /* XXX: dtto */
+ (can_id & r->rules_raw[i].can_mask & CAN_SFF_MASK)) {
match = true;
break;
}
{
}
-
static unsigned int canfltr_gen_handle(struct tcf_proto *tp)
{
struct canfltr_head *head = (struct canfltr_head *)tp->root;
return 0;
}
-
static void canfltr_rules_free_rcu(struct rcu_head *rcu)
{
kfree(container_of(rcu, struct canfltr_rules, rcu));
rules_tmp = kzalloc(sizeof(*rules_tmp), GFP_KERNEL);
if (rules_tmp == NULL)
- return -ENOBUFS;
+ return -ENOBUFS; /* XXX: Why not -ENOMEM? */
err = -EINVAL;
if (tb[TCA_CANFLTR_CLASSID] == NULL)
if (rules_tmp->rules_raw == NULL)
goto errout;
- /* Process EFF frames */
+ /* We need two for() loops for copying rules into two contiguous areas in rules_raw */
+
+ /* Process EFF frame rules*/
for (i = 0; i < rules_tmp->rules_count; i++) {
if ((canfltr_nl_rules[i].can_id & CAN_EFF_FLAG) &&
- (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) {
-
+ (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) {
memcpy(rules_tmp->rules_raw + rules_tmp->eff_rules_count,
- &canfltr_nl_rules[i], sizeof(struct can_filter));
+ &canfltr_nl_rules[i], sizeof(struct can_filter));
rules_tmp->eff_rules_count ++;
} else {
continue;
}
}
- /* Process SFF frames
- We need two for() loops for copying rules into two contiguous areas in rules_raw */
+ /* Process SFF frame rules */
for (i = 0; i < rules_tmp->rules_count; i++) {
if ((canfltr_nl_rules[i].can_id & CAN_EFF_FLAG) &&
- (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) {
-
+ (canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) {
continue;
} else {
memcpy(rules_tmp->rules_raw + rules_tmp->eff_rules_count + rules_tmp->sff_rules_count,
- &canfltr_nl_rules[i], sizeof(struct can_filter));
+ &canfltr_nl_rules[i], sizeof(struct can_filter));
rules_tmp->sff_rules_count ++;
-
-#ifdef SFF_BITMAP
canfltr_sff_match_add(rules_tmp, canfltr_nl_rules[i].can_id,
canfltr_nl_rules[i].can_mask);
-#endif
}
}
}
MODULE_LICENSE("GPL");
MODULE_AUTHOR(""); // FIXME
MODULE_DESCRIPTION("Controller Area Network classifier");
-