Author: marek Date: 2010-06-28 14:25:04 +0200 (Mon, 28 Jun 2010) New Revision: 1729
Modified: trunk/batman-adv/bat_debugfs.c trunk/batman-adv/bat_sysfs.c trunk/batman-adv/compat.h trunk/batman-adv/gateway_common.c trunk/batman-adv/gateway_common.h trunk/batman-adv/hard-interface.c trunk/batman-adv/icmp_socket.c trunk/batman-adv/main.c trunk/batman-adv/main.h trunk/batman-adv/originator.c trunk/batman-adv/routing.c trunk/batman-adv/send.c trunk/batman-adv/translation-table.c trunk/batman-adv/vis.c Log: batman-adv: Move printk to simplified macros
Each general printk which is not informative by itself for a specific batX device were moved to pr_(info|warning|err) as it provides an easy interface which for example resolves the problem to add the prefix "batman-adv: " before each line.
All information which is specific to a batX device will be printed using a bat_(info|err|warning) macro to prefix it also with "batman-adv: batX:" in each line.
Reported-by: Joe Perches joe@perches.com Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de Signed-off-by: Marek Lindner lindner_marek@yahoo.de
Modified: trunk/batman-adv/bat_debugfs.c =================================================================== --- trunk/batman-adv/bat_debugfs.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/bat_debugfs.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -19,9 +19,10 @@ * */
+#include "main.h" + #include <linux/debugfs.h>
-#include "main.h" #include "bat_debugfs.h" #include "translation-table.h" #include "originator.h" @@ -320,8 +321,8 @@ bat_priv->debug_dir, dev, &(*bat_debug)->fops); if (!file) { - printk(KERN_ERR "batman-adv:Can't add debugfs file: " - "%s/%s\n", dev->name, ((*bat_debug)->attr).name); + bat_err(dev, "Can't add debugfs file: %s/%s\n", + dev->name, ((*bat_debug)->attr).name); goto rem_attr; } }
Modified: trunk/batman-adv/bat_sysfs.c =================================================================== --- trunk/batman-adv/bat_sysfs.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/bat_sysfs.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -70,18 +70,19 @@ if (buff[count - 1] == '\n') buff[count - 1] = '\0';
- printk(KERN_INFO "batman-adv:Invalid parameter for 'aggregate OGM' setting on mesh %s received: %s\n", - net_dev->name, buff); + bat_info(net_dev, + "Invalid parameter for 'aggregate OGM' setting" + "received: %s\n", buff); return -EINVAL; }
if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp) return count;
- printk(KERN_INFO "batman-adv:Changing aggregation from: %s to: %s on mesh: %s\n", - atomic_read(&bat_priv->aggregation_enabled) == 1 ? - "enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled", - net_dev->name); + bat_info(net_dev, "Changing aggregation from: %s to: %s\n", + atomic_read(&bat_priv->aggregation_enabled) == 1 ? + "enabled" : "disabled", aggr_tmp == 1 ? "enabled" : + "disabled");
atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp); return count; @@ -118,19 +119,19 @@ if (buff[count - 1] == '\n') buff[count - 1] = '\0';
- printk(KERN_ERR "batman-adv:Invalid parameter for 'bonding' setting on mesh %s received: %s\n", - net_dev->name, buff); + bat_err(net_dev, + "Invalid parameter for 'bonding' setting received: " + "%s\n", buff); return -EINVAL; }
if (atomic_read(&bat_priv->bonding_enabled) == bonding_enabled_tmp) return count;
- printk(KERN_INFO "batman-adv:Changing bonding from: %s to: %s on mesh: %s\n", - atomic_read(&bat_priv->bonding_enabled) == 1 ? - "enabled" : "disabled", - bonding_enabled_tmp == 1 ? "enabled" : "disabled", - net_dev->name); + bat_info(net_dev, "Changing bonding from: %s to: %s\n", + atomic_read(&bat_priv->bonding_enabled) == 1 ? + "enabled" : "disabled", + bonding_enabled_tmp == 1 ? "enabled" : "disabled");
atomic_set(&bat_priv->bonding_enabled, (unsigned)bonding_enabled_tmp); return count; @@ -172,18 +173,19 @@ if (buff[count - 1] == '\n') buff[count - 1] = '\0';
- printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n", - net_dev->name, buff); + bat_info(net_dev, + "Invalid parameter for 'vis mode' setting received: " + "%s\n", buff); return -EINVAL; }
if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp) return count;
- printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n", - atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ? - "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? - "client" : "server", net_dev->name); + bat_info(net_dev, "Changing vis mode from: %s to: %s\n", + atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ? + "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? + "client" : "server");
atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp); return count; @@ -228,9 +230,8 @@ { struct device *dev = to_dev(kobj->parent); struct net_device *net_dev = to_net_dev(dev); - struct bat_priv *bat_priv = netdev_priv(net_dev);
- return gw_mode_set(bat_priv, buff, count); + return gw_mode_set(net_dev, buff, count); }
static ssize_t show_orig_interval(struct kobject *kobj, struct attribute *attr, @@ -254,23 +255,23 @@
ret = strict_strtoul(buff, 10, &orig_interval_tmp); if (ret) { - printk(KERN_INFO "batman-adv:Invalid parameter for 'orig_interval' setting on mesh %s received: %s\n", - net_dev->name, buff); + bat_info(net_dev, "Invalid parameter for 'orig_interval' " + "setting received: %s\n", buff); return -EINVAL; }
if (orig_interval_tmp < JITTER * 2) { - printk(KERN_INFO "batman-adv:New originator interval too small: %li (min: %i)\n", - orig_interval_tmp, JITTER * 2); + bat_info(net_dev, "New originator interval too small: %li " + "(min: %i)\n", orig_interval_tmp, JITTER * 2); return -EINVAL; }
if (atomic_read(&bat_priv->orig_interval) == orig_interval_tmp) return count;
- printk(KERN_INFO "batman-adv:Changing originator interval from: %i to: %li on mesh: %s\n", - atomic_read(&bat_priv->orig_interval), - orig_interval_tmp, net_dev->name); + bat_info(net_dev, "Changing originator interval from: %i to: %li\n", + atomic_read(&bat_priv->orig_interval), + orig_interval_tmp);
atomic_set(&bat_priv->orig_interval, orig_interval_tmp); return count; @@ -298,24 +299,23 @@
ret = strict_strtoul(buff, 10, &log_level_tmp); if (ret) { - printk(KERN_INFO "batman-adv:Invalid parameter for 'log_level' setting on mesh %s received: %s\n", - net_dev->name, buff); + bat_info(net_dev, "Invalid parameter for 'log_level' " + "setting received: %s\n", buff); return -EINVAL; }
if (log_level_tmp > 3) { - printk(KERN_INFO "batman-adv:New log level too big: %li (max: %i)\n", - log_level_tmp, 3); + bat_info(net_dev, "New log level too big: %li " + "(max: %i)\n", log_level_tmp, 3); return -EINVAL; }
if (atomic_read(&bat_priv->log_level) == log_level_tmp) return count;
- printk(KERN_INFO - "batman-adv:Changing log level from: %i to: %li on mesh: %s\n", - atomic_read(&bat_priv->log_level), - log_level_tmp, net_dev->name); + bat_info(net_dev, "Changing log level from: %i to: %li\n", + atomic_read(&bat_priv->log_level), + log_level_tmp);
atomic_set(&bat_priv->log_level, (unsigned)log_level_tmp); return count; @@ -370,8 +370,8 @@ bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, batif_kobject); if (!bat_priv->mesh_obj) { - printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n", - dev->name, SYSFS_IF_MESH_SUBDIR); + bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, + SYSFS_IF_MESH_SUBDIR); goto out; }
@@ -379,9 +379,9 @@ err = sysfs_create_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); if (err) { - printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", - dev->name, SYSFS_IF_MESH_SUBDIR, - ((*bat_attr)->attr).name); + bat_err(dev, "Can't add sysfs file: %s/%s/%s\n", + dev->name, SYSFS_IF_MESH_SUBDIR, + ((*bat_attr)->attr).name); goto rem_attr; } } @@ -446,8 +446,8 @@ if (buff[count - 1] == '\n') buff[count - 1] = '\0';
- printk(KERN_ERR "batman-adv:Invalid parameter for 'mesh_iface' setting received: %s\n", - buff); + pr_err("Invalid parameter for 'mesh_iface' setting received: " + "%s\n", buff); return -EINVAL; }
@@ -509,17 +509,17 @@ hardif_kobject);
if (!*hardif_obj) { - printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n", - dev->name, SYSFS_IF_BAT_SUBDIR); + bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, + SYSFS_IF_BAT_SUBDIR); goto out; }
for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) { err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); if (err) { - printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", - dev->name, SYSFS_IF_BAT_SUBDIR, - ((*bat_attr)->attr).name); + bat_err(dev, "Can't add sysfs file: %s/%s/%s\n", + dev->name, SYSFS_IF_BAT_SUBDIR, + ((*bat_attr)->attr).name); goto rem_attr; } }
Modified: trunk/batman-adv/compat.h =================================================================== --- trunk/batman-adv/compat.h 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/compat.h 2010-06-28 12:25:04 UTC (rev 1729) @@ -63,6 +63,19 @@
#endif /* < KERNEL_VERSION(2, 6, 23) */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) + +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + +#define pr_err(fmt, ...) \ + printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warning(fmt, ...) \ + printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) + +#endif /* < KERNEL_VERSION(2, 6, 24) */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
#define strict_strtoul(cp, base, res) \
Modified: trunk/batman-adv/gateway_common.c =================================================================== --- trunk/batman-adv/gateway_common.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/gateway_common.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -76,7 +76,8 @@ *up = ((upart + 1) * (*down)) / 8; }
-static bool parse_gw_mode_tok(char *tokptr, long *gw_mode_tmp, +static bool parse_gw_mode_tok(struct net_device *net_dev, + char *tokptr, long *gw_mode_tmp, char **gw_mode_tmp_str, long *gw_class_tmp, long *up, long *down) { @@ -87,16 +88,15 @@ case GW_MODE_CLIENT: ret = strict_strtoul(tokptr, 10, gw_class_tmp); if (ret) { - printk(KERN_ERR "batman-adv: " - "Client class of gateway mode invalid: %s\n", - tokptr); + bat_err(net_dev, "Client class of gateway mode invalid:" + " %s\n", tokptr); return false; }
if (*gw_class_tmp > TQ_MAX_VALUE) { - printk(KERN_ERR "batman-adv: Client class of gateway " - "mode greater than %i: %ld\n", - TQ_MAX_VALUE, *gw_class_tmp); + bat_err(net_dev, + "Client class of gateway mode greater than %i: " + "%ld\n", TQ_MAX_VALUE, *gw_class_tmp); return false; }
@@ -121,9 +121,9 @@
ret = strict_strtoul(tokptr, 10, down); if (ret) { - printk(KERN_ERR "batman-adv: " - "Download speed of gateway mode invalid: %s\n", - tokptr); + bat_err(net_dev, + "Download speed of gateway mode invalid: %s\n", + tokptr); return false; }
@@ -147,9 +147,9 @@
ret = strict_strtoul(slash_ptr + 1, 10, up); if (ret) { - printk(KERN_ERR "batman-adv: Upload speed of " - "gateway mode invalid: %s\n", - slash_ptr + 1); + bat_err(net_dev, + "Upload speed of gateway mode invalid: " + "%s\n", slash_ptr + 1); return false; }
@@ -177,13 +177,14 @@ return true; }
-ssize_t gw_mode_set(struct bat_priv *bat_priv, char *buff, size_t count) +ssize_t gw_mode_set(struct net_device *net_dev, char *buff, size_t count) { char *tokptr, *cp, finished; char *gw_mode_curr_str, *gw_mode_tmp_str = NULL; long gw_mode_curr, gw_mode_tmp = GW_MODE_OFF; long gw_class_tmp = 0, up = 0, down = 0; bool ret; + struct bat_priv *bat_priv = netdev_priv(net_dev);
tokptr = buff; gw_mode_curr = atomic_read(&bat_priv->gw_mode); @@ -200,9 +201,8 @@ if (strlen(tokptr) == 0) goto next;
- ret = parse_gw_mode_tok(tokptr, &gw_mode_tmp, - &gw_mode_tmp_str, - &gw_class_tmp, + ret = parse_gw_mode_tok(net_dev, tokptr, &gw_mode_tmp, + &gw_mode_tmp_str, &gw_class_tmp, &up, &down);
if (!ret) @@ -217,11 +217,9 @@ }
if (!gw_mode_tmp_str) { - printk(KERN_INFO "batman-adv: " - "Gateway mode can only be set to: '%s', '%s' or '%s' - " - "given value: %s\n", - GW_MODE_OFF_NAME, GW_MODE_CLIENT_NAME, - GW_MODE_SERVER_NAME, buff); + bat_info(net_dev, "Gateway mode can only be set to: '%s', '%s' " + "or '%s' - given value: %s\n", GW_MODE_OFF_NAME, + GW_MODE_CLIENT_NAME, GW_MODE_SERVER_NAME, buff); goto end; }
@@ -242,10 +240,9 @@ if ((gw_mode_tmp == GW_MODE_CLIENT) && (!gw_class_tmp)) gw_class_tmp = 20;
- printk(KERN_INFO "batman-adv: " - "Changing gateway mode from: '%s' to: '%s' " - "(gw_class: %ld)\n", - gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp); + bat_info(net_dev, "Changing gateway mode from: '%s' to: '%s' " + "(gw_class: %ld)\n", + gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp); break; case GW_MODE_SERVER: if (!down) @@ -265,19 +262,17 @@ (int *)&down, (int *)&up);
gw_deselect(); - printk(KERN_INFO - "batman-adv: Changing gateway mode from: '%s' to: '%s' " - "(gw_class: %ld -> propagating: %ld%s/%ld%s)\n", - gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp, - (down > 2048 ? down / 1024 : down), - (down > 2048 ? "MBit" : "KBit"), - (up > 2048 ? up / 1024 : up), - (up > 2048 ? "MBit" : "KBit")); + bat_info(net_dev, "Changing gateway mode from: '%s' to: '%s' " + "(gw_class: %ld -> propagating: %ld%s/%ld%s)\n", + gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp, + (down > 2048 ? down / 1024 : down), + (down > 2048 ? "MBit" : "KBit"), + (up > 2048 ? up / 1024 : up), + (up > 2048 ? "MBit" : "KBit")); break; default: - printk(KERN_INFO "batman-adv: " - "Changing gateway mode from: '%s' to: '%s'\n", - gw_mode_curr_str, gw_mode_tmp_str); + bat_info(net_dev, "Changing gateway mode from: '%s' to: '%s'\n", + gw_mode_curr_str, gw_mode_tmp_str); break; }
Modified: trunk/batman-adv/gateway_common.h =================================================================== --- trunk/batman-adv/gateway_common.h 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/gateway_common.h 2010-06-28 12:25:04 UTC (rev 1729) @@ -33,6 +33,6 @@ #define GW_MODE_SERVER_NAME "server"
void gw_srv_class_to_kbit(uint8_t gw_class, int *down, int *up); -ssize_t gw_mode_set(struct bat_priv *bat_priv, char *buff, size_t count); +ssize_t gw_mode_set(struct net_device *net_dev, char *buff, size_t count);
#endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */
Modified: trunk/batman-adv/hard-interface.c =================================================================== --- trunk/batman-adv/hard-interface.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/hard-interface.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -152,12 +152,10 @@ if (!compare_orig(batman_if->net_dev->dev_addr, addr)) continue;
- 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"); + pr_warning("The newly added mac address (%pM) already exists " + "on: %s\n", addr, batman_if->dev); + pr_warning("It is strongly recommended to keep mac addresses " + "unique to avoid problems!\n"); } rcu_read_unlock(); } @@ -191,7 +189,8 @@ soft_device->mtu = min_mtu; }
-static void hardif_activate_interface(struct bat_priv *bat_priv, +static void hardif_activate_interface(struct net_device *net_dev, + struct bat_priv *bat_priv, struct batman_if *batman_if) { if (batman_if->if_status != IF_INACTIVE) @@ -209,8 +208,7 @@ if (!bat_priv->primary_if) set_primary_if(bat_priv, batman_if);
- printk(KERN_INFO "batman-adv:Interface activated: %s\n", - batman_if->dev); + bat_info(net_dev, "Interface activated: %s\n", batman_if->dev);
if (atomic_read(&module_state) == MODULE_INACTIVE) activate_module(); @@ -219,7 +217,8 @@ return; }
-static void hardif_deactivate_interface(struct batman_if *batman_if) +static void hardif_deactivate_interface(struct net_device *net_dev, + struct batman_if *batman_if) { if ((batman_if->if_status != IF_ACTIVE) && (batman_if->if_status != IF_TO_BE_ACTIVATED)) @@ -229,8 +228,7 @@
batman_if->if_status = IF_INACTIVE;
- printk(KERN_INFO "batman-adv:Interface deactivated: %s\n", - batman_if->dev); + bat_info(net_dev, "Interface deactivated: %s\n", batman_if->dev);
update_min_mtu(); } @@ -248,9 +246,8 @@ batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
if (!batman_if->packet_buff) { - printk(KERN_ERR "batman-adv:" - "Can't add interface packet (%s): out of memory\n", - batman_if->dev); + bat_err(soft_device, "Can't add interface packet (%s): " + "out of memory\n", batman_if->dev); goto err; }
@@ -268,15 +265,14 @@ orig_hash_add_if(batman_if, bat_priv->num_ifaces);
atomic_set(&batman_if->seqno, 1); - printk(KERN_INFO "batman-adv:Adding interface: %s\n", batman_if->dev); + bat_info(soft_device, "Adding interface: %s\n", batman_if->dev);
if (hardif_is_iface_up(batman_if)) - hardif_activate_interface(bat_priv, batman_if); + hardif_activate_interface(soft_device, bat_priv, batman_if); else - printk(KERN_ERR "batman-adv:" - "Not using interface %s " - "(retrying later): interface not active\n", - batman_if->dev); + bat_err(soft_device, "Not using interface %s " + "(retrying later): interface not active\n", + batman_if->dev);
/* begin scheduling originator messages on that interface */ schedule_own_packet(batman_if); @@ -294,12 +290,12 @@ struct bat_priv *bat_priv = netdev_priv(soft_device);
if (batman_if->if_status == IF_ACTIVE) - hardif_deactivate_interface(batman_if); + hardif_deactivate_interface(soft_device, batman_if);
if (batman_if->if_status != IF_INACTIVE) return;
- printk(KERN_INFO "batman-adv:Removing interface: %s\n", batman_if->dev); + bat_info(soft_device, "Removing interface: %s\n", batman_if->dev); bat_priv->num_ifaces--; orig_hash_del_if(batman_if, bat_priv->num_ifaces);
@@ -326,8 +322,7 @@
batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC); if (!batman_if) { - printk(KERN_ERR "batman-adv:" - "Can't add interface (%s): out of memory\n", + pr_err("Can't add interface (%s): out of memory\n", net_dev->name); goto out; } @@ -410,11 +405,11 @@ case NETDEV_REGISTER: break; case NETDEV_UP: - hardif_activate_interface(bat_priv, batman_if); + hardif_activate_interface(soft_device, bat_priv, batman_if); break; case NETDEV_GOING_DOWN: case NETDEV_DOWN: - hardif_deactivate_interface(batman_if); + hardif_deactivate_interface(soft_device, batman_if); break; case NETDEV_UNREGISTER: hardif_remove_interface(batman_if);
Modified: trunk/batman-adv/icmp_socket.c =================================================================== --- trunk/batman-adv/icmp_socket.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/icmp_socket.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -19,9 +19,9 @@ * */
+#include "main.h" #include <linux/debugfs.h> #include <linux/slab.h> -#include "main.h" #include "icmp_socket.h" #include "send.h" #include "types.h" @@ -60,8 +60,7 @@ }
if (i == ARRAY_SIZE(socket_client_hash)) { - printk(KERN_ERR "batman-adv:" - "Error - can't add another packet client: " + pr_err("Error - can't add another packet client: " "maximum number of clients reached\n"); kfree(socket_client); return -EXFULL;
Modified: trunk/batman-adv/main.c =================================================================== --- trunk/batman-adv/main.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/main.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -94,16 +94,14 @@ interface_setup);
if (!soft_device) { - printk(KERN_ERR "batman-adv:" - "Unable to allocate the batman interface\n"); + pr_err("Unable to allocate the batman interface\n"); goto end; }
retval = register_netdev(soft_device);
if (retval < 0) { - printk(KERN_ERR "batman-adv:" - "Unable to register the batman interface: %i\n", retval); + pr_err("Unable to register the batman interface: %i\n", retval); goto free_soft_device; }
@@ -120,9 +118,9 @@ register_netdevice_notifier(&hard_if_notifier); dev_add_pack(&batman_adv_packet_type);
- printk(KERN_INFO "batman-adv:" - "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n", - SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION); + pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) " + "loaded\n", SOURCE_VERSION, REVISION_VERSION_STR, + COMPAT_VERSION);
return 0;
@@ -183,8 +181,7 @@ goto end;
err: - printk(KERN_ERR "batman-adv:" - "Unable to allocate memory for mesh information structures: " + pr_err("Unable to allocate memory for mesh information structures: " "out of mem ?\n"); deactivate_module(); end:
Modified: trunk/batman-adv/main.h =================================================================== --- trunk/batman-adv/main.h 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/main.h 2010-06-28 12:25:04 UTC (rev 1729) @@ -86,10 +86,13 @@ /* * Debug Messages */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before + * kernel messages */
#define DBG_BATMAN 1 /* all messages related to routing / flooding / * broadcasting / etc */ #define DBG_ROUTES 2 /* route or hna added / changed / deleted */ +#define DBG_ALL 3
#define LOG_BUF_LEN 8192 /* has to be a power of 2 */
@@ -169,4 +172,26 @@ } #endif
+#define bat_warning(net_dev, fmt, arg...) \ + do { \ + struct net_device *_netdev = (net_dev); \ + struct bat_priv *_batpriv = netdev_priv(_netdev); \ + bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + pr_warning("%s: " fmt, _netdev->name, ## arg); \ + } while (0) +#define bat_info(net_dev, fmt, arg...) \ + do { \ + struct net_device *_netdev = (net_dev); \ + struct bat_priv *_batpriv = netdev_priv(_netdev); \ + bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + pr_info("%s: " fmt, _netdev->name, ## arg); \ + } while (0) +#define bat_err(net_dev, fmt, arg...) \ + do { \ + struct net_device *_netdev = (net_dev); \ + struct bat_priv *_batpriv = netdev_priv(_netdev); \ + bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + pr_err("%s: " fmt, _netdev->name, ## arg); \ + } while (0) + #endif /* _NET_BATMAN_ADV_MAIN_H_ */
Modified: trunk/batman-adv/originator.c =================================================================== --- trunk/batman-adv/originator.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/originator.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -169,8 +169,8 @@ swaphash = hash_resize(orig_hash, orig_hash->size * 2);
if (swaphash == NULL) - printk(KERN_ERR - "batman-adv:Couldn't resize orig hash table\n"); + bat_err(soft_device, + "Couldn't resize orig hash table\n"); else orig_hash = swaphash; } @@ -364,8 +364,7 @@ data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS, GFP_ATOMIC); if (!data_ptr) { - printk(KERN_ERR - "batman-adv:Can't resize orig: out of memory\n"); + pr_err("Can't resize orig: out of memory\n"); return -1; }
@@ -376,8 +375,7 @@
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); if (!data_ptr) { - printk(KERN_ERR - "batman-adv:Can't resize orig: out of memory\n"); + pr_err("Can't resize orig: out of memory\n"); return -1; }
@@ -426,8 +424,7 @@ chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS; data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); if (!data_ptr) { - printk(KERN_ERR - "batman-adv:Can't resize orig: out of memory\n"); + pr_err("Can't resize orig: out of memory\n"); return -1; }
@@ -448,8 +445,7 @@
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); if (!data_ptr) { - printk(KERN_ERR - "batman-adv:Can't resize orig: out of memory\n"); + pr_err("Can't resize orig: out of memory\n"); return -1; }
Modified: trunk/batman-adv/routing.c =================================================================== --- trunk/batman-adv/routing.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/routing.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -871,10 +871,9 @@
/* send TTL exceeded if packet is an echo request (traceroute) */ if (icmp_packet->msg_type != ECHO_REQUEST) { - printk(KERN_WARNING "batman-adv:" - "Warning - can't forward icmp packet from %pM to %pM: " - "ttl exceeded\n", - icmp_packet->orig, icmp_packet->dst); + pr_warning("Warning - can't forward icmp packet from %pM to " + "%pM: ttl exceeded\n", icmp_packet->orig, + icmp_packet->dst); return NET_RX_DROP; }
@@ -1146,10 +1145,9 @@
/* TTL exceeded */ if (unicast_packet->ttl < 2) { - printk(KERN_WARNING "batman-adv:Warning - " - "can't forward unicast packet from %pM to %pM: " - "ttl exceeded\n", - ethhdr->h_source, unicast_packet->dest); + pr_warning("Warning - can't forward unicast packet from %pM to " + "%pM: ttl exceeded\n", ethhdr->h_source, + unicast_packet->dest); return NET_RX_DROP; }
Modified: trunk/batman-adv/send.c =================================================================== --- trunk/batman-adv/send.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/send.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -70,10 +70,8 @@ goto send_skb_err;
if (!(batman_if->net_dev->flags & IFF_UP)) { - printk(KERN_WARNING - "batman-adv:Interface %s " - "is not up - can't send packet via that interface!\n", - batman_if->dev); + pr_warning("Interface %s is not up - can't send packet via " + "that interface!\n", batman_if->dev); goto send_skb_err; }
@@ -192,8 +190,8 @@ unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
if (!forw_packet->if_incoming) { - printk(KERN_ERR "batman-adv: Error - can't forward packet: " - "incoming iface not specified\n"); + pr_err("Error - can't forward packet: incoming iface not " + "specified\n"); return; }
Modified: trunk/batman-adv/translation-table.c =================================================================== --- trunk/batman-adv/translation-table.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/translation-table.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -117,8 +117,7 @@ hna_local_hash->size * 2);
if (swaphash == NULL) - printk(KERN_ERR "batman-adv:" - "Couldn't resize local hna hash table\n"); + pr_err("Couldn't resize local hna hash table\n"); else hna_local_hash = swaphash; } @@ -373,8 +372,7 @@ hna_global_hash->size * 2);
if (swaphash == NULL) - printk(KERN_ERR "batman-adv:" - "Couldn't resize global hna hash table\n"); + pr_err("Couldn't resize global hna hash table\n"); else hna_global_hash = swaphash; }
Modified: trunk/batman-adv/vis.c =================================================================== --- trunk/batman-adv/vis.c 2010-06-28 12:25:03 UTC (rev 1728) +++ trunk/batman-adv/vis.c 2010-06-28 12:25:04 UTC (rev 1729) @@ -679,7 +679,7 @@ int packet_length;
if (info->packet.ttl < 2) { - printk(KERN_WARNING "batman-adv: Error - can't send vis packet: ttl exceeded\n"); + pr_warning("Error - can't send vis packet: ttl exceeded\n"); return; }
@@ -741,13 +741,13 @@
vis_hash = hash_new(256, vis_info_cmp, vis_info_choose); if (!vis_hash) { - printk(KERN_ERR "batman-adv:Can't initialize vis_hash\n"); + pr_err("Can't initialize vis_hash\n"); goto err; }
my_vis_info = kmalloc(1000, GFP_ATOMIC); if (!my_vis_info) { - printk(KERN_ERR "batman-adv:Can't initialize vis packet\n"); + pr_err("Can't initialize vis packet\n"); goto err; }
@@ -768,8 +768,7 @@ memcpy(my_vis_info->packet.sender_orig, main_if_addr, ETH_ALEN);
if (hash_add(vis_hash, my_vis_info) < 0) { - printk(KERN_ERR - "batman-adv:Can't add own vis packet into hash\n"); + pr_err("Can't add own vis packet into hash\n"); /* not in hash, need to remove it manually. */ kref_put(&my_vis_info->refcount, free_info); goto err;