Commit b9b27e4e authored by Andrew Lunn's avatar Andrew Lunn Committed by Greg Kroah-Hartman
Browse files

Staging: batman-adv: Use printk(%pM) for MAC addresses



printk() since kernel version 2.6.29 has supported printing MAC
addresses directly, as an extension to the %p processing. This patch
makes use of this for printk() and bat_dbg(). This will remove the
overhead of using addr_to_string() which is normally never actually
output.

Fixed a typo found by Gus Wirth.

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarSimon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a9c2910a
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -17,10 +17,6 @@
-> transtable_global (read-only) [outputs the global translation table]
-> transtable_local (read-only) [outputs the local translation table]

=> logging
* make use of printk %pM support instead of converting mac addresses
* manually

=> strip out all backward compatibility support to older kernels
   (only found in compat.h)

+64 −18
Original line number Diff line number Diff line
@@ -35,41 +35,87 @@
#define list_first_entry(ptr, type, member) \
	list_entry((ptr)->next, type, member)

#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) */
#define skb_mac_header(_skb) \
    ((_skb)->mac.raw)

#define skb_network_header(_skb) \
    ((_skb)->nh.raw)

#define skb_mac_header(_skb) \
    ((_skb)->mac.raw)

#endif /* < KERNEL_VERSION(2,6,22) */

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)

static inline int skb_clone_writable(struct sk_buff *skb, unsigned int len)
{
	/* skb->hdr_len not available, just "not writable" to enforce a copy */
	return 0;
}

#define cancel_delayed_work_sync(wq) cancel_rearming_delayed_work(wq)

#endif /* < KERNEL_VERSION(2, 6, 23) */

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)

#define strict_strtoul(cp, base, res) \
	({ \
	int ret = 0; \
	char *endp; \
	*res = simple_strtoul(cp, &endp, base); \
	if (cp == endp) \
		ret = -EINVAL; \
	ret; \
})

#endif /* < KERNEL_VERSION(2, 6, 25) */

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)

static const char hex_asc[] = "0123456789abcdef";
#define hex_asc_lo(x)   hex_asc[((x) & 0x0f)]
#define hex_asc_hi(x)   hex_asc[((x) & 0xf0) >> 4]
static inline char *pack_hex_byte(char *buf, u8 byte)
{
    *buf++ = hex_asc_hi(byte);
    *buf++ = hex_asc_lo(byte);
    return buf;
}

#define device_create(_cls, _parent, _devt, _device, _fmt) \
	class_device_create(_cls, _parent, _devt, _device, _fmt)

#define device_destroy(_cls, _device) \
	class_device_destroy(_cls, _device)

#else
#endif /* < KERNEL_VERSION(2, 6, 26) */

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)

#ifndef dereference_function_descriptor
#define dereference_function_descriptor(p) (p)
#endif

#ifndef device_create
#define device_create(_cls, _parent, _devt, _device, _fmt) \
	device_create_drvdata(_cls, _parent, _devt, _device, _fmt)
#endif

#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) */
#endif /* < KERNEL_VERSION(2, 6, 27) */

#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
asmlinkage int bat_printk(const char *fmt, ...);
#define printk bat_printk

#define cancel_delayed_work_sync(wq) cancel_rearming_delayed_work(wq)
static inline struct net_device_stats *dev_get_stats(struct net_device *dev)
{
	if (dev->get_stats)
		return dev->get_stats(dev);
	else
		return NULL;
}

#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
#define strict_strtoul(cp, base, res) \
	({ \
	int ret = 0; \
	char *endp; \
	*res = simple_strtoul(cp, &endp, base); \
	if (cp == endp) \
		ret = -EINVAL; \
	ret; \
})
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) */
#endif /* < KERNEL_VERSION(2, 6, 29) */
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
 *
 */

#include <linux/device.h>
#include "main.h"
#include "device.h"
#include "send.h"
+7 −7
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ int hardif_min_mtu(void)
static void check_known_mac_addr(uint8_t *addr)
{
	struct batman_if *batman_if;
	char mac_string[ETH_STR_LEN];

	rcu_read_lock();
	list_for_each_entry_rcu(batman_if, &if_list, list) {
@@ -85,9 +84,8 @@ static void check_known_mac_addr(uint8_t *addr)
		if (!compare_orig(batman_if->net_dev->dev_addr, addr))
			continue;

		addr_to_string(mac_string, addr);
		printk(KERN_WARNING "batman-adv:The newly added mac address (%s) already exists on: %s\n",
		       mac_string, batman_if->dev);
		printk(KERN_WARNING "batman-adv:The newly added mac address (%pM) already exists on: %s\n",
		       addr, batman_if->dev);
		printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
	}
	rcu_read_unlock();
@@ -447,9 +445,11 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
	if (!batman_if)
		goto err_free;

    stats = &skb->dev->stats;
    stats = (struct net_device_stats *) dev_get_stats(skb->dev);
	if (stats) {
		stats->rx_packets++;
		stats->rx_bytes += skb->len;
	}

	batman_packet = (struct batman_packet *)skb->data;

+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ unsigned char broadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
atomic_t module_state;

static struct packet_type batman_adv_packet_type __read_mostly = {
	.type = cpu_to_be16(ETH_P_BATMAN),
	.type = __constant_htons(ETH_P_BATMAN),
	.func = batman_skb_recv,
};

Loading