Commit b4c84ec0 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

net/atm/lec.c: Add __lec_arp_check_expire and other cleanups

Reduce indentation in lec_arp_check_expire
Indent a case label
Remove != NULL logical tests from while ((skb = foo())) assign and tests
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b7d9371b
...@@ -285,7 +285,6 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, ...@@ -285,7 +285,6 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
/* Make sure we have room for lec_id */ /* Make sure we have room for lec_id */
if (skb_headroom(skb) < 2) { if (skb_headroom(skb) < 2) {
pr_debug("reallocating skb\n"); pr_debug("reallocating skb\n");
skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
kfree_skb(skb); kfree_skb(skb);
...@@ -515,21 +514,18 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -515,21 +514,18 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
if (br_fdb_test_addr_hook == NULL) if (br_fdb_test_addr_hook == NULL)
break; break;
if (br_fdb_test_addr_hook(dev, if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) {
mesg->content.proxy.mac_addr)) {
/* hit from bridge table, send LE_ARP_RESPONSE */ /* hit from bridge table, send LE_ARP_RESPONSE */
struct sk_buff *skb2; struct sk_buff *skb2;
struct sock *sk; struct sock *sk;
pr_debug("%s: entry found, responding to zeppelin\n", pr_debug("%s: entry found, responding to zeppelin\n",
dev->name); dev->name);
skb2 = alloc_skb(sizeof(struct atmlec_msg), skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
GFP_ATOMIC);
if (skb2 == NULL) if (skb2 == NULL)
break; break;
skb2->len = sizeof(struct atmlec_msg); skb2->len = sizeof(struct atmlec_msg);
skb_copy_to_linear_data(skb2, mesg, skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg));
sizeof(*mesg));
atm_force_charge(priv->lecd, skb2->truesize); atm_force_charge(priv->lecd, skb2->truesize);
sk = sk_atm(priv->lecd); sk = sk_atm(priv->lecd);
skb_queue_tail(&sk->sk_receive_queue, skb2); skb_queue_tail(&sk->sk_receive_queue, skb2);
...@@ -561,7 +557,7 @@ static void lec_atm_close(struct atm_vcc *vcc) ...@@ -561,7 +557,7 @@ static void lec_atm_close(struct atm_vcc *vcc)
if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) if (skb_peek(&sk_atm(vcc)->sk_receive_queue))
pr_info("%s closing with messages pending\n", dev->name); pr_info("%s closing with messages pending\n", dev->name);
while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) {
atm_return(vcc, skb->truesize); atm_return(vcc, skb->truesize);
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
...@@ -1748,6 +1744,50 @@ static void lec_arp_expire_vcc(unsigned long data) ...@@ -1748,6 +1744,50 @@ static void lec_arp_expire_vcc(unsigned long data)
lec_arp_put(to_remove); lec_arp_put(to_remove);
} }
static bool __lec_arp_check_expire(struct lec_arp_table *entry,
unsigned long now,
struct lec_priv *priv)
{
unsigned long time_to_check;
if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change)
time_to_check = priv->forward_delay_time;
else
time_to_check = priv->aging_time;
pr_debug("About to expire: %lx - %lx > %lx\n",
now, entry->last_used, time_to_check);
if (time_after(now, entry->last_used + time_to_check) &&
!(entry->flags & LEC_PERMANENT_FLAG) &&
!(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */
/* Remove entry */
pr_debug("Entry timed out\n");
lec_arp_remove(priv, entry);
lec_arp_put(entry);
} else {
/* Something else */
if ((entry->status == ESI_VC_PENDING ||
entry->status == ESI_ARP_PENDING) &&
time_after_eq(now, entry->timestamp +
priv->max_unknown_frame_time)) {
entry->timestamp = jiffies;
entry->packets_flooded = 0;
if (entry->status == ESI_VC_PENDING)
send_to_lecd(priv, l_svc_setup,
entry->mac_addr,
entry->atm_addr,
NULL);
}
if (entry->status == ESI_FLUSH_PENDING &&
time_after_eq(now, entry->timestamp +
priv->path_switching_delay)) {
lec_arp_hold(entry);
return true;
}
}
return false;
}
/* /*
* Expire entries. * Expire entries.
* 1. Re-set timer * 1. Re-set timer
...@@ -1772,7 +1812,6 @@ static void lec_arp_check_expire(struct work_struct *work) ...@@ -1772,7 +1812,6 @@ static void lec_arp_check_expire(struct work_struct *work)
struct hlist_node *node, *next; struct hlist_node *node, *next;
struct lec_arp_table *entry; struct lec_arp_table *entry;
unsigned long now; unsigned long now;
unsigned long time_to_check;
int i; int i;
pr_debug("%p\n", priv); pr_debug("%p\n", priv);
...@@ -1782,54 +1821,22 @@ static void lec_arp_check_expire(struct work_struct *work) ...@@ -1782,54 +1821,22 @@ static void lec_arp_check_expire(struct work_struct *work)
for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
hlist_for_each_entry_safe(entry, node, next, hlist_for_each_entry_safe(entry, node, next,
&priv->lec_arp_tables[i], next) { &priv->lec_arp_tables[i], next) {
if ((entry->flags) & LEC_REMOTE_FLAG && if (__lec_arp_check_expire(entry, now, priv)) {
priv->topology_change)
time_to_check = priv->forward_delay_time;
else
time_to_check = priv->aging_time;
pr_debug("About to expire: %lx - %lx > %lx\n",
now, entry->last_used, time_to_check);
if (time_after(now, entry->last_used + time_to_check) &&
!(entry->flags & LEC_PERMANENT_FLAG) &&
!(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */
/* Remove entry */
pr_debug("Entry timed out\n");
lec_arp_remove(priv, entry);
lec_arp_put(entry);
} else {
/* Something else */
if ((entry->status == ESI_VC_PENDING ||
entry->status == ESI_ARP_PENDING) &&
time_after_eq(now,
entry->timestamp +
priv->max_unknown_frame_time)) {
entry->timestamp = jiffies;
entry->packets_flooded = 0;
if (entry->status == ESI_VC_PENDING)
send_to_lecd(priv, l_svc_setup,
entry->mac_addr,
entry->atm_addr,
NULL);
}
if (entry->status == ESI_FLUSH_PENDING &&
time_after_eq(now, entry->timestamp +
priv->path_switching_delay)) {
struct sk_buff *skb; struct sk_buff *skb;
struct atm_vcc *vcc = entry->vcc; struct atm_vcc *vcc = entry->vcc;
lec_arp_hold(entry); spin_unlock_irqrestore(&priv->lec_arp_lock,
spin_unlock_irqrestore(&priv->lec_arp_lock, flags); flags);
while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) while ((skb = skb_dequeue(&entry->tx_wait)))
lec_send(vcc, skb); lec_send(vcc, skb);
entry->last_used = jiffies; entry->last_used = jiffies;
entry->status = ESI_FORWARD_DIRECT; entry->status = ESI_FORWARD_DIRECT;
lec_arp_put(entry); lec_arp_put(entry);
goto restart; goto restart;
} }
} }
} }
}
spin_unlock_irqrestore(&priv->lec_arp_lock, flags); spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
...@@ -2237,7 +2244,7 @@ static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id) ...@@ -2237,7 +2244,7 @@ static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
lec_arp_hold(entry); lec_arp_hold(entry);
spin_unlock_irqrestore(&priv->lec_arp_lock, spin_unlock_irqrestore(&priv->lec_arp_lock,
flags); flags);
while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) while ((skb = skb_dequeue(&entry->tx_wait)))
lec_send(vcc, skb); lec_send(vcc, skb);
entry->last_used = jiffies; entry->last_used = jiffies;
entry->status = ESI_FORWARD_DIRECT; entry->status = ESI_FORWARD_DIRECT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment