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

Commit 21f644f3 authored by David S. Miller's avatar David S. Miller
Browse files

[NET]: Undo code bloat in hot paths due to print_mac().



If print_mac() is used inside of a pr_debug() the compiler
can't see that the call is redundant so still performs it
even of pr_debug() ends up being a nop.

So don't use print_mac() in such cases in hot code paths,
use MAC_FMT et al. instead.

As noted by Joe Perches, pr_debug() could be modified to
handle this better, but that is a change to an interface
used by the entire kernel and thus needs to be validated
carefully.  This here is thus the less risky fix for
2.6.25

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6adb4f73
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1472,13 +1472,12 @@ static int __netdev_rx(struct net_device *dev, int *quota)
#ifndef final_version			/* Remove after testing. */
		/* You will want this info for the initial debug. */
		if (debug > 5) {
			DECLARE_MAC_BUF(mac);
			DECLARE_MAC_BUF(mac2);

			printk(KERN_DEBUG "  Rx data %s %s"
			printk(KERN_DEBUG "  Rx data " MAC_FMT " " MAC_FMT
			       " %2.2x%2.2x.\n",
			       print_mac(mac, &skb->data[0]),
			       print_mac(mac2, &skb->data[6]),
			       skb->data[0], skb->data[1], skb->data[2],
			       skb->data[3], skb->data[4], skb->data[5],
			       skb->data[6], skb->data[7], skb->data[8],
			       skb->data[9], skb->data[10], skb->data[11],
			       skb->data[12], skb->data[13]);
		}
#endif
+10 −5
Original line number Diff line number Diff line
@@ -1438,13 +1438,18 @@ static void olympic_arb_cmd(struct net_device *dev)

		if (olympic_priv->olympic_network_monitor) { 
			struct trh_hdr *mac_hdr;
			DECLARE_MAC_BUF(mac);
			printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name);
			mac_hdr = tr_hdr(mac_frame);
			printk(KERN_WARNING "%s: MAC Frame Dest. Addr: %s\n",
			       dev->name, print_mac(mac, mac_hdr->daddr));
			printk(KERN_WARNING "%s: MAC Frame Srce. Addr: %s\n",
			       dev->name, print_mac(mac, mac_hdr->saddr));
			printk(KERN_WARNING "%s: MAC Frame Dest. Addr: "
			       MAC_FMT " \n", dev->name,
			       mac_hdr->daddr[0], mac_hdr->daddr[1],
			       mac_hdr->daddr[2], mac_hdr->daddr[3],
			       mac_hdr->daddr[4], mac_hdr->daddr[5]);
			printk(KERN_WARNING "%s: MAC Frame Srce. Addr: "
			       MAC_FMT " \n", dev->name,
			       mac_hdr->saddr[0], mac_hdr->saddr[1],
			       mac_hdr->saddr[2], mac_hdr->saddr[3],
			       mac_hdr->saddr[4], mac_hdr->saddr[5]);
		}
		netif_rx(mac_frame);
		dev->last_rx = jiffies;
+3 −2
Original line number Diff line number Diff line
@@ -234,11 +234,12 @@ static int start_xmit(struct sk_buff *skb, struct net_device *dev)
	struct scatterlist sg[1+MAX_SKB_FRAGS];
	struct virtio_net_hdr *hdr;
	const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
	DECLARE_MAC_BUF(mac);

	sg_init_table(sg, 1+MAX_SKB_FRAGS);

	pr_debug("%s: xmit %p %s\n", dev->name, skb, print_mac(mac, dest));
	pr_debug("%s: xmit %p " MAC_FMT "\n", dev->name, skb,
		 dest[0], dest[1], dest[2],
		 dest[3], dest[4], dest[5]);

	/* Encode metadata header at front. */
	hdr = skb_vnet_hdr(skb);
+24 −15
Original line number Diff line number Diff line
@@ -635,7 +635,6 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
{
	struct ieee80211_hdr_4addr *hdr;
	int res, hdrlen;
	DECLARE_MAC_BUF(mac);

	if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
		return 0;
@@ -647,8 +646,10 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
	    strcmp(crypt->ops->name, "TKIP") == 0) {
		if (net_ratelimit()) {
			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
			       "received packet from %s\n",
			       local->dev->name, print_mac(mac, hdr->addr2));
			       "received packet from " MAC_FMT "\n",
			       local->dev->name,
			       hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
			       hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
		}
		return -1;
	}
@@ -657,9 +658,12 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
	res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
	atomic_dec(&crypt->refcnt);
	if (res < 0) {
		printk(KERN_DEBUG "%s: decryption failed (SA=%s"
		printk(KERN_DEBUG "%s: decryption failed (SA=" MAC_FMT
		       ") res=%d\n",
		       local->dev->name, print_mac(mac, hdr->addr2), res);
		       local->dev->name,
		       hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
		       hdr->addr2[3], hdr->addr2[4], hdr->addr2[5],
		       res);
		local->comm_tallies.rx_discards_wep_undecryptable++;
		return -1;
	}
@@ -721,7 +725,6 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
	struct ieee80211_crypt_data *crypt = NULL;
	void *sta = NULL;
	int keyidx = 0;
	DECLARE_MAC_BUF(mac);

	iface = netdev_priv(dev);
	local = iface->local;
@@ -798,8 +801,10 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
			 * frames silently instead of filling system log with
			 * these reports. */
			printk(KERN_DEBUG "%s: WEP decryption failed (not set)"
			       " (SA=%s)\n",
			       local->dev->name, print_mac(mac, hdr->addr2));
			       " (SA=" MAC_FMT ")\n",
			       local->dev->name,
			       hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
			       hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
#endif
			local->comm_tallies.rx_discards_wep_undecryptable++;
			goto rx_dropped;
@@ -813,8 +818,9 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
		    (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
		{
			printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
			       "from %s\n", dev->name,
			       print_mac(mac, hdr->addr2));
			       "from " MAC_FMT "\n", dev->name,
			       hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
			       hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
			/* TODO: could inform hostapd about this so that it
			 * could send auth failure report */
			goto rx_dropped;
@@ -982,8 +988,10 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
			       "unencrypted EAPOL frame\n", local->dev->name);
		} else {
			printk(KERN_DEBUG "%s: encryption configured, but RX "
			       "frame not encrypted (SA=%s)\n",
			       local->dev->name, print_mac(mac, hdr->addr2));
			       "frame not encrypted (SA=" MAC_FMT ")\n",
			       local->dev->name,
			       hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
			       hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
			goto rx_dropped;
		}
	}
@@ -992,9 +1000,10 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
	    !hostap_is_eapol_frame(local, skb)) {
		if (net_ratelimit()) {
			printk(KERN_DEBUG "%s: dropped unencrypted RX data "
			       "frame from %s"
			       " (drop_unencrypted=1)\n",
			       dev->name, print_mac(mac, hdr->addr2));
			       "frame from " MAC_FMT " (drop_unencrypted=1)\n",
			       dev->name,
			       hdr->addr2[0], hdr->addr2[1], hdr->addr2[2],
			       hdr->addr2[3], hdr->addr2[4], hdr->addr2[5]);
		}
		goto rx_dropped;
	}
+4 −3
Original line number Diff line number Diff line
@@ -314,7 +314,6 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
	struct ieee80211_hdr_4addr *hdr;
	u16 fc;
	int prefix_len, postfix_len, hdr_len, res;
	DECLARE_MAC_BUF(mac);

	iface = netdev_priv(skb->dev);
	local = iface->local;
@@ -329,8 +328,10 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
		hdr = (struct ieee80211_hdr_4addr *) skb->data;
		if (net_ratelimit()) {
			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
			       "TX packet to %s\n",
			       local->dev->name, print_mac(mac, hdr->addr1));
			       "TX packet to " MAC_FMT "\n",
			       local->dev->name,
			       hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
			       hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
		}
		kfree_skb(skb);
		return NULL;
Loading