#define CAN_EFF_ID_BITS 29
#endif
-#define SFF_BITMAP 1
+#define SFF_BITMAP 1 /* Use bitmap for storing rules
+ for SFF frames? */
-/* Definition of Netlink messages */
+/* Definition of Netlink message parts */
enum {
TCA_CANFLTR_UNSPEC,
TCA_CANFLTR_CLASSID,
- TCA_CANFLTR_RULES, /* Array of can_filter structs; We are able
+ TCA_CANFLTR_RULES, /* Array of can_filter structs; We are able
to determine the length after receiving */
__TCA_CANFLTR_MAX
};
};
struct canfltr_rules {
- struct can_filter *rules_raw; /* Raw rules copied from netlink message;
- Used for sending information to userspace
- (when 'tc filter show' is invoked) AND
- when matching EFF frames*/
+ struct can_filter *rules_raw; /* Raw rules copied from netlink
+ message; Used for sending information
+ to userspace (when 'tc filter show' is
+ invoked) AND when matching EFF frames*/
#ifdef SFF_BITMAP
- DECLARE_BITMAP(match_sff, (1 << CAN_SFF_ID_BITS)); /* For each SFF Can
+ DECLARE_BITMAP(match_sff, (1 << CAN_SFF_ID_BITS)); /* For each SFF CAN
ID (11 bit) there is one record in this
bitfield */
#endif
struct canfltr_state {
u32 handle;
- struct canfltr_rules *rules; /* All rules necessary for classification */
+ struct canfltr_rules *rules; /* All rules necessary for
+ classification */
struct tcf_result res; /* Class ID (flow id) the instance
of a filter is bound to */
struct list_head link;
* ----------------------------------------------------------------------------
*/
-static void canfltr_sff_match_add(struct canfltr_rules *rls, u32 can_id, u32 can_mask)
+static void canfltr_sff_match_add(struct canfltr_rules *rls,
+ u32 can_id, u32 can_mask)
{
#ifdef SFF_BITMAP
int i;
}
/* individual frame filter */
- /* Add record (set bit to 1) for each ID that conforms particular rule */
+ /* Add record (set bit to 1) for each ID that
+ conforms particular rule */
for (i = 0; i < (1 << CAN_SFF_ID_BITS); i++) {
if ((i & can_mask) == can_id)
set_bit(i, rls->match_sff);
canfltr_nl_rules = nla_data(tb[TCA_CANFLTR_RULES]);
rules_tmp->sff_rules_count = 0;
rules_tmp->eff_rules_count = 0;
- rules_tmp->rules_count =
- (nla_len(tb[TCA_CANFLTR_RULES]) / sizeof(struct can_filter));
+ rules_tmp->rules_count = (nla_len(tb[TCA_CANFLTR_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;
- /* We need two for() loops for copying rules into two contiguous areas in rules_raw */
+ /* 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)) {
- memcpy(rules_tmp->rules_raw + rules_tmp->eff_rules_count,
- &canfltr_nl_rules[i], sizeof(struct can_filter));
+ memcpy(rules_tmp->rules_raw +
+ rules_tmp->eff_rules_count,
+ &canfltr_nl_rules[i],
+ sizeof(struct can_filter));
rules_tmp->eff_rules_count++;
} else {
continue;
(canfltr_nl_rules[i].can_mask & CAN_EFF_FLAG)) {
continue;
} else {
- memcpy(rules_tmp->rules_raw + rules_tmp->eff_rules_count +
+ 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++;
- canfltr_sff_match_add(rules_tmp, canfltr_nl_rules[i].can_id,
- canfltr_nl_rules[i].can_mask);
+ canfltr_sff_match_add(rules_tmp,
+ canfltr_nl_rules[i].can_id,
+ canfltr_nl_rules[i].can_mask);
}
}
}
- if (f->rules == NULL) { /* Setting parameters for newly created filter */
+ /* Setting parameters for newly created filter */
+ if (f->rules == NULL) {
rcu_assign_pointer(f->rules, rules_tmp);
} else { /* Changing existing filter */
struct canfltr_rules *rules_old;
}
-static void canfltr_delete_filter(struct tcf_proto *tp, struct canfltr_state *f)
+static void canfltr_delete_filter(struct tcf_proto *tp,
+ struct canfltr_state *f)
{
tcf_unbind_filter(tp, &f->res);