batman-adv debug logging (v2)
Hi,
I worked through the received feedback (thanks!) my first set of patches provoked and improved the code. The following changes have been made:
* the log level no longer is a global variable and can be configured for each mesh individually
* the "unused variable" warnings have been eliminated
* now dead batctl code has been removed
I also considered making the debug log available via the standard kernel logging facilities but right now I can only see little value in this feature. We can still add it as soon as somebody complains.
Unless there are futher comments I will go ahead and commit the changes.
Regards,
Marek
PATCH 1/2 batman-adv: add routing debug log accessible via debugfs
All routing debug messages are saved in a ring buffer that can be read via the debugfs file "log".
Note that CONFIG_BATMAN_ADV_DEBUG must be activated to have the debug logs compiled in.
--- batman-adv/aggregation.c | 3 +- batman-adv/bat_debugfs.c | 187 ++++++++++++++++++++++++++++++++++++++++ batman-adv/bat_sysfs.c | 53 +++++++++++ batman-adv/bitarray.c | 7 +- batman-adv/gateway_client.c | 20 +++-- batman-adv/hard-interface.c | 4 +- batman-adv/icmp_socket.c | 8 +- batman-adv/main.h | 33 ++++--- batman-adv/originator.c | 16 +++- batman-adv/routing.c | 58 ++++++++----- batman-adv/send.c | 23 ++++-- batman-adv/translation-table.c | 21 +++-- batman-adv/types.h | 12 ++- 13 files changed, 375 insertions(+), 70 deletions(-)
batman-adv/aggregation.c +2 -1
@@ -112,7 +112,8 @@ static void new_aggregated_packet(unsigned char *packet_buff,/* own packet should always be scheduled */ if (!own_packet) {if (!atomic_dec_not_zero (&bat_priv->batman_queue_left)) { -bat_dbg (DBG_BATMAN ,"batman packet queue full\n" ); +bat_dbg (DBG_BATMAN , bat_priv, +"batman packet queue full\n" );return ; } }
batman-adv/bat_debugfs.c +187 -0
205 lines not on this page · raw message
batman-adv/bat_sysfs.c +53 -0
77 lines not on this page · raw message
batman-adv/bitarray.c +5 -2
@@ -128,6 +128,9 @@ static void bit_reset_window(TYPE_OF_WORD *seq_bits)char bit_get_packet (TYPE_OF_WORD *seq_bits,int32_t seq_num_diff,int8_t set_mark) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device); +/* sequence number is slightly older. We already got a sequence number * higher than this one, so we just mark it. */
@@ -152,7 +155,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff,if ((seq_num_diff >=TQ_LOCAL_WINDOW_SIZE ) || (seq_num_diff <EXPECTED_SEQNO_RANGE )) { -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"We missed a lot of packets (%i) !\n" , seq_num_diff -1 );bit_reset_window (seq_bits);
@@ -169,7 +172,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff,if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE ) || (seq_num_diff >=EXPECTED_SEQNO_RANGE )) { -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Other host probably restarted!\n" );bit_reset_window (seq_bits);
batman-adv/gateway_client.c +12 -8
@@ -80,7 +80,7 @@ void gw_election(void)rcu_read_unlock ();if (curr_gateway) { -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Removing selected gateway - " "no gateway in range\n" );gw_deselect ();
@@ -137,18 +137,18 @@ void gw_election(void)spin_lock (&curr_gw_lock);if (curr_gateway != curr_gw_tmp) {if ((curr_gateway) && (!curr_gw_tmp)) -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Removing selected gateway - " "no gateway in range\n" );else if ((!curr_gateway) && (curr_gw_tmp)) -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Adding route to gateway %pM " "(gw_flags: %i, tq: %i)\n" , curr_gw_tmp->orig_node->orig, curr_gw_tmp->orig_node->gw_flags, curr_gw_tmp->orig_node->router->tq_avg);else - bat_dbg(DBG_BATMAN, + bat_dbg(DBG_BATMAN, bat_priv, "Changing route to gateway %pM " "(gw_flags: %i, tq: %i)\n", curr_gw_tmp->orig_node->orig,
@@ -200,7 +200,7 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_class))) return; -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Restarting gateway selection: better gateway found (tq curr: " "%i, tq new: %i)\n" , gw_tq_avg, orig_tq_avg);
@@ -211,6 +211,8 @@ deselect:static void gw_node_add (struct orig_node *orig_node,uint8_t new_gwflags) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct gw_node *gw_node;int down, up;
@@ -225,7 +227,7 @@ static void gw_node_add(struct orig_node *orig_node, uint8_t new_gwflags)list_add_tail_rcu (&gw_node->list, &gw_list);gw_srv_class_to_kbit (new_gwflags, &down, &up); - bat_dbg(DBG_BATMAN, + bat_dbg(DBG_BATMAN, bat_priv, "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", orig_node->orig, new_gwflags, (down > 2048 ? down / 1024 : down),
@@ -236,6 +238,8 @@ static void gw_node_add(struct orig_node *orig_node, uint8_t new_gwflags)void gw_node_update (struct orig_node *orig_node,uint8_t new_gwflags) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct gw_node *gw_node;rcu_read_lock ();
@@ -243,7 +247,7 @@ void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags)if (gw_node->orig_node != orig_node)continue ; - bat_dbg(DBG_BATMAN, + bat_dbg(DBG_BATMAN, bat_priv, "Gateway class of originator %pM changed from " "%i to %i\n", orig_node->orig, gw_node->orig_node->gw_flags,
@@ -253,7 +257,7 @@ void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags)if (new_gwflags ==0 ) { gw_node->deleted = jiffies; -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Gateway %pM removed from gateway list\n" , orig_node->orig);
batman-adv/hard-interface.c +3 -1
@@ -445,6 +445,8 @@ static int batman_skb_recv_finish(struct sk_buff *skb)int batman_skb_recv (struct sk_buff *skb,struct net_device *dev,struct packet_type *ptype,struct net_device *orig_dev) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct batman_packet *batman_packet;struct batman_if *batman_if;struct net_device_stats *stats;
@@ -492,7 +494,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, batman_packet = (struct batman_packet *)skb->data;if (batman_packet->version !=COMPAT_VERSION ) { -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Drop packet: incompatible batman version (%i)\n" , batman_packet->version); goto err_free;
batman-adv/icmp_socket.c +5 -3
@@ -156,6 +156,8 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf,static ssize_t bat_socket_write (struct file *file,const char __user *buff,size_t len,loff_t *off) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct socket_client *socket_client = (struct socket_client *)file->private_data;struct icmp_packet_rr icmp_packet;
@@ -166,7 +168,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,unsigned long flags;if (len <sizeof (struct icmp_packet )) { -bat_dbg (DBG_BATMAN ,"batman-adv:" +bat_dbg (DBG_BATMAN , bat_priv,"Error - can't send packet from char device: " "invalid packet size\n" );return -EINVAL ;
@@ -182,14 +184,14 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,return -EFAULT ;if (icmp_packet.packet_type !=BAT_ICMP ) { -bat_dbg (DBG_BATMAN ,"batman-adv:" +bat_dbg (DBG_BATMAN , bat_priv,"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 ) { -bat_dbg (DBG_BATMAN ,"batman-adv:" +bat_dbg (DBG_BATMAN , bat_priv,"Error - can't send packet from char device: " "got bogus message type (expected: ECHO_REQUEST)\n" );return -EINVAL ;
batman-adv/main.h +20 -13
@@ -91,20 +91,8 @@* broadcasting / etc */ #define DBG_ROUTES 2/* route or hna added / changed / deleted */ -#ifdef CONFIG_BATMAN_ADV_DEBUG -extern int debug; +#define LOG_BUF_LEN 8192/* has to be a power of 2 */ -extern int bat_debug_type (int type); -#define bat_dbg(type, fmt, arg...) do { \ - if (bat_debug_type(type)) \ - printk(KERN_DEBUG "batman-adv:" fmt, ## arg); \ - } \ - while (0) -#else /* !CONFIG_BATMAN_ADV_DEBUG */ -#define bat_dbg(type, fmt, arg...) do { \ - } \ - while (0) -#endif /* * Vis
@@ -164,4 +152,23 @@ int is_my_mac(uint8_t *addr);int is_bcast (uint8_t *addr);int is_mcast (uint8_t *addr); +#ifdef CONFIG_BATMAN_ADV_DEBUG +extern int debug; + +extern int bat_debug_type (int type); +extern int debug_log (struct bat_priv *bat_priv,char *fmt, ...); + +#define bat_dbg(type, bat_priv, fmt, arg...) do { \ + if (atomic_read(&bat_priv->log_level) & type) \ + debug_log(bat_priv, fmt, ## arg); \ + } \ + while (0) +#else /* !CONFIG_BATMAN_ADV_DEBUG */ +static inline void bat_dbg (char type __attribute__((unused)), +struct bat_priv *bat_priv __attribute__((unused)), +char *fmt __attribute__((unused)), ...) +{ +} +#endif +#endif /* _NET_BATMAN_ADV_MAIN_H_ */
batman-adv/originator.c +11 -5
@@ -62,9 +62,12 @@ struct neigh_node * create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh, struct batman_if *if_incoming) { + /* FIXME: each orig_node->batman_if will be attached to a softif */ + struct bat_priv *bat_priv = netdev_priv(soft_device);struct neigh_node *neigh_node; -bat_dbg (DBG_BATMAN ,"Creating new last-hop neighbor of originator\n" ); +bat_dbg (DBG_BATMAN , bat_priv, +"Creating new last-hop neighbor of originator\n" ); neigh_node =kzalloc (sizeof (struct neigh_node ),GFP_ATOMIC );if (!neigh_node)
@@ -131,7 +134,8 @@ struct orig_node *get_orig_node(uint8_t *addr)if (orig_node !=NULL )return orig_node; -bat_dbg (DBG_BATMAN ,"Creating new originator: %pM\n" , addr); +bat_dbg (DBG_BATMAN , bat_priv, +"Creating new originator: %pM\n" , addr); orig_node =kzalloc (sizeof (struct orig_node ),GFP_ATOMIC );if (!orig_node)
@@ -184,6 +188,8 @@ free_orig_node:static bool purge_orig_neighbors (struct orig_node *orig_node,struct neigh_node **best_neigh_node) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct list_head *list_pos, *list_pos_tmp;struct neigh_node *neigh_node;bool neigh_purged = false;
@@ -201,13 +207,13 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,if (neigh_node->if_incoming->if_status ==IF_TO_BE_REMOVED ) -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"neighbor purge: originator %pM, " "neighbor: %pM, iface: %s\n" , orig_node->orig, neigh_node->addr, neigh_node->if_incoming->dev);else - bat_dbg(DBG_BATMAN, + bat_dbg(DBG_BATMAN, bat_priv, "neighbor timeout: originator %pM, " "neighbor: %pM, last_valid: %lu\n", orig_node->orig, neigh_node->addr,
@@ -234,7 +240,7 @@ static bool purge_orig_node(struct orig_node *orig_node)if (time_after (jiffies, orig_node->last_valid +2 *PURGE_TIMEOUT *HZ )) { -bat_dbg (DBG_BATMAN , +bat_dbg (DBG_BATMAN , bat_priv,"Originator timeout: originator %pM, last_valid %lu\n" , orig_node->orig, (orig_node->last_valid /HZ ));return true;
batman-adv/routing.c +36 -22
206 lines not on this page · raw message
batman-adv/send.c +16 -7
@@ -128,6 +128,8 @@ void send_raw_packet(unsigned char *pack_buff, int pack_buff_len,static void send_packet_to_if (struct forw_packet *forw_packet,struct batman_if *batman_if) { +/* FIXME: each batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);char *fwd_str;uint8_t packet_num;int16_t buff_pos;
@@ -157,7 +159,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet, fwd_str = (packet_num >0 ?"Forwarding" : (forw_packet->own ?"Sending own" :"Forwarding" )); - bat_dbg(DBG_BATMAN, + bat_dbg(DBG_BATMAN, bat_priv, "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d," " IDF %s) on interface %s [%s]\n", fwd_str, (packet_num > 0 ? "aggregated " : ""),
@@ -182,6 +184,8 @@ static void send_packet_to_if(struct forw_packet *forw_packet,/* send a batman packet */ static void send_packet (struct forw_packet *forw_packet) { +/* FIXME: each batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct batman_if *batman_if;struct batman_packet *batman_packet = (struct batman_packet *)(forw_packet->packet_buff);
@@ -202,7 +206,7 @@ static void send_packet(struct forw_packet *forw_packet) (forw_packet->own && (forw_packet->if_incoming->if_num > 0))) {/* FIXME: what about aggregated packets ? */ - bat_dbg(DBG_BATMAN, + bat_dbg(DBG_BATMAN, bat_priv, "%s packet (originator %pM, seqno %d, TTL %d) " "on interface %s [%s]\n", (forw_packet->own ? "Sending own" : "Forwarding"),
@@ -321,7 +325,7 @@ void schedule_forward_packet(struct orig_node *orig_node,unsigned long send_time;if (batman_packet->ttl <=1 ) { -bat_dbg (DBG_BATMAN ,"ttl exceeded\n" ); +bat_dbg (DBG_BATMAN , bat_priv,"ttl exceeded\n" );return ; }
@@ -350,7 +354,8 @@ void schedule_forward_packet(struct orig_node *orig_node,/* apply hop penalty */ batman_packet->tq =hop_penalty (batman_packet->tq); -bat_dbg (DBG_BATMAN ,"Forwarding packet: tq_orig: %i, tq_avg: %i, " +bat_dbg (DBG_BATMAN , bat_priv, +"Forwarding packet: tq_orig: %i, tq_avg: %i, " "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n" , in_tq, tq_avg, batman_packet->tq, in_ttl -1 , batman_packet->ttl);
@@ -414,7 +419,7 @@ int add_bcast_packet_to_list(struct sk_buff *skb)struct bat_priv *bat_priv =netdev_priv (soft_device);if (!atomic_dec_not_zero (&bat_priv->bcast_queue_left)) { -bat_dbg (DBG_BATMAN ,"bcast packet queue full\n" ); +bat_dbg (DBG_BATMAN , bat_priv,"bcast packet queue full\n" ); goto out; }
@@ -530,15 +535,19 @@ out:void purge_outstanding_packets (struct batman_if *batman_if) { +/* FIXME: each batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct forw_packet *forw_packet;struct hlist_node *tmp_node, *safe_tmp_node;unsigned long flags;if (batman_if) -bat_dbg (DBG_BATMAN ,"purge_outstanding_packets(): %s\n" , +bat_dbg (DBG_BATMAN , bat_priv, +"purge_outstanding_packets(): %s\n" , batman_if->dev);else -bat_dbg (DBG_BATMAN ,"purge_outstanding_packets()\n" ); +bat_dbg (DBG_BATMAN , bat_priv, +"purge_outstanding_packets()\n" );/* free bcast list */ spin_lock_irqsave (&forw_bcast_list_lock, flags);
batman-adv/translation-table.c +15 -6
@@ -61,6 +61,8 @@ int hna_local_init(void)void hna_local_add (uint8_t *addr) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct hna_local_entry *hna_local_entry;struct hna_global_entry *hna_global_entry;struct hashtable_t *swaphash;
@@ -81,15 +83,15 @@ void hna_local_add(uint8_t *addr)MAC-flooding. */ if ((num_hna +1 > (ETH_DATA_LEN -BAT_PACKET_LEN ) /ETH_ALEN ) || (num_hna +1 >255 )) { -bat_dbg (DBG_ROUTES , +bat_dbg (DBG_ROUTES , bat_priv,"Can't add new local hna entry (%pM): " "number of local hna entries exceeds packet size\n" , addr);return ; } -bat_dbg (DBG_ROUTES ,"Creating new local hna entry: %pM\n" , - addr); +bat_dbg (DBG_ROUTES , bat_priv, +"Creating new local hna entry: %pM\n" , addr); hna_local_entry =kmalloc (sizeof (struct hna_local_entry ),GFP_ATOMIC );if (!hna_local_entry)
@@ -224,7 +226,9 @@ static void _hna_local_del(void *data)static void hna_local_del (struct hna_local_entry *hna_local_entry,char *message) { -bat_dbg (DBG_ROUTES ,"Deleting local hna entry (%pM): %s\n" , +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device); +bat_dbg (DBG_ROUTES , bat_priv,"Deleting local hna entry (%pM): %s\n" , hna_local_entry->addr, message);hash_remove (hna_local_hash, hna_local_entry->addr);
@@ -294,6 +298,8 @@ int hna_global_init(void)void hna_global_add_orig (struct orig_node *orig_node,unsigned char *hna_buff,int hna_buff_len) { +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device);struct hna_global_entry *hna_global_entry;struct hna_local_entry *hna_local_entry;struct hashtable_t *swaphash;
@@ -320,7 +326,7 @@ void hna_global_add_orig(struct orig_node *orig_node,memcpy (hna_global_entry->addr, hna_ptr,ETH_ALEN ); -bat_dbg (DBG_ROUTES , +bat_dbg (DBG_ROUTES , bat_priv,"Creating new global hna entry: " "%pM (via %pM)\n" , hna_global_entry->addr, orig_node->orig);
@@ -429,7 +435,10 @@ int hna_global_seq_print_text(struct seq_file *seq, void *offset)static void _hna_global_del_orig (struct hna_global_entry *hna_global_entry,char *message) { -bat_dbg (DBG_ROUTES ,"Deleting global hna entry %pM (via %pM): %s\n" , +/* FIXME: each orig_node->batman_if will be attached to a softif */ +struct bat_priv *bat_priv =netdev_priv (soft_device); +bat_dbg (DBG_ROUTES , bat_priv, +"Deleting global hna entry %pM (via %pM): %s\n" , hna_global_entry->addr, hna_global_entry->orig_node->orig, message);
batman-adv/types.h +10 -2
@@ -21,8 +21,6 @@ - -#ifndef _NET_BATMAN_ADV_TYPES_H_#define _NET_BATMAN_ADV_TYPES_H_
@@ -124,9 +122,11 @@ struct bat_priv {atomic_t gw_mode;atomic_t gw_class;atomic_t orig_interval; +atomic_t log_level;atomic_t bcast_queue_left;atomic_t batman_queue_left;char num_ifaces; +struct debug_log *debug_log;struct batman_if *primary_if;struct kobject *mesh_obj;struct dentry *debug_dir;
@@ -184,4 +184,12 @@ struct if_list_entry { struct hlist_node list; }; +struct debug_log { +char log_buff[LOG_BUF_LEN ]; +unsigned long log_start; +unsigned long log_end; +spinlock_t lock; +wait_queue_head_t queue_wait; +}; +#endif /* _NET_BATMAN_ADV_TYPES_H_ */
Signature · 1 line
1.7.1
PATCH 2/2 batctl: add debug log support
In reply to Marek Lindnerbatctl offers the possibilities to read the debug log file in the debugfs folder of batman-adv (given that the debug log was compiled in).
--- batctl/debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++ batctl/debug.h | 2 ++ batctl/functions.c | 34 ++-------------------------------- batctl/man/batctl.8 | 4 ++-- batctl/sys.c | 44 ++------------------------------------------ batctl/sys.h | 4 +--- 6 files changed, 52 insertions(+), 79 deletions(-)
batctl/debug.c +43 -0
@@ -101,3 +101,46 @@ int handle_debug_table(int argc, char **argv, char *file_path, void table_usage(debugfs_make_path (DEBUG_BATIF_PATH "/" , full_path,sizeof (full_path));return read_file (full_path, file_path, read_opt); } + +static void log_usage (void ) +{ +printf ("Usage: batctl [options] log \n" ); +printf ("options:\n" ); +printf (" \t -h print this help\n" ); +printf (" \t -n don't replace mac addresses with bat-host names\n" ); +} + +int log_print (int argc,char **argv) +{ +int optchar, res, read_opt =USE_BAT_HOSTS |LOG_MODE ; +char full_path[MAX_PATH +1 ]; +char *debugfs_mnt; + +while ((optchar =getopt (argc, argv,"hn" )) !=-1 ) { +switch (optchar) { +case 'h' : +log_usage (); +return EXIT_SUCCESS ; +case 'n' : + read_opt &= ~USE_BAT_HOSTS ; +break ; +default : +log_usage (); +return EXIT_FAILURE ; + } + } + + debugfs_mnt =debugfs_mount (NULL ); +if (!debugfs_mnt) { +printf ("Error - can't mount or find debugfs\n" ); +return EXIT_FAILURE ; + } + +debugfs_make_path (DEBUG_BATIF_PATH "/" , full_path,sizeof (full_path)); + res =read_file (full_path,DEBUG_LOG , read_opt); + +if ((res !=EXIT_SUCCESS ) && (errno ==ENOENT )) +printf ("To read the debug log you need to compile the module with debugging enabled (see the README)\n" ); + +return res; +}
batctl/debug.h +2 -0
@@ -26,9 +26,11 @@#define DEBUG_TRANSTABLE_GLOBAL "transtable_global"#define DEBUG_GATEWAYS "gateways"#define DEBUG_VIS_DATA "vis_data" +#define DEBUG_LOG "log"void originators_usage (void );void trans_local_usage (void );void trans_global_usage (void );void gateways_usage (void );int handle_debug_table (int argc,char **argv,char *file_path,void table_usage (void )); +int log_print (int argc,char **argv);
batctl/functions.c +2 -32
@@ -99,24 +99,6 @@ char *get_name_by_macstr(char *mac_str, int read_opt)return get_name_by_macaddr (mac_addr, read_opt); } -static int check_proc_dir (char *dir) -{ -struct stat st; - -if (stat ("/proc/" , &st) !=0 ) { -printf ("Error - the folder '/proc' was not found on the system\n" ); -printf ("Please make sure that the proc filesystem is properly mounted\n" ); -return EXIT_FAILURE ; - } - -if (stat (dir, &st) ==0 ) -return EXIT_SUCCESS ; - -printf ("Error - the folder '%s' was not found within the proc filesystem\n" , dir); -printf ("Please make sure that the batman-adv kernel module is loaded\n" ); -return EXIT_FAILURE ; -} -static int check_sys_dir (char *dir) {struct stat st;
@@ -148,10 +130,7 @@ int read_file(char *dir, char *fname, int read_opt)if (read_opt &USE_BAT_HOSTS )bat_hosts_init (); -if (strstr (dir,"/proc/" )) { -if (check_proc_dir (dir) !=EXIT_SUCCESS ) - goto out; - }else if (strstr (dir,"/sys/" )) { +if (strstr (dir,"/sys/" )) {if (check_sys_dir (dir) !=EXIT_SUCCESS ) goto out; }
@@ -178,12 +157,6 @@ read:if (read_opt &USE_READ_BUFF )break ; -if (read_opt &LOG_MODE ) { -/* omit log lines which don't start with the correct tag */ -if (strncmp (line_ptr,BATMAN_ADV_TAG ,strlen (BATMAN_ADV_TAG )) !=0 ) -continue ; - } -if (!(read_opt &USE_BAT_HOSTS )) {printf ("%s" , line_ptr);continue ;
@@ -267,10 +240,7 @@ int write_file(char *dir, char *fname, char *arg1, char *arg2)char full_path[500 ];ssize_t write_len; -if (strstr (dir,"/proc/" )) { -if (check_proc_dir (dir) !=EXIT_SUCCESS ) - goto out; - }else if (strstr (dir,"/sys/" )) { +if (strstr (dir,"/sys/" )) {if (check_sys_dir (dir) !=EXIT_SUCCESS ) goto out; }
batctl/man/batctl.8 +2 -2
@@ -65,8 +65,8 @@ If no parameter is given the current originator interval setting is displayed ot .IP "\fBloglevel\fP|\fBll\fP [\fBlevel\fP]" If no parameter is given the current log level settings are displayed otherwise the parameter is used to set the log level. Level 0 disables all verbose logging. Level 1 enables messages related to routing / flooding / broadcasting. Level 2 enables messages related to route or hna added / changed / deleted. Level 3 enables all messages. The messages are sent to the kernel log. Use \fBdmesg\fP(1) to see them. Make sure to have debugging output enabled when compiling the module otherwise the output as well as the loglevel options won't be available. .br -.IP "\fBlog\fP|\fBl\fP [\fBlogfile\fP][\fB\-w\fP][\fB\-n\fP]\fP" -batctl will read the file logfile, or stdin if the logfile parameter is not given, applying filtering so only the B.A.T.M.A.N. Advanced messages are displayed. Once the end of the file has been reached batctl will exit unless the option "\-w" was specified which causes batctl to continue reading the file and print log output whenever new log data has been appended to the file. +.IP "\fBlog\fP|\fBl\fP [\fB\-n\fP]\fP" +batctl will read the batman-adv debug log which has to be compiled into the kernel module. If "\-n" is given batctl will not replace the MAC addresses with bat\-host names in the output. .br .IP "\fBgw_mode|gw\fP [\fBoff\fP|\fBclient\fP|\fBserver\fP] [\fBgw_class\fP]\fP" If no parameter is given the current gateway mode is displayed otherwise the parameter is used to set the gateway mode. The second (optional) argument specifies the gateway class. Its function depends on whether the node is a server or a client. If the node is a server this parameter is used to inform other nodes in the network about this node's internet connection bandwidth. Just enter any number (optionally followed by "kbit" or "mbit") and the batman-adv module will guess your appropriate gateway class. Use "/" to separate the down\(hy and upload rates. You can omit the upload rate and the module will assume an upload of download / 5.
batctl/sys.c +2 -42
59 lines not on this page · raw message
batctl/sys.h +1 -3
@@ -20,9 +20,8 @@*/ -#define SYS_MODULE_PATH "/sys/module/batman_adv/"#define SYS_BATIF_PATH "/sys/class/net/bat0/mesh/" -#define SYS_LOG_LEVEL "parameters/debug" +#define SYS_LOG_LEVEL "log_level"#define SYS_LOG "log"#define SYS_AGGR "aggregated_ogms"#define SYS_BONDING "bonding"
@@ -41,7 +40,6 @@ void bonding_usage(void);void gw_mode_usage (void );void vis_mode_usage (void );void orig_interval_usage (void ); -int log_print (int argc,char **argv);int interface (int argc,char **argv);int handle_loglevel (int argc,char **argv); int handle_sys_setting(int argc, char **argv, char *file_path,
Signature · 1 line
1.7.1
Hi Marek and all,
One question:
Would have the debugging available VIA the "usual" kernel process mean
I could more easily turn on debugging. That is to say: I think I have a problem, I turn on debugging without having to recompile, etc. I can now easily observe what is going wrong and solve my problem more easily?
warm regards to all,
wiz
Quoted 19 lines · Marek Lindner
Hi,
I worked through the received feedback (thanks!) my first set of patches provoked and improved the code. The following changes have been made:
* the log level no longer is a global variable and can be configured for each mesh individually
* the "unused variable" warnings have been eliminated
* now dead batctl code has been removedI also considered making the debug log available via the standard kernel logging facilities but right now I can only see little value in this feature. We can still add it as soon as somebody complains.
Unless there are futher comments I will go ahead and commit the changes.
Regards,
Marek
Quoted 4 lines · On Sunday 27 June 2010 02:47:16 RHS Linux User wrote:
Would have the debugging available VIA the "usual" kernel process mean
I could more easily turn on debugging. That is to say: I think I have a problem, I turn on debugging without having to recompile, etc. I can now easily observe what is going wrong and solve my problem more easily?
No, debugging can be turned on/off at runtime no matter where the logs end up (given you enabled the debugging option at compile time). Both systems behave identical in this aspect.
The question is: Should the routing logs go into the standard linux log or in a seperate file that only contains batman stuff.
Cheers,
Marek
Hi,
IMHO if the logs are more or less small put them into kernel log.
That's where I would first look for them.
If "big" into their own circular log. So I can leave them on and just
look at them when I have a problem to (hopefully) see what led up to the problem.
Consider the case where I get an error fatal/non-fatal once every day
or so. I just happen to be sitting there and want to stop and examine the history file.
Comment: There have been a number of subtle Atheros bugs like this
recently. No one knows what is going wrong and now what do we do? Or do we just grab at straws!!
Wouldn't it be nice to put my multichannel recording oscilloscope
probes on several software points and then just review the tracings after I notice a problem.
Just MHO.
wiz
Quoted 15 lines · Marek Lindner
Quoted 4 lines · On Sunday 27 June 2010 02:47:16 RHS Linux User wrote:
Would have the debugging available VIA the "usual" kernel process mean
I could more easily turn on debugging. That is to say: I think I have a problem, I turn on debugging without having to recompile, etc. I can now easily observe what is going wrong and solve my problem more easily?No, debugging can be turned on/off at runtime no matter where the logs end up (given you enabled the debugging option at compile time). Both systems behave identical in this aspect.
The question is: Should the routing logs go into the standard linux log or in a seperate file that only contains batman stuff.Cheers,
Marek