batman-adv debug logging
Hi,
a couple of months ago a series of patches had been introduced which removed the batman-adv log inside the proc filesystem and redirected the messages to the standard linux logs. This allowed us to be more compliant with the linux rules but also crippled our debugging mechanisms. The following patches re- introduce thedebug logging but inside debugfs which should be ok according to Greg KH.
Feedback is welcome, :-)
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/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 | 31 ++++--- 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 | 11 ++- 12 files changed, 318 insertions(+), 71 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/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 +18 -13
@@ -88,20 +88,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
@@ -160,3 +148,20 @@ int choose_orig(void *data, int32_t size);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 (bat_debug_type(type)) \ + debug_log(bat_priv, fmt, ## arg); \ + } \ + while (0) +#else /* !CONFIG_BATMAN_ADV_DEBUG */ +#define bat_dbg(type, bat_priv, fmt, arg...) do { \ + } \ + while (0) +#endif
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 +8 -3
@@ -20,9 +20,6 @@*/ - - -#ifndef TYPES_H #define TYPES_H
@@ -127,6 +124,7 @@ struct bat_priv {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 +182,11 @@ 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
Signature · 1 line
1.7.1
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
batman-adv/main.h int choose_orig(void *data, int32_t size); · line 153
Quoted 3 lines
batman-adv/main.h +3
-0+ +#ifdef CONFIG_BATMAN_ADV_DEBUG +extern int debug;
What is debug used for now? Does it still have a purpose?
Thanks
Andrew
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 5 lines · On Wednesday 23 June 2010 16:51:54 Andrew Lunn wrote:
batman-adv/main.h int choose_orig(void *data, int32_t size); · line 153
Quoted 3 lines
batman-adv/main.h +3
-0+ +#ifdef CONFIG_BATMAN_ADV_DEBUG +extern int debug;What is debug used for now? Does it still have a purpose?
Oh yes, it does. You have to use it to configure the log level as before.
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 8 lines · Marek Lindner
Quoted 5 lines · On Wednesday 23 June 2010 16:51:54 Andrew Lunn wrote:
batman-adv/main.h int choose_orig(void *data, int32_t size); · line 153
Quoted 3 lines
batman-adv/main.h +3
-0+ +#ifdef CONFIG_BATMAN_ADV_DEBUG +extern int debug;What is debug used for now? Does it still have a purpose?
Oh yes, it does. You have to use it to configure the log level as before.
So you get one global setting, which affects all meshes? Should this maybe pushed into priv? Is there a use case for having different logging levels for different meshes in a node?
Andrew
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 3 lines · On Wednesday 23 June 2010 17:12:33 Andrew Lunn wrote:
So you get one global setting, which affects all meshes? Should this maybe pushed into priv? Is there a use case for having different logging levels for different meshes in a node?
You got a point here. Someone could want to debug one mesh but not the other. I will move it into bat_priv then.
Cheers,
Marek
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
In reply to Marek LindnerHi Marek
batman-adv/bat_debugfs.c line 85
Quoted 10 lines
batman-adv/bat_debugfs.c +10
-0+int debug_log (struct bat_priv *bat_priv,char *fmt, ...) +{ +va_list args; +char tmp_log_buf[256 ]; + +va_start (args, fmt); +vscnprintf (tmp_log_buf,sizeof (tmp_log_buf), fmt, args); +fdebug_log (bat_priv->debug_log,"[%10u] %s" , + (jiffies /HZ ), tmp_log_buf); +va_end (args);
Thinking forward to when we try to get multiple meshes working, or are trying to debug why they don't work together...
There will be a ring buffer per mesh. When debugging problems between meshes it is likely both logs will be combined performing a merge based on the timestamp. However at this point you have lost information about which line belongs to which mesh. Could we maybe include the soft interface name in the output?
Also, do you really want to do jiffies / HZ? You are throwing away useful information. Either keep it as jiffies, or scale the remainder to ms and print it as well?
Andrew
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 5 lines · On Wednesday 23 June 2010 17:09:13 Andrew Lunn wrote:
There will be a ring buffer per mesh. When debugging problems between meshes it is likely both logs will be combined performing a merge based on the timestamp. However at this point you have lost information about which line belongs to which mesh. Could we maybe include the soft interface name in the output?
Actually, this information is (indirectly) present, since each log file resides inside debugfs/batman_adv/$mesh_if/log. It would be a little bit redundant to add this on every line, wouldn't you agree ? If someone merges 2 mesh files it still can be added ?
Quoted 3 lines
Also, do you really want to do jiffies / HZ? You are throwing away useful information. Either keep it as jiffies, or scale the remainder to ms and print it as well?
You are right - we could leave it as jiffies. Might be the best solution.
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 11 lines · Marek Lindner
Quoted 5 lines · On Wednesday 23 June 2010 17:09:13 Andrew Lunn wrote:
There will be a ring buffer per mesh. When debugging problems between meshes it is likely both logs will be combined performing a merge based on the timestamp. However at this point you have lost information about which line belongs to which mesh. Could we maybe include the soft interface name in the output?
Actually, this information is (indirectly) present, since each log file resides inside debugfs/batman_adv/$mesh_if/log. It would be a little bit redundant to add this on every line, wouldn't you agree ? If someone merges 2 mesh files it still can be added ?
It can be done, its just more complex. If it was in the line already, i could probably just do cat /debugfs/batman_adv/bat?/log | sort | less
Alternatively, batctl could add the interface name after the time stamp. But there is then no easy way with pipes to combine the output from two batctls and pass it to sort. So maybe batctl has to do it all?
Quoted 1 line
You are right - we could leave it as jiffies. Might be the best solution.
O.K.
Andrew
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
In reply to Marek LindnerQuoted 13 lines · Marek Lindner
/*
* Visbatman-adv/main.h +7
-0@@ -160,3 +148,20 @@ int choose_orig(void *data, int32_t size);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, ...); +
batman-adv/main.h int choose_orig(void *data, int32_t size); · line 167
Quoted 10 lines
batman-adv/main.h +10
-0+#define bat_dbg(type, bat_priv, fmt, arg...) do { \ + if (bat_debug_type(type)) \ + debug_log(bat_priv, fmt, ## arg); \ + } \ + while (0) +#else /* !CONFIG_BATMAN_ADV_DEBUG */ +#define bat_dbg(type, bat_priv, fmt, arg...) do { \ + } \ + while (0) +#endif
Can you please change that (at least the 'null' function) from a define to an static inline function? Otherwise there are a lot of "unused" warning when compiling without debug support.
static inline void bat_dbg(char type __attribute__((unused)),
struct bat_priv *bat_priv __attribute__((unused)), char *fmt __attribute__((unused)), ...)
{ }
I will send a include guard patch later which is needed to get this working.
To you suggestion to add more information from kernel log to the debug log - it seems to be interesting, but we must ensure that those information are specific to a mesh device. I will sent a patch which modifies all printks later. Maybe we could discuss where it would be a benefit and where it is not needed (~54 printks are for discussion).
Best regards,
Sven
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 8 lines · On Wednesday 23 June 2010 17:17:27 Sven Eckelmann wrote:
Can you please change that (at least the 'null' function) from a define to an static inline function? Otherwise there are a lot of "unused" warning when compiling without debug support.
static inline void bat_dbg(char type __attribute__((unused)),
struct bat_priv *bat_priv __attribute__((unused)), char *fmt __attribute__((unused)), ...){ }
Sure, will do.
Quoted 5 lines
To you suggestion to add more information from kernel log to the debug log
- it seems to be interesting, but we must ensure that those information are specific to a mesh device. I will sent a patch which modifies all printks later. Maybe we could discuss where it would be a benefit and where it is not needed (~54 printks are for discussion).
Yes, sounds good.
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
In reply to Marek LindnerOn Wed, Jun 23, 2010 at 04:20:38PM +0200, Marek Lindner wrote:
Hi Marek
batman-adv/main.h line 97
Quoted 2 lines
batman-adv/main.h +0
-2-if (bat_debug_type (type)) \ - printk(KERN_DEBUG "batman-adv:" fmt, ## arg); \
did you think about keeping this? Maybe use some of the spare bits of debug to indicate what goes into the circular buffer and what goes to the kernel log?
I don't see the two schemes are mutually exclusive. "Normal" kernel hackers will look in the normal kernel logging places and could be a bit surprised when its not there.
Andrew
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 10 lines · On Wednesday 23 June 2010 17:23:59 Andrew Lunn wrote:
batman-adv/main.h line 97
Quoted 2 lines
batman-adv/main.h +0
-2-if (bat_debug_type (type)) \ - printk(KERN_DEBUG "batman-adv:" fmt, ## arg); \did you think about keeping this? Maybe use some of the spare bits of debug to indicate what goes into the circular buffer and what goes to the kernel log?
I don't see the two schemes are mutually exclusive. "Normal" kernel hackers will look in the normal kernel logging places and could be a bit surprised when its not there.
Sven is in the progress of revising the "ordinary" printks to make them more "kernel-ish".
Or do you think that normal kernel hackers would be interested in seeing the routing debug messages in the standard kernel log as well ?
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: add routing debug log accessible via debugfs
Quoted 4 lines
Sven is in the progress of revising the "ordinary" printks to make them more "kernel-ish".
Or do you think that normal kernel hackers would be interested in seeing the routing debug messages in the standard kernel log as well ?
The kernel log is the normal place to expect debug output. I think most normal kernel people will be surprised to find it is not there, but somewhere else. It adds very little overhead to keep supporting the kernel log for normal kernel hackers, so i would keep it. Maybe have debug values 1 and 2 send debug messages to the kernel, and 256 and 512 to the circular log. Then everybody is happy.
Andrew
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 | 40 ---------------------------------------- batctl/sys.h | 1 - 6 files changed, 49 insertions(+), 75 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 +0 -40
@@ -169,46 +169,6 @@ err:return EXIT_FAILURE ; } -static void log_usage (void ) -{ -printf ("Usage: batctl [options] log [logfile]\n" ); -printf ("Note: if no logfile was specified stdin is read" ); -printf ("options:\n" ); -printf (" \t -h print this help\n" ); -printf (" \t -n don't replace mac addresses with bat-host names\n" ); -printf (" \t -w watch mode - read the log file continuously\n" ); -} - -int log_print (int argc,char **argv) -{ -int optchar, read_opt =USE_BAT_HOSTS |LOG_MODE ; -int found_args =1 ; - -while ((optchar =getopt (argc, argv,"hnw" )) !=-1 ) { -switch (optchar) { -case 'h' : -log_usage (); -return EXIT_SUCCESS ; -case 'n' : - read_opt &= ~USE_BAT_HOSTS ; - found_args +=1 ; -break ; -case 'w' : - read_opt |=CONT_READ ; - found_args +=1 ; -break ; -default : -log_usage (); -return EXIT_FAILURE ; - } - } - -if (argc > found_args) -return read_file ("" , argv[found_args], read_opt); -else -return read_file ("" ,"/proc/self/fd/0" , read_opt); -} -static void log_level_usage (void ) {printf ("Usage: batctl [options] loglevel [level]\n" );
batctl/sys.h +0 -1
@@ -41,7 +41,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