* [PATCH] netfilter: ebtables: Use print_mac instead of own function
@ 2009-07-15 10:55 Tobias Klauser
2009-07-15 15:13 ` Patrick McHardy
2009-07-16 7:25 ` [PATCH v2] netfilter: ebtables: Use %pM conversion specifier Tobias Klauser
0 siblings, 2 replies; 5+ messages in thread
From: Tobias Klauser @ 2009-07-15 10:55 UTC (permalink / raw)
To: bart.de.schuymer, shemminger, kaber, davem, ebtables-devel,
netfilter-devel
Cc: netdev, Tobias Klauser
ebt_log uses its own implementation of print_mac to print MAC addresses.
This patch converts it to use print_mac from linux/if_ether.h
Signed-off-by: Tobias Klauser <klto@zhaw.ch>
---
net/bridge/netfilter/ebt_log.c | 31 +++++++++++--------------------
1 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index a94f3cc..70fd072 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -12,6 +12,7 @@
#include <linux/ip.h>
#include <linux/in.h>
#include <linux/if_arp.h>
+#include <linux/if_ether.h>
#include <linux/spinlock.h>
#include <net/netfilter/nf_log.h>
#include <linux/ipv6.h>
@@ -50,14 +51,6 @@ struct arppayload
unsigned char ip_dst[4];
};
-static void print_MAC(const unsigned char *p)
-{
- int i;
-
- for (i = 0; i < ETH_ALEN; i++, p++)
- printk("%02x%c", *p, i == ETH_ALEN - 1 ? ' ':':');
-}
-
static void
print_ports(const struct sk_buff *skb, uint8_t protocol, int offset)
{
@@ -86,16 +79,16 @@ ebt_log_packet(u_int8_t pf, unsigned int hooknum,
const char *prefix)
{
unsigned int bitmask;
+ DECLARE_MAC_BUF(macbuf);
spin_lock_bh(&ebt_log_lock);
- printk("<%c>%s IN=%s OUT=%s MAC source = ", '0' + loginfo->u.log.level,
- prefix, in ? in->name : "", out ? out->name : "");
-
- print_MAC(eth_hdr(skb)->h_source);
- printk("MAC dest = ");
- print_MAC(eth_hdr(skb)->h_dest);
-
- printk("proto = 0x%04x", ntohs(eth_hdr(skb)->h_proto));
+ printk("<%c>%s IN=%s OUT=%s MAC source = %s",
+ '0' + loginfo->u.log.level, prefix,
+ in ? in->name : "", out ? out->name : "",
+ print_mac(macbuf, eth_hdr(skb)->h_source));
+ printk(" MAC dest = %s proto = 0x%04x",
+ print_mac(macbuf, eth_hdr(skb)->h_dest),
+ ntohs(eth_hdr(skb)->h_proto));
if (loginfo->type == NF_LOG_TYPE_LOG)
bitmask = loginfo->u.log.logflags;
@@ -171,11 +164,9 @@ ebt_log_packet(u_int8_t pf, unsigned int hooknum,
printk(" INCOMPLETE ARP payload");
goto out;
}
- printk(" ARP MAC SRC=");
- print_MAC(ap->mac_src);
+ printk(" ARP MAC SRC=%s", print_mac(macbuf, ap->mac_src));
printk(" ARP IP SRC=%pI4", ap->ip_src);
- printk(" ARP MAC DST=");
- print_MAC(ap->mac_dst);
+ printk(" ARP MAC DST=%s", print_mac(macbuf, ap->mac_dst));
printk(" ARP IP DST=%pI4", ap->ip_dst);
}
}
--
1.6.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] netfilter: ebtables: Use print_mac instead of own function
2009-07-15 10:55 [PATCH] netfilter: ebtables: Use print_mac instead of own function Tobias Klauser
@ 2009-07-15 15:13 ` Patrick McHardy
2009-07-16 7:25 ` Tobias Klauser
2009-07-16 7:25 ` [PATCH v2] netfilter: ebtables: Use %pM conversion specifier Tobias Klauser
1 sibling, 1 reply; 5+ messages in thread
From: Patrick McHardy @ 2009-07-15 15:13 UTC (permalink / raw)
To: Tobias Klauser
Cc: bart.de.schuymer, shemminger, davem, ebtables-devel,
netfilter-devel, netdev
Tobias Klauser wrote:
> ebt_log uses its own implementation of print_mac to print MAC addresses.
> This patch converts it to use print_mac from linux/if_ether.h
You can do this even simpler by using %pM as format string.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] netfilter: ebtables: Use print_mac instead of own function
2009-07-15 15:13 ` Patrick McHardy
@ 2009-07-16 7:25 ` Tobias Klauser
0 siblings, 0 replies; 5+ messages in thread
From: Tobias Klauser @ 2009-07-16 7:25 UTC (permalink / raw)
To: Patrick McHardy
Cc: bart.de.schuymer, shemminger, davem, ebtables-devel,
netfilter-devel, netdev
On 07/15/2009 05:13 PM, Patrick McHardy wrote:
> Tobias Klauser wrote:
>> ebt_log uses its own implementation of print_mac to print MAC addresses.
>> This patch converts it to use print_mac from linux/if_ether.h
>
> You can do this even simpler by using %pM as format string.
Sorry, I didn't know about that one. I'll send an updated patch.
Thanks for the hint.
Tobias
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] netfilter: ebtables: Use %pM conversion specifier
2009-07-15 10:55 [PATCH] netfilter: ebtables: Use print_mac instead of own function Tobias Klauser
2009-07-15 15:13 ` Patrick McHardy
@ 2009-07-16 7:25 ` Tobias Klauser
2009-08-10 8:11 ` Patrick McHardy
1 sibling, 1 reply; 5+ messages in thread
From: Tobias Klauser @ 2009-07-16 7:25 UTC (permalink / raw)
To: bart.de.schuymer, shemminger, kaber, davem, netfilter-devel
Cc: netdev, Tobias Klauser
ebt_log uses its own implementation of print_mac to print MAC addresses.
This patch converts it to use the %pM conversion specifier for printk.
Signed-off-by: Tobias Klauser <klto@zhaw.ch>
---
net/bridge/netfilter/ebt_log.c | 29 +++++++----------------------
1 files changed, 7 insertions(+), 22 deletions(-)
diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index a94f3cc..e4ea3fd 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -50,14 +50,6 @@ struct arppayload
unsigned char ip_dst[4];
};
-static void print_MAC(const unsigned char *p)
-{
- int i;
-
- for (i = 0; i < ETH_ALEN; i++, p++)
- printk("%02x%c", *p, i == ETH_ALEN - 1 ? ' ':':');
-}
-
static void
print_ports(const struct sk_buff *skb, uint8_t protocol, int offset)
{
@@ -88,14 +80,11 @@ ebt_log_packet(u_int8_t pf, unsigned int hooknum,
unsigned int bitmask;
spin_lock_bh(&ebt_log_lock);
- printk("<%c>%s IN=%s OUT=%s MAC source = ", '0' + loginfo->u.log.level,
- prefix, in ? in->name : "", out ? out->name : "");
-
- print_MAC(eth_hdr(skb)->h_source);
- printk("MAC dest = ");
- print_MAC(eth_hdr(skb)->h_dest);
-
- printk("proto = 0x%04x", ntohs(eth_hdr(skb)->h_proto));
+ printk("<%c>%s IN=%s OUT=%s MAC source = %pM MAC dest = %pM proto = 0x%04x",
+ '0' + loginfo->u.log.level, prefix,
+ in ? in->name : "", out ? out->name : "",
+ eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
+ ntohs(eth_hdr(skb)->h_proto));
if (loginfo->type == NF_LOG_TYPE_LOG)
bitmask = loginfo->u.log.logflags;
@@ -171,12 +160,8 @@ ebt_log_packet(u_int8_t pf, unsigned int hooknum,
printk(" INCOMPLETE ARP payload");
goto out;
}
- printk(" ARP MAC SRC=");
- print_MAC(ap->mac_src);
- printk(" ARP IP SRC=%pI4", ap->ip_src);
- printk(" ARP MAC DST=");
- print_MAC(ap->mac_dst);
- printk(" ARP IP DST=%pI4", ap->ip_dst);
+ printk(" ARP MAC SRC=%pM ARP IP SRC=%pI4 ARP MAC DST=%pM ARP IP DST=%pI4",
+ ap->mac_src, ap->ip_src, ap->mac_dst, ap->ip_dst);
}
}
out:
--
1.6.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-08-10 8:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-15 10:55 [PATCH] netfilter: ebtables: Use print_mac instead of own function Tobias Klauser
2009-07-15 15:13 ` Patrick McHardy
2009-07-16 7:25 ` Tobias Klauser
2009-07-16 7:25 ` [PATCH v2] netfilter: ebtables: Use %pM conversion specifier Tobias Klauser
2009-08-10 8:11 ` Patrick McHardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).