Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+80 −73
Original line number Diff line number Diff line
@@ -285,7 +285,6 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,

	/* Make sure we have room for lec_id */
	if (skb_headroom(skb) < 2) {

		pr_debug("reallocating skb\n");
		skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
		kfree_skb(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)
			break;

			if (br_fdb_test_addr_hook(dev,
						  mesg->content.proxy.mac_addr)) {
		if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) {
			/* hit from bridge table, send LE_ARP_RESPONSE */
			struct sk_buff *skb2;
			struct sock *sk;

			pr_debug("%s: entry found, responding to zeppelin\n",
				 dev->name);
				skb2 = alloc_skb(sizeof(struct atmlec_msg),
						 GFP_ATOMIC);
			skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
			if (skb2 == NULL)
				break;
			skb2->len = sizeof(struct atmlec_msg);
				skb_copy_to_linear_data(skb2, mesg,
							sizeof(*mesg));
			skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg));
			atm_force_charge(priv->lecd, skb2->truesize);
			sk = sk_atm(priv->lecd);
			skb_queue_tail(&sk->sk_receive_queue, skb2);
@@ -561,7 +557,7 @@ static void lec_atm_close(struct atm_vcc *vcc)

	if (skb_peek(&sk_atm(vcc)->sk_receive_queue))
		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);
		dev_kfree_skb(skb);
	}
@@ -1748,6 +1744,50 @@ static void lec_arp_expire_vcc(unsigned long data)
	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.
 * 1. Re-set timer
@@ -1772,7 +1812,6 @@ static void lec_arp_check_expire(struct work_struct *work)
	struct hlist_node *node, *next;
	struct lec_arp_table *entry;
	unsigned long now;
	unsigned long time_to_check;
	int i;

	pr_debug("%p\n", priv);
@@ -1782,54 +1821,22 @@ restart:
	for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
		hlist_for_each_entry_safe(entry, node, next,
					  &priv->lec_arp_tables[i], next) {
			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)) {
			if (__lec_arp_check_expire(entry, now, priv)) {
				struct sk_buff *skb;
				struct atm_vcc *vcc = entry->vcc;

					lec_arp_hold(entry);
					spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
					while ((skb = skb_dequeue(&entry->tx_wait)) != NULL)
				spin_unlock_irqrestore(&priv->lec_arp_lock,
						       flags);
				while ((skb = skb_dequeue(&entry->tx_wait)))
					lec_send(vcc, skb);
				entry->last_used = jiffies;
				entry->status = ESI_FORWARD_DIRECT;
				lec_arp_put(entry);

				goto restart;
			}
		}
	}
	}
	spin_unlock_irqrestore(&priv->lec_arp_lock, flags);

	schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
@@ -2237,7 +2244,7 @@ restart:
				lec_arp_hold(entry);
				spin_unlock_irqrestore(&priv->lec_arp_lock,
						       flags);
				while ((skb = skb_dequeue(&entry->tx_wait)) != NULL)
				while ((skb = skb_dequeue(&entry->tx_wait)))
					lec_send(vcc, skb);
				entry->last_used = jiffies;
				entry->status = ESI_FORWARD_DIRECT;