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

[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
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
......
This diff is collapsed.
......@@ -10192,7 +10192,6 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
u8 id, hdr_len, unicast;
u16 remaining_bytes;
int fc;
DECLARE_MAC_BUF(mac);
hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
switch (priv->ieee->iw_mode) {
......@@ -10203,8 +10202,10 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
id = ipw_add_station(priv, hdr->addr1);
if (id == IPW_INVALID_STATION) {
IPW_WARNING("Attempt to send data to "
"invalid cell: %s\n",
print_mac(mac, hdr->addr1));
"invalid cell: " MAC_FMT "\n",
hdr->addr1[0], hdr->addr1[1],
hdr->addr1[2], hdr->addr1[3],
hdr->addr1[4], hdr->addr1[5]);
goto drop;
}
}
......
......@@ -266,7 +266,6 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
char buf[300];
int i = 0;
#endif /* DUMP_PACKETS >0 */
DECLARE_MAC_BUF(mac);
pr_debug("lec_start_xmit called\n");
if (!priv->lecd) {
......@@ -374,15 +373,19 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
pr_debug("%s:lec_start_xmit: queuing packet, ",
dev->name);
pr_debug("MAC address %s\n",
print_mac(mac, lec_h->h_dest));
pr_debug("MAC address " MAC_FMT "\n",
lec_h->h_dest[0], lec_h->h_dest[1],
lec_h->h_dest[2], lec_h->h_dest[3],
lec_h->h_dest[4], lec_h->h_dest[5]);
skb_queue_tail(&entry->tx_wait, skb);
} else {
pr_debug
("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ",
dev->name);
pr_debug("MAC address %s\n",
print_mac(mac, lec_h->h_dest));
pr_debug("MAC address " MAC_FMT "\n",
lec_h->h_dest[0], lec_h->h_dest[1],
lec_h->h_dest[2], lec_h->h_dest[3],
lec_h->h_dest[4], lec_h->h_dest[5]);
priv->stats.tx_dropped++;
dev_kfree_skb(skb);
}
......@@ -394,8 +397,10 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
pr_debug("lec.c: emptying tx queue, ");
pr_debug("MAC address %s\n",
print_mac(mac, lec_h->h_dest));
pr_debug("MAC address " MAC_FMT "\n",
lec_h->h_dest[0], lec_h->h_dest[1],
lec_h->h_dest[2], lec_h->h_dest[3],
lec_h->h_dest[4], lec_h->h_dest[5]);
lec_send(vcc, skb2, priv);
}
......@@ -449,7 +454,6 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
struct lec_arp_table *entry;
int i;
char *tmp; /* FIXME */
DECLARE_MAC_BUF(mac);
atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
mesg = (struct atmlec_msg *)skb->data;
......@@ -536,9 +540,14 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
struct net_bridge_fdb_entry *f;
pr_debug
("%s: bridge zeppelin asks about %s\n",
("%s: bridge zeppelin asks about " MAC_FMT "\n",
dev->name,
print_mac(mac, mesg->content.proxy.mac_addr));
mesg->content.proxy.mac_addr[0],
mesg->content.proxy.mac_addr[1],
mesg->content.proxy.mac_addr[2],
mesg->content.proxy.mac_addr[3],
mesg->content.proxy.mac_addr[4],
mesg->content.proxy.mac_addr[5]);
if (br_fdb_get_hook == NULL || dev->br_port == NULL)
break;
......
......@@ -271,7 +271,6 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
{
struct ieee80211_hdr_3addr *hdr;
int res, hdrlen;
DECLARE_MAC_BUF(mac);
if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
return 0;
......@@ -283,8 +282,12 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
atomic_dec(&crypt->refcnt);
if (res < 0) {
IEEE80211_DEBUG_DROP("decryption failed (SA=%s"
") res=%d\n", print_mac(mac, hdr->addr2), res);
IEEE80211_DEBUG_DROP("decryption failed (SA=" MAC_FMT
") res=%d\n",
hdr->addr2[0], hdr->addr2[1],
hdr->addr2[2], hdr->addr2[3],
hdr->addr2[4], hdr->addr2[5],
res);
if (res == -2)
IEEE80211_DEBUG_DROP("Decryption failed ICV "
"mismatch (key %d)\n",
......@@ -304,7 +307,6 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee,
{
struct ieee80211_hdr_3addr *hdr;
int res, hdrlen;
DECLARE_MAC_BUF(mac);
if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
return 0;
......@@ -317,8 +319,12 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee,
atomic_dec(&crypt->refcnt);
if (res < 0) {
printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
" (SA=%s keyidx=%d)\n",
ieee->dev->name, print_mac(mac, hdr->addr2), keyidx);
" (SA=" MAC_FMT " keyidx=%d)\n",
ieee->dev->name,
hdr->addr2[0], hdr->addr2[1],
hdr->addr2[2], hdr->addr2[3],
hdr->addr2[4], hdr->addr2[5],
keyidx);
return -1;
}
......@@ -462,8 +468,10 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
* frames silently instead of filling system log with
* these reports. */
IEEE80211_DEBUG_DROP("Decryption failed (not set)"
" (SA=%s)\n",
print_mac(mac, hdr->addr2));
" (SA=" MAC_FMT ")\n",
hdr->addr2[0], hdr->addr2[1],
hdr->addr2[2], hdr->addr2[3],
hdr->addr2[4], hdr->addr2[5]);
ieee->ieee_stats.rx_discards_undecryptable++;
goto rx_dropped;
}
......@@ -474,8 +482,10 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt &&
(keyidx = hostap_rx_frame_decrypt(ieee, 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;
......@@ -653,8 +663,11 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
* configured */
} else {
IEEE80211_DEBUG_DROP("encryption configured, but RX "
"frame not encrypted (SA=%s"
")\n", print_mac(mac, hdr->addr2));
"frame not encrypted (SA="
MAC_FMT ")\n",
hdr->addr2[0], hdr->addr2[1],
hdr->addr2[2], hdr->addr2[3],
hdr->addr2[4], hdr->addr2[5]);
goto rx_dropped;
}
}
......@@ -662,9 +675,11 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
!ieee80211_is_eapol_frame(ieee, skb)) {
IEEE80211_DEBUG_DROP("dropped unencrypted RX data "
"frame from %s"
"frame from " MAC_FMT
" (drop_unencrypted=1)\n",
print_mac(mac, hdr->addr2));
hdr->addr2[0], hdr->addr2[1],
hdr->addr2[2], hdr->addr2[3],
hdr->addr2[4], hdr->addr2[5]);
goto rx_dropped;
}
......
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