staging:batman-adv
cover staging:batman-adv
Hi Greg.
Here are a collection of BATMAM Advanced patches for Linux Next.
Thanks
Andrew
Andrew Lunn (2):
staging:batman-adv: Update TODO file to reflect current state. staging:batman-adv: updating README
Dan Carpenter (1):
staging:batman-adv: cleanup: change test for end of array
Linus L��ssing (2):
batman-adv: only modify hna-table on active module staging:batman-adv: Fix aggregation direct-link bug
Marek Lindner (9):
staging:batman-adv: fix aggregation timing bug staging:batman-adv: fix whitespace style issues staging:batman-adv: convert multiple /proc files to use sysfs staging:batman-adv: convert more files from /proc to /sys staging:batman-adv: move originator interval setting from /proc to
/sys
staging:batman-adv: remove redundant pointer to originator interface staging:batman-adv: move /proc interface handling to /sys staging:batman-adv: Fix whitespace problems criticized by
checkpatch.pl
staging:batman-adv: Reduce max characters on a line to 80
Simon Wunderlich (9):
staging:batman-adv: Update copyright years staging:batman-adv: remove the beta from main.h for release staging:batman-adv: Remove dead max addr and obsolete VIS_FORMAT
strings
staging:batman-adv: Add 0.2.1 changes to the CHANGELOG staging:batman-adv: Update README about vis raw output staging:batman-adv: Changing version to 0.2.2-beta staging:batman-adv: Reorganize sequence number handling staging:batman-adv: Limit queue lengths for batman and broadcast
packets
staging:batman-adv: kfree_skb() in interface_tx() in error case
Sven Eckelmann (3):
staging: batman-adv: Clone shared bat packets before modifying them staging:batman-adv: fix whitespace style issues staging:batman-adv: Update pointer to ethhdr after skb_copy
drivers/staging/batman-adv/CHANGELOG | 14 + drivers/staging/batman-adv/Makefile | 4 +- drivers/staging/batman-adv/README | 255 ++++++--- drivers/staging/batman-adv/TODO | 23 +- drivers/staging/batman-adv/aggregation.c | 45 ++- drivers/staging/batman-adv/aggregation.h | 7 +- drivers/staging/batman-adv/bat_sysfs.c | 484 +++++++++++++++++ drivers/staging/batman-adv/bat_sysfs.h | 29 + drivers/staging/batman-adv/bitarray.c | 76 ++- drivers/staging/batman-adv/bitarray.h | 2 +- drivers/staging/batman-adv/device.c | 37 +- drivers/staging/batman-adv/device.h | 2 +- drivers/staging/batman-adv/hard-interface.c | 531 ++++++++++--------- drivers/staging/batman-adv/hard-interface.h | 20 +- drivers/staging/batman-adv/hash.c | 2 +- drivers/staging/batman-adv/hash.h | 2 +- drivers/staging/batman-adv/main.c | 60 ++- drivers/staging/batman-adv/main.h | 23 +- drivers/staging/batman-adv/originator.c | 295 ++++++++++- drivers/staging/batman-adv/originator.h | 7 +- drivers/staging/batman-adv/packet.h | 2 +- drivers/staging/batman-adv/proc.c | 689 ------------------------ drivers/staging/batman-adv/proc.h | 40 -- drivers/staging/batman-adv/ring_buffer.c | 2 +- drivers/staging/batman-adv/ring_buffer.h | 2 +- drivers/staging/batman-adv/routing.c | 221 ++++++--- drivers/staging/batman-adv/routing.h | 2 +- drivers/staging/batman-adv/send.c | 146 ++++-- drivers/staging/batman-adv/send.h | 6 +- drivers/staging/batman-adv/soft-interface.c | 30 +- drivers/staging/batman-adv/soft-interface.h | 2 +- drivers/staging/batman-adv/translation-table.c | 92 +++- drivers/staging/batman-adv/translation-table.h | 8 +- drivers/staging/batman-adv/types.h | 54 ++- drivers/staging/batman-adv/vis.c | 140 ++++- drivers/staging/batman-adv/vis.h | 21 +- 36 files changed, 1966 insertions(+), 1409 deletions(-) create mode 100644 drivers/staging/batman-adv/bat_sysfs.c create mode 100644 drivers/staging/batman-adv/bat_sysfs.h delete mode 100644 drivers/staging/batman-adv/proc.c delete mode 100644 drivers/staging/batman-adv/proc.h
PATCH 1/26 staging:batman-adv: only modify hna-table on active module
From: Linus Lüssing <[email protected]>
If we haven't set the module to MODULE_ACTIVE state before (in general, no interface has yet been added to batman-adv) then the hna table is not initialised yet. If the kernel changes the mac address of the bat0 interface at this moment then an hna_local_add() called by interface_set_mac_addr() then resulted in a null pointer derefernce. With this patch we are now explicitly checking before if the state is MODULE_ACTIVE right now so that we can assume having an initialised hna table.
--- drivers/staging/batman-adv/soft-interface.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/staging/batman-adv/soft-interface.c +6 -2
@@ -152,9 +152,13 @@ int interface_set_mac_addr(struct net_device *dev, void *p)if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; -hna_local_remove (dev->dev_addr,"mac address changed" ); +/* only modify hna-table if it has been initialised before */ +if (atomic_read (&module_state) ==MODULE_ACTIVE ) { +hna_local_remove (dev->dev_addr,"mac address changed" ); +hna_local_add (addr->sa_data); + } +memcpy (dev->dev_addr, addr->sa_data,ETH_ALEN ); -hna_local_add (dev->dev_addr);return 0 ; }
Signature · 1 line
1.7.1
PATCH 2/26 staging:batman-adv: Clone shared bat packets before modifying them
In reply to Andrew LunnFrom: Sven Eckelmann <[email protected]>
"tcpdump" and "batctl td" will receive packets with a wrong sequence number on systems with a different endianess than network byte order. This happens due to the reordering of bytes in the function which handles aggregated bat packets. The function which receives the bat packets must ensure that these buffers aren't shared with anything else before that function tries to write into it. Otherwise it has to copy the buffers so it is save again to change them.
--- drivers/staging/batman-adv/routing.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)
drivers/staging/batman-adv/routing.c +12 -4
@@ -549,6 +549,7 @@ int recv_bat_packet(struct sk_buff *skb, {struct ethhdr *ethhdr;unsigned long flags; +struct sk_buff *skb_old;/* drop packet if it has not necessary minimum size */ if (skb_headlen (skb) <sizeof (struct batman_packet ))
@@ -564,12 +565,19 @@ int recv_bat_packet(struct sk_buff *skb,if (is_bcast (ethhdr->h_source))return NET_RX_DROP ; -spin_lock_irqsave (&orig_hash_lock, flags);/* TODO: we use headlen instead of "length", because * only this data is paged in. */ -/* TODO: is another skb_copy needed here? there will be -* written on the data, but nobody (?) should further use -* this data */ + +/* create a copy of the skb, if needed, to modify it. */ +if (!skb_clone_writable (skb,skb_headlen (skb))) { + skb_old = skb; + skb =skb_copy (skb,GFP_ATOMIC ); +if (!skb) +return NET_RX_DROP ; +kfree_skb (skb_old); + } + +spin_lock_irqsave (&orig_hash_lock, flags); receive_aggr_bat_packet(ethhdr, skb->data, skb_headlen(skb),
Signature · 1 line
1.7.1
PATCH 3/26 staging:batman-adv: fix aggregation timing bug
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
batman-adv aggregates routing packets to reduce the number of packets in the air. Every outgoing packet is compared with other packets in the buffer to determine whether it can be aggregated or not. Packets sent at a lower interval can be held back longer to maximize the aggregation. Due to insufficient checking batman-adv held back all packets for a certain time depending on its own lowest interval rate which slowed down all other nodes.
--- drivers/staging/batman-adv/aggregation.c | 12 ++++++++++++ drivers/staging/batman-adv/send.c | 10 +--------- 2 files changed, 13 insertions(+), 9 deletions(-)
drivers/staging/batman-adv/aggregation.c +12 -0
@@ -52,6 +52,8 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,*/ if (time_before (send_time, forw_packet->send_time) && +time_after_eq (send_time +msecs_to_jiffies (MAX_AGGREGATION_MS ), + forw_packet->send_time) && (aggregated_bytes <=MAX_AGGREGATION_BYTES )) {/**
@@ -195,6 +197,16 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,if (forw_packet_aggr ==NULL ) {/* the following section can run without the lock */ spin_unlock_irqrestore (&forw_bat_list_lock, flags); + +/** +* if we could not aggregate this packet with one of the others +* we hold it back for a while, so that it might be aggregated +* later on +*/ +if ((!own_packet) && + (atomic_read (&bat_priv->aggregation_enabled))) + send_time +=msecs_to_jiffies (MAX_AGGREGATION_MS ); +new_aggregated_packet (packet_buff, packet_len, send_time, direct_link, if_incoming, own_packet);
drivers/staging/batman-adv/send.c +1 -9
@@ -46,15 +46,7 @@ static unsigned long own_send_time(void)/* when do we schedule a forwarded packet to be sent */ static unsigned long forward_send_time (void ) { -unsigned long send_time = jiffies;/* Starting now plus... */ - -if (atomic_read (&aggregation_enabled)) - send_time += (((MAX_AGGREGATION_MS - (JITTER /2 ) + - (random32 () %JITTER )) *HZ ) /1000 ); -else - send_time += (((random32 () % (JITTER /2 )) *HZ ) /1000 ); - -return send_time; +return jiffies + (((random32 () % (JITTER /2 )) *HZ ) /1000 ); }/* send out an already prepared packet to the given address via the
Signature · 1 line
1.7.1
PATCH 4/26 staging:batman-adv: Fix aggregation direct-link bug
In reply to Andrew LunnFrom: Linus Lüssing <[email protected]>
So far, neighbour's secondary interface OGMs can involuntarily piggyback on primary interface OGMs that arrived on the same secondary interface before. Secondary interface OGMs should NEVER leave their direct neighbour broadcast domain! This patch ensures that secondary interface OGMs can only be aggregated to other secondary interface OGMs.
--- drivers/staging/batman-adv/aggregation.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
drivers/staging/batman-adv/aggregation.c +9 -3
@@ -81,9 +81,15 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,* interface only - we still can aggregate */ if ((directlink) && (new_batman_packet->ttl ==1 ) && - (forw_packet->if_incoming == if_incoming)) + (forw_packet->if_incoming == if_incoming) && + +/* packets from direct neighbors or +* own secondary interface packets +* (= secondary interface packets in general) */ + (batman_packet->flags &DIRECTLINK || + (forw_packet->own && + forw_packet->if_incoming->if_num !=0 )))return true; - }return false;
@@ -204,7 +210,7 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,* later on */ if ((!own_packet) && - (atomic_read (&bat_priv->aggregation_enabled))) + (atomic_read (&aggregation_enabled))) send_time +=msecs_to_jiffies (MAX_AGGREGATION_MS ); new_aggregated_packet(packet_buff, packet_len,
Signature · 1 line
1.7.1
PATCH 5/26 staging:batman-adv: Update copyright years
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
--- drivers/staging/batman-adv/Makefile | 2 +- drivers/staging/batman-adv/aggregation.c | 2 +- drivers/staging/batman-adv/aggregation.h | 2 +- drivers/staging/batman-adv/bitarray.c | 2 +- drivers/staging/batman-adv/bitarray.h | 2 +- drivers/staging/batman-adv/device.c | 2 +- drivers/staging/batman-adv/device.h | 2 +- drivers/staging/batman-adv/hard-interface.c | 2 +- drivers/staging/batman-adv/hard-interface.h | 2 +- drivers/staging/batman-adv/hash.c | 2 +- drivers/staging/batman-adv/hash.h | 2 +- drivers/staging/batman-adv/main.c | 2 +- drivers/staging/batman-adv/main.h | 2 +- drivers/staging/batman-adv/originator.c | 2 +- drivers/staging/batman-adv/originator.h | 2 +- drivers/staging/batman-adv/packet.h | 2 +- drivers/staging/batman-adv/proc.c | 2 +- drivers/staging/batman-adv/proc.h | 2 +- drivers/staging/batman-adv/ring_buffer.c | 2 +- drivers/staging/batman-adv/ring_buffer.h | 2 +- drivers/staging/batman-adv/routing.c | 2 +- drivers/staging/batman-adv/routing.h | 2 +- drivers/staging/batman-adv/send.c | 2 +- drivers/staging/batman-adv/send.h | 2 +- drivers/staging/batman-adv/soft-interface.c | 2 +- drivers/staging/batman-adv/soft-interface.h | 2 +- drivers/staging/batman-adv/translation-table.c | 2 +- drivers/staging/batman-adv/translation-table.h | 2 +- drivers/staging/batman-adv/types.h | 2 +- drivers/staging/batman-adv/vis.c | 2 +- drivers/staging/batman-adv/vis.h | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-)
drivers/staging/batman-adv/Makefile +1 -1
@@ -1,5 +1,5 @@ # -# Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +# Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: # # Marek Lindner, Simon Wunderlich #
drivers/staging/batman-adv/aggregation.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/aggregation.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/bitarray.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner *
drivers/staging/batman-adv/bitarray.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner *
drivers/staging/batman-adv/device.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner *
drivers/staging/batman-adv/device.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner *
drivers/staging/batman-adv/hard-interface.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/hard-interface.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/hash.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner *
drivers/staging/batman-adv/hash.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2006-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2006-2010 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner *
drivers/staging/batman-adv/main.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/main.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/originator.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/originator.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/packet.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/proc.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/proc.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/ring_buffer.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner *
drivers/staging/batman-adv/ring_buffer.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner *
drivers/staging/batman-adv/routing.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/routing.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/send.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/send.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/soft-interface.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/soft-interface.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner *
drivers/staging/batman-adv/translation-table.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/translation-table.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/types.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich *
drivers/staging/batman-adv/vis.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2008-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2008-2010 B.A.T.M.A.N. contributors: * * Simon Wunderlich *
drivers/staging/batman-adv/vis.h +1 -1
@@ -1,5 +1,5 @@/* -* Copyright (C) 2008-2009 B.A.T.M.A.N. contributors: +* Copyright (C) 2008-2010 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner *
Signature · 1 line
1.7.1
PATCH 6/26 staging:batman-adv: remove the beta from main.h for release
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
--- drivers/staging/batman-adv/main.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/batman-adv/main.h +1 -1
@@ -26,7 +26,7 @@#define DRIVER_DESC "B.A.T.M.A.N. advanced"#define DRIVER_DEVICE "batman-adv" -#define SOURCE_VERSION "0.2.1-beta" +#define SOURCE_VERSION "0.2.1"/* B.A.T.M.A.N. parameters */
Signature · 1 line
1.7.1
PATCH 7/26 staging:batman-adv: Remove dead max addr and obsolete VIS_FORMAT strings
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
Max address is not being used anywhere and just misleading, therefore removing it. VIS_FORMAT string is now obsolete, so also remove it.
--- drivers/staging/batman-adv/main.h | 2 -- drivers/staging/batman-adv/vis.h | 2 -- 2 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/batman-adv/main.h +0 -2
@@ -34,8 +34,6 @@#define TQ_MAX_VALUE 255#define JITTER 20#define TTL 50/* Time To Live of broadcast messages */ -#define MAX_ADDR 16/* number of interfaces which can be added to -* batman. */ #define PURGE_TIMEOUT 200000/* purge originators after time in ms if no * valid packet comes in -> TODO: check
drivers/staging/batman-adv/vis.h +0 -2
@@ -20,8 +20,6 @@*/ #define VIS_TIMEOUT 200000 -#define VIS_FORMAT_DD_NAME "dot_draw" -#define VIS_FORMAT_JSON_NAME "json"struct vis_info {unsigned long first_seen;
Signature · 1 line
1.7.1
PATCH 8/26 staging:batman-adv: Add 0.2.1 changes to the CHANGELOG
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
--- drivers/staging/batman-adv/CHANGELOG | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/staging/batman-adv/CHANGELOG +14 -0
@@ -1,3 +1,17 @@ +batman-adv 0.2.1: + +* support latest kernels (2.6.20 - 2.6.33) +* receive packets directly using skbs, remove old sockets and threads +* fix various regressions in the vis server +* don't disable interrupts while sending +* replace internal logging mechanism with standard kernel logging +* move vis formats into userland, one general format remains in the kernel +* allow MAC address to be set, correctly initialize them +* code refactoring and cleaning for coding style +* many bugs (null pointers, locking, hash iterators) squashed + + -- Sun, 21 Mar 2010 20:46:47 +0100 + batman-adv 0.2: * support latest kernels (2.6.20 - 2.6.31)
Signature · 1 line
1.7.1
PATCH 9/26 staging:batman-adv: Update README about vis raw output
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
We are now having a newer, more neutral vis output so that we won't have to change the kernelmodule for adding support of new vis output formats. This patch adds an explanation about this in the README file of batman-adv and removes the description about the dot/json format (they will be added to the README of batctl).
--- drivers/staging/batman-adv/README | 36 ++++++++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 8 deletions(-)
drivers/staging/batman-adv/README +28 -8
@@ -1,4 +1,4 @@ -[state: 06-01-2010] +[state: 22-03-2010] BATMAN-ADV ----------
@@ -44,10 +44,11 @@ regular interface: # ping 192.168.0.2 ... +--- If you want topology visualization, your meshnode must be configured as VIS-server: -# echo "server" > /proc/net/batman-adv/vis +# echo "server" > /proc/net/batman-adv/vis_server Each node is either configured as "server" or as "client" (default: "client"). Clients send their topology data to the server next to them,
@@ -58,12 +59,31 @@ more vis servers sharing the same (or at least very similar) data. When configured as server, you can get a topology snapshot of your mesh: -# cat /proc/net/batman-adv/vis - -The output is in a generic raw format. Use the batctl tool (See below) -to convert this to other formats more suitable for graphing, eg -graphviz dot, or JSON data-interchange format. - +# cat /proc/net/batman-adv/vis_data + +This raw output is intended to be easily parsable and convertable with +other tools. Have a look at the batctl README if you want a vis output +in dot or json format for instance and how those outputs could then be +visualised in an image. + +The raw format consists of comma seperated values per entry where each +entry is giving information about a certain source interface. Each entry +can/has to have the following values: +-> "mac" -> mac address of an originator's source interface + (each line begins with it) +-> "TQ mac value" -> src mac's link quality towards mac address of a neighbor + originator's interface which is being used for routing +-> "HNA mac" -> HNA announced by source mac +-> "PRIMARY" -> this is a primary interface +-> "SEC mac" -> secondary mac address of source (requires preceeding +-> PRIMARY) + +The TQ value has a range from 4 to 255 with 255 being the best. +The HNA entries are showing which hosts are connected to the mesh via bat0 +or being bridged into the mesh network. +The PRIMARY/SEC values are only applied on primary interfaces + +--- In very mobile scenarios, you might want to adjust the originator interval to a lower value. This will make the mesh more responsive to topology changes, but will also increase the overhead. Please make sure
Signature · 1 line
1.7.1
PATCH 10/26 staging:batman-adv: Changing version to 0.2.2-beta
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
--- drivers/staging/batman-adv/main.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/batman-adv/main.h +1 -1
@@ -26,7 +26,7 @@#define DRIVER_DESC "B.A.T.M.A.N. advanced"#define DRIVER_DEVICE "batman-adv" -#define SOURCE_VERSION "0.2.1" +#define SOURCE_VERSION "0.2.2-beta"/* B.A.T.M.A.N. parameters */
Signature · 1 line
1.7.1
PATCH 11/26 staging:batman-adv: cleanup: change test for end of array
In reply to Andrew LunnFrom: Dan Carpenter <[email protected]>
The code here is testing to see if "i" is passed the end of the array. The original code works probably, but it's not the cleanest way.
Andrew Lunn suggested that I also remove all the hard coded references to 256 so I have done that as well.
--- drivers/staging/batman-adv/device.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-)
drivers/staging/batman-adv/device.c +4 -7
@@ -44,10 +44,7 @@ static struct device_client *device_client_hash[256];void bat_device_init (void ) { -int i; - -for (i =0 ; i <256 ; i++) - device_client_hash[i] =NULL ; +memset (device_client_hash,0 ,sizeof (device_client_hash)); }int bat_device_setup (void )
@@ -103,15 +100,15 @@ int bat_device_open(struct inode *inode, struct file *file)if (!device_client)return -ENOMEM ; -for (i =0 ; i <256 ; i++) { +for (i =0 ; i <ARRAY_SIZE (device_client_hash); i++) {if (!device_client_hash[i]) { device_client_hash[i] = device_client;break ; } } -if (device_client_hash[i] != device_client) { -printk (KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached \n" ); +if (i ==ARRAY_SIZE (device_client_hash)) { +printk (KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n" );kfree (device_client);return -EXFULL ; }
Signature · 1 line
1.7.1
PATCH 12/26 staging:batman-adv: fix whitespace style issues
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
This patch fixes the 31 unnecessary whitespaces before a quoted newline that the batman-adv files had.
Signed-off-bt: Andrew Lunn <[email protected]>
--- drivers/staging/batman-adv/device.c | 2 +- drivers/staging/batman-adv/main.c | 2 +- drivers/staging/batman-adv/originator.c | 4 ++-- drivers/staging/batman-adv/routing.c | 18 +++++++++--------- drivers/staging/batman-adv/send.c | 4 ++-- drivers/staging/batman-adv/translation-table.c | 14 +++++++------- 6 files changed, 22 insertions(+), 22 deletions(-)
drivers/staging/batman-adv/device.c +1 -1
@@ -65,7 +65,7 @@ int bat_device_setup(void) batman_class =class_create (THIS_MODULE ,"batman-adv" );if (IS_ERR (batman_class)) { -printk (KERN_ERR "batman-adv:Could not register class 'batman-adv' \n" ); +printk (KERN_ERR "batman-adv:Could not register class 'batman-adv'\n" );return 0 ; }
drivers/staging/batman-adv/main.c +1 -1
@@ -119,7 +119,7 @@ int init_module(void)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" , +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 );return 0 ;
drivers/staging/batman-adv/originator.c +2 -2
@@ -126,7 +126,7 @@ 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 ,"Creating new originator: %pM\n" , addr); orig_node =kzalloc (sizeof (struct orig_node ),GFP_ATOMIC );if (!orig_node)
@@ -158,7 +158,7 @@ struct orig_node *get_orig_node(uint8_t *addr)if (swaphash ==NULL )printk (KERN_ERR -"batman-adv:Couldn't resize orig hash table \n" ); +"batman-adv:Couldn't resize orig hash table\n" );else orig_hash = swaphash; }
drivers/staging/batman-adv/routing.c +9 -9
@@ -212,7 +212,7 @@ static int isBidirectionalNeigh(struct orig_node *orig_node, orig_neigh_node->tq_asym_penalty) / (TQ_MAX_VALUE * TQ_MAX_VALUE)); -bat_dbg (DBG_BATMAN ,"bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i \n" , +bat_dbg (DBG_BATMAN ,"bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n" , orig_node->orig, orig_neigh_node->orig, total_count, neigh_node->real_packet_count, orig_neigh_node->tq_own, orig_neigh_node->tq_asym_penalty, batman_packet->tq);
@@ -234,7 +234,7 @@ static void update_orig(struct orig_node *orig_node, struct ethhdr *ethhdr,struct neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ;int tmp_hna_buff_len; -bat_dbg (DBG_BATMAN ,"update_originator(): Searching and updating originator entry of received packet \n" ); +bat_dbg (DBG_BATMAN ,"update_originator(): Searching and updating originator entry of received packet\n" );list_for_each_entry (tmp_neigh_node, &orig_node->neigh_list, list) { if (compare_orig(tmp_neigh_node->addr, ethhdr->h_source) &&
@@ -341,7 +341,7 @@ static char count_real_packets(struct ethhdr *ethhdr, }if (!is_duplicate) { -bat_dbg (DBG_BATMAN ,"updating last_seqno: old %d, new %d \n" , +bat_dbg (DBG_BATMAN ,"updating last_seqno: old %d, new %d\n" , orig_node->last_real_seqno, batman_packet->seqno); orig_node->last_real_seqno = batman_packet->seqno; }
@@ -385,7 +385,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, is_single_hop_neigh = (compare_orig (ethhdr->h_source, batman_packet->orig) ?1 :0 ); - bat_dbg(DBG_BATMAN, "Received BATMAN packet via NB: %pM, IF: %s [%s] (from OG: %pM, via prev OG: %pM, seqno %d, tq %d, TTL %d, V %d, IDF %d) \n", + bat_dbg(DBG_BATMAN, "Received BATMAN packet via NB: %pM, IF: %s [%s] (from OG: %pM, via prev OG: %pM, seqno %d, tq %d, TTL %d, V %d, IDF %d)\n", ethhdr->h_source, if_incoming->dev, if_incoming->addr_str, batman_packet->orig, batman_packet->prev_sender, batman_packet->seqno, batman_packet->tq, batman_packet->ttl,
@@ -426,7 +426,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, }if (is_broadcast) { -bat_dbg (DBG_BATMAN ,"Drop packet: ignoring all packets with broadcast source addr (sender: %pM) \n" , ethhdr->h_source); +bat_dbg (DBG_BATMAN ,"Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n" , ethhdr->h_source);return ; }
@@ -454,19 +454,19 @@ void receive_bat_packet(struct ethhdr *ethhdr,bit_packet_count (word); } -bat_dbg (DBG_BATMAN ,"Drop packet: originator packet from myself (via neighbor) \n" ); +bat_dbg (DBG_BATMAN ,"Drop packet: originator packet from myself (via neighbor)\n" );return ; }if (batman_packet->tq ==0 ) {count_real_packets (ethhdr, batman_packet, if_incoming); -bat_dbg (DBG_BATMAN ,"Drop packet: originator packet with tq equal 0 \n" ); +bat_dbg (DBG_BATMAN ,"Drop packet: originator packet with tq equal 0\n" );return ; }if (is_my_oldorig) { -bat_dbg (DBG_BATMAN ,"Drop packet: ignoring all rebroadcast echos (sender: %pM) \n" , ethhdr->h_source); +bat_dbg (DBG_BATMAN ,"Drop packet: ignoring all rebroadcast echos (sender: %pM)\n" , ethhdr->h_source);return ; }
@@ -484,7 +484,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, !(compare_orig(batman_packet->orig, batman_packet->prev_sender)) && (compare_orig(orig_node->router->addr, orig_node->router->orig_node->router->addr))) { -bat_dbg (DBG_BATMAN ,"Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM) \n" , ethhdr->h_source); +bat_dbg (DBG_BATMAN ,"Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n" , ethhdr->h_source);return ; }
drivers/staging/batman-adv/send.c +2 -2
@@ -290,7 +290,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 ,"ttl exceeded\n" );return ; }
@@ -318,7 +318,7 @@ 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, tq_forw: %i, ttl_orig: %i, ttl_forw: %i \n" , +bat_dbg (DBG_BATMAN ,"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);
drivers/staging/batman-adv/translation-table.c +7 -7
@@ -77,11 +77,11 @@ 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 ,"Can't add new local hna entry (%pM): number of local hna entries exceeds packet size \n" , addr); +bat_dbg (DBG_ROUTES ,"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" , +bat_dbg (DBG_ROUTES ,"Creating new local hna entry: %pM\n" , addr); hna_local_entry =kmalloc (sizeof (struct hna_local_entry ),GFP_ATOMIC );
@@ -108,7 +108,7 @@ void hna_local_add(uint8_t *addr) hna_local_hash->size * 2);if (swaphash ==NULL ) -printk (KERN_ERR "batman-adv:Couldn't resize local hna hash table \n" ); +printk (KERN_ERR "batman-adv:Couldn't resize local hna hash table\n" );else hna_local_hash = swaphash; }
@@ -197,7 +197,7 @@ 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" , +bat_dbg (DBG_ROUTES ,"Deleting local hna entry (%pM): %s\n" , hna_local_entry->addr, message);hash_remove (hna_local_hash, hna_local_entry->addr);
@@ -340,7 +340,7 @@ void hna_global_add_orig(struct orig_node *orig_node, hna_global_hash->size * 2);if (swaphash ==NULL ) -printk (KERN_ERR "batman-adv:Couldn't resize global hna hash table \n" ); +printk (KERN_ERR "batman-adv:Couldn't resize global hna hash table\n" );else hna_global_hash = swaphash; }
@@ -365,7 +365,7 @@ int hna_global_fill_buffer_text(unsigned char *buff, int buff_len) bytes_written += snprintf(buff + bytes_written, (2 * ETH_STR_LEN) + 10, - " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x \n", + " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x\n", hna_global_entry->addr[0], hna_global_entry->addr[1], hna_global_entry->addr[2],
@@ -388,7 +388,7 @@ int hna_global_fill_buffer_text(unsigned char *buff, int buff_len)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" , +bat_dbg (DBG_ROUTES ,"Deleting global hna entry %pM (via %pM): %s\n" , hna_global_entry->addr, hna_global_entry->orig_node->orig, message);
Signature · 1 line
1.7.1
PATCH 13/26 staging:batman-adv: convert multiple /proc files to use sysfs
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
This is the first patch in a series of patches which aim to convert all batman-adv /proc files to sysfs. To keep the changes in a digestable size it has been split up into smaller chunks. During the transition period batman-adv will use /proc as well as sysfs.
As a first step the following files have been converted:aggregate_ogm, originators, transtable_global, transtable_local
--- drivers/staging/batman-adv/Makefile | 2 +- drivers/staging/batman-adv/aggregation.c | 7 +- drivers/staging/batman-adv/aggregation.h | 3 +- drivers/staging/batman-adv/bat_sysfs.c | 272 +++++++++++++++++++++++ drivers/staging/batman-adv/bat_sysfs.h | 26 +++ drivers/staging/batman-adv/main.c | 11 +- drivers/staging/batman-adv/main.h | 1 - drivers/staging/batman-adv/originator.c | 73 ++++++ drivers/staging/batman-adv/originator.h | 2 +- drivers/staging/batman-adv/proc.c | 279 +----------------------- drivers/staging/batman-adv/proc.h | 4 - drivers/staging/batman-adv/send.c | 15 +- drivers/staging/batman-adv/translation-table.c | 42 +++- drivers/staging/batman-adv/translation-table.h | 6 +- drivers/staging/batman-adv/types.h | 2 + 15 files changed, 439 insertions(+), 306 deletions(-) create mode 100644 drivers/staging/batman-adv/bat_sysfs.c create mode 100644 drivers/staging/batman-adv/bat_sysfs.h
drivers/staging/batman-adv/Makefile +1 -1
@@ -19,4 +19,4 @@ # obj-m += batman-adv.o -batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o +batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o bat_sysfs.o
drivers/staging/batman-adv/aggregation.c +4 -3
@@ -167,7 +167,8 @@ static void aggregate(struct forw_packet *forw_packet_aggr,void add_bat_packet_to_list (unsigned char *packet_buff,int packet_len,struct batman_if *if_incoming,char own_packet, -unsigned long send_time) +unsigned long send_time, +struct bat_priv *bat_priv) {/** * _aggr -> pointer to the packet we want to aggregate with
@@ -183,7 +184,7 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,/* find position for the packet in the forward queue */ spin_lock_irqsave (&forw_bat_list_lock, flags);/* own packets are not to be aggregated */ -if ((atomic_read (&aggregation_enabled)) && (!own_packet)) { +if ((atomic_read (&bat_priv->aggregation_enabled)) && (!own_packet)) {hlist_for_each_entry (forw_packet_pos, tmp_node, &forw_bat_list, list) { if (can_aggregate_with(batman_packet,
@@ -210,7 +211,7 @@ void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,* later on */ if ((!own_packet) && - (atomic_read (&aggregation_enabled))) + (atomic_read (&bat_priv->aggregation_enabled))) send_time +=msecs_to_jiffies (MAX_AGGREGATION_MS ); new_aggregated_packet(packet_buff, packet_len,
drivers/staging/batman-adv/aggregation.h +2 -1
@@ -32,6 +32,7 @@ static inline int aggregated_packet(int buff_pos, int packet_len, int num_hna)void add_bat_packet_to_list (unsigned char *packet_buff,int packet_len,struct batman_if *if_outgoing,char own_packet, -unsigned long send_time); +unsigned long send_time, +struct bat_priv *bat_priv);void receive_aggr_bat_packet (struct ethhdr *ethhdr,unsigned char *packet_buff,int packet_len,struct batman_if *if_incoming);
drivers/staging/batman-adv/bat_sysfs.c new file +272 -0
272 lines not on this page · raw message
drivers/staging/batman-adv/bat_sysfs.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (C) 2010 B.A.T.M.A.N. contributors: +* +* Marek Lindner +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +* +*/ + + +#define SYSFS_IF_MESH_SUBDIR "mesh" + +int sysfs_add_meshif (struct net_device *dev); +void sysfs_del_meshif (struct net_device *dev);
drivers/staging/batman-adv/main.c +9 -2
@@ -21,6 +21,7 @@#include "main.h" #include "proc.h" +#include "bat_sysfs.h" #include "routing.h" #include "send.h" #include "originator.h"
@@ -44,7 +45,6 @@ DEFINE_SPINLOCK(forw_bcast_list_lock);atomic_t originator_interval;atomic_t vis_interval;atomic_t vis_mode; -atomic_t aggregation_enabled;int16_t num_hna;int16_t num_ifs;
@@ -85,7 +85,6 @@ int init_module(void)atomic_set (&vis_interval,1000 );/* TODO: raise this later, this is only * for debugging now. */ atomic_set (&vis_mode,VIS_TYPE_CLIENT_UPDATE ); -atomic_set (&aggregation_enabled,1 );/* the name should not be longer than 10 chars - see * http://lwn.net/Articles/23634/ */
@@ -116,6 +115,11 @@ int init_module(void) goto free_soft_device; } + retval =sysfs_add_meshif (soft_device); + +if (retval <0 ) + goto unreg_soft_device; +register_netdevice_notifier (&hard_if_notifier);dev_add_pack (&batman_adv_packet_type);
@@ -124,6 +128,8 @@ int init_module(void)return 0 ; +unreg_soft_device: +unregister_netdevice (soft_device); free_soft_device:free_netdev (soft_device); soft_device =NULL ;
@@ -136,6 +142,7 @@ void cleanup_module(void)shutdown_module ();if (soft_device) { +sysfs_del_meshif (soft_device);unregister_netdev (soft_device); soft_device =NULL ; }
drivers/staging/batman-adv/main.h +0 -1
@@ -130,7 +130,6 @@ extern spinlock_t forw_bcast_list_lock;extern atomic_t originator_interval;extern atomic_t vis_interval;extern atomic_t vis_mode; -extern atomic_t aggregation_enabled;extern int16_t num_hna;extern int16_t num_ifs;
drivers/staging/batman-adv/originator.c +73 -0
77 lines not on this page · raw message
drivers/staging/batman-adv/originator.h +1 -1
@@ -28,4 +28,4 @@ struct orig_node *get_orig_node(uint8_t *addr);struct neigh_node *create_neighbor (struct orig_node *orig_node,struct orig_node *orig_neigh_node,uint8_t *neigh,struct batman_if *if_incoming); - +ssize_t orig_fill_buffer_text (char *buff,size_t count,loff_t off);
drivers/staging/batman-adv/proc.c +1 -278
333 lines not on this page · raw message
drivers/staging/batman-adv/proc.h +0 -4
@@ -25,15 +25,11 @@#define PROC_ROOT_DIR "batman-adv"#define PROC_FILE_INTERFACES "interfaces"#define PROC_FILE_ORIG_INTERVAL "orig_interval" -#define PROC_FILE_ORIGINATORS "originators"#define PROC_FILE_GATEWAYS "gateways"#define PROC_FILE_LOG "log"#define PROC_FILE_LOG_LEVEL "log_level" -#define PROC_FILE_TRANST_LOCAL "transtable_local" -#define PROC_FILE_TRANST_GLOBAL "transtable_global"#define PROC_FILE_VIS_SRV "vis_server"#define PROC_FILE_VIS_DATA "vis_data" -#define PROC_FILE_AGGR "aggregate_ogm"void cleanup_procfs (void );int setup_procfs (void );
drivers/staging/batman-adv/send.c +11 -4
@@ -44,7 +44,7 @@ static unsigned long own_send_time(void) }/* when do we schedule a forwarded packet to be sent */ -static unsigned long forward_send_time (void ) +static unsigned long forward_send_time (struct bat_priv *bat_priv) {return jiffies + (((random32 () % (JITTER /2 )) *HZ ) /1000 ); }
@@ -239,6 +239,8 @@ static void rebuild_batman_packet(struct batman_if *batman_if)void schedule_own_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);unsigned long send_time;struct batman_packet *batman_packet;int vis_server =atomic_read (&vis_mode);
@@ -277,7 +279,9 @@ void schedule_own_packet(struct batman_if *batman_if)slide_own_bcast_window (batman_if); send_time =own_send_time ();add_bat_packet_to_list (batman_if->packet_buff, - batman_if->packet_len, batman_if,1 , send_time); + batman_if->packet_len, + batman_if,1 , send_time, + bat_priv); } void schedule_forward_packet(struct orig_node *orig_node,
@@ -286,6 +290,8 @@ void schedule_forward_packet(struct orig_node *orig_node, uint8_t directlink, int hna_buff_len, struct batman_if *if_incoming) { + /* FIXME: each batman_if will be attached to a softif */ + struct bat_priv *bat_priv = netdev_priv(soft_device);unsigned char in_tq, in_ttl, tq_avg =0 ;unsigned long send_time;
@@ -329,10 +335,11 @@ void schedule_forward_packet(struct orig_node *orig_node,else batman_packet->flags &= ~DIRECTLINK ; - send_time =forward_send_time (); + send_time =forward_send_time (bat_priv);add_bat_packet_to_list ((unsigned char *)batman_packet,sizeof (struct batman_packet ) + hna_buff_len, - if_incoming,0 , send_time); + if_incoming,0 , send_time, + bat_priv); }static void forw_packet_free (struct forw_packet *forw_packet)
drivers/staging/batman-adv/translation-table.c +33 -9
93 lines not on this page · raw message
drivers/staging/batman-adv/translation-table.h +4 -2
@@ -25,13 +25,15 @@ int hna_local_init(void);void hna_local_add (uint8_t *addr);void hna_local_remove (uint8_t *addr,char *message);int hna_local_fill_buffer (unsigned char *buff,int buff_len); -int hna_local_fill_buffer_text (unsigned char *buff,int buff_len); +int hna_local_fill_buffer_text (struct net_device *net_dev,char *buff, +size_t count,loff_t off);void hna_local_purge (struct work_struct *work);void hna_local_free (void );int hna_global_init (void );void hna_global_add_orig (struct orig_node *orig_node,unsigned char *hna_buff,int hna_buff_len); -int hna_global_fill_buffer_text (unsigned char *buff,int buff_len); +int hna_global_fill_buffer_text (struct net_device *net_dev,char *buff, +size_t count,loff_t off);void _hna_global_del_orig (struct hna_global_entry *hna_global_entry,char *orig_str);void hna_global_del_orig (struct orig_node *orig_node,char *message);
drivers/staging/batman-adv/types.h +2 -0
@@ -82,6 +82,8 @@ struct neigh_node {struct bat_priv {struct net_device_stats stats; +atomic_t aggregation_enabled; +struct kobject *mesh_obj; };struct device_client {
Signature · 1 line
1.7.1
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Quoted 9 lines · Andrew Lunn
From: Marek Lindner <[email protected]>
This is the first patch in a series of patches which aim to convert all batman-adv /proc files to sysfs. To keep the changes in a digestable size it has been split up into smaller chunks. During the transition period batman-adv will use /proc as well as sysfs.
As a first step the following files have been converted:
aggregate_ogm, originators,transtable_global,transtable_local
Please document all sysfs files with a Documentation/ABI/ entry. You can put it in the drivers/staging/batman-adv/ directory for now.
Also note, binary sysfs files are for things that are "pass-through", not for things that you try to intrepret like I think you are doing here. What's wrong with configfs for something like this?
Note, I still applied the patch :)
thanks,
greg k-h
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Hi Greg,
Quoted 6 lines
Please document all sysfs files with a
Documentation/ABI/entry. You can put it in thedrivers/staging/batman-adv/directory for now.Also note, binary sysfs files are for things that are "pass-through", not for things that you try to intrepret like I think you are doing here. What's wrong with configfs for something like this?
I drafted the ABI documentation which you will find attached to this mail. Since this is my very first attempt I'd appreciate feedback from your side before we submit it. I looked at various existing ABI docs in the linux kernel tree to get an idea how it should look like. Bear with me if it is not perfect yet. ;-)
Regarding the question which kernel configuration interface to use, we would be more than happy to receive some guidance. At this point we are rather unsure which of the many (procfs/sysfs/configfs/etc) filesystems are we supposed to go forward with. To better judge our case I recommend reading this page
http://www.open-mesh.org/wiki/tweaking-batman-adv
as it explains the purpose of the various sysfs files.
Right now, I would say that configfs does not belong to my favorite solutions, simply because it seems to be a rather new/uncommon choice. Batman's main deployment field are embedded devices (mostly low cost routers) that have quite some contraints regarding cpu power and available disk space. Typically, those systems try to deactivate all "unnecessary" functionality in the kernel to have a few more bytes available for other stuff. For example OpenWRT: They deactivated configfs on all platforms (except one). I fear we create more problems than we solve if we go down this path.
Cheers,
Marek
What: /sys/class/net/<iface>/batman-adv/mesh_iface Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
The /sys/class/net/<iface>/batman-adv/mesh_iface file displays the batman mesh interface this <iface> currently is associated with.
What: /sys/class/net/<iface>/batman-adv/iface_status Date: May 2010 Contact: Marek Lindner <[email protected]> Description: Indicates the status of <iface> as it is seen by batman. What: /sys/class/net/<mesh_iface>/mesh/aggregate_ogm Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
Indicates whether the batman protocol messages of the mesh <mesh_iface> shall be aggregated or not.
What: /sys/class/net/<mesh_iface>/mesh/orig_interval Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
Defines the interval in milliseconds in which batman sends its protocol messages.
What: /sys/class/net/<mesh_iface>/mesh/originators Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
Displays the table of all batman nodes (in range) and the link quality towards them. Each line contains the following values:
1 - originator
2 - TQ (transmit quality) value of originator 3 - best next hop towards originator
4 - outgoing iface to reach best next hop 5 - list of alternative best next hops
What: /sys/class/net/<mesh_iface>/mesh/transtable_global Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
Displays the table of mesh-wide announced mac addresses. Each line contains the following values:
1 - announced mac address
2 - originator announcing the mac address
What: /sys/class/net/<mesh_iface>/mesh/transtable_local Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
Displays the table of mac addresses announced to the mesh network by this node. Each line contains the following values:
1 - announced mac address
What: /sys/class/net/<mesh_iface>/mesh/vis_mode Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
Each batman node only maintains information about its own local neighborhood, therefore generating graphs showing the topology of the entire mesh is not easily feasible without having a central instance to collect the local topologies from all nodes. This file allows to activate the collecting (server) mode. Once activated the topology can be retrieved by reading the vis_data file.
What: /sys/class/net/<mesh_iface>/mesh/vis_data Date: May 2010 Contact: Marek Lindner <[email protected]>
Description:
This file outputs the collected entire mesh topology information (if available) in a neutral (raw) format. Each line contains a set of identifiers. Values may or may not follow depending on their respective meanings:
* "mac" - mac address of an originator's source interface (each line begins with it)
* "TQ mac value" - src mac's link quality towards mac address of a neighbor originator's interface which is being used for routing
* "HNA mac" - HNA announced by source mac
* "PRIMARY" - this is a primary interface
* "SEC mac" - secondary mac address of source (requires preceding PRIMARY)
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Quoted 23 lines · Marek Lindner
Hi Greg,
Quoted 6 lines
Please document all sysfs files with a
Documentation/ABI/entry. You can put it in thedrivers/staging/batman-adv/directory for now.Also note, binary sysfs files are for things that are "pass-through", not for things that you try to intrepret like I think you are doing here. What's wrong with configfs for something like this?
I drafted the ABI documentation which you will find attached to this mail. Since this is my very first attempt I'd appreciate feedback from your side before we submit it. I looked at various existing ABI docs in the linux kernel tree to get an idea how it should look like. Bear with me if it is not perfect yet. ;-)
Regarding the question which kernel configuration interface to use, we would be more than happy to receive some guidance. At this point we are rather unsure which of the many (procfs/sysfs/configfs/etc) filesystems are we supposed to go forward with. To better judge our case I recommend reading this page
http://www.open-mesh.org/wiki/tweaking-batman-adv
as it explains the purpose of the various sysfs files.
Quoted 2 lines
Right now, I would say that configfs does not belong to my favorite solutions, simply because it seems to be a rather new/uncommon choice.
configfs is very old, and has been around almost as long as sysfs has been. But yes, it's not used as much, that is true.
Quoted 7 lines
Batman's main deployment field are embedded devices (mostly low cost routers) that have quite some contraints regarding cpu power and available disk space. Typically, those systems try to deactivate all "unnecessary" functionality in the kernel to have a few more bytes available for other stuff. For example OpenWRT: They deactivated configfs on all platforms (except one). I fear we create more problems than we solve if we go down this path.
Well, it is simple to enable configfs if you need/want batman, right? It's not that much extra kernel code.
Quoted 12 lines
What: /sys/class/net/<mesh_iface>/mesh/originators Date: May 2010 Contact: Marek Lindner <[email protected]>Description:
Displays the table of all batman nodes (in range) and the link quality towards them. Each line contains the following values:
1 - originator
2 - TQ (transmit quality) value of originator 3 - best next hop towards originator
4 - outgoing iface to reach best next hop 5 - list of alternative best next hops
Sorry, but sysfs is for "one value per file" attributes, which this one violates.
Is this something that everyone always needs to know? Or could it be a debugfs file?
Quoted 8 lines
What: /sys/class/net/<mesh_iface>/mesh/transtable_global Date: May 2010 Contact: Marek Lindner <[email protected]>Description:
Displays the table of mesh-wide announced mac addresses. Each line contains the following values:
1 - announced mac address
2 - originator announcing the mac address
Again, no "tables" in sysfs please.
Quoted 8 lines
What: /sys/class/net/<mesh_iface>/mesh/transtable_local Date: May 2010 Contact: Marek Lindner <[email protected]>Description:
Displays the table of mac addresses announced to the mesh network by this node. Each line contains the following values:
1 - announced mac address
Same here.
Quoted 16 lines
What: /sys/class/net/<mesh_iface>/mesh/vis_mode Date: May 2010 Contact: Marek Lindner <[email protected]>Description:
Each batman node only maintains information about its own local neighborhood, therefore generating graphs showing the topology of the entire mesh is not easily feasible without having a central instance to collect the local topologies from all nodes. This file allows to activate the collecting (server) mode. Once activated the topology can be retrieved by reading thevis_datafile.What: /sys/class/net/<mesh_iface>/mesh/vis_data Date: May 2010 Contact: Marek Lindner <[email protected]>
Quoted 16 lines
Description:
This file outputs the collected entire mesh topology information (if available) in a neutral (raw) format. Each line contains a set of identifiers. Values may or may not follow depending on their respective meanings:
* "mac" - mac address of an originator's source interface (each line begins with it)
* "TQ mac value" - src mac's link quality towards mac address of a neighbor originator's interface which is being used for routing
* "HNA mac" - HNA announced by source mac
* "PRIMARY" - this is a primary interface
* "SEC mac" - secondary mac address of source (requires preceding PRIMARY)
Again, this is not a single value, so please move it somewhere else.
thanks,
greg k-h
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Thank you for the fast answer.
Quoted 37 lines · Greg KH
Quoted 22 lines · Marek Lindner
Hi Greg,
Quoted 6 lines
Please document all sysfs files with a
Documentation/ABI/entry. You can put it in thedrivers/staging/batman-adv/directory for now.Also note, binary sysfs files are for things that are "pass-through", not for things that you try to intrepret like I think you are doing here. What's wrong with configfs for something like this?
I drafted the ABI documentation which you will find attached to this mail. Since this is my very first attempt I'd appreciate feedback from your side before we submit it. I looked at various existing ABI docs in the linux kernel tree to get an idea how it should look like. Bear with me if it is not perfect yet. ;-)
Regarding the question which kernel configuration interface to use, we would be more than happy to receive some guidance. At this point we are rather unsure which of the many (procfs/sysfs/configfs/etc) filesystems are we supposed to go forward with. To better judge our case I recommend reading this page http://www.open-mesh.org/wiki/tweaking-batman-adv
as it explains the purpose of the various sysfs files.Quoted 2 lines
Right now, I would say that configfs does not belong to my favorite solutions, simply because it seems to be a rather new/uncommon choice.
configfs is very old, and has been around almost as long as sysfs has been. But yes, it's not used as much, that is true.
Quoted 7 lines
Batman's main deployment field are embedded devices (mostly low cost routers) that have quite some contraints regarding cpu power and available disk space. Typically, those systems try to deactivate all "unnecessary" functionality in the kernel to have a few more bytes available for other stuff. For example OpenWRT: They deactivated configfs on all platforms (except one). I fear we create more problems than we solve if we go down this path.
Quoted 2 lines
Well, it is simple to enable configfs if you need/want batman, right? It's not that much extra kernel code.
Yes, it should be possible to enable it. It was just meant to describe the current situation and the target systems were batman-adv is currently used. There is for example the requirement by one developer that it runs on his hardware which currently only support 2.6.24 as kernel due to different out of kernel drivers. There were also some request to port it back to 2.6.15 to get the Atheros drivers working... which is out of scope for us due to different changes in the kernel since 2.6.15. It isn't always easy to support all those requirements and get it in the right shape for a merge in the mainline kernel (and my/our gap in education about all virtualfs doesn't help either).
This makes invalid entries in sysfs not better, but maybe helps you to get in the correct mood to point us in the right direction.
Quoted 1 line
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/originators
[...]
Quoted 6 lines
Sorry, but sysfs is for "one value per file" attributes, which this one violates.
Is this something that everyone always needs to know? Or could it be a debugfs file?
Everyone/always - not really. They are needed by someone who wants to test and debug the status of batman-adv - which sounds like a perfect target for debugfs, right?
So batctl has to check if /sys/kernel/debug/ is mounted (or the batman- adv/mesh_iface/originator) file can be found and give the user a helpful error message that either batman-adv is not loaded, debugfs is not mounted at /sys/kernel/debug/ or the mesh_iface just doesn't exists.
Quoted 1 line
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/transtable_global
[...]
Quoted 4 lines
Again, no "tables" in sysfs please.
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/transtable_local
[...]
Quoted 4 lines
Same here.
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/vis_mode
[...]
Quoted 2 lines
Quoted 2 lines
What: /sys/class/net/<mesh_iface>/mesh/vis_data
[...]
Quoted 2 lines
Again, this is not a single value, so please move it somewhere else.
As far as I can see only these files with (more or less) debug information are the problem right now and should go to the debugfs?
The rest can be in sysfs?:
* /sys/class/net/<iface>/batman-adv/mesh_iface
* /sys/class/net/<iface>/batman-adv/iface_status
* /sys/class/net/<mesh_iface>/mesh/aggregate_ogm
* /sys/class/net/<mesh_iface>/mesh/orig_interval
* /sys/class/net/<mesh_iface>/mesh/vis_mode (not sure about that one because it is in the no-list, but without comment. You can only write "client"/ "server" into that file and read the same value. So probably in the sysfs list)
Best regards,
Sven Eckelmann
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Quoted 43 lines · Sven Eckelmann
Thank you for the fast answer.
Quoted 37 lines · Greg KH
Quoted 22 lines · Marek Lindner
Hi Greg,
Quoted 6 lines
Please document all sysfs files with a
Documentation/ABI/entry. You can put it in thedrivers/staging/batman-adv/directory for now.Also note, binary sysfs files are for things that are "pass-through", not for things that you try to intrepret like I think you are doing here. What's wrong with configfs for something like this?
I drafted the ABI documentation which you will find attached to this mail. Since this is my very first attempt I'd appreciate feedback from your side before we submit it. I looked at various existing ABI docs in the linux kernel tree to get an idea how it should look like. Bear with me if it is not perfect yet. ;-)
Regarding the question which kernel configuration interface to use, we would be more than happy to receive some guidance. At this point we are rather unsure which of the many (procfs/sysfs/configfs/etc) filesystems are we supposed to go forward with. To better judge our case I recommend reading this page http://www.open-mesh.org/wiki/tweaking-batman-adv
as it explains the purpose of the various sysfs files.Quoted 2 lines
Right now, I would say that configfs does not belong to my favorite solutions, simply because it seems to be a rather new/uncommon choice.
configfs is very old, and has been around almost as long as sysfs has been. But yes, it's not used as much, that is true.
Quoted 7 lines
Batman's main deployment field are embedded devices (mostly low cost routers) that have quite some contraints regarding cpu power and available disk space. Typically, those systems try to deactivate all "unnecessary" functionality in the kernel to have a few more bytes available for other stuff. For example OpenWRT: They deactivated configfs on all platforms (except one). I fear we create more problems than we solve if we go down this path.
Quoted 2 lines
Well, it is simple to enable configfs if you need/want batman, right? It's not that much extra kernel code.
Quoted 9 lines
Yes, it should be possible to enable it. It was just meant to describe the current situation and the target systems were batman-adv is currently used. There is for example the requirement by one developer that it runs on his hardware which currently only support 2.6.24 as kernel due to different out of kernel drivers. There were also some request to port it back to 2.6.15 to get the Atheros drivers working... which is out of scope for us due to different changes in the kernel since 2.6.15. It isn't always easy to support all those requirements and get it in the right shape for a merge in the mainline kernel (and my/our gap in education about all virtualfs doesn't help either).
configfs has been around since 2.6.3 or so, so even ancient kernels like 2.6.15 is fine.
Quoted 2 lines
This makes invalid entries in sysfs not better, but maybe helps you to get in the correct mood to point us in the right direction.
I honestly don't care about older kernels, as this is all about merging the code into the current kernel version, not older ones :)
Quoted 6 lines
Quoted 1 line
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/originators
[...]
Quoted 4 lines
Sorry, but sysfs is for "one value per file" attributes, which this one violates.
Quoted 6 lines
Quoted 2 lines
Is this something that everyone always needs to know? Or could it be a debugfs file?
Everyone/always - not really. They are needed by someone who wants to test and debug the status of batman-adv - which sounds like a perfect target for debugfs, right?
Yup.
Quoted 4 lines
So batctl has to check if
/sys/kernel/debug/is mounted (or the batman- adv/mesh_iface/originator) file can be found and give the user a helpful error message that either batman-adv is not loaded, debugfs is not mounted at/sys/kernel/debug/or themesh_ifacejust doesn't exists.
Yes, that should be quite simple. The perf code does this today, you can just steal their function that handles this. Almost all distros are mounting debugfs these days, so it's not really a big deal.
Quoted 13 lines
Quoted 1 line
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/transtable_global
[...]
Quoted 4 lines
Again, no "tables" in sysfs please.
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/transtable_local
[...]
Quoted 4 lines
Same here.
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/vis_mode
[...]
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 1 line
Quoted 1 line
What: /sys/class/net/<mesh_iface>/mesh/vis_data
[...]
Quoted 2 lines
Again, this is not a single value, so please move it somewhere else.
As far as I can see only these files with (more or less) debug information are the problem right now and should go to the debugfs?
Yes.
Quoted 9 lines
The rest can be in sysfs?:
* /sys/class/net/<iface>/batman-adv/mesh_iface
* /sys/class/net/<iface>/batman-adv/iface_status
* /sys/class/net/<mesh_iface>/mesh/aggregate_ogm
* /sys/class/net/<mesh_iface>/mesh/orig_interval
* /sys/class/net/<mesh_iface>/mesh/vis_mode (not sure about that one because it is in the no-list, but without comment. You can only write "client"/ "server" into that file and read the same value. So probably in the sysfs list)
The mode is only a single value that you write to, right? If it makes sense to be in debugfs (not a normal config value), then is should move there.
The others are all single-value files, right? Or did I miss something? If they are single-value files, then yes, they can stay in sysfs, unless you feel they are debug-type things, then debugfs is the place for them (debugfs makes is trivial to handle single value files, even easier than sysfs.)
thanks,
greg k-h
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Quoted 5 lines · On Thursday 13 May 2010 03:17:20 Greg KH wrote:
Quoted 2 lines
This makes invalid entries in sysfs not better, but maybe helps you to get in the correct mood to point us in the right direction.
I honestly don't care about older kernels, as this is all about merging the code into the current kernel version, not older ones :)
In addition to our our efforts of merging the code into the current version we offer a backward compatible module (similar to wireless-compat) which also works on older kernels. We would very much prefer if everybody simply used the latest kernel but the world is not as perfect as we wish it to be. Therefore, we always have to look back a bit.
Quoted 3 lines
Yes, that should be quite simple. The perf code does this today, you can just steal their function that handles this. Almost all distros are mounting debugfs these days, so it's not really a big deal.
Debugfs looks like an option.
Quoted 5 lines
The others are all single-value files, right? Or did I miss something? If they are single-value files, then yes, they can stay in sysfs, unless you feel they are debug-type things, then debugfs is the place for them (debugfs makes is trivial to handle single value files, even easier than sysfs.)
Well, now that you mention it .. :-)
Next to the sysfs interface batman creates a file in /dev (/dev/batman-adv at the moment) that is used to inject (debug) packets into the mesh from user space. Due to our ongoing mesh abstraction effort we would need to create one file per virtual mesh which is little bit messy in /dev (although doable). I'd like to get it out of there - can/should we move it to debugfs ? The initial reason to choose /dev was the ability get the open() and close() syscalls because we need to maintain a state for each user.
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Quoted 6 lines · Marek Lindner
Quoted 5 lines
The others are all single-value files, right? Or did I miss something? If they are single-value files, then yes, they can stay in sysfs, unless you feel they are debug-type things, then debugfs is the place for them (debugfs makes is trivial to handle single value files, even easier than sysfs.)
Quoted 8 lines
Well, now that you mention it .. :-)
Next to the sysfs interface batman creates a file in /dev (/dev/batman-advat the moment) that is used to inject (debug) packets into the mesh from user space. Due to our ongoing mesh abstraction effort we would need to create one file per virtual mesh which is little bit messy in /dev (although doable). I'd like to get it out of there - can/should we move it to debugfs ? The initial reason to choose /dev was the ability get theopen()andclose()syscalls because we need to maintain a state for each user.
Yes, that sounds like debugfs might work for you there.
Just remember the one rule of debugfs:
There are no rules for debugfs
If you are ok with that, then by all means, use it :)
thanks,
greg k-h
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
In reply to Sven EckelmannQuoted 6 lines
The rest can be in sysfs?:
* /sys/class/net/<iface>/batman-adv/mesh_iface
* /sys/class/net/<iface>/batman-adv/iface_status
* /sys/class/net/<mesh_iface>/mesh/aggregate_ogm
* /sys/class/net/<mesh_iface>/mesh/orig_interval
* /sys/class/net/<mesh_iface>/mesh/vis_mode
As far as i can see, these are all single values. I would however suggest a few changes, to make it a bit clearer what the values are and what units are used.
* /sys/class/net/<mesh_iface>/mesh/enable_aggregated_OGMs
* /sys/class/net/<mesh_iface>/mesh/enable_vis_data
* /sys/class/net/<mesh_iface>/mesh/orig_interval_msec
"enable" suggests the control can be enabled/disabled. It gives the user a hint to try Boolean values: 0/1, true/false, enable/disable. Our current code accepts 0/1 and enable/disable, so the user has a good chance of guessing correct.
enable_aggregated_OGMs is more grammatically correct. We are aggregating multiple OGMs into one big OGM packet.
"_msec" gives the user the units to use for the orig_interval.
I would also change the values read from the files. Currently it is not a simple value. It is a value, plus some text which batctl uses, or hints for the user when using cat/echo. eg:
return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1\n",
aggr_status == 0 ? "disabled" : "enabled");
IMHO, we should just output 0/1, true/false/ enabled/disabled. I don't really care which, but is should be only a single word.
For me, batctl parsing the hint the kernel returns does not make much sense. Once this kernel ABI is defined, it will never change, ever. Since it will never change, we can hard code the hint into batctl. That then brings the syfs files in line with the single value requirement.
What we loose is the hint for people using cat/echo, not batctl. How big a problem is this? I don't think it is a big problem. When you cat the file you see "enabled", go guessing "disabled" is not too hard. We already return -EINVAL when in invalid value is tried and log a message to the kernel log. It would be easy to extend this kernel log message with: "Usage: enable | disable.
For orig_interval_msec, i would extend the kernel log message with:
"Usage: integer between %d and %d", (JITTER * 2)+1, 0x00ffffff.
That i think covers all the mainline configuration options. We have a few more in trunk. I would suggest a rename to be consistent:
enable_bonding
gateway is a bigger problem. I think it needs splitting up into a number of files, but i don't know the code well enough, and could not quickly find a good description of the options.
Andrew
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Hello Andrew,
thank you very much for your suggetions. I'm currently sitting here with Marek and Sven in Berlin and we were discussing your suggestions. Our conclusion is:
* We could write and read "enable/disable" only from the respective files (like aggregation). In this case we don't need the word "enabled" in the name however, as we already use it to set the status, so we would rather skip it.
* we can rename aggregate_ogm to aggregate_ogms, i personally don't like CAPS in these names. ;)
* We don't like the _msecs suggestion. It does not seem very common with other kernel driver configurations. We could not find any other files in batman-adv which are configured with a unit, so we would suggest to keep it like it is.
* As you suggest, we should move the hints/verbose stuff from the module into batctl. There we could explain the possible commands, or also show the units. Then we would keep the sysfs "minimal". Also the "Usage" kernel change is a good idea imho.
* The bonding and gateway features should be discussed at another time, i'll have some more changes in bonding soon, not sure about Marek gateway plans. These are 0.3 features and it does not hurt the maint version if we change these a little bit later.
best regards,
Simon
Quoted 63 lines · Andrew Lunn
Quoted 6 lines
The rest can be in sysfs?:
* /sys/class/net/<iface>/batman-adv/mesh_iface
* /sys/class/net/<iface>/batman-adv/iface_status
* /sys/class/net/<mesh_iface>/mesh/aggregate_ogm
* /sys/class/net/<mesh_iface>/mesh/orig_interval
* /sys/class/net/<mesh_iface>/mesh/vis_modeAs far as i can see, these are all single values. I would however suggest a few changes, to make it a bit clearer what the values are and what units are used.
* /sys/class/net/<mesh_iface>/mesh/enable_aggregated_OGMs
* /sys/class/net/<mesh_iface>/mesh/enable_vis_data
* /sys/class/net/<mesh_iface>/mesh/orig_interval_msec"enable" suggests the control can be enabled/disabled. It gives the user a hint to try Boolean values: 0/1, true/false, enable/disable. Our current code accepts 0/1 and enable/disable, so the user has a good chance of guessing correct.
enable_aggregated_OGMsis more grammatically correct. We are aggregating multiple OGMs into one big OGM packet."
_msec" gives the user the units to use for theorig_interval.I would also change the values read from the files. Currently it is not a simple value. It is a value, plus some text which batctl uses, or hints for the user when using cat/echo. eg:
return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1\n",
aggr_status== 0 ? "disabled" : "enabled");IMHO, we should just output 0/1, true/false/ enabled/disabled. I don't really care which, but is should be only a single word.
For me, batctl parsing the hint the kernel returns does not make much sense. Once this kernel ABI is defined, it will never change, ever. Since it will never change, we can hard code the hint into batctl. That then brings the syfs files in line with the single value requirement.
What we loose is the hint for people using cat/echo, not batctl. How big a problem is this? I don't think it is a big problem. When you cat the file you see "enabled", go guessing "disabled" is not too hard. We already return
-EINVALwhen in invalid value is tried and log a message to the kernel log. It would be easy to extend this kernel log message with: "Usage: enable | disable.
Fororig_interval_msec, i would extend the kernel log message with:
"Usage: integer between %d and %d", (JITTER * 2)+1,0x00ffffff.That i think covers all the mainline configuration options. We have a few more in trunk. I would suggest a rename to be consistent:
enable_bondinggateway is a bigger problem. I think it needs splitting up into a number of files, but i don't know the code well enough, and could not quickly find a good description of the options.
Andrew
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
In reply to Greg KHQuoted 2 lines · On Thursday 13 May 2010 01:38:30 Greg KH wrote:
Well, it is simple to enable configfs if you need/want batman, right? It's not that much extra kernel code.
If you have 4MB flash for the bootloader, bootloader config, kernel, user space and some data you don't want to add another filesystem just for batman. As hardware development moves on, I defintely see more flexibility regarding these contraints.
Quoted 9 lines
Quoted 6 lines
following values:
1 - originator
2 - TQ (transmit quality) value of originator 3 - best next hop towards originator 4 - outgoing iface to reach best next hop 5 - list of alternative best next hopsSorry, but sysfs is for "one value per file" attributes, which this one violates.
Actually, this is a good example for our confusion. For this table I used Documentation/ABI/testing/sysfs-block as an example. The very first entry looks exactly like ours ...
Thanks for your quick feedback!
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
In reply to Marek LindnerQuoted 4 lines
Regarding the question which kernel configuration interface to use, we would be more than happy to receive some guidance. At this point we are rather unsure which of the many (procfs/sysfs/configfs/etc) filesystems are we supposed to go forward with.
Does it even need to be a filesystem?
cfg80211 uses netlink.
ifconfig seems to use ioctl calls.
What over APIs are available for passing configuration and tables of status information back and forth?
Tomorrow is a holiday in the part of the world i live in, and it is supposed to be raining. Sounds like ideal conditions for doing a bit of research and then comparing and contrasting our options...
Andrew
Re: [B.A.T.M.A.N.] [PATCH 13/26] staging:batman-adv: convert multiple /proc files to use sysfs
Quoted 10 lines · Andrew Lunn
Quoted 4 lines
Regarding the question which kernel configuration interface to use, we would be more than happy to receive some guidance. At this point we are rather unsure which of the many (procfs/sysfs/configfs/etc) filesystems are we supposed to go forward with.
Does it even need to be a filesystem?
cfg80211 uses netlink.
ifconfig seems to use ioctl calls.
Quoted 6 lines
What over APIs are available for passing configuration and tables of status information back and forth?
Tomorrow is a holiday in the part of the world i live in, and it is supposed to be raining. Sounds like ideal conditions for doing a bit of research and then comparing and contrasting our options...
Top priority in the conversation from proc to something else was to allow configuration/debugging with simple file operations (read, write) and not to depend on a special tool like batctl.
Best regards,
Sven Eckelmann
PATCH 14/26 staging:batman-adv: convert more files from /proc to /sys
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
converted files:vis_mode, vis_data
--- drivers/staging/batman-adv/aggregation.c | 6 +- drivers/staging/batman-adv/aggregation.h | 8 +- drivers/staging/batman-adv/bat_sysfs.c | 118 ++++++++++------- drivers/staging/batman-adv/main.c | 2 - drivers/staging/batman-adv/main.h | 1 - drivers/staging/batman-adv/originator.c | 33 ++++- drivers/staging/batman-adv/originator.h | 3 +- drivers/staging/batman-adv/proc.c | 167 ------------------------ drivers/staging/batman-adv/proc.h | 5 - drivers/staging/batman-adv/routing.c | 10 +- drivers/staging/batman-adv/send.c | 16 +- drivers/staging/batman-adv/soft-interface.c | 4 + drivers/staging/batman-adv/translation-table.c | 26 ++++ drivers/staging/batman-adv/types.h | 1 + drivers/staging/batman-adv/vis.c | 124 +++++++++++++++--- drivers/staging/batman-adv/vis.h | 17 +-- 16 files changed, 265 insertions(+), 276 deletions(-)
drivers/staging/batman-adv/aggregation.c +3 -3
@@ -165,10 +165,10 @@ static void aggregate(struct forw_packet *forw_packet_aggr, (1 << forw_packet_aggr->num_packets); } -void add_bat_packet_to_list (unsigned char *packet_buff,int packet_len, +void add_bat_packet_to_list (struct bat_priv *bat_priv, +unsigned char *packet_buff,int packet_len,struct batman_if *if_incoming,char own_packet, -unsigned long send_time, -struct bat_priv *bat_priv) +unsigned long send_time) {/** * _aggr -> pointer to the packet we want to aggregate with
drivers/staging/batman-adv/aggregation.h +4 -4
@@ -30,9 +30,9 @@ static inline int aggregated_packet(int buff_pos, int packet_len, int num_hna) (next_buff_pos <=MAX_AGGREGATION_BYTES ); } -void add_bat_packet_to_list (unsigned char *packet_buff,int packet_len, -struct batman_if *if_outgoing,char own_packet, -unsigned long send_time, -struct bat_priv *bat_priv); +void add_bat_packet_to_list (struct bat_priv *bat_priv, +unsigned char *packet_buff,int packet_len, +struct batman_if *if_incoming,char own_packet, +unsigned long send_time);void receive_aggr_bat_packet (struct ethhdr *ethhdr,unsigned char *packet_buff,int packet_len,struct batman_if *if_incoming);
drivers/staging/batman-adv/bat_sysfs.c +68 -50
174 lines not on this page · raw message
drivers/staging/batman-adv/main.c +0 -2
@@ -44,7 +44,6 @@ DEFINE_SPINLOCK(forw_bcast_list_lock);atomic_t originator_interval;atomic_t vis_interval; -atomic_t vis_mode;int16_t num_hna;int16_t num_ifs;
@@ -84,7 +83,6 @@ int init_module(void)atomic_set (&originator_interval,1000 );atomic_set (&vis_interval,1000 );/* TODO: raise this later, this is only * for debugging now. */ -atomic_set (&vis_mode,VIS_TYPE_CLIENT_UPDATE );/* the name should not be longer than 10 chars - see * http://lwn.net/Articles/23634/ */
drivers/staging/batman-adv/main.h +0 -1
@@ -129,7 +129,6 @@ extern spinlock_t forw_bcast_list_lock;extern atomic_t originator_interval;extern atomic_t vis_interval; -extern atomic_t vis_mode;extern int16_t num_hna;extern int16_t num_ifs;
drivers/staging/batman-adv/originator.c +29 -4
@@ -26,6 +26,7 @@#include "hash.h" #include "translation-table.h" #include "routing.h" +#include "hard-interface.h" static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);
@@ -205,7 +206,6 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,return neigh_purged; } -static bool purge_orig_node (struct orig_node *orig_node) {struct neigh_node *best_neigh_node;
@@ -224,6 +224,7 @@ static bool purge_orig_node(struct orig_node *orig_node) orig_node->hna_buff, orig_node->hna_buff_len); } +return false; }
@@ -249,7 +250,8 @@ void purge_orig(struct work_struct *work)start_purge_timer (); } -ssize_t orig_fill_buffer_text (char *buff,size_t count,loff_t off) +ssize_t orig_fill_buffer_text (struct net_device *net_dev,char *buff, +size_t count,loff_t off) {HASHIT (hashit);struct orig_node *orig_node;
@@ -260,12 +262,35 @@ ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off)char orig_str[ETH_STR_LEN ], router_str[ETH_STR_LEN ];rcu_read_lock (); +if (list_empty (&if_list)) { +rcu_read_unlock (); + +if (off ==0 ) +return sprintf (buff, +"BATMAN mesh %s disabled - please specify interfaces to enable it\n" , + net_dev->name); + +return 0 ; + } + +if (((struct batman_if *)if_list.next)->if_active !=IF_ACTIVE ) { +rcu_read_unlock (); + +if (off ==0 ) +return sprintf (buff, +"BATMAN mesh %s disabled - primary interface not active\n" , + net_dev->name); + +return 0 ; + } + hdr_len =sprintf (buff, -" %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n" , +" %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n" ,"Originator" ,"#" ,TQ_MAX_VALUE ,"Nexthop" ,"outgoingIF" ,"Potential nexthops" ,SOURCE_VERSION ,REVISION_VERSION_STR , ((struct batman_if *)if_list.next)->dev, - ((struct batman_if *)if_list.next)->addr_str); + ((struct batman_if *)if_list.next)->addr_str, + net_dev->name);rcu_read_unlock ();if (off < hdr_len)
drivers/staging/batman-adv/originator.h +2 -1
@@ -28,4 +28,5 @@ struct orig_node *get_orig_node(uint8_t *addr);struct neigh_node *create_neighbor (struct orig_node *orig_node,struct orig_node *orig_neigh_node,uint8_t *neigh,struct batman_if *if_incoming); -ssize_t orig_fill_buffer_text (char *buff,size_t count,loff_t off); +ssize_t orig_fill_buffer_text (struct net_device *net_dev,char *buff, +size_t count,loff_t off);
drivers/staging/batman-adv/proc.c +0 -167
190 lines not on this page · raw message
drivers/staging/batman-adv/proc.h +0 -5
@@ -25,11 +25,6 @@#define PROC_ROOT_DIR "batman-adv"#define PROC_FILE_INTERFACES "interfaces"#define PROC_FILE_ORIG_INTERVAL "orig_interval" -#define PROC_FILE_GATEWAYS "gateways" -#define PROC_FILE_LOG "log" -#define PROC_FILE_LOG_LEVEL "log_level" -#define PROC_FILE_VIS_SRV "vis_server" -#define PROC_FILE_VIS_DATA "vis_data"void cleanup_procfs (void );int setup_procfs (void );
drivers/staging/batman-adv/routing.c +8 -2
@@ -946,6 +946,7 @@ int recv_vis_packet(struct sk_buff *skb) {struct vis_packet *vis_packet;struct ethhdr *ethhdr; +struct bat_priv *bat_priv;int hdr_size =sizeof (struct vis_packet );if (skb_headlen (skb) < hdr_size)
@@ -965,15 +966,20 @@ int recv_vis_packet(struct sk_buff *skb)if (is_my_mac (vis_packet->sender_orig))return NET_RX_DROP ; +/* FIXME: each batman_if will be attached to a softif */ + bat_priv =netdev_priv (soft_device); +switch (vis_packet->vis_type) {case VIS_TYPE_SERVER_SYNC :/* TODO: handle fragmented skbs properly */ -receive_server_sync_packet (vis_packet,skb_headlen (skb)); +receive_server_sync_packet (bat_priv, vis_packet, +skb_headlen (skb));break ;case VIS_TYPE_CLIENT_UPDATE :/* TODO: handle fragmented skbs properly */ -receive_client_update_packet (vis_packet,skb_headlen (skb)); +receive_client_update_packet (bat_priv, vis_packet, +skb_headlen (skb));break ;default :/* ignore unknown packet */
drivers/staging/batman-adv/send.c +8 -8
@@ -243,7 +243,7 @@ void schedule_own_packet(struct batman_if *batman_if)struct bat_priv *bat_priv =netdev_priv (soft_device);unsigned long send_time;struct batman_packet *batman_packet; -int vis_server =atomic_read (&vis_mode); +int vis_server =atomic_read (&bat_priv->vis_mode);/** * the interface gets activated here to avoid race conditions between
@@ -271,17 +271,17 @@ void schedule_own_packet(struct batman_if *batman_if)if (vis_server ==VIS_TYPE_SERVER_SYNC ) batman_packet->flags =VIS_SERVER ;else - batman_packet->flags =0 ; + batman_packet->flags &= ~VIS_SERVER ;/* could be read by receive_bat_packet() */ atomic_inc (&batman_if->seqno);slide_own_bcast_window (batman_if); send_time =own_send_time (); -add_bat_packet_to_list (batman_if->packet_buff, +add_bat_packet_to_list (bat_priv, + batman_if->packet_buff, batman_if->packet_len, - batman_if,1 , send_time, - bat_priv); + batman_if,1 , send_time); } void schedule_forward_packet(struct orig_node *orig_node,
@@ -336,10 +336,10 @@ void schedule_forward_packet(struct orig_node *orig_node, batman_packet->flags &= ~DIRECTLINK ; send_time =forward_send_time (bat_priv); -add_bat_packet_to_list ((unsigned char *)batman_packet, +add_bat_packet_to_list (bat_priv, + (unsigned char *)batman_packet,sizeof (struct batman_packet ) + hna_buff_len, - if_incoming,0 , send_time, - bat_priv); + if_incoming,0 , send_time); }static void forw_packet_free (struct forw_packet *forw_packet)
drivers/staging/batman-adv/soft-interface.c +4 -0
@@ -182,6 +182,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)struct ethhdr *ethhdr = (struct ethhdr *)skb->data;struct bat_priv *priv =netdev_priv (dev);struct batman_if *batman_if; +struct bat_priv *bat_priv;uint8_t dstaddr[6 ];int data_len = skb->len;unsigned long flags;
@@ -189,6 +190,9 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)if (atomic_read (&module_state) !=MODULE_ACTIVE ) goto dropped; +/* FIXME: each batman_if will be attached to a softif */ + bat_priv =netdev_priv (soft_device); + dev->trans_start = jiffies;/* TODO: check this for locks */ hna_local_add (ethhdr->h_source);
drivers/staging/batman-adv/translation-table.c +26 -0
@@ -165,6 +165,19 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,unsigned long flags;size_t hdr_len; +rcu_read_lock (); +if (list_empty (&if_list)) { +rcu_read_unlock (); + +if (off ==0 ) +return sprintf (buff, +"BATMAN mesh %s disabled - please specify interfaces to enable it\n" , + net_dev->name); + +return 0 ; + } +rcu_read_unlock (); + hdr_len =sprintf (buff,"Locally retrieved addresses (from %s) announced via HNA:\n" , net_dev->name);
@@ -369,6 +382,19 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,unsigned long flags;size_t hdr_len; +rcu_read_lock (); +if (list_empty (&if_list)) { +rcu_read_unlock (); + +if (off ==0 ) +return sprintf (buff, +"BATMAN mesh %s disabled - please specify interfaces to enable it\n" , + net_dev->name); + +return 0 ; + } +rcu_read_unlock (); + hdr_len =sprintf (buff,"Globally announced HNAs received via the mesh %s (translation table):\n" , net_dev->name);
drivers/staging/batman-adv/types.h +1 -0
@@ -83,6 +83,7 @@ struct neigh_node {struct bat_priv {struct net_device_stats stats;atomic_t aggregation_enabled; +atomic_t vis_mode;struct kobject *mesh_obj; };
drivers/staging/batman-adv/vis.c +106 -18
200 lines not on this page · raw message
drivers/staging/batman-adv/vis.h +6 -11
@@ -47,18 +47,13 @@ struct recvlist_node {extern struct hashtable_t *vis_hash;extern spinlock_t vis_hash_lock; -void proc_vis_insert_interface (const uint8_t *interface, -struct hlist_head *if_list, -bool primary); -void proc_vis_read_entry (struct seq_file *seq, -struct vis_info_entry *entry, -uint8_t *src, -bool primary); -void proc_vis_read_prim_sec (struct seq_file *seq, -struct hlist_head *if_list); -void receive_server_sync_packet (struct vis_packet *vis_packet, +ssize_t vis_fill_buffer_text (struct net_device *net_dev,char *buff, +size_t count,loff_t off); +void receive_server_sync_packet (struct bat_priv *bat_priv, +struct vis_packet *vis_packet,int vis_info_len); -void receive_client_update_packet (struct vis_packet *vis_packet, +void receive_client_update_packet (struct bat_priv *bat_priv, +struct vis_packet *vis_packet,int vis_info_len);int vis_init (void );void vis_quit (void );
Signature · 1 line
1.7.1
PATCH 15/26 staging:batman-adv: move originator interval setting from /proc to /sys
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
--- drivers/staging/batman-adv/bat_sysfs.c | 47 ++++++++++++++++++++ drivers/staging/batman-adv/main.c | 2 - drivers/staging/batman-adv/main.h | 1 - drivers/staging/batman-adv/proc.c | 75 -------------------------------- drivers/staging/batman-adv/proc.h | 1 - drivers/staging/batman-adv/send.c | 6 +- drivers/staging/batman-adv/types.h | 1 + 7 files changed, 51 insertions(+), 82 deletions(-)
drivers/staging/batman-adv/bat_sysfs.c +47 -0
@@ -153,13 +153,59 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,return count; } +static ssize_t show_orig_interval (struct kobject *kobj,struct attribute *attr, +char *buff) +{ +struct device *dev =to_dev (kobj->parent); +struct bat_priv *bat_priv =netdev_priv (to_net_dev (dev)); + +return sprintf (buff,"status: %i\n" , +atomic_read (&bat_priv->orig_interval)); +} + +static ssize_t store_orig_interval (struct kobject *kobj,struct attribute *attr, +char *buff,size_t count) +{ +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); +unsigned long orig_interval_tmp; +int ret; + + 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); +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 ); +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); + +atomic_set (&bat_priv->orig_interval, orig_interval_tmp); +return count; +} + static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR, show_aggr_ogm, store_aggr_ogm); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); +static BAT_ATTR(orig_interval, S_IRUGO | S_IWUSR, + show_orig_interval, store_orig_interval);static struct bat_attribute *mesh_attrs[] = { &bat_attr_aggregate_ogm, &bat_attr_vis_mode, + &bat_attr_orig_interval,NULL , };
@@ -228,6 +274,7 @@ int sysfs_add_meshif(struct net_device *dev)routine as soon as we have it */ atomic_set (&bat_priv->aggregation_enabled,1 );atomic_set (&bat_priv->vis_mode,VIS_TYPE_CLIENT_UPDATE ); +atomic_set (&bat_priv->orig_interval,1000 ); bat_priv->mesh_obj =kobject_create_and_add (SYSFS_IF_MESH_SUBDIR , batif_kobject);
drivers/staging/batman-adv/main.c +0 -2
@@ -42,7 +42,6 @@ DEFINE_SPINLOCK(orig_hash_lock);DEFINE_SPINLOCK (forw_bat_list_lock);DEFINE_SPINLOCK (forw_bcast_list_lock); -atomic_t originator_interval;atomic_t vis_interval;int16_t num_hna;int16_t num_ifs;
@@ -80,7 +79,6 @@ int init_module(void)atomic_set (&module_state,MODULE_INACTIVE ); -atomic_set (&originator_interval,1000 );atomic_set (&vis_interval,1000 );/* TODO: raise this later, this is only * for debugging now. */
drivers/staging/batman-adv/main.h +0 -1
@@ -127,7 +127,6 @@ extern spinlock_t orig_hash_lock;extern spinlock_t forw_bat_list_lock;extern spinlock_t forw_bcast_list_lock; -extern atomic_t originator_interval;extern atomic_t vis_interval;extern int16_t num_hna;extern int16_t num_ifs;
drivers/staging/batman-adv/proc.c +0 -75
100 lines not on this page · raw message
drivers/staging/batman-adv/proc.h +0 -1
@@ -24,7 +24,6 @@#define PROC_ROOT_DIR "batman-adv"#define PROC_FILE_INTERFACES "interfaces" -#define PROC_FILE_ORIG_INTERVAL "orig_interval"void cleanup_procfs (void );int setup_procfs (void );
drivers/staging/batman-adv/send.c +3 -3
@@ -36,10 +36,10 @@ static uint8_t hop_penalty(const uint8_t tq) }/* when do we schedule our own packet to be sent */ -static unsigned long own_send_time (void ) +static unsigned long own_send_time (struct bat_priv *bat_priv) {return jiffies + - (((atomic_read (&originator_interval) -JITTER + + (((atomic_read (&bat_priv->orig_interval) -JITTER + (random32 () %2 *JITTER )) *HZ ) /1000 ); }
@@ -277,7 +277,7 @@ void schedule_own_packet(struct batman_if *batman_if)atomic_inc (&batman_if->seqno);slide_own_bcast_window (batman_if); - send_time =own_send_time (); + send_time =own_send_time (bat_priv); add_bat_packet_to_list(bat_priv, batman_if->packet_buff, batman_if->packet_len,
drivers/staging/batman-adv/types.h +1 -0
@@ -84,6 +84,7 @@ struct bat_priv {struct net_device_stats stats;atomic_t aggregation_enabled;atomic_t vis_mode; +atomic_t orig_interval;struct kobject *mesh_obj; };
Signature · 1 line
1.7.1
PATCH 16/26 staging:batman-adv: remove redundant pointer to originator interface
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
--- drivers/staging/batman-adv/device.c | 2 +- drivers/staging/batman-adv/originator.c | 1 - drivers/staging/batman-adv/routing.c | 17 ++++------------- drivers/staging/batman-adv/soft-interface.c | 5 ++--- drivers/staging/batman-adv/types.h | 1 - drivers/staging/batman-adv/vis.c | 15 +++++++-------- 6 files changed, 14 insertions(+), 27 deletions(-)
drivers/staging/batman-adv/device.c +1 -1
@@ -250,7 +250,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,if (!orig_node->router) goto unlock; - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
drivers/staging/batman-adv/originator.c +0 -1
@@ -137,7 +137,6 @@ struct orig_node *get_orig_node(uint8_t *addr)memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ; - orig_node->batman_if =NULL ; orig_node->hna_buff =NULL ; size = num_ifs *sizeof (TYPE_OF_WORD ) *NUM_WORDS ;
drivers/staging/batman-adv/routing.c +4 -13
@@ -97,11 +97,6 @@ static void update_route(struct orig_node *orig_node,bat_dbg (DBG_ROUTES ,"Changing route towards: %pM (now via %pM - was via %pM)\n" , orig_node->orig, neigh_node->addr, orig_node->router->addr); } -if (neigh_node !=NULL ) - orig_node->batman_if = neigh_node->if_incoming; -else - orig_node->batman_if =NULL ; - orig_node->router = neigh_node; }
@@ -616,12 +611,11 @@ static int recv_my_icmp_packet(struct sk_buff *skb) ret =NET_RX_DROP ;if ((orig_node !=NULL ) && - (orig_node->batman_if !=NULL ) && (orig_node->router !=NULL )) {/* don't lock while sending the packets ... we therefore * copy the required data before sending */ - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
@@ -678,12 +672,11 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb) ret =NET_RX_DROP ;if ((orig_node !=NULL ) && - (orig_node->batman_if !=NULL ) && (orig_node->router !=NULL )) {/* don't lock while sending the packets ... we therefore * copy the required data before sending */ - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
@@ -760,12 +753,11 @@ int recv_icmp_packet(struct sk_buff *skb) hash_find(orig_hash, icmp_packet->dst));if ((orig_node !=NULL ) && - (orig_node->batman_if !=NULL ) && (orig_node->router !=NULL )) {/* don't lock while sending the packets ... we therefore * copy the required data before sending */ - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
@@ -844,12 +836,11 @@ int recv_unicast_packet(struct sk_buff *skb) hash_find(orig_hash, unicast_packet->dest));if ((orig_node !=NULL ) && - (orig_node->batman_if !=NULL ) && (orig_node->router !=NULL )) {/* don't lock while sending the packets ... we therefore * copy the required data before sending */ - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
drivers/staging/batman-adv/soft-interface.c +2 -3
@@ -236,7 +236,6 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) orig_node =transtable_search (ethhdr->h_dest);if ((orig_node) && - (orig_node->batman_if) && (orig_node->router)) {if (my_skb_push (skb,sizeof (struct unicast_packet )) <0 ) goto unlock;
@@ -252,13 +251,13 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)memcpy (unicast_packet->dest, orig_node->orig,ETH_ALEN );/* net_dev won't be available when not active */ -if (orig_node->batman_if->if_active !=IF_ACTIVE ) +if (orig_node->router->if_incoming->if_active !=IF_ACTIVE ) goto unlock;/* don't lock while sending the packets ... we therefore * copy the required data before sending */ - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
drivers/staging/batman-adv/types.h +0 -1
@@ -49,7 +49,6 @@ struct batman_if {struct orig_node {/* structure for orig_list maintaining nodes of mesh */ uint8_t orig[ETH_ALEN ];struct neigh_node *router; -struct batman_if *batman_if;TYPE_OF_WORD *bcast_own;uint8_t *bcast_own_sum;uint8_t tq_own;
drivers/staging/batman-adv/vis.c +7 -8
@@ -498,14 +498,14 @@ static int generate_vis_packet(struct bat_priv *bat_priv)if (orig_node->router !=NULL &&compare_orig (orig_node->router->addr, orig_node->orig) - && orig_node->batman_if - && (orig_node->batman_if->if_active ==IF_ACTIVE ) + && (orig_node->router->if_incoming->if_active == +IF_ACTIVE ) && orig_node->router->tq_avg >0 ) {/* fill one entry into buffer. */ entry = &entry_array[info->packet.entries];memcpy (entry->src, - orig_node->batman_if->net_dev->dev_addr, + orig_node->router->if_incoming->net_dev->dev_addr,ETH_ALEN );memcpy (entry->dest, orig_node->orig,ETH_ALEN ); entry->quality = orig_node->router->tq_avg;
@@ -573,8 +573,7 @@ static void broadcast_vis_packet(struct vis_info *info, int packet_length) orig_node = hashit.bucket->data;/* if it's a vis server and reachable, send it. */ -if ((!orig_node) || (!orig_node->batman_if) || - (!orig_node->router)) +if ((!orig_node) || (!orig_node->router))continue ;if (!(orig_node->flags &VIS_SERVER ))continue ;
@@ -584,7 +583,7 @@ static void broadcast_vis_packet(struct vis_info *info, int packet_length)continue ;memcpy (info->packet.target_orig, orig_node->orig,ETH_ALEN ); - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
@@ -609,12 +608,12 @@ static void unicast_vis_packet(struct vis_info *info, int packet_length) orig_node = ((struct orig_node *)hash_find (orig_hash, info->packet.target_orig)); -if ((!orig_node) || (!orig_node->batman_if) || (!orig_node->router)) +if ((!orig_node) || (!orig_node->router)) goto out;/* don't lock while sending the packets ... we therefore * copy the required data before sending */ - batman_if = orig_node->batman_if; + batman_if = orig_node->router->if_incoming;memcpy (dstaddr, orig_node->router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);
Signature · 1 line
1.7.1
PATCH 17/26 staging:batman-adv: move /proc interface handling to /sys
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
Instead of having a single /proc file "interfaces" in which you have to echo the wanted interface batman-adv will create a subfolder in each suitable /sys/class/net folder. This subfolder contains files for the interface specific settings. For example, mesh_iface to add/remove an interface from a virtual mesh network (at the moment only bat0 is supported).
Example:
echo bat0 > /sys/class/net/eth0/batman-adv/mesh_iface
to deactivate:
echo none > /sys/class/net/eth0/batman-adv/mesh_iface
Interfaces which are not compatible with batman-adv won't contain the batman-adv folder, therefore can't be activated. Not supported are:
loopback, non-ethernet, non-ARP and virtual mesh network interfaces
--- drivers/staging/batman-adv/Makefile | 2 +- drivers/staging/batman-adv/bat_sysfs.c | 147 +++++++ drivers/staging/batman-adv/bat_sysfs.h | 3 + drivers/staging/batman-adv/device.c | 2 +- drivers/staging/batman-adv/hard-interface.c | 515 ++++++++++++------------ drivers/staging/batman-adv/hard-interface.h | 18 +- drivers/staging/batman-adv/main.c | 21 +- drivers/staging/batman-adv/main.h | 3 +- drivers/staging/batman-adv/originator.c | 193 ++++++++- drivers/staging/batman-adv/originator.h | 2 + drivers/staging/batman-adv/proc.c | 170 -------- drivers/staging/batman-adv/proc.h | 30 -- drivers/staging/batman-adv/routing.c | 6 +- drivers/staging/batman-adv/send.c | 59 ++- drivers/staging/batman-adv/send.h | 2 +- drivers/staging/batman-adv/soft-interface.c | 2 +- drivers/staging/batman-adv/translation-table.c | 14 +- drivers/staging/batman-adv/types.h | 5 +- drivers/staging/batman-adv/vis.c | 9 +- 19 files changed, 670 insertions(+), 533 deletions(-) delete mode 100644 drivers/staging/batman-adv/proc.c delete mode 100644 drivers/staging/batman-adv/proc.h
drivers/staging/batman-adv/Makefile +1 -1
@@ -19,4 +19,4 @@ # obj-m += batman-adv.o -batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o bat_sysfs.o +batman-adv-objs := main.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o bat_sysfs.o
drivers/staging/batman-adv/bat_sysfs.c +147 -0
168 lines not on this page · raw message
drivers/staging/batman-adv/bat_sysfs.h +3 -0
@@ -21,6 +21,9 @@#define SYSFS_IF_MESH_SUBDIR "mesh" +#define SYSFS_IF_BAT_SUBDIR "batman_adv"int sysfs_add_meshif (struct net_device *dev);void sysfs_del_meshif (struct net_device *dev); +int sysfs_add_hardif (struct kobject **hardif_obj,struct net_device *dev); +void sysfs_del_hardif (struct kobject **hardif_obj);
drivers/staging/batman-adv/device.c +1 -1
@@ -258,7 +258,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,if (!batman_if) goto dst_unreach; -if (batman_if->if_active !=IF_ACTIVE ) +if (batman_if->if_status !=IF_ACTIVE ) goto dst_unreach; memcpy(icmp_packet.orig,
drivers/staging/batman-adv/hard-interface.c +262 -253
655 lines not on this page · raw message
drivers/staging/batman-adv/hard-interface.h +9 -9
@@ -19,19 +19,19 @@* */ -#define IF_INACTIVE 0 -#define IF_ACTIVE 1 -/* #define IF_TO_BE_DEACTIVATED 2 - not needed anymore */ -#define IF_TO_BE_ACTIVATED 3 +#define IF_NOT_IN_USE 0 +#define IF_TO_BE_REMOVED 1 +#define IF_INACTIVE 2 +#define IF_ACTIVE 3 +#define IF_TO_BE_ACTIVATED 4 +#define IF_I_WANT_YOU 5extern struct notifier_block hard_if_notifier; +struct batman_if *get_batman_if_by_netdev (struct net_device *net_dev); +int hardif_enable_interface (struct batman_if *batman_if); +void hardif_disable_interface (struct batman_if *batman_if);void hardif_remove_interfaces (void ); -int hardif_add_interface (char *dev,int if_num); -void hardif_deactivate_interface (struct batman_if *batman_if); -char hardif_get_active_if_num (void ); -void hardif_check_interfaces_status (void ); -void hardif_check_interfaces_status_wq (struct work_struct *work); int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype,
drivers/staging/batman-adv/main.c +7 -14
@@ -20,7 +20,6 @@*/ #include "main.h" -#include "proc.h" #include "bat_sysfs.h" #include "routing.h" #include "send.h"
@@ -44,7 +43,6 @@ DEFINE_SPINLOCK(forw_bcast_list_lock);atomic_t vis_interval;int16_t num_hna; -int16_t num_ifs;struct net_device *soft_device;
@@ -89,10 +87,6 @@ int init_module(void)if (!bat_event_workqueue)return -ENOMEM ; - retval =setup_procfs (); -if (retval <0 ) -return retval; -bat_device_init ();/* initialize layer 2 interface */
@@ -135,7 +129,10 @@ end:void cleanup_module (void ) { -shutdown_module (); +deactivate_module (); + +unregister_netdevice_notifier (&hard_if_notifier); +hardif_remove_interfaces ();if (soft_device) {sysfs_del_meshif (soft_device);
@@ -145,9 +142,6 @@ void cleanup_module(void)dev_remove_pack (&batman_adv_packet_type); -unregister_netdevice_notifier (&hard_if_notifier); -cleanup_procfs (); -destroy_workqueue (bat_event_workqueue); bat_event_workqueue =NULL ; }
@@ -178,17 +172,17 @@ void activate_module(void) err:printk (KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n" ); -shutdown_module (); +deactivate_module (); end:return ; }/* shuts down the whole module.*/ -void shutdown_module (void ) +void deactivate_module (void ) {atomic_set (&module_state,MODULE_DEACTIVATING ); -purge_outstanding_packets (); +purge_outstanding_packets (NULL );flush_workqueue (bat_event_workqueue);vis_quit ();
@@ -203,7 +197,6 @@ void shutdown_module(void)synchronize_net ();bat_device_destroy (); -hardif_remove_interfaces ();synchronize_rcu ();atomic_set (&module_state,MODULE_INACTIVE ); }
drivers/staging/batman-adv/main.h +1 -2
@@ -129,7 +129,6 @@ extern spinlock_t forw_bcast_list_lock;extern atomic_t vis_interval;extern int16_t num_hna; -extern int16_t num_ifs;extern struct net_device *soft_device;
@@ -138,7 +137,7 @@ extern atomic_t module_state;extern struct workqueue_struct *bat_event_workqueue;void activate_module (void ); -void shutdown_module (void ); +void deactivate_module (void );void inc_module_count (void );void dec_module_count (void );int addr_to_string (char *buff,uint8_t *addr);
drivers/staging/batman-adv/originator.c +176 -17
258 lines not on this page · raw message
drivers/staging/batman-adv/originator.h +2 -0
@@ -30,3 +30,5 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh, struct batman_if *if_incoming);ssize_t orig_fill_buffer_text (struct net_device *net_dev,char *buff,size_t count,loff_t off); +int orig_hash_add_if (struct batman_if *batman_if,int max_if_num); +int orig_hash_del_if (struct batman_if *batman_if,int max_if_num);
drivers/staging/batman-adv/proc.c deleted +0 -170
170 lines not on this page · raw message
drivers/staging/batman-adv/proc.h deleted +0 -30
@@ -1,30 +0,0 @@ -/* -* Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: -* -* Marek Lindner, Simon Wunderlich -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of version 2 of the GNU General Public -* License as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -* 02110-1301, USA -* -*/ - -#include <linux/proc_fs.h> -#include <linux/seq_file.h> - -#define PROC_ROOT_DIR "batman-adv" -#define PROC_FILE_INTERFACES "interfaces" - -void cleanup_procfs (void ); -int setup_procfs (void ); -
drivers/staging/batman-adv/routing.c +3 -3
@@ -205,7 +205,7 @@ static int isBidirectionalNeigh(struct orig_node *orig_node, batman_packet->tq = ((batman_packet->tq * orig_neigh_node->tq_own * orig_neigh_node->tq_asym_penalty) / - (TQ_MAX_VALUE *TQ_MAX_VALUE )); + (TQ_MAX_VALUE *TQ_MAX_VALUE )); bat_dbg(DBG_BATMAN, "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", orig_node->orig, orig_neigh_node->orig, total_count,
@@ -387,7 +387,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, batman_packet->version, has_directlink_flag);list_for_each_entry_rcu (batman_if, &if_list, list) { -if (batman_if->if_active !=IF_ACTIVE ) +if (batman_if->if_status !=IF_ACTIVE )continue ; if (compare_orig(ethhdr->h_source,
@@ -893,7 +893,7 @@ int recv_bcast_packet(struct sk_buff *skb)if (is_my_mac (ethhdr->h_source))return NET_RX_DROP ; - bcast_packet = (struct bcast_packet *) skb->data; + bcast_packet = (struct bcast_packet *)skb->data;/* ignore broadcasts originated by myself */ if (is_my_mac (bcast_packet->orig))
drivers/staging/batman-adv/send.c +45 -14
128 lines not on this page · raw message
drivers/staging/batman-adv/send.h +1 -1
@@ -36,4 +36,4 @@ void schedule_forward_packet(struct orig_node *orig_node,void add_bcast_packet_to_list (struct sk_buff *skb);void send_outstanding_bcast_packet (struct work_struct *work);void send_outstanding_bat_packet (struct work_struct *work); -void purge_outstanding_packets (void ); +void purge_outstanding_packets (struct batman_if *batman_if);
drivers/staging/batman-adv/soft-interface.c +1 -1
@@ -251,7 +251,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)memcpy (unicast_packet->dest, orig_node->orig,ETH_ALEN );/* net_dev won't be available when not active */ -if (orig_node->router->if_incoming->if_active !=IF_ACTIVE ) +if (orig_node->router->if_incoming->if_status !=IF_ACTIVE ) goto unlock;/* don't lock while sending the packets ... we therefore
drivers/staging/batman-adv/translation-table.c +4 -10
@@ -159,16 +159,14 @@ int hna_local_fill_buffer(unsigned char *buff, int buff_len)int hna_local_fill_buffer_text (struct net_device *net_dev,char *buff,size_t count,loff_t off) { +struct bat_priv *bat_priv =netdev_priv (net_dev);struct hna_local_entry *hna_local_entry;HASHIT (hashit);int bytes_written =0 ;unsigned long flags;size_t hdr_len; -rcu_read_lock (); -if (list_empty (&if_list)) { -rcu_read_unlock (); - +if (!bat_priv->primary_if) {if (off ==0 ) return sprintf(buff, "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -176,7 +174,6 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,return 0 ; } -rcu_read_unlock (); hdr_len = sprintf(buff, "Locally retrieved addresses (from %s) announced via HNA:\n",
@@ -376,16 +373,14 @@ void hna_global_add_orig(struct orig_node *orig_node,int hna_global_fill_buffer_text (struct net_device *net_dev,char *buff,size_t count,loff_t off) { +struct bat_priv *bat_priv =netdev_priv (net_dev);struct hna_global_entry *hna_global_entry;HASHIT (hashit);int bytes_written =0 ;unsigned long flags;size_t hdr_len; -rcu_read_lock (); -if (list_empty (&if_list)) { -rcu_read_unlock (); - +if (!bat_priv->primary_if) {if (off ==0 ) return sprintf(buff, "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -393,7 +388,6 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,return 0 ; } -rcu_read_unlock (); hdr_len = sprintf(buff, "Globally announced HNAs received via the mesh %s (translation table):\n",
drivers/staging/batman-adv/types.h +4 -1
@@ -36,12 +36,13 @@ struct batman_if {struct list_head list;int16_t if_num;char *dev; -char if_active; +char if_status;char addr_str[ETH_STR_LEN ];struct net_device *net_dev;atomic_t seqno;unsigned char *packet_buff;int packet_len; +struct kobject *hardif_obj;struct rcu_head rcu; };
@@ -84,6 +85,8 @@ struct bat_priv {atomic_t aggregation_enabled;atomic_t vis_mode;atomic_t orig_interval; +char num_ifaces; +struct batman_if *primary_if;struct kobject *mesh_obj; };
drivers/staging/batman-adv/vis.c +3 -6
@@ -173,13 +173,10 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff,unsigned long flags;int vis_server =atomic_read (&bat_priv->vis_mode); -rcu_read_lock (); -if (list_empty (&if_list) || (vis_server ==VIS_TYPE_CLIENT_UPDATE )) { -rcu_read_unlock (); +if ((!bat_priv->primary_if) || + (vis_server ==VIS_TYPE_CLIENT_UPDATE ))return 0 ; - } -rcu_read_unlock (); hdr_len =0 ;spin_lock_irqsave (&vis_hash_lock, flags);
@@ -498,7 +495,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)if (orig_node->router !=NULL &&compare_orig (orig_node->router->addr, orig_node->orig) - && (orig_node->router->if_incoming->if_active == + && (orig_node->router->if_incoming->if_status ==IF_ACTIVE ) && orig_node->router->tq_avg >0 ) {
Signature · 1 line
1.7.1
PATCH 18/26 staging:batman-adv: fix whitespace style issues
In reply to Andrew LunnFrom: Sven Eckelmann <[email protected]>
This patch fixes unnecessary whitespaces before a quoted newline that the remaining batman-adv files had.
--- drivers/staging/batman-adv/bat_sysfs.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/batman-adv/bat_sysfs.c +3 -3
@@ -75,7 +75,7 @@ static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr,struct bat_priv *bat_priv =netdev_priv (to_net_dev (dev));int aggr_status =atomic_read (&bat_priv->aggregation_enabled); -return sprintf (buff,"status: %s\ncommands: enable, disable, 0, 1 \n" , +return sprintf (buff,"status: %s\ncommands: enable, disable, 0, 1\n" , aggr_status ==0 ?"disabled" :"enabled" ); }
@@ -123,7 +123,7 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,struct bat_priv *bat_priv =netdev_priv (to_net_dev (dev));int vis_mode =atomic_read (&bat_priv->vis_mode); -return sprintf (buff,"status: %s\ncommands: client, server, %d, %d \n" , +return sprintf (buff,"status: %s\ncommands: client, server, %d, %d\n" , vis_mode ==VIS_TYPE_CLIENT_UPDATE ?"client" :"server" ,VIS_TYPE_SERVER_SYNC ,VIS_TYPE_CLIENT_UPDATE );
@@ -364,7 +364,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,if (!batman_if)return 0 ; -return sprintf (buff,"status: %s\ncommands: none, bat0 \n" , +return sprintf (buff,"status: %s\ncommands: none, bat0\n" , batman_if->if_status ==IF_NOT_IN_USE ?"none" :"bat0" ); }
Signature · 1 line
1.7.1
PATCH 19/26 staging:batman-adv: Reorganize sequence number handling
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
BATMAN and broadcast packets are tracked with a sequence number window of currently 64 entries to measure and avoid duplicates. Packets which have a sequence number smaller than the newest received packet minus 64 are not within this sequence number window anymore and are called "old packets" from now on.
When old packets are received, the routing code assumes that the host of the originator has been restarted. This assumption however might be wrong as packets can also be delayed by NIC drivers, e.g. because of long queues or collision detection in dense WiFi? environments. This behaviour can be reproduced by doing a broadcast ping flood in a dense node environment.
The effect is that the sequence number window is jumping forth and back, accepting and forwarding any packet (because packets are assumed to be "new") and causing loops.
To overcome this problem, the sequence number handling has been reorganized. When an old packet is received, the window is reset back only once. Other old packets are dropped for (currently) 30 seconds to "protect" the new sequence number and avoid the hopping as described above.
The reorganization brings some code cleanups (at least i hope you feel the same) and also fixes a bug in count_real_packets() which falsely updated the last_real_seqno for slightly older packets within the seqno window if they are no duplicates.
This second version of the patch also fixes a problem where for seq_diff==64 bit_shift() reads from outside of the seqno window, and removes the loop for seq_diff == -64 which was present in the first patch.
The third iteration also adds a window for the next expected sequence numbers. This minimizes sequence number flapping for packets with very big differences (e.g. 3 packets with seqno 0, 25000 and 50000 might still cause problems without this window).
--- drivers/staging/batman-adv/bitarray.c | 74 ++++++++++++++++------- drivers/staging/batman-adv/main.h | 4 + drivers/staging/batman-adv/originator.c | 2 + drivers/staging/batman-adv/routing.c | 99 +++++++++++++++++++++++-------- drivers/staging/batman-adv/types.h | 4 + 5 files changed, 136 insertions(+), 47 deletions(-)
drivers/staging/batman-adv/bitarray.c +51 -23
@@ -68,7 +68,7 @@ void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n)int32_t word_offset, word_num;int32_t i; -if (n <=0 ) +if (n <=0 || n >=TQ_LOCAL_WINDOW_SIZE )return ; word_offset = n %WORD_BIT_SIZE ;/* shift how much inside each word */
@@ -111,48 +111,76 @@ void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n) seq_bits[i] =0 ; } +static void bit_reset_window (TYPE_OF_WORD *seq_bits) +{ +int i; +for (i =0 ; i <NUM_WORDS ; i++) + seq_bits[i] =0 ; +} + -/* receive and process one packet, returns 1 if received seq_num is considered -* new, 0 if old */ +/* receive and process one packet within the sequence number window. +* +* returns: +* 1 if the window was moved (either new or very old) +* 0 if the window was not moved/shifted. +*/ char bit_get_packet (TYPE_OF_WORD *seq_bits,int16_t seq_num_diff,int8_t set_mark) { -int i; +/* sequence number is slightly older. We already got a sequence number +* higher than this one, so we just mark it. */ -/* we already got a sequence number higher than this one, so we just -* mark it. this should wrap around the integer just fine */ -if ((seq_num_diff <0 ) && (seq_num_diff >= -TQ_LOCAL_WINDOW_SIZE )) { +if ((seq_num_diff <=0 ) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE )) {if (set_mark)bit_mark (seq_bits, -seq_num_diff);return 0 ; } -/* it seems we missed a lot of packets or the other host restarted */ -if ((seq_num_diff >TQ_LOCAL_WINDOW_SIZE ) || - (seq_num_diff < -TQ_LOCAL_WINDOW_SIZE )) { +/* sequence number is slightly newer, so we shift the window and +* set the mark if required */ -if (seq_num_diff >TQ_LOCAL_WINDOW_SIZE ) -bat_dbg (DBG_BATMAN , -"We missed a lot of packets (%i) !\n" , - seq_num_diff-1 ); +if ((seq_num_diff >0 ) && (seq_num_diff <TQ_LOCAL_WINDOW_SIZE )) { +bit_shift (seq_bits, seq_num_diff); -if (-seq_num_diff >TQ_LOCAL_WINDOW_SIZE ) -bat_dbg (DBG_BATMAN , -"Other host probably restarted !\n" ); +if (set_mark) +bit_mark (seq_bits,0 ); +return 1 ; + } -for (i =0 ; i <NUM_WORDS ; i++) - seq_bits[i] =0 ; +/* sequence number is much newer, probably missed a lot of packets */ +if ((seq_num_diff >=TQ_LOCAL_WINDOW_SIZE ) + || (seq_num_diff <EXPECTED_SEQNO_RANGE )) { +bat_dbg (DBG_BATMAN , +"We missed a lot of packets (%i) !\n" , + seq_num_diff -1 ); +bit_reset_window (seq_bits);if (set_mark) - seq_bits[0 ] =1 ;/* we only have the latest packet */ - }else { -bit_shift (seq_bits, seq_num_diff); +bit_mark (seq_bits,0 ); +return 1 ; + } + +/* received a much older packet. The other host either restarted +* or the old packet got delayed somewhere in the network. The +* packet should be dropped without calling this function if the +* seqno window is protected. */ + +if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE ) + || (seq_num_diff >=EXPECTED_SEQNO_RANGE )) { +bat_dbg (DBG_BATMAN , +"Other host probably restarted!\n" ); + +bit_reset_window (seq_bits);if (set_mark)bit_mark (seq_bits,0 ); + +return 1 ; } -return 1 ; +/* never reached */ +return 0 ; }/* count the hamming weight, how many good packets did we receive? just count
drivers/staging/batman-adv/main.h +4 -0
@@ -61,6 +61,10 @@* forw_packet->direct_link_flags */ #define MAX_AGGREGATION_MS 100 +#define RESET_PROTECTION_MS 30000 +#define EXPECTED_SEQNO_RANGE 4096 +/* don't reset again within 30 seconds */ +#define MODULE_INACTIVE 0#define MODULE_ACTIVE 1#define MODULE_DEACTIVATING 2
drivers/staging/batman-adv/originator.c +2 -0
@@ -140,6 +140,8 @@ struct orig_node *get_orig_node(uint8_t *addr)memcpy (orig_node->orig, addr,ETH_ALEN ); orig_node->router =NULL ; orig_node->hna_buff =NULL ; + orig_node->bcast_seqno_reset = jiffies -msecs_to_jiffies (RESET_PROTECTION_MS ) -1 ; + orig_node->batman_seqno_reset = jiffies -msecs_to_jiffies (RESET_PROTECTION_MS ) -1 ; size = bat_priv->num_ifaces *sizeof (TYPE_OF_WORD ) *NUM_WORDS ;
drivers/staging/batman-adv/routing.c +75 -24
170 lines not on this page · raw message
drivers/staging/batman-adv/types.h +4 -0
@@ -55,6 +55,10 @@ struct orig_node { /* structure for orig_list maintaining nodes ofuint8_t tq_own;int tq_asym_penalty;unsigned long last_valid;/* when last packet from this node was received */ +unsigned long bcast_seqno_reset;/* time when the broadcast +seqno window was reset. */ +unsigned long batman_seqno_reset;/* time when the batman seqno +window was reset. */ /* uint8_t gwflags; * flags related to gateway functions: gateway class */ uint8_t flags;/* for now only VIS_SERVER flag. */ unsigned char *hna_buff;
Signature · 1 line
1.7.1
PATCH 20/26 staging:batman-adv: Limit queue lengths for batman and broadcast packets
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
This patch limits the queue lengths of batman and broadcast packets. BATMAN packets are held back for aggregation and jittered to avoid interferences. Broadcast packets are stored to be sent out multiple times to increase the probability to be received by other nodes in lossy environments.
Especially in extreme cases like broadcast storms, the queues have been seen to run full, eating up all the memory and triggering the infamous OOM killer. With the queue length limits introduced in this patch, this problem is avoided.
Each queue is limited to 256 entries for now, resulting in 1 MB of maximum space available in total for typical setups (assuming one packet including overhead does not require more than 2000 byte). This should also be reasonable for smaller routers, otherwise the defines can be tweaked later.
This third version of the patch does not increase the local broadcast sequence number when the queue is already full.
--- drivers/staging/batman-adv/aggregation.c | 16 ++++++++++++- drivers/staging/batman-adv/main.c | 5 ++++ drivers/staging/batman-adv/main.h | 4 +++ drivers/staging/batman-adv/send.c | 33 ++++++++++++++++++++++---- drivers/staging/batman-adv/send.h | 2 +- drivers/staging/batman-adv/soft-interface.c | 6 ++-- 6 files changed, 56 insertions(+), 10 deletions(-)
drivers/staging/batman-adv/aggregation.c +15 -1
@@ -95,6 +95,7 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,return false; } +#define atomic_dec_not_zero (v) atomic_add_unless((v), -1, 0)/* create a new aggregated packet and add this packet to it */ static void new_aggregated_packet(unsigned char *packet_buff, int packet_len,
@@ -106,13 +107,26 @@ static void new_aggregated_packet(unsigned char *packet_buff,struct forw_packet *forw_packet_aggr;unsigned long flags; +/* own packet should always be scheduled */ +if (!own_packet) { +if (!atomic_dec_not_zero (&batman_queue_left)) { +bat_dbg (DBG_BATMAN ,"batman packet queue full\n" ); +return ; + } + } + forw_packet_aggr =kmalloc (sizeof (struct forw_packet ),GFP_ATOMIC ); -if (!forw_packet_aggr) +if (!forw_packet_aggr) { +if (!own_packet) +atomic_inc (&batman_queue_left);return ; + } forw_packet_aggr->packet_buff =kmalloc (MAX_AGGREGATION_BYTES ,GFP_ATOMIC );if (!forw_packet_aggr->packet_buff) { +if (!own_packet) +atomic_inc (&batman_queue_left);kfree (forw_packet_aggr);return ; }
drivers/staging/batman-adv/main.c +5 -0
@@ -42,6 +42,9 @@ DEFINE_SPINLOCK(forw_bat_list_lock);DEFINE_SPINLOCK (forw_bcast_list_lock);atomic_t vis_interval; +atomic_t bcast_queue_left; +atomic_t batman_queue_left; +int16_t num_hna;struct net_device *soft_device;
@@ -79,6 +82,8 @@ int init_module(void)atomic_set (&vis_interval,1000 );/* TODO: raise this later, this is only * for debugging now. */ +atomic_set (&bcast_queue_left,BCAST_QUEUE_LEN ); +atomic_set (&batman_queue_left,BATMAN_QUEUE_LEN );/* the name should not be longer than 10 chars - see * http://lwn.net/Articles/23634/ */
drivers/staging/batman-adv/main.h +4 -0
@@ -69,6 +69,8 @@#define MODULE_ACTIVE 1#define MODULE_DEACTIVATING 2 +#define BCAST_QUEUE_LEN 256 +#define BATMAN_QUEUE_LE 256/* * Debug Messages
@@ -132,6 +134,8 @@ extern spinlock_t forw_bat_list_lock;extern spinlock_t forw_bcast_list_lock;extern atomic_t vis_interval; +extern atomic_t bcast_queue_left; +extern atomic_t batman_queue_left;extern int16_t num_hna;extern struct net_device *soft_device;
drivers/staging/batman-adv/send.c +28 -5
@@ -375,13 +375,28 @@ static void _add_bcast_packet_to_list(struct forw_packet *forw_packet, send_time); } -void add_bcast_packet_to_list (struct sk_buff *skb) +#define atomic_dec_not_zero (v) atomic_add_unless((v), -1, 0) +/* add a broadcast packet to the queue and setup timers. broadcast packets +* are sent multiple times to increase probability for beeing received. +* +* This function returns NETDEV_TX_OK on success and NETDEV_TX_BUSY on +* errors. +* +* The skb is not consumed, so the caller should make sure that the +* skb is freed. */ +int add_bcast_packet_to_list (struct sk_buff *skb) {struct forw_packet *forw_packet; +if (!atomic_dec_not_zero (&bcast_queue_left)) { +bat_dbg (DBG_BATMAN ,"bcast packet queue full\n" ); + goto out; + } + forw_packet =kmalloc (sizeof (struct forw_packet ),GFP_ATOMIC ); +if (!forw_packet) - goto out; + goto out_and_inc; skb =skb_copy (skb,GFP_ATOMIC );if (!skb)
@@ -396,12 +411,14 @@ void add_bcast_packet_to_list(struct sk_buff *skb) forw_packet->num_packets =0 ;_add_bcast_packet_to_list (forw_packet,1 ); -return ; +return NETDEV_TX_OK ; packet_free:kfree (forw_packet); +out_and_inc: +atomic_inc (&bcast_queue_left); out: -return ; +return NETDEV_TX_BUSY ; }void send_outstanding_bcast_packet (struct work_struct *work)
@@ -436,8 +453,10 @@ void send_outstanding_bcast_packet(struct work_struct *work)if ((forw_packet->num_packets <3 ) && (atomic_read (&module_state) !=MODULE_DEACTIVATING ))_add_bcast_packet_to_list (forw_packet, ((5 *HZ ) /1000 )); -else +else {forw_packet_free (forw_packet); +atomic_inc (&bcast_queue_left); + } }void send_outstanding_bat_packet (struct work_struct *work)
@@ -463,6 +482,10 @@ void send_outstanding_bat_packet(struct work_struct *work) (atomic_read(&module_state) != MODULE_DEACTIVATING))schedule_own_packet (forw_packet->if_incoming); +/* don't count own packet */ +if (!forw_packet->own) +atomic_inc (&batman_queue_left); +forw_packet_free (forw_packet); }
drivers/staging/batman-adv/send.h +1 -1
@@ -33,7 +33,7 @@ void schedule_forward_packet(struct orig_node *orig_node,struct batman_packet *batman_packet, uint8_t directlink, int hna_buff_len, struct batman_if *if_outgoing); -void add_bcast_packet_to_list (struct sk_buff *skb); +int add_bcast_packet_to_list (struct sk_buff *skb);void send_outstanding_bcast_packet (struct work_struct *work);void send_outstanding_bat_packet (struct work_struct *work);void purge_outstanding_packets (struct batman_if *batman_if);
drivers/staging/batman-adv/soft-interface.c +3 -3
@@ -216,10 +216,10 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)/* set broadcast sequence number */ bcast_packet->seqno =htons (bcast_seqno); - bcast_seqno++; +/* broadcast packet. on success, increase seqno. */ +if (add_bcast_packet_to_list (skb) ==NETDEV_TX_OK ) + bcast_seqno++; -/* broadcast packet */ -add_bcast_packet_to_list (skb);/* a copy is stored in the bcast list, therefore removing * the original skb. */ kfree_skb (skb);
Signature · 1 line
1.7.1
PATCH 21/26 staging:batman-adv: kfree_skb() in interface_tx() in error case
In reply to Andrew LunnFrom: Simon Wunderlich <[email protected]>
As we always return that the we consumed the skb, we should also free the skb in the case of an error.
--- drivers/staging/batman-adv/soft-interface.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/staging/batman-adv/soft-interface.c +1 -0
@@ -275,6 +275,7 @@ unlock:spin_unlock_irqrestore (&orig_hash_lock, flags); dropped: priv->stats.tx_dropped++; +kfree_skb (skb); end:return NETDEV_TX_OK ; }
Signature · 1 line
1.7.1
PATCH 22/26 staging:batman-adv: Update pointer to ethhdr after skb_copy
In reply to Andrew LunnFrom: Sven Eckelmann <[email protected]>
We must ensure that all pointer to a socket buffer are updated when we copy a socket buffer and free our reference to the old one. Another part of the kernel could also free its reference which maybe removes the buffer completely. In that situation we would would feed wrong information to the routing algorithm after the memory area is written again by someone else.
--- drivers/staging/batman-adv/routing.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-)
drivers/staging/batman-adv/routing.c +12 -6
@@ -614,6 +614,7 @@ int recv_bat_packet(struct sk_buff *skb, skb =skb_copy (skb,GFP_ATOMIC );if (!skb)return NET_RX_DROP ; + ethhdr = (struct ethhdr *)skb_mac_header (skb);kfree_skb (skb_old); }
@@ -639,8 +640,8 @@ static int recv_my_icmp_packet(struct sk_buff *skb)unsigned long flags;uint8_t dstaddr[ETH_ALEN ]; - icmp_packet = (struct icmp_packet *) skb->data; - ethhdr = (struct ethhdr *)skb_mac_header (skb); + icmp_packet = (struct icmp_packet *)skb->data; + ethhdr = (struct ethhdr *)skb_mac_header (skb);/* add data to device queue */ if (icmp_packet->msg_type !=ECHO_REQUEST ) {
@@ -671,7 +672,9 @@ static int recv_my_icmp_packet(struct sk_buff *skb) skb =skb_copy (skb,GFP_ATOMIC );if (!skb)return NET_RX_DROP ; - icmp_packet = (struct icmp_packet *) skb->data; + + icmp_packet = (struct icmp_packet *)skb->data; + ethhdr = (struct ethhdr *)skb_mac_header (skb);kfree_skb (skb_old); }
@@ -732,6 +735,7 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb)if (!skb)return NET_RX_DROP ; icmp_packet = (struct icmp_packet *) skb->data; + ethhdr = (struct ethhdr *)skb_mac_header (skb);kfree_skb (skb_old); }
@@ -780,7 +784,7 @@ int recv_icmp_packet(struct sk_buff *skb)if (!is_my_mac (ethhdr->h_dest))return NET_RX_DROP ; - icmp_packet = (struct icmp_packet *) skb->data; + icmp_packet = (struct icmp_packet *)skb->data;/* packet for me */ if (is_my_mac (icmp_packet->dst))
@@ -812,7 +816,8 @@ int recv_icmp_packet(struct sk_buff *skb) skb =skb_copy (skb,GFP_ATOMIC );if (!skb)return NET_RX_DROP ; - icmp_packet = (struct icmp_packet *) skb->data; + icmp_packet = (struct icmp_packet *)skb->data; + ethhdr = (struct ethhdr *)skb_mac_header (skb);kfree_skb (skb_old); }
@@ -895,7 +900,8 @@ int recv_unicast_packet(struct sk_buff *skb) skb =skb_copy (skb,GFP_ATOMIC );if (!skb)return NET_RX_DROP ; - unicast_packet = (struct unicast_packet *) skb->data; + unicast_packet = (struct unicast_packet *)skb->data; + ethhdr = (struct ethhdr *)skb_mac_header (skb);kfree_skb (skb_old); }/* decrement ttl */
Signature · 1 line
1.7.1
PATCH 23/26 staging:batman-adv: Update TODO file to reflect current state.
In reply to Andrew LunnNot much left to do on the TODO list :-)
--- drivers/staging/batman-adv/TODO | 23 +++-------------------- 1 files changed, 3 insertions(+), 20 deletions(-)
drivers/staging/batman-adv/TODO +3 -20
@@ -1,23 +1,6 @@ -=> proc interface -* implement new interface to add/delete interfaces and setting options -* /proc/sys/net/batman-adv/ as main folder -* in interfaces/ list every available interface of the host -* each interfaces/$iface/ contains the following files: --> enable (def: 0) [add/remove this interface to batman-adv] --> ogm_interval (def: 1000) [ogm interval of that interface] --> context (def: bat0) [later we want to support multiple mesh instances via --> bat0/bat1/bat2/..] --> status (read-only) [outputs the interface status from batman's --> perspective] -* in mesh/batX/ list every available mesh subnet --> vis_server (def: 0) [enable/disable vis server for that mesh] --> vis_data (read-only) [outputs the vis data in a raw format] --> aggregate_ogm (def: 1) [enable/disable ogm aggregation for that mesh] --> originators (read-only) [outputs the originator table] --> transtable_global (read-only) [outputs the global translation table] --> transtable_local (read-only) [outputs the local translation table] - -=> fix checkpatch.pl errors +Request a review. +Process the comments from the review. +Move into mainline proper. Please send all patches to: Marek Lindner <[email protected]>
Signature · 1 line
1.7.1
PATCH 24/26 staging:batman-adv: Fix whitespace problems criticized by checkpatch.pl
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
Trailing spaces at the end of a line or before a tab are against Documentation/CodingStyle "3.1: Spaces" and should be avoided. It is also common style to add a single space after commas unless it is followed either by a newline or a tab.
--- drivers/staging/batman-adv/main.h | 2 +- drivers/staging/batman-adv/originator.c | 4 ++-- drivers/staging/batman-adv/types.h | 3 +-- drivers/staging/batman-adv/vis.c | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-)
drivers/staging/batman-adv/main.h +1 -1
@@ -70,7 +70,7 @@#define MODULE_DEACTIVATING 2#define BCAST_QUEUE_LEN 256 -#define BATMAN_QUEUE_LE 256 +#define BATMAN_QUEUE_LEN 256/* * Debug Messages
drivers/staging/batman-adv/originator.c +2 -2
@@ -297,7 +297,7 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,rcu_read_lock (); hdr_len = sprintf(buff, - " %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n", + " %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR, bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
@@ -354,7 +354,7 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,if ((batman_count ==0 ) && (off ==0 )) bytes_written +=sprintf (buff + bytes_written, -"No batman nodes in range ... \n" ); +"No batman nodes in range ...\n" );return bytes_written; }
drivers/staging/batman-adv/types.h +1 -2
@@ -59,8 +59,7 @@ struct orig_node { /* structure for orig_list maintaining nodes ofseqno window was reset. */ unsigned long batman_seqno_reset;/* time when the batman seqno window was reset. */ -/* uint8_t gwflags; * flags related to gateway functions: gateway class */ -uint8_t flags;/* for now only VIS_SERVER flag. */ +uint8_t flags;/* for now only VIS_SERVER flag. */ unsigned char *hna_buff;int16_t hna_buff_len;uint16_t last_real_seqno;/* last and best known squence number */
drivers/staging/batman-adv/vis.c +1 -1
@@ -40,7 +40,7 @@* when adding 128 - it is neither a predecessor nor a successor, * after adding more than 127 to the starting value - it is a successor */ #define seq_before (x, y) ({typeof(x) _dummy = (x - y); \ - _dummy > smallest_signed_int(_dummy); }) + _dummy > smallest_signed_int(_dummy); })#define seq_after (x, y) seq_before(y, x)struct hashtable_t *vis_hash;
Signature · 1 line
1.7.1
PATCH 25/26 staging:batman-adv: Reduce max characters on a line to 80
In reply to Andrew LunnFrom: Marek Lindner <[email protected]>
Documentation/CodingStyle sets a strongly prefered limit of 80 characters per line in "Chapter 2: Breaking long lines and strings".
Strings must be broken into smaller parts and long statements must be rewritten.
--- drivers/staging/batman-adv/device.c | 22 +++++++--- drivers/staging/batman-adv/hard-interface.c | 20 ++++++--- drivers/staging/batman-adv/main.c | 17 +++++--- drivers/staging/batman-adv/main.h | 3 +- drivers/staging/batman-adv/originator.c | 47 ++++++++++++------- drivers/staging/batman-adv/routing.c | 57 +++++++++++++++++------ drivers/staging/batman-adv/send.c | 21 +++++--- drivers/staging/batman-adv/soft-interface.c | 8 ++- drivers/staging/batman-adv/translation-table.c | 34 +++++++++----- drivers/staging/batman-adv/types.h | 45 +++++++++++++----- 10 files changed, 186 insertions(+), 88 deletions(-)
drivers/staging/batman-adv/device.c +16 -6
@@ -57,7 +57,8 @@ int bat_device_setup(void)/* register our device - kernel assigns a free major number */ tmp_major =register_chrdev (0 ,DRIVER_DEVICE , &fops);if (tmp_major <0 ) { -printk (KERN_ERR "batman-adv:Registering the character device failed with %d\n" , +printk (KERN_ERR "batman-adv:" +"Registering the character device failed with %d\n" , tmp_major);return 0 ; }
@@ -65,7 +66,8 @@ int bat_device_setup(void) batman_class =class_create (THIS_MODULE ,"batman-adv" );if (IS_ERR (batman_class)) { -printk (KERN_ERR "batman-adv:Could not register class 'batman-adv'\n" ); +printk (KERN_ERR "batman-adv:" +"Could not register class 'batman-adv'\n" );return 0 ; }
@@ -108,7 +110,9 @@ int bat_device_open(struct inode *inode, struct file *file) }if (i ==ARRAY_SIZE (device_client_hash)) { -printk (KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n" ); +printk (KERN_ERR "batman-adv:" +"Error - can't add another packet client: " +"maximum number of clients reached\n" );kfree (device_client);return -EXFULL ; }
@@ -209,7 +213,9 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,unsigned long flags;if (len <sizeof (struct icmp_packet )) { -bat_dbg (DBG_BATMAN ,"batman-adv:Error - can't send packet from char device: invalid packet size\n" ); +bat_dbg (DBG_BATMAN ,"batman-adv:" +"Error - can't send packet from char device: " +"invalid packet size\n" );return -EINVAL ; }
@@ -220,12 +226,16 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,return -EFAULT ;if (icmp_packet.packet_type !=BAT_ICMP ) { -bat_dbg (DBG_BATMAN ,"batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n" ); +bat_dbg (DBG_BATMAN ,"batman-adv:" +"Error - can't send packet from char device: " +"got bogus packet type (expected: BAT_ICMP)\n" );return -EINVAL ; }if (icmp_packet.msg_type !=ECHO_REQUEST ) { -bat_dbg (DBG_BATMAN ,"batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n" ); +bat_dbg (DBG_BATMAN ,"batman-adv:" +"Error - can't send packet from char device: " +"got bogus message type (expected: ECHO_REQUEST)\n" );return -EINVAL ; }
drivers/staging/batman-adv/hard-interface.c +14 -6
@@ -149,9 +149,12 @@ static void check_known_mac_addr(uint8_t *addr)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" ); +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" ); }rcu_read_unlock (); }
@@ -242,7 +245,8 @@ int hardif_enable_interface(struct batman_if *batman_if) 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" , +printk (KERN_ERR "batman-adv:" +"Can't add interface packet (%s): out of memory\n" , batman_if->dev); goto err; }
@@ -266,7 +270,10 @@ int hardif_enable_interface(struct batman_if *batman_if)if (hardif_is_iface_up (batman_if))hardif_activate_interface (bat_priv, batman_if);else -printk (KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n" , batman_if->dev); +printk (KERN_ERR "batman-adv:" +"Not using interface %s " +"(retrying later): interface not active\n" , + batman_if->dev);/* begin scheduling originator messages on that interface */ schedule_own_packet (batman_if);
@@ -316,7 +323,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev) 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" , +printk (KERN_ERR "batman-adv:" +"Can't add interface (%s): out of memory\n" , net_dev->name); goto out; }
drivers/staging/batman-adv/main.c +11 -6
@@ -99,14 +99,16 @@ int init_module(void) interface_setup);if (!soft_device) { -printk (KERN_ERR "batman-adv:Unable to allocate the batman interface\n" ); +printk (KERN_ERR "batman-adv:" +"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); +printk (KERN_ERR "batman-adv:" +"Unable to register the batman interface: %i\n" , retval); goto free_soft_device; }
@@ -118,8 +120,9 @@ int init_module(void)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 ); +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 );return 0 ;
@@ -176,7 +179,9 @@ void activate_module(void) goto end; err: -printk (KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n" ); +printk (KERN_ERR "batman-adv:" +"Unable to allocate memory for mesh information structures: " +"out of mem ?\n" );deactivate_module (); end:return ;
@@ -218,7 +223,7 @@ void dec_module_count(void)int addr_to_string (char *buff,uint8_t *addr) { -return sprintf (buff,"%02x:%02x:%02x:%02x:%02x:%02x" , +return sprintf (buff,MAC_FMT , addr[0 ], addr[1 ], addr[2 ], addr[3 ], addr[4 ], addr[5 ]); }
drivers/staging/batman-adv/main.h +2 -1
@@ -22,7 +22,8 @@/* Kernel Programming */ #define LINUX -#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, Simon Wunderlich <[email protected]>" +#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, " \ + "Simon Wunderlich <[email protected]>"#define DRIVER_DESC "B.A.T.M.A.N. advanced"#define DRIVER_DEVICE "batman-adv"
drivers/staging/batman-adv/originator.c +29 -18
100 lines not on this page · raw message
drivers/staging/batman-adv/routing.c +42 -15
136 lines not on this page · raw message
drivers/staging/batman-adv/send.c +13 -8
@@ -65,7 +65,8 @@ int send_skb_packet(struct sk_buff *skb,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-adv:Interface %s " +"is not up - can't send packet via that interface!\n" , batman_if->dev); goto send_skb_err; }
@@ -148,9 +149,9 @@ static void send_packet_to_if(struct forw_packet *forw_packet, "Sending own" : "Forwarding")); bat_dbg(DBG_BATMAN, - "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) on interface %s [%s]\n", - fwd_str, - (packet_num > 0 ? "aggregated " : ""), + "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d," + " IDF %s) on interface %s [%s]\n", + fwd_str, (packet_num > 0 ? "aggregated " : ""), batman_packet->orig, ntohs(batman_packet->seqno), batman_packet->tq, batman_packet->ttl, (batman_packet->flags & DIRECTLINK ?
@@ -178,7 +179,8 @@ static void send_packet(struct forw_packet *forw_packet)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" ); +printk (KERN_ERR "batman-adv: Error - can't forward packet: " +"incoming iface not specified\n" );return ; }
@@ -192,7 +194,8 @@ static void send_packet(struct forw_packet *forw_packet)/* FIXME: what about aggregated packets ? */ bat_dbg(DBG_BATMAN, - "%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%s]\n", + "%s packet (originator %pM, seqno %d, TTL %d) " + "on interface %s [%s]\n", (forw_packet->own ? "Sending own" : "Forwarding"), batman_packet->orig, ntohs(batman_packet->seqno), batman_packet->ttl, forw_packet->if_incoming->dev,
@@ -322,7 +325,8 @@ void schedule_forward_packet(struct orig_node *orig_node, batman_packet->tq = orig_node->router->tq_avg;if (orig_node->router->last_ttl) - batman_packet->ttl = orig_node->router->last_ttl -1 ; + batman_packet->ttl = orig_node->router->last_ttl + -1 ; } tq_avg = orig_node->router->tq_avg;
@@ -331,7 +335,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, tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n" , +bat_dbg (DBG_BATMAN ,"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);
drivers/staging/batman-adv/soft-interface.c +5 -3
@@ -237,6 +237,8 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)if ((orig_node) && (orig_node->router)) { +struct neigh_node *router = orig_node->router; +if (my_skb_push (skb,sizeof (struct unicast_packet )) <0 ) goto unlock;
@@ -251,14 +253,14 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)memcpy (unicast_packet->dest, orig_node->orig,ETH_ALEN );/* net_dev won't be available when not active */ -if (orig_node->router->if_incoming->if_status !=IF_ACTIVE ) +if (router->if_incoming->if_status !=IF_ACTIVE ) goto unlock;/* don't lock while sending the packets ... we therefore * copy the required data before sending */ - batman_if = orig_node->router->if_incoming; -memcpy (dstaddr, orig_node->router->addr,ETH_ALEN ); + batman_if = router->if_incoming; +memcpy (dstaddr, router->addr,ETH_ALEN );spin_unlock_irqrestore (&orig_hash_lock, flags);send_skb_packet (skb, batman_if, dstaddr);
drivers/staging/batman-adv/translation-table.c +22 -12
@@ -77,7 +77,10 @@ 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 ,"Can't add new local hna entry (%pM): number of local hna entries exceeds packet size\n" , addr); +bat_dbg (DBG_ROUTES , +"Can't add new local hna entry (%pM): " +"number of local hna entries exceeds packet size\n" , + addr);return ; }
@@ -108,7 +111,8 @@ void hna_local_add(uint8_t *addr) hna_local_hash->size * 2);if (swaphash ==NULL ) -printk (KERN_ERR "batman-adv:Couldn't resize local hna hash table\n" ); +printk (KERN_ERR "batman-adv:" +"Couldn't resize local hna hash table\n" );else hna_local_hash = swaphash; }
@@ -169,14 +173,16 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,if (!bat_priv->primary_if) {if (off ==0 )return sprintf (buff, -"BATMAN mesh %s disabled - please specify interfaces to enable it\n" , - net_dev->name); +"BATMAN mesh %s disabled - " +"please specify interfaces to enable it\n" , + net_dev->name);return 0 ; } hdr_len =sprintf (buff, -"Locally retrieved addresses (from %s) announced via HNA:\n" , +"Locally retrieved addresses (from %s) " +"announced via HNA:\n" , net_dev->name);if (off < hdr_len)
@@ -196,7 +202,7 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, hna_local_entry = hashit.bucket->data; bytes_written += snprintf(buff + bytes_written, 22, - " * %02x:%02x:%02x:%02x:%02x:%02x\n", + " * " MAC_FMT "\n", hna_local_entry->addr[0], hna_local_entry->addr[1], hna_local_entry->addr[2],
@@ -317,7 +323,8 @@ void hna_global_add_orig(struct orig_node *orig_node,memcpy (hna_global_entry->addr, hna_ptr,ETH_ALEN );bat_dbg (DBG_ROUTES , -"Creating new global hna entry: %pM (via %pM)\n" , +"Creating new global hna entry: " +"%pM (via %pM)\n" , hna_global_entry->addr, orig_node->orig);spin_lock_irqsave (&hna_global_hash_lock, flags);
@@ -362,7 +369,8 @@ void hna_global_add_orig(struct orig_node *orig_node, hna_global_hash->size * 2);if (swaphash ==NULL ) -printk (KERN_ERR "batman-adv:Couldn't resize global hna hash table\n" ); +printk (KERN_ERR "batman-adv:" +"Couldn't resize global hna hash table\n" );else hna_global_hash = swaphash; }
@@ -383,14 +391,16 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,if (!bat_priv->primary_if) {if (off ==0 )return sprintf (buff, -"BATMAN mesh %s disabled - please specify interfaces to enable it\n" , - net_dev->name); +"BATMAN mesh %s disabled - " +"please specify interfaces to enable it\n" , + net_dev->name);return 0 ; } hdr_len =sprintf (buff, -"Globally announced HNAs received via the mesh %s (translation table):\n" , +"Globally announced HNAs received via the mesh %s " +"(translation table):\n" , net_dev->name);if (off < hdr_len)
@@ -410,7 +420,7 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, hna_global_entry = hashit.bucket->data; bytes_written += snprintf(buff + bytes_written, 44, - " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x\n", + " * " MAC_FMT " via " MAC_FMT "\n", hna_global_entry->addr[0], hna_global_entry->addr[1], hna_global_entry->addr[2],
drivers/staging/batman-adv/types.h +32 -13
81 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 26/26 staging:batman-adv: updating README
In reply to Andrew Lunn--- drivers/staging/batman-adv/README | 275 +++++++++++++++++++++++-------------- 1 files changed, 173 insertions(+), 102 deletions(-)
drivers/staging/batman-adv/README +173 -102
@@ -1,169 +1,240 @@ -[state: 22-03-2010] +[state: 03-05-2010] BATMAN-ADV ---------- -Batman-advanced is a new approach to wireless networking which does no longer -operate on the IP basis. Unlike B.A.T.M.A.N, which exchanges information -using UDP packets and sets routing tables, batman-advanced operates on ISO/OSI -Layer 2 only and uses and routes (or better: bridges) Ethernet Frames. It -emulates a virtual network switch of all nodes participating. Therefore all -nodes appear to be link local, thus all higher operating protocols won't be -affected by any changes within the network. You can run almost any protocol -above B.A.T.M.A.N. Advanced, prominent examples are: IPv4, IPv6, DHCP, IPX. +Batman advanced is a new approach to wireless networking which +does no longer operate on the IP basis. Unlike the batman daemon, +which exchanges information using UDP packets and sets routing +tables, batman-advanced operates on ISO/OSI Layer 2 only and uses +and routes (or better: bridges) Ethernet Frames. It emulates a +virtual network switch of all nodes participating. Therefore all +nodes appear to be link local, thus all higher operating proto- +cols won't be affected by any changes within the network. You can +run almost any protocol above batman advanced, prominent examples +are: IPv4, IPv6, DHCP, IPX. -This is batman-advanced implemented as Linux kernel driver. It does not depend -on any network (other) driver, and can be used on wifi as well as ethernet, -vpn, etc ... (anything with ethernet-style layer 2). +Batman advanced was implemented as a Linux kernel driver to re- +duce the overhead to a minimum. It does not depend on any (other) +network driver, and can be used on wifi as well as ethernet lan, +vpn, etc ... (anything with ethernet-style layer 2). -USAGE ------ +CONFIGURATION +------------- -insmod the batman-adv.ko in your kernel: +Load the batman-adv module into your kernel: # insmod batman-adv.ko -the module is now waiting for activation. You must add some interfaces -on which batman can operate. Each interface must be added separately: +The module is now waiting for activation. You must add some in- +terfaces on which batman can operate. After loading the module +batman advanced will scan your systems interfaces to search for +compatible interfaces. Once found, it will create subfolders in +the /sys directories of each supported interface, e.g. -# echo wlan0 > /proc/net/batman-adv/interfaces +# ls /sys/class/net/eth0/batman_adv/ +# iface_status mesh_iface -( # echo wlan1 > /proc/net/batman-adv/interfaces ) -( # echo eth0 > /proc/net/batman-adv/interfaces ) -( ... ) +If an interface does not have the "batman_adv" subfolder it prob- +ably is not supported. Not supported interfaces are: loopback, +non-ethernet and batman's own interfaces. -Now batman starts broadcasting on this interface. -You can now view the table of originators (mesh participants) with: +Note: After the module was loaded it will continuously watch for +new interfaces to verify the compatibility. There is no need to +reload the module if you plug your USB wifi adapter into your ma- +chine after batman advanced was initially loaded. -# cat /proc/net/batman-adv/originators +To activate a given interface simply write "bat0" into its +"mesh_iface" file inside the batman_adv subfolder: -The module will create a new interface "bat0", which can be used as a -regular interface: +# echo bat0 > /sys/class/net/eth0/batman_adv/mesh_iface -# ifconfig bat0 inet 192.168.0.1 up -# ping 192.168.0.2 -... +Repeat this step for all interfaces you wish to add. Now batman +starts using/broadcasting on this/these interface(s). ---- -If you want topology visualization, your meshnode must be configured -as VIS-server: +By reading the "iface_status" file you can check its status: -# echo "server" > /proc/net/batman-adv/vis_server +# cat /sys/class/net/eth0/batman_adv/iface_status +# active -Each node is either configured as "server" or as "client" (default: -"client"). Clients send their topology data to the server next to them, -and server synchronize with other servers. If there is no server -configured (default) within the mesh, no topology information will be -transmitted. With these "synchronizing servers", there can be 1 or -more vis servers sharing the same (or at least very similar) data. +To deactivate an interface you have to write "none" into its +"mesh_iface" file: -When configured as server, you can get a topology snapshot of your mesh: +# echo none > /sys/class/net/eth0/batman_adv/mesh_iface -# cat /proc/net/batman-adv/vis_data -This raw output is intended to be easily parsable and convertable with -other tools. Have a look at the batctl README if you want a vis output -in dot or json format for instance and how those outputs could then be -visualised in an image. +All mesh wide settings can be found in batman's own interface +folder: + +# ls /sys/class/net/bat0/mesh/ +# aggregate_ogm originators transtable_global vis_mode +# orig_interval transtable_local vis_data + + +Some of the files contain all sort of status information regard- +ing the mesh network. For example, you can view the table of +originators (mesh participants) with: + +# cat /sys/class/net/bat0/mesh/originators + +Other files allow to change batman's behaviour to better fit your +requirements. For instance, you can check the current originator +interval (value in milliseconds which determines how often batman +sends its broadcast packets): + +# cat /sys/class/net/bat0/mesh/orig_interval +# status: 1000 + +and also change its value: + +# echo 3000 > /sys/class/net/bat0/mesh/orig_interval -The raw format consists of comma seperated values per entry where each -entry is giving information about a certain source interface. Each entry -can/has to have the following values: --> "mac" -> mac address of an originator's source interface - (each line begins with it) --> "TQ mac value" -> src mac's link quality towards mac address of a neighbor - originator's interface which is being used for routing --> "HNA mac" -> HNA announced by source mac --> "PRIMARY" -> this is a primary interface --> "SEC mac" -> secondary mac address of source (requires preceeding --> PRIMARY) - -The TQ value has a range from 4 to 255 with 255 being the best. -The HNA entries are showing which hosts are connected to the mesh via bat0 -or being bridged into the mesh network. -The PRIMARY/SEC values are only applied on primary interfaces - ---- In very mobile scenarios, you might want to adjust the originator -interval to a lower value. This will make the mesh more responsive to -topology changes, but will also increase the overhead. Please make sure -that all nodes in your mesh use the same interval. The default value -is 1000 ms (1 second). +interval to a lower value. This will make the mesh more respon- +sive to topology changes, but will also increase the overhead. + + +USAGE +----- + +To make use of your newly created mesh, batman advanced provides +a new interface "bat0" which you should use from this point on. +All interfaces added to batman advanced are not relevant any +longer because batman handles them for you. Basically, one "hands +over" the data by using the batman interface and batman will make +sure it reaches its destination. -# echo 1000 > /proc/net/batman-adv/orig_interval +The "bat0" interface can be used like any other regular inter- +face. It needs an IP address which can be either statically con- +figured or dynamically (by using DHCP or similar services): -To deactivate batman, do: +# NodeA: ifconfig bat0 192.168.0.1 +# NodeB: ifconfig bat0 192.168.0.2 +# NodeB: ping 192.168.0.1 + +Note: In order to avoid problems remove all IP addresses previ- +ously assigned to interfaces now used by batman advanced, e.g. + +# ifconfig eth0 0.0.0.0 + + +VISUALIZATION +------------- + +If you want topology visualization, at least one mesh node must +be configured as VIS-server: + +# echo "server" > /sys/class/net/bat0/mesh/vis_mode + +Each node is either configured as "server" or as "client" (de- +fault: "client"). Clients send their topology data to the server +next to them, and server synchronize with other servers. If there +is no server configured (default) within the mesh, no topology +information will be transmitted. With these "synchronizing +servers", there can be 1 or more vis servers sharing the same (or +at least very similar) data. + +When configured as server, you can get a topology snapshot of +your mesh: + +# cat /sys/class/net/bat0/mesh/vis_data + +This raw output is intended to be easily parsable and convertable +with other tools. Have a look at the batctl README if you want a +vis output in dot or json format for instance and how those out- +puts could then be visualised in an image. + +The raw format consists of comma separated values per entry where +each entry is giving information about a certain source inter- +face. Each entry can/has to have the following values: +-> "mac" - mac address of an originator's source interface + (each line begins with it) +-> "TQ mac value" - src mac's link quality towards mac address + of a neighbor originator's interface which + is being used for routing +-> "HNA mac" - HNA announced by source mac +-> "PRIMARY" - this is a primary interface +-> "SEC mac" - secondary mac address of source + (requires preceding PRIMARY) + +The TQ value has a range from 4 to 255 with 255 being the best. +The HNA entries are showing which hosts are connected to the mesh +via bat0 or being bridged into the mesh network. The PRIMARY/SEC +values are only applied on primary interfaces -# echo "" > /proc/net/batman-adv/interfaces LOGGING/DEBUGGING ----------------- -All error messages, warnings and information messages are sent to the -kernel log. Depending on your operating system distribution this can be -read in one of a number of ways. Try using the commands: dmesg, -logread, or looking in the files /var/log/kern.log or -/var/log/syslog. All batman-adv messages are prefixed with +All error messages, warnings and information messages are sent to +the kernel log. Depending on your operating system distribution +this can be read in one of a number of ways. Try using the com- +mands: dmesg, logread, or looking in the files /var/log/kern.log +or /var/log/syslog. All batman-adv messages are prefixed with "batman-adv:" So to see just these messages try -dmesg | grep batman-adv +# dmesg | grep batman-adv -When investigating problems with your mesh network it is sometimes -necessary to see more detail debug messages. This must be enabled when -compiling the batman-adv module. Use "make menuconfig" and enable the +When investigating problems with your mesh network it is some- +times necessary to see more detail debug messages. This must be +enabled when compiling the batman-adv module. When building bat- +man-adv as part of kernel, use "make menuconfig" and enable the option "B.A.T.M.A.N. debugging". -The additional debug output is by default disabled. It can be enabled -either at kernel module load time or during run time. To enable debug -output at module load time, add the module parameter debug=<value>. -<value> can take one of four values. +The additional debug output is by default disabled. It can be en- +abled either at kernel modules load time or during run time. To +enable debug output at module load time, add the module parameter +debug=<value>. <value> can take one of four values. -0 - All debug output disabled +0 - All debug output disabled 1 - Enable messages related to routing / flooding / broadcasting 2 - Enable route or hna added / changed / deleted 3 - Enable all messages e.g. -modprobe batman-adv debug=2 +# modprobe batman-adv debug=2 -will load the module and enable debug messages for when routes or HNAs -change. +will load the module and enable debug messages for when routes or +HNAs change. -The debug output can also be changed at runtime using the file +The debug output can also be changed at runtime using the file /sys/module/batman-adv/parameters/debug. e.g. -echo 2 > /sys/module/batman-adv/parameters/debug +# echo 2 > /sys/module/batman-adv/parameters/debug enables debug messages for when routes or HNAs -The debug output is sent to the kernel logs. So try dmesg, logread etc -to see the debug messages. +The debug output is sent to the kernel logs. So try dmesg, lo- +gread, etc to see the debug messages. + BATCTL ------ -B.A.T.M.A.N. advanced operates on layer 2 and thus all hosts -participating in the virtual switch are completely transparent for all -protocols above layer 2. Therefore the common diagnosis tools do not -work as expected. To overcome these problems batctl was created. At -the moment the batctl contains ping, traceroute, tcpdump and +As batman advanced operates on layer 2 all hosts participating in +the virtual switch are completely transparent for all protocols +above layer 2. Therefore the common diagnosis tools do not work +as expected. To overcome these problems batctl was created. At +the moment the batctl contains ping, traceroute, tcpdump and interfaces to the kernel module settings. For more information, please see the manpage (man batctl). -batctl is available on http://www.open-mesh.net/ +batctl is available on http://www.open-mesh.org/ + CONTACT ------- Please send us comments, experiences, questions, anything :) -IRC: #batman on irc.freenode.org -Mailing-list: [email protected] -(subscription at https://list.open-mesh.net/mm/listinfo/b.a.t.m.a.n ) +IRC: #batman on irc.freenode.org +Mailing-list: [email protected] (optional subscription + at https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n) You can also contact the Authors: -Marek Lindner <[email protected]> -Simon Wunderlich <[email protected]> +Marek Lindner <[email protected]> +Simon Wunderlich <[email protected]> +
Signature · 1 line
1.7.1
Quoted 13 lines · Andrew Lunn
Marek Lindner (9):
staging:batman-adv: fix aggregation timing bug staging:batman-adv: fix whitespace style issues staging:batman-adv: convert multiple /proc files to use sysfs staging:batman-adv: convert more files from /proc to /sys staging:batman-adv: move originator interval setting from /proc to
/sys
staging:batman-adv: remove redundant pointer to originator interface staging:batman-adv: move /proc interface handling to /sys staging:batman-adv: Fix whitespace problems criticized by
checkpatch.pl
staging:batman-adv: Reduce max characters on a line to 80
Am I the only one who thinks that Marek takes credits for too many patches? Yes, we all have to praise him for his work, but just noticed those minor glitches:
* fix whitespace style issues
- work from Luis de Bethencourt <[email protected]>
* Fix whitespace problems criticized by
Reduce max characters on a line to 80
- work from me... somewhat
Not that I really want credit for those patches (maybe I should have submitted them under a different name.....), but that didn't happen in the past and now more than one time in a row. What happened here? git-am's fault?
And thanks to Andrew for the preparation and submission of that huge patchset. Some patches are missing the signed-off-by line from you or have typos inside that line. Maybe you can use git format-patch --signoff to get that automatically added if it is missing.
Best regards,
Sven
Quoted 9 lines · On Friday 07 May 2010 05:44:06 Sven Eckelmann wrote:
Am I the only one who thinks that Marek takes credits for too many patches? Yes, we all have to praise him for his work, but just noticed those minor glitches:
* fix whitespace style issues
- work from Luis de Bethencourt <[email protected]>
* Fix whitespace problems criticized by
Reduce max characters on a line to 80
- work from me... somewhat
Quoted 4 lines
Not that I really want credit for those patches (maybe I should have submitted them under a different name.....), but that didn't happen in the past and now more than one time in a row. What happened here? git-am's fault?
It seems there are a couple of patches wrong but I don't know how this initial credit list gets created. I had the impression the first "Signed-off-by" is the owner of a patch ?
Here is the complete list of incorrect assignments (as far as I can tell):
* Simon to Linus
=> [PATCH 07/26] staging:batman-adv: Remove dead max addr and obsoleteVIS_FORMAT strings
=> [PATCH 09/26] staging:batman-adv: Update README about vis raw output
* Marek to Luis
=> [PATCH 12/26] staging:batman-adv: fix whitespace style issues
* Marek to Mikal:
=> [PATCH 24/26] staging:batman-adv: Fix whitespace problems criticized by
checkpatch.pl
=> [PATCH 25/26] staging:batman-adv: Reduce max characters on a line to 80
Quoted 2 lines
And thanks to Andrew for the preparation and submission of that huge patchset.
Many thanks to all that helped making so much progress in that short time frame. The new TODO file looks awesome ! :-)
Regards,
Marek
Quoted 15 lines · Marek Lindner
Quoted 14 lines · On Friday 07 May 2010 05:44:06 Sven Eckelmann wrote:
Am I the only one who thinks that Marek takes credits for too many patches? Yes, we all have to praise him for his work, but just noticed those minor
glitches:
* fix whitespace style issues- work from Luis de Bethencourt <[email protected]>
* Fix whitespace problems criticized by
Reduce max characters on a line to 80
- work from me... somewhat
Quoted 8 lines
Quoted 4 lines
Not that I really want credit for those patches (maybe I should have submitted them under a different name.....), but that didn't happen in the past and now more than one time in a row. What happened here? git-am's fault?
It seems there are a couple of patches wrong but I don't know how this initial credit list gets created. I had the impression the first "Signed-off-by" is the owner of a patch ?
Ok, there seems to be a problem misunderstanding in what our "infrastructure" does. Let's see what svn does:
* svn does not have a field to store the complex information "Full Name <email@address>" for committer and author
* svn stores the username of the committer
So we get a commit in svn it must get somehow to our repository. We have a "translation and synchronisation" repository hidden in a private directory. We use git-svn there to fetch our data from svn and then push it to our public git repository into the master branch.
If you look at a specific commit using something likegit cat-file -p v0.2-59-g23a0a47 then you will see the committer and author information which is part of the metadata of a git commit and not really part of the actual commit message. An example would be:
tree 359ee2bfbc9ad702b9f6ef1649833793090244fe
parent 0024f65f2c6cc1765bc7034cf82b9dc2b7626630
author Daniel Seither <[email protected]> 1266335052 +0000 committer Marek Lindner <[email protected]> 1266335052 +0000
....
author is obviously the author of a patch/change. This is something which should not be changed by the person who applies the patch. Thereof we have also the committer part which shows who has applied the patch. The committer information is changed in many situations. A common one would be that someone cherry picks a patch from master to maint. In other words: we have enough information to thank the person for their contribution and to blame the person who applied in on the wrong branch. :)
So where do we get that information svn only stores the committer username? git-svn uses different information to gather such data. The first one is the a translation table statically defined by us. We use it to translate the svn committer to a something like "Marek Lindner <[email protected]>" in the git committer field. We still have the problem that the author isn't stored inside the svn commit... normally.
We defined that all commits in trunk/batman-adv-kernelland must have a valid 'Signed-off-by: ' line and must be submitted by an eligible committer (Simon or Marek). git-svn can now extract the first Signed-off-by-line to get the actual author information from a (special) svn commit..... Problem solved for svn to git translation.
So what does git-commit do here? Nothing real exciting. When a new commit is created (and not otherwise specified) then both author and committer fields get the same information fetched from ~/.gitconfig or an other configuration file. When we change a commit then only the committer field is updated.
So we have nothing like signed-off-by parsing in git-commit. There are some "tricks" described in the git-commit-tree manpage to supply such information directly - but that is nothing you really want to do for each patch.
The way patches get applied are using git-am. This program use(s|d?) internally git-mailinfo to extract important information from the patch. Lets use
"[PATCH 21/26] staging:batman-adv: kfree_skb() in interface_tx() in error case" for further explanations. We would normally just save that as file or in a mbox. Now just use git am FILENAME and everything should be parsed and committed. If not than you can try git am -3 FILENAME to try a 3-way merge - if it still not work than maybe it is the best idea to inform the patch author that he should resubmit the patch.
So what information is now extract? Lets call git-mailinfo with patch21.mbox (the patch mentioned above saved as mbox file).
git mailinfo msg patch < patch21.mbox > info
We have 3 new files. "msg" is the commit message, "patch" is a patch which can be applied using a normal patch program or git-apply and "info" - which is the extracted info we are interested in.
Author: Simon Wunderlich
Email: [email protected]
Subject: staging:batman-adv: kfree_skb() in interface_tx() in error case
Date: Thu, 6 May 2010 22:18:47 +0200
mailinfo has now the possibility to extract the From: line in the mail header
- this is the usual way. But Andrew submitted the patch instead of Simon. Thereof there is a second way to extract that information - the first 'From: ' line in the mail body. git-format-patch added this line because Andrew was not the author of the patch and git-mailinfo will strip this line again from the commit message.
We can see that the Signed-off-by line is not used at all in git-am or git- commit and that we must tools like git-am to get the correct author field in a commit when applying a patch. If you apply your patch with another tool than you must use git-commit differently (not explained here because I don't want to encourage people to it). So even if the Signed-off-by thing is more a social thing (read linux-2.6/Documentation/SubmittingPatches), it is still used in different scripts to find out who is responsible for a specific part of the kernel or similar things. We only use it here when getting patches from svn to translate them into git commits.
This "credit" list you saw here is more or less the thing you get when running git-shortlog. It just gathers the commits of all authors and shows a summary commit list for each author. "author" means here the author mentioned in the author field of the git commit. So it is not Andrews fault, but the committer has done something different than the above mentioned steps to get the commit applied in maint.
Best regards,
Sven
Quoted 15 lines · Sven Eckelmann
Quoted 13 lines · Andrew Lunn
Marek Lindner (9):
staging:batman-adv: fix aggregation timing bug staging:batman-adv: fix whitespace style issues staging:batman-adv: convert multiple /proc files to use sysfs staging:batman-adv: convert more files from /proc to /sys staging:batman-adv: move originator interval setting from /proc to
/sys
staging:batman-adv: remove redundant pointer to originator interface staging:batman-adv: move /proc interface handling to /sys staging:batman-adv: Fix whitespace problems criticized by
checkpatch.pl
staging:batman-adv: Reduce max characters on a line to 80
Quoted 1 line
Am I the only one who thinks that Marek takes credits for too many patches?
Sorry, i never thought about checking this.
I will have to track this backwards and see where it got the information from. It does not look like it is simply the first Signed-off-by. It is also possible i get something wrong when squashing patches together...
Quoted 3 lines
Some patches are missing the signed-off-by line from you or have typos inside that line. Maybe you can use
git format-patch --signoffto get that automatically added if it is missing.
Yes, i only found that after manually adding them... I should read the man pages from top to bottom and see what other useful flags i don't know about :-)
Andrew