* Reduced can_id to have a preprocessed filter compare value.
*/
static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask,
- struct can_dev_rcv_lists *d)
+ struct can_dev_rcv_lists *dev_rcv_lists)
{
canid_t inv = *can_id & CAN_INV_FILTER; /* save flag before masking */
if (*mask & CAN_ERR_FLAG) {
/* clear CAN_ERR_FLAG in filter entry */
*mask &= CAN_ERR_MASK;
- return &d->rx[RX_ERR];
+ return &dev_rcv_lists->rx[RX_ERR];
}
/* with cleared CAN_ERR_FLAG we have a simple mask/value filterpair */
/* inverse can_id/can_mask filter */
if (inv)
- return &d->rx[RX_INV];
+ return &dev_rcv_lists->rx[RX_INV];
/* mask == 0 => no condition testing at receive time */
if (!(*mask))
- return &d->rx[RX_ALL];
+ return &dev_rcv_lists->rx[RX_ALL];
/* extra filterlists for the subscription of a single non-RTR can_id */
if (((*mask & CAN_EFF_RTR_FLAGS) == CAN_EFF_RTR_FLAGS) &&
!(*can_id & CAN_RTR_FLAG)) {
if (*can_id & CAN_EFF_FLAG) {
if (*mask == (CAN_EFF_MASK | CAN_EFF_RTR_FLAGS))
- return &d->rx_eff[effhash(*can_id)];
+ return &dev_rcv_lists->rx_eff[effhash(*can_id)];
} else {
if (*mask == (CAN_SFF_MASK | CAN_EFF_RTR_FLAGS))
- return &d->rx_sff[*can_id];
+ return &dev_rcv_lists->rx_sff[*can_id];
}
}
/* default: filter via can_id/can_mask */
- return &d->rx[RX_FIL];
+ return &dev_rcv_lists->rx[RX_FIL];
}
/**
{
struct receiver *r;
struct hlist_head *rl;
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
int err = 0;
spin_lock(&net->can.rcvlists_lock);
- d = find_dev_rcv_lists(net, dev);
- if (d) {
- rl = find_rcv_list(&can_id, &mask, d);
+ dev_rcv_lists = find_dev_rcv_lists(net, dev);
+ if (dev_rcv_lists) {
+ rl = find_rcv_list(&can_id, &mask, dev_rcv_lists);
r->can_id = can_id;
r->mask = mask;
r->sk = sk;
hlist_add_head_rcu(&r->list, rl);
- d->entries++;
+ dev_rcv_lists->entries++;
rcv_lists_stats->rcv_entries++;
if (rcv_lists_stats->rcv_entries_max < rcv_lists_stats->rcv_entries)
struct receiver *r = NULL;
struct hlist_head *rl;
struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
if (dev && dev->type != ARPHRD_CAN)
return;
spin_lock(&net->can.rcvlists_lock);
- d = find_dev_rcv_lists(net, dev);
- if (!d) {
+ dev_rcv_lists = find_dev_rcv_lists(net, dev);
+ if (!dev_rcv_lists) {
pr_err("BUG: receive list not found for dev %s, id %03X, mask %03X\n",
DNAME(dev), can_id, mask);
goto out;
}
- rl = find_rcv_list(&can_id, &mask, d);
+ rl = find_rcv_list(&can_id, &mask, dev_rcv_lists);
/* Search the receiver list for the item to delete. This should
* exist, since no receiver may be unregistered that hasn't
* been registered before.
*/
-
hlist_for_each_entry_rcu(r, rl, list) {
if (r->can_id == can_id && r->mask == mask &&
r->func == func && r->data == data)
}
hlist_del_rcu(&r->list);
- d->entries--;
+ dev_rcv_lists->entries--;
if (rcv_lists_stats->rcv_entries > 0)
rcv_lists_stats->rcv_entries--;
/* remove device structure requested by NETDEV_UNREGISTER */
- if (d->remove_on_zero_entries && !d->entries) {
- kfree(d);
+ if (dev_rcv_lists->remove_on_zero_entries && !dev_rcv_lists->entries) {
+ kfree(dev_rcv_lists);
dev->ml_priv = NULL;
}
r->matches++;
}
-static int can_rcv_filter(struct can_dev_rcv_lists *d, struct sk_buff *skb)
+static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buff *skb)
{
struct receiver *r;
int matches = 0;
struct can_frame *cf = (struct can_frame *)skb->data;
canid_t can_id = cf->can_id;
- if (d->entries == 0)
+ if (dev_rcv_lists->entries == 0)
return 0;
if (can_id & CAN_ERR_FLAG) {
/* check for error message frame entries only */
- hlist_for_each_entry_rcu(r, &d->rx[RX_ERR], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_ERR], list) {
if (can_id & r->mask) {
deliver(skb, r);
matches++;
}
/* check for unfiltered entries */
- hlist_for_each_entry_rcu(r, &d->rx[RX_ALL], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_ALL], list) {
deliver(skb, r);
matches++;
}
/* check for can_id/mask entries */
- hlist_for_each_entry_rcu(r, &d->rx[RX_FIL], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_FIL], list) {
if ((can_id & r->mask) == r->can_id) {
deliver(skb, r);
matches++;
}
/* check for inverted can_id/mask entries */
- hlist_for_each_entry_rcu(r, &d->rx[RX_INV], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_INV], list) {
if ((can_id & r->mask) != r->can_id) {
deliver(skb, r);
matches++;
return matches;
if (can_id & CAN_EFF_FLAG) {
- hlist_for_each_entry_rcu(r, &d->rx_eff[effhash(can_id)], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx_eff[effhash(can_id)], list) {
if (r->can_id == can_id) {
deliver(skb, r);
matches++;
}
} else {
can_id &= CAN_SFF_MASK;
- hlist_for_each_entry_rcu(r, &d->rx_sff[can_id], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx_sff[can_id], list) {
deliver(skb, r);
matches++;
}
static void can_receive(struct sk_buff *skb, struct net_device *dev)
{
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
struct net *net = dev_net(dev);
struct can_pkg_stats *pkg_stats = net->can.pkg_stats;
int matches;
matches = can_rcv_filter(net->can.rx_alldev_list, skb);
/* find receive list for this device */
- d = find_dev_rcv_lists(net, dev);
- if (d)
- matches += can_rcv_filter(d, skb);
+ dev_rcv_lists = find_dev_rcv_lists(net, dev);
+ if (dev_rcv_lists)
+ matches += can_rcv_filter(dev_rcv_lists, skb);
rcu_read_unlock();
void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
if (dev->type != ARPHRD_CAN)
return NOTIFY_DONE;
case NETDEV_REGISTER:
/* create new dev_rcv_lists for this device */
- d = kzalloc(sizeof(*d), GFP_KERNEL);
- if (!d)
+ dev_rcv_lists = kzalloc(sizeof(*dev_rcv_lists), GFP_KERNEL);
+ if (!dev_rcv_lists)
return NOTIFY_DONE;
BUG_ON(dev->ml_priv);
- dev->ml_priv = d;
+ dev->ml_priv = dev_rcv_lists;
break;
case NETDEV_UNREGISTER:
spin_lock(&dev_net(dev)->can.rcvlists_lock);
- d = dev->ml_priv;
- if (d) {
- if (d->entries) {
- d->remove_on_zero_entries = 1;
- } else {
- kfree(d);
+ dev_rcv_lists = dev->ml_priv;
+ if (dev_rcv_lists) {
+ if (dev_rcv_lists->entries)
+ dev_rcv_lists->remove_on_zero_entries = 1;
+ else {
+ kfree(dev_rcv_lists);
dev->ml_priv = NULL;
}
} else {
rcu_read_lock();
for_each_netdev_rcu(net, dev) {
if (dev->type == ARPHRD_CAN && dev->ml_priv) {
- struct can_dev_rcv_lists *d = dev->ml_priv;
+ struct can_dev_rcv_lists *dev_rcv_lists = dev->ml_priv;
- BUG_ON(d->entries);
- kfree(d);
+ BUG_ON(dev_rcv_lists->entries);
+ kfree(dev_rcv_lists);
dev->ml_priv = NULL;
}
}