提交 c1641862 编写于 作者: S Sven Eckelmann 提交者: Greg Kroah-Hartman

Staging: 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: NJoe Perches <joe@perches.com>
Signed-off-by: NSven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 84ec0864
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
* *
*/ */
#include "main.h"
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include "main.h"
#include "bat_debugfs.h" #include "bat_debugfs.h"
#include "translation-table.h" #include "translation-table.h"
#include "originator.h" #include "originator.h"
...@@ -309,8 +310,8 @@ int debugfs_add_meshif(struct net_device *dev) ...@@ -309,8 +310,8 @@ int debugfs_add_meshif(struct net_device *dev)
bat_priv->debug_dir, bat_priv->debug_dir,
dev, &(*bat_debug)->fops); dev, &(*bat_debug)->fops);
if (!file) { if (!file) {
printk(KERN_ERR "batman-adv:Can't add debugfs file: " bat_err(dev, "Can't add debugfs file: %s/%s\n",
"%s/%s\n", dev->name, ((*bat_debug)->attr).name); dev->name, ((*bat_debug)->attr).name);
goto rem_attr; goto rem_attr;
} }
} }
......
...@@ -67,18 +67,19 @@ static ssize_t store_aggr_ogms(struct kobject *kobj, struct attribute *attr, ...@@ -67,18 +67,19 @@ static ssize_t store_aggr_ogms(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
printk(KERN_INFO "batman-adv:Invalid parameter for 'aggregate OGM' setting on mesh %s received: %s\n", bat_info(net_dev,
net_dev->name, buff); "Invalid parameter for 'aggregate OGM' setting"
"received: %s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp) if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp)
return count; return count;
printk(KERN_INFO "batman-adv:Changing aggregation from: %s to: %s on mesh: %s\n", bat_info(net_dev, "Changing aggregation from: %s to: %s\n",
atomic_read(&bat_priv->aggregation_enabled) == 1 ? atomic_read(&bat_priv->aggregation_enabled) == 1 ?
"enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled", "enabled" : "disabled", aggr_tmp == 1 ? "enabled" :
net_dev->name); "disabled");
atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp); atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp);
return count; return count;
...@@ -115,19 +116,19 @@ static ssize_t store_bond(struct kobject *kobj, struct attribute *attr, ...@@ -115,19 +116,19 @@ static ssize_t store_bond(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
printk(KERN_ERR "batman-adv:Invalid parameter for 'bonding' setting on mesh %s received: %s\n", bat_err(net_dev,
net_dev->name, buff); "Invalid parameter for 'bonding' setting received: "
"%s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->bonding_enabled) == bonding_enabled_tmp) if (atomic_read(&bat_priv->bonding_enabled) == bonding_enabled_tmp)
return count; return count;
printk(KERN_INFO "batman-adv:Changing bonding from: %s to: %s on mesh: %s\n", bat_info(net_dev, "Changing bonding from: %s to: %s\n",
atomic_read(&bat_priv->bonding_enabled) == 1 ? atomic_read(&bat_priv->bonding_enabled) == 1 ?
"enabled" : "disabled", "enabled" : "disabled",
bonding_enabled_tmp == 1 ? "enabled" : "disabled", bonding_enabled_tmp == 1 ? "enabled" : "disabled");
net_dev->name);
atomic_set(&bat_priv->bonding_enabled, (unsigned)bonding_enabled_tmp); atomic_set(&bat_priv->bonding_enabled, (unsigned)bonding_enabled_tmp);
return count; return count;
...@@ -169,18 +170,19 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, ...@@ -169,18 +170,19 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n", bat_info(net_dev,
net_dev->name, buff); "Invalid parameter for 'vis mode' setting received: "
"%s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp) if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
return count; return count;
printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n", bat_info(net_dev, "Changing vis mode from: %s to: %s\n",
atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ? atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server", net_dev->name); "client" : "server");
atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp); atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
return count; return count;
...@@ -207,23 +209,23 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr, ...@@ -207,23 +209,23 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr,
ret = strict_strtoul(buff, 10, &orig_interval_tmp); ret = strict_strtoul(buff, 10, &orig_interval_tmp);
if (ret) { if (ret) {
printk(KERN_INFO "batman-adv:Invalid parameter for 'orig_interval' setting on mesh %s received: %s\n", bat_info(net_dev, "Invalid parameter for 'orig_interval' "
net_dev->name, buff); "setting received: %s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (orig_interval_tmp < JITTER * 2) { if (orig_interval_tmp < JITTER * 2) {
printk(KERN_INFO "batman-adv:New originator interval too small: %li (min: %i)\n", bat_info(net_dev, "New originator interval too small: %li "
orig_interval_tmp, JITTER * 2); "(min: %i)\n", orig_interval_tmp, JITTER * 2);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->orig_interval) == orig_interval_tmp) if (atomic_read(&bat_priv->orig_interval) == orig_interval_tmp)
return count; return count;
printk(KERN_INFO "batman-adv:Changing originator interval from: %i to: %li on mesh: %s\n", bat_info(net_dev, "Changing originator interval from: %i to: %li\n",
atomic_read(&bat_priv->orig_interval), atomic_read(&bat_priv->orig_interval),
orig_interval_tmp, net_dev->name); orig_interval_tmp);
atomic_set(&bat_priv->orig_interval, orig_interval_tmp); atomic_set(&bat_priv->orig_interval, orig_interval_tmp);
return count; return count;
...@@ -251,24 +253,23 @@ static ssize_t store_log_level(struct kobject *kobj, struct attribute *attr, ...@@ -251,24 +253,23 @@ static ssize_t store_log_level(struct kobject *kobj, struct attribute *attr,
ret = strict_strtoul(buff, 10, &log_level_tmp); ret = strict_strtoul(buff, 10, &log_level_tmp);
if (ret) { if (ret) {
printk(KERN_INFO "batman-adv:Invalid parameter for 'log_level' setting on mesh %s received: %s\n", bat_info(net_dev, "Invalid parameter for 'log_level' "
net_dev->name, buff); "setting received: %s\n", buff);
return -EINVAL; return -EINVAL;
} }
if (log_level_tmp > 3) { if (log_level_tmp > 3) {
printk(KERN_INFO "batman-adv:New log level too big: %li (max: %i)\n", bat_info(net_dev, "New log level too big: %li "
log_level_tmp, 3); "(max: %i)\n", log_level_tmp, 3);
return -EINVAL; return -EINVAL;
} }
if (atomic_read(&bat_priv->log_level) == log_level_tmp) if (atomic_read(&bat_priv->log_level) == log_level_tmp)
return count; return count;
printk(KERN_INFO bat_info(net_dev, "Changing log level from: %i to: %li\n",
"batman-adv:Changing log level from: %i to: %li on mesh: %s\n", atomic_read(&bat_priv->log_level),
atomic_read(&bat_priv->log_level), log_level_tmp);
log_level_tmp, net_dev->name);
atomic_set(&bat_priv->log_level, (unsigned)log_level_tmp); atomic_set(&bat_priv->log_level, (unsigned)log_level_tmp);
return count; return count;
...@@ -317,8 +318,8 @@ int sysfs_add_meshif(struct net_device *dev) ...@@ -317,8 +318,8 @@ int sysfs_add_meshif(struct net_device *dev)
bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
batif_kobject); batif_kobject);
if (!bat_priv->mesh_obj) { if (!bat_priv->mesh_obj) {
printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n", bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
dev->name, SYSFS_IF_MESH_SUBDIR); SYSFS_IF_MESH_SUBDIR);
goto out; goto out;
} }
...@@ -326,9 +327,9 @@ int sysfs_add_meshif(struct net_device *dev) ...@@ -326,9 +327,9 @@ int sysfs_add_meshif(struct net_device *dev)
err = sysfs_create_file(bat_priv->mesh_obj, err = sysfs_create_file(bat_priv->mesh_obj,
&((*bat_attr)->attr)); &((*bat_attr)->attr));
if (err) { if (err) {
printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
dev->name, SYSFS_IF_MESH_SUBDIR, dev->name, SYSFS_IF_MESH_SUBDIR,
((*bat_attr)->attr).name); ((*bat_attr)->attr).name);
goto rem_attr; goto rem_attr;
} }
} }
...@@ -393,8 +394,8 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, ...@@ -393,8 +394,8 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
printk(KERN_ERR "batman-adv:Invalid parameter for 'mesh_iface' setting received: %s\n", pr_err("Invalid parameter for 'mesh_iface' setting received: "
buff); "%s\n", buff);
return -EINVAL; return -EINVAL;
} }
...@@ -456,17 +457,17 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) ...@@ -456,17 +457,17 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
hardif_kobject); hardif_kobject);
if (!*hardif_obj) { if (!*hardif_obj) {
printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n", bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
dev->name, SYSFS_IF_BAT_SUBDIR); SYSFS_IF_BAT_SUBDIR);
goto out; goto out;
} }
for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) { for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) {
err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
if (err) { if (err) {
printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
dev->name, SYSFS_IF_BAT_SUBDIR, dev->name, SYSFS_IF_BAT_SUBDIR,
((*bat_attr)->attr).name); ((*bat_attr)->attr).name);
goto rem_attr; goto rem_attr;
} }
} }
......
...@@ -150,12 +150,10 @@ static void check_known_mac_addr(uint8_t *addr) ...@@ -150,12 +150,10 @@ static void check_known_mac_addr(uint8_t *addr)
if (!compare_orig(batman_if->net_dev->dev_addr, addr)) if (!compare_orig(batman_if->net_dev->dev_addr, addr))
continue; continue;
printk(KERN_WARNING "batman-adv:" pr_warning("The newly added mac address (%pM) already exists "
"The newly added mac address (%pM) already exists on: %s\n", "on: %s\n", addr, batman_if->dev);
addr, batman_if->dev); pr_warning("It is strongly recommended to keep mac addresses "
printk(KERN_WARNING "batman-adv:" "unique to avoid problems!\n");
"It is strongly recommended to keep mac addresses unique"
"to avoid problems!\n");
} }
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -189,7 +187,8 @@ void update_min_mtu(void) ...@@ -189,7 +187,8 @@ void update_min_mtu(void)
soft_device->mtu = min_mtu; 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) struct batman_if *batman_if)
{ {
if (batman_if->if_status != IF_INACTIVE) if (batman_if->if_status != IF_INACTIVE)
...@@ -207,8 +206,7 @@ static void hardif_activate_interface(struct bat_priv *bat_priv, ...@@ -207,8 +206,7 @@ static void hardif_activate_interface(struct bat_priv *bat_priv,
if (!bat_priv->primary_if) if (!bat_priv->primary_if)
set_primary_if(bat_priv, batman_if); set_primary_if(bat_priv, batman_if);
printk(KERN_INFO "batman-adv:Interface activated: %s\n", bat_info(net_dev, "Interface activated: %s\n", batman_if->dev);
batman_if->dev);
if (atomic_read(&module_state) == MODULE_INACTIVE) if (atomic_read(&module_state) == MODULE_INACTIVE)
activate_module(); activate_module();
...@@ -217,7 +215,8 @@ static void hardif_activate_interface(struct bat_priv *bat_priv, ...@@ -217,7 +215,8 @@ static void hardif_activate_interface(struct bat_priv *bat_priv,
return; 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) && if ((batman_if->if_status != IF_ACTIVE) &&
(batman_if->if_status != IF_TO_BE_ACTIVATED)) (batman_if->if_status != IF_TO_BE_ACTIVATED))
...@@ -227,8 +226,7 @@ static void hardif_deactivate_interface(struct batman_if *batman_if) ...@@ -227,8 +226,7 @@ static void hardif_deactivate_interface(struct batman_if *batman_if)
batman_if->if_status = IF_INACTIVE; batman_if->if_status = IF_INACTIVE;
printk(KERN_INFO "batman-adv:Interface deactivated: %s\n", bat_info(net_dev, "Interface deactivated: %s\n", batman_if->dev);
batman_if->dev);
update_min_mtu(); update_min_mtu();
} }
...@@ -246,9 +244,8 @@ int hardif_enable_interface(struct batman_if *batman_if) ...@@ -246,9 +244,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC); batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
if (!batman_if->packet_buff) { if (!batman_if->packet_buff) {
printk(KERN_ERR "batman-adv:" bat_err(soft_device, "Can't add interface packet (%s): "
"Can't add interface packet (%s): out of memory\n", "out of memory\n", batman_if->dev);
batman_if->dev);
goto err; goto err;
} }
...@@ -266,15 +263,14 @@ int hardif_enable_interface(struct batman_if *batman_if) ...@@ -266,15 +263,14 @@ int hardif_enable_interface(struct batman_if *batman_if)
orig_hash_add_if(batman_if, bat_priv->num_ifaces); orig_hash_add_if(batman_if, bat_priv->num_ifaces);
atomic_set(&batman_if->seqno, 1); 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)) if (hardif_is_iface_up(batman_if))
hardif_activate_interface(bat_priv, batman_if); hardif_activate_interface(soft_device, bat_priv, batman_if);
else else
printk(KERN_ERR "batman-adv:" bat_err(soft_device, "Not using interface %s "
"Not using interface %s " "(retrying later): interface not active\n",
"(retrying later): interface not active\n", batman_if->dev);
batman_if->dev);
/* begin scheduling originator messages on that interface */ /* begin scheduling originator messages on that interface */
schedule_own_packet(batman_if); schedule_own_packet(batman_if);
...@@ -292,12 +288,12 @@ void hardif_disable_interface(struct batman_if *batman_if) ...@@ -292,12 +288,12 @@ void hardif_disable_interface(struct batman_if *batman_if)
struct bat_priv *bat_priv = netdev_priv(soft_device); struct bat_priv *bat_priv = netdev_priv(soft_device);
if (batman_if->if_status == IF_ACTIVE) 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) if (batman_if->if_status != IF_INACTIVE)
return; 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--; bat_priv->num_ifaces--;
orig_hash_del_if(batman_if, bat_priv->num_ifaces); orig_hash_del_if(batman_if, bat_priv->num_ifaces);
...@@ -324,8 +320,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev) ...@@ -324,8 +320,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC); batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
if (!batman_if) { if (!batman_if) {
printk(KERN_ERR "batman-adv:" pr_err("Can't add interface (%s): out of memory\n",
"Can't add interface (%s): out of memory\n",
net_dev->name); net_dev->name);
goto out; goto out;
} }
...@@ -408,11 +403,11 @@ static int hard_if_event(struct notifier_block *this, ...@@ -408,11 +403,11 @@ static int hard_if_event(struct notifier_block *this,
case NETDEV_REGISTER: case NETDEV_REGISTER:
break; break;
case NETDEV_UP: case NETDEV_UP:
hardif_activate_interface(bat_priv, batman_if); hardif_activate_interface(soft_device, bat_priv, batman_if);
break; break;
case NETDEV_GOING_DOWN: case NETDEV_GOING_DOWN:
case NETDEV_DOWN: case NETDEV_DOWN:
hardif_deactivate_interface(batman_if); hardif_deactivate_interface(soft_device, batman_if);
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
hardif_remove_interface(batman_if); hardif_remove_interface(batman_if);
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
* *
*/ */
#include "main.h"
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "main.h"
#include "icmp_socket.h" #include "icmp_socket.h"
#include "send.h" #include "send.h"
#include "types.h" #include "types.h"
...@@ -58,8 +58,7 @@ static int bat_socket_open(struct inode *inode, struct file *file) ...@@ -58,8 +58,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
} }
if (i == ARRAY_SIZE(socket_client_hash)) { if (i == ARRAY_SIZE(socket_client_hash)) {
printk(KERN_ERR "batman-adv:" pr_err("Error - can't add another packet client: "
"Error - can't add another packet client: "
"maximum number of clients reached\n"); "maximum number of clients reached\n");
kfree(socket_client); kfree(socket_client);
return -EXFULL; return -EXFULL;
......
...@@ -87,16 +87,14 @@ int init_module(void) ...@@ -87,16 +87,14 @@ int init_module(void)
interface_setup); interface_setup);
if (!soft_device) { if (!soft_device) {
printk(KERN_ERR "batman-adv:" pr_err("Unable to allocate the batman interface\n");
"Unable to allocate the batman interface\n");
goto end; goto end;
} }
retval = register_netdev(soft_device); retval = register_netdev(soft_device);
if (retval < 0) { if (retval < 0) {
printk(KERN_ERR "batman-adv:" pr_err("Unable to register the batman interface: %i\n", retval);
"Unable to register the batman interface: %i\n", retval);
goto free_soft_device; goto free_soft_device;
} }
...@@ -113,9 +111,9 @@ int init_module(void) ...@@ -113,9 +111,9 @@ int init_module(void)
register_netdevice_notifier(&hard_if_notifier); register_netdevice_notifier(&hard_if_notifier);
dev_add_pack(&batman_adv_packet_type); dev_add_pack(&batman_adv_packet_type);
printk(KERN_INFO "batman-adv:" pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) "
"B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n", "loaded\n", SOURCE_VERSION, REVISION_VERSION_STR,
SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION); COMPAT_VERSION);
return 0; return 0;
...@@ -176,8 +174,7 @@ void activate_module(void) ...@@ -176,8 +174,7 @@ void activate_module(void)
goto end; goto end;
err: err:
printk(KERN_ERR "batman-adv:" pr_err("Unable to allocate memory for mesh information structures: "
"Unable to allocate memory for mesh information structures: "
"out of mem ?\n"); "out of mem ?\n");
deactivate_module(); deactivate_module();
end: end:
......
...@@ -86,10 +86,13 @@ ...@@ -86,10 +86,13 @@
/* /*
* Debug Messages * 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 / #define DBG_BATMAN 1 /* all messages related to routing / flooding /
* broadcasting / etc */ * broadcasting / etc */
#define DBG_ROUTES 2 /* route or hna added / changed / deleted */ #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 */ #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
...@@ -171,4 +174,26 @@ static inline void bat_dbg(char type __attribute__((unused)), ...@@ -171,4 +174,26 @@ static inline void bat_dbg(char type __attribute__((unused)),
} }
#endif #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_ */ #endif /* _NET_BATMAN_ADV_MAIN_H_ */
...@@ -167,8 +167,8 @@ struct orig_node *get_orig_node(uint8_t *addr) ...@@ -167,8 +167,8 @@ struct orig_node *get_orig_node(uint8_t *addr)
swaphash = hash_resize(orig_hash, orig_hash->size * 2); swaphash = hash_resize(orig_hash, orig_hash->size * 2);
if (swaphash == NULL) if (swaphash == NULL)
printk(KERN_ERR bat_err(soft_device,
"batman-adv:Couldn't resize orig hash table\n"); "Couldn't resize orig hash table\n");
else else
orig_hash = swaphash; orig_hash = swaphash;
} }
...@@ -357,8 +357,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) ...@@ -357,8 +357,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS, data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS,
GFP_ATOMIC); GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
...@@ -369,8 +368,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) ...@@ -369,8 +368,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
...@@ -419,8 +417,7 @@ static int orig_node_del_if(struct orig_node *orig_node, ...@@ -419,8 +417,7 @@ static int orig_node_del_if(struct orig_node *orig_node,
chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS; chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS;
data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
...@@ -441,8 +438,7 @@ static int orig_node_del_if(struct orig_node *orig_node, ...@@ -441,8 +438,7 @@ static int orig_node_del_if(struct orig_node *orig_node,
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) { if (!data_ptr) {
printk(KERN_ERR pr_err("Can't resize orig: out of memory\n");
"batman-adv:Can't resize orig: out of memory\n");
return -1; return -1;
} }
......
...@@ -859,10 +859,9 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len) ...@@ -859,10 +859,9 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
/* send TTL exceeded if packet is an echo request (traceroute) */ /* send TTL exceeded if packet is an echo request (traceroute) */
if (icmp_packet->msg_type != ECHO_REQUEST) { if (icmp_packet->msg_type != ECHO_REQUEST) {
printk(KERN_WARNING "batman-adv:" pr_warning("Warning - can't forward icmp packet from %pM to "
"Warning - can't forward icmp packet from %pM to %pM: " "%pM: ttl exceeded\n", icmp_packet->orig,
"ttl exceeded\n", icmp_packet->dst);
icmp_packet->orig, icmp_packet->dst);
return NET_RX_DROP; return NET_RX_DROP;
} }
...@@ -1134,10 +1133,9 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) ...@@ -1134,10 +1133,9 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)
/* TTL exceeded */ /* TTL exceeded */
if (unicast_packet->ttl < 2) { if (unicast_packet->ttl < 2) {
printk(KERN_WARNING "batman-adv:Warning - " pr_warning("Warning - can't forward unicast packet from %pM to "
"can't forward unicast packet from %pM to %pM: " "%pM: ttl exceeded\n", ethhdr->h_source,
"ttl exceeded\n", unicast_packet->dest);
ethhdr->h_source, unicast_packet->dest);
return NET_RX_DROP; return NET_RX_DROP;
} }
......
...@@ -68,10 +68,8 @@ int send_skb_packet(struct sk_buff *skb, ...@@ -68,10 +68,8 @@ int send_skb_packet(struct sk_buff *skb,
goto send_skb_err; goto send_skb_err;
if (!(batman_if->net_dev->flags & IFF_UP)) { if (!(batman_if->net_dev->flags & IFF_UP)) {
printk(KERN_WARNING pr_warning("Interface %s is not up - can't send packet via "
"batman-adv:Interface %s " "that interface!\n", batman_if->dev);
"is not up - can't send packet via that interface!\n",
batman_if->dev);
goto send_skb_err; goto send_skb_err;
} }
...@@ -190,8 +188,8 @@ static void send_packet(struct forw_packet *forw_packet) ...@@ -190,8 +188,8 @@ static void send_packet(struct forw_packet *forw_packet)
unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0); unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
if (!forw_packet->if_incoming) { if (!forw_packet->if_incoming) {
printk(KERN_ERR "batman-adv: Error - can't forward packet: " pr_err("Error - can't forward packet: incoming iface not "
"incoming iface not specified\n"); "specified\n");
return; return;
} }
......
...@@ -116,8 +116,7 @@ void hna_local_add(uint8_t *addr) ...@@ -116,8 +116,7 @@ void hna_local_add(uint8_t *addr)
hna_local_hash->size * 2); hna_local_hash->size * 2);
if (swaphash == NULL) if (swaphash == NULL)
printk(KERN_ERR "batman-adv:" pr_err("Couldn't resize local hna hash table\n");
"Couldn't resize local hna hash table\n");
else else
hna_local_hash = swaphash; hna_local_hash = swaphash;
} }
...@@ -372,8 +371,7 @@ void hna_global_add_orig(struct orig_node *orig_node, ...@@ -372,8 +371,7 @@ void hna_global_add_orig(struct orig_node *orig_node,
hna_global_hash->size * 2); hna_global_hash->size * 2);
if (swaphash == NULL) if (swaphash == NULL)
printk(KERN_ERR "batman-adv:" pr_err("Couldn't resize global hna hash table\n");
"Couldn't resize global hna hash table\n");
else else
hna_global_hash = swaphash; hna_global_hash = swaphash;
} }
......
...@@ -678,7 +678,7 @@ static void send_vis_packet(struct vis_info *info) ...@@ -678,7 +678,7 @@ static void send_vis_packet(struct vis_info *info)
int packet_length; int packet_length;
if (info->packet.ttl < 2) { 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; return;
} }
...@@ -740,13 +740,13 @@ int vis_init(void) ...@@ -740,13 +740,13 @@ int vis_init(void)
vis_hash = hash_new(256, vis_info_cmp, vis_info_choose); vis_hash = hash_new(256, vis_info_cmp, vis_info_choose);
if (!vis_hash) { if (!vis_hash) {
printk(KERN_ERR "batman-adv:Can't initialize vis_hash\n"); pr_err("Can't initialize vis_hash\n");
goto err; goto err;
} }
my_vis_info = kmalloc(1000, GFP_ATOMIC); my_vis_info = kmalloc(1000, GFP_ATOMIC);
if (!my_vis_info) { 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; goto err;
} }
...@@ -767,8 +767,7 @@ int vis_init(void) ...@@ -767,8 +767,7 @@ int vis_init(void)
memcpy(my_vis_info->packet.sender_orig, main_if_addr, ETH_ALEN); memcpy(my_vis_info->packet.sender_orig, main_if_addr, ETH_ALEN);
if (hash_add(vis_hash, my_vis_info) < 0) { if (hash_add(vis_hash, my_vis_info) < 0) {
printk(KERN_ERR pr_err("Can't add own vis packet into hash\n");
"batman-adv:Can't add own vis packet into hash\n");
/* not in hash, need to remove it manually. */ /* not in hash, need to remove it manually. */
kref_put(&my_vis_info->refcount, free_info); kref_put(&my_vis_info->refcount, free_info);
goto err; goto err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册