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

Staging: batman-adv: replace internal logging mechanism.



batman-adv used its own logging infrastructure. Replace this with
standard kernel logging, printk(), with compile time and runtime
options to enable/disable different debug levels.

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e89230ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,4 +19,4 @@
#

obj-m += batman-adv.o
batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o log.o
batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o
+49 −1
Original line number Diff line number Diff line
[state: 07-11-2009]
[state: 13-11-2009]

BATMAN-ADV
----------
@@ -96,6 +96,54 @@ To deactivate batman, do:

# echo "" > /proc/net/batman-adv/interfaces

LOGGING/DEBUGGING
-----------------

All error messages, warnings and information messages are sent to the
kernel log. Depending on your operating system distribution this can be
read in one of a number of ways. Try using the commands: dmesg,
logread, or looking in the files /var/log/kern.log or
/var/log/syslog. All batman-adv messages are prefixed with
"batman-adv:" So to see just these messages try

dmesg | grep batman-adv

When investigating problems with your mesh network it is sometimes
necessary to see more detail debug messages. This must be enabled when
compiling the batman-adv module. When building batman-adv as part of
kernel, use "make menuconfig" and enable the option
"B.A.T.M.A.N. debugging". When compiling outside of the kernel tree it
is necessary to edit the file Makefile.kbuild and uncomment the line

#EXTRA_CFLAGS += -DCONFIG_BATMAN_DEBUG

The additional debug output is by default disabled. It can be enabled
either at kernel modules load time or during run time. To enable debug
output at module load time, add the module parameter debug=<value>.
<value> can take one of four values.

0 - All debug output disabled
1 - Enable messages related to routing / flooding / broadcasting
2 - Enable route or hna added / changed / deleted
3 - Enable all messages

e.g.

modprobe batman-adv debug=2

will load the module and enable debug messages for when routes or HNAs
change.

The debug output can also be changed at runtime using the file
/sys/module/batman-adv/parameters/debug. e.g.

echo 2 > /sys/module/batman-adv/parameters/debug

enables debug messages for when routes or HNAs

The debug output is sent to the kernel logs. So try dmesg, logread etc
to see the debug messages.

BATCTL
------

+7 −8
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@

#include "main.h"
#include "bitarray.h"
#include "log.h"

/* returns true if the corresponding bit in the given seq_bits indicates true
 * and curr_seqno is within range of last_seqno */
@@ -133,12 +132,12 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff,
	    (seq_num_diff < -TQ_LOCAL_WINDOW_SIZE)) {

		if (seq_num_diff > TQ_LOCAL_WINDOW_SIZE)
			debug_log(LOG_TYPE_BATMAN,
			bat_dbg(DBG_BATMAN,
				"We missed a lot of packets (%i) !\n",
				seq_num_diff-1);

		if (-seq_num_diff > TQ_LOCAL_WINDOW_SIZE)
			debug_log(LOG_TYPE_BATMAN,
			bat_dbg(DBG_BATMAN,
				"Other host probably restarted !\n");

		for (i = 0; i < NUM_WORDS; i++)
+6 −7
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@

#include "main.h"
#include "device.h"
#include "log.h"
#include "send.h"
#include "types.h"
#include "hash.h"
@@ -60,7 +59,7 @@ int bat_device_setup(void)
	/* register our device - kernel assigns a free major number */
	tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
	if (tmp_major < 0) {
		debug_log(LOG_TYPE_WARN, "Registering the character device failed with %d\n",
		printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
			  tmp_major);
		return 0;
	}
@@ -68,7 +67,7 @@ int bat_device_setup(void)
	batman_class = class_create(THIS_MODULE, "batman-adv");

	if (IS_ERR(batman_class)) {
		debug_log(LOG_TYPE_WARN, "Could not register class 'batman-adv' \n");
		printk(KERN_ERR "batman-adv:Could not register class 'batman-adv' \n");
		return 0;
	}

@@ -111,7 +110,7 @@ int bat_device_open(struct inode *inode, struct file *file)
	}

	if (device_client_hash[i] != device_client) {
		debug_log(LOG_TYPE_WARN, "Error - can't add another packet client: maximum number of clients reached \n");
		printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached \n");
		kfree(device_client);
		return -EXFULL;
	}
@@ -208,7 +207,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
	struct batman_if *batman_if;

	if (len < sizeof(struct icmp_packet)) {
		debug_log(LOG_TYPE_NOTICE, "Error - can't send packet from char device: invalid packet size\n");
		printk(KERN_DEBUG "batman-adv:Error - can't send packet from char device: invalid packet size\n");
		return -EINVAL;
	}

@@ -219,12 +218,12 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
		return -EFAULT;

	if (icmp_packet.packet_type != BAT_ICMP) {
		debug_log(LOG_TYPE_NOTICE, "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
		printk(KERN_DEBUG "batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
		return -EINVAL;
	}

	if (icmp_packet.msg_type != ECHO_REQUEST) {
		debug_log(LOG_TYPE_NOTICE, "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
		printk(KERN_DEBUG "batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
		return -EINVAL;
	}

+17 −19
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@

#include "main.h"
#include "hard-interface.h"
#include "log.h"
#include "soft-interface.h"
#include "send.h"
#include "translation-table.h"
@@ -87,9 +86,9 @@ static void check_known_mac_addr(uint8_t *addr)
			continue;

		addr_to_string(mac_string, addr);
		debug_log(LOG_TYPE_WARN, "The newly added mac address (%s) already exists on: %s\n",
		printk(KERN_WARNING "batman-adv:The newly added mac address (%s) already exists on: %s\n",
		       mac_string, batman_if->dev);
		debug_log(LOG_TYPE_WARN, "It is strongly recommended to keep mac addresses unique to avoid problems!\n");
		printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
	}
	rcu_read_unlock();
}
@@ -171,7 +170,7 @@ void hardif_deactivate_interface(struct batman_if *batman_if)
	batman_if->if_active = IF_INACTIVE;
	active_ifs--;

	debug_log(LOG_TYPE_NOTICE, "Interface deactivated: %s\n",
	printk(KERN_INFO "batman-adv:Interface deactivated: %s\n",
		  batman_if->dev);
}

@@ -197,7 +196,7 @@ static void hardif_activate_interface(struct batman_if *batman_if)
				  &batman_if->raw_sock);

	if (retval < 0) {
		debug_log(LOG_TYPE_WARN, "Can't create raw socket: %i\n",
		printk(KERN_ERR "batman-adv:Can't create raw socket: %i\n",
			  retval);
		goto sock_err;
	}
@@ -210,7 +209,7 @@ static void hardif_activate_interface(struct batman_if *batman_if)
			     (struct sockaddr *)&bind_addr, sizeof(bind_addr));

	if (retval < 0) {
		debug_log(LOG_TYPE_WARN, "Can't create bind raw socket: %i\n",
		printk(KERN_ERR "batman-adv:Can't create bind raw socket: %i\n",
			  retval);
		goto bind_err;
	}
@@ -235,7 +234,7 @@ static void hardif_activate_interface(struct batman_if *batman_if)
	if (batman_if->if_num == 0)
		set_main_if_addr(batman_if->net_dev->dev_addr);

	debug_log(LOG_TYPE_NOTICE, "Interface activated: %s\n",
	printk(KERN_INFO "batman-adv:Interface activated: %s\n",
		  batman_if->dev);

	return;
@@ -290,7 +289,7 @@ static int resize_orig(struct orig_node *orig_node, int if_num)
	data_ptr = kmalloc((if_num + 1) * sizeof(TYPE_OF_WORD) * NUM_WORDS,
			   GFP_ATOMIC);
	if (!data_ptr) {
		debug_log(LOG_TYPE_WARN, "Can't resize orig: out of memory\n");
		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
		return -1;
	}

@@ -301,7 +300,7 @@ static int resize_orig(struct orig_node *orig_node, int if_num)

	data_ptr = kmalloc((if_num + 1) * sizeof(uint8_t), GFP_ATOMIC);
	if (!data_ptr) {
		debug_log(LOG_TYPE_WARN, "Can't resize orig: out of memory\n");
		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
		return -1;
	}

@@ -324,7 +323,7 @@ int hardif_add_interface(char *dev, int if_num)
	batman_if = kmalloc(sizeof(struct batman_if), GFP_KERNEL);

	if (!batman_if) {
		debug_log(LOG_TYPE_WARN, "Can't add interface (%s): out of memory\n", dev);
		printk(KERN_ERR "batman-adv:Can't add interface (%s): out of memory\n", dev);
		return -1;
	}

@@ -339,7 +338,7 @@ int hardif_add_interface(char *dev, int if_num)
	batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_KERNEL);

	if (!batman_if->packet_buff) {
		debug_log(LOG_TYPE_WARN, "Can't add interface packet (%s): out of memory\n", dev);
		printk(KERN_ERR "batman-adv:Can't add interface packet (%s): out of memory\n", dev);
		goto out;
	}

@@ -348,7 +347,7 @@ int hardif_add_interface(char *dev, int if_num)
	batman_if->if_active = IF_INACTIVE;
	INIT_RCU_HEAD(&batman_if->rcu);

	debug_log(LOG_TYPE_NOTICE, "Adding interface: %s\n", dev);
	printk(KERN_INFO "batman-adv:Adding interface: %s\n", dev);
	avail_ifs++;

	INIT_LIST_HEAD(&batman_if->list);
@@ -389,7 +388,7 @@ int hardif_add_interface(char *dev, int if_num)
	spin_unlock(&orig_hash_lock);

	if (!hardif_is_interface_up(batman_if->dev))
		debug_log(LOG_TYPE_WARN, "Not using interface %s (retrying later): interface not active\n", batman_if->dev);
		printk(KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n", batman_if->dev);
	else
		hardif_activate_interface(batman_if);

@@ -436,7 +435,6 @@ static int hard_if_event(struct notifier_block *this,
		break;
	/* NETDEV_CHANGEADDR - mac address change - what are we doing here ? */
	default:
		/* debug_log(LOG_TYPE_CRIT, "hard_if_event: %s %i\n", dev->name, event); */
		break;
	};

Loading