1
0
Fork 0
Commit Graph

184 Commits (3d48749d93a3dce732dd30a14002ab90ec4355f3)

Author SHA1 Message Date
Antonio Quartulli 980d55b20a batman-adv: keep global table consistency in case of roaming
To keep consistency of other originator tables, new clients detected as
roamed, are kept in the global table but are marked as TT_CLIENT_PENDING
They are purged only when the new ttvn is received by the corresponding
originator. Moreover they need to be considered as removed in case of global
transtable lookup.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-07 18:49:26 +02:00
Antonio Quartulli 058d0e2698 batman-adv: keep local table consistency for further TT_RESPONSE
To keep transtable consistency among all the nodes, an originator must
not send not yet announced clients within a full table TT_RESPONSE.
Instead, deleted client have to be kept in the table in order to be sent
within an immediate TT_RESPONSE. In this way all the nodes in the
network will always provide the same response for the same request.

All the modification are committed at the next ttvn increment event.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-07 18:49:26 +02:00
Antonio Quartulli c8c991bf20 batman-adv: initialise last_ttvn and tt_crc for the orig_node structure
The last_ttvn and tt_crc fields of the orig_node structure were not
initialised causing an immediate TT_REQ/RES dialogue even if not needed.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-07 18:49:26 +02:00
David S. Miller f8bae99ee5 Merge branch 'batman-adv/next' of git://git.open-mesh.org/linux-merge 2011-07-05 19:45:12 -07:00
Sven Eckelmann 44c4349a2a batman-adv: Replace version info instead of appending them
The version number of modules build outside of the tree can get revision
numbers added. This is useful to give hints about the revision of a
distribution package and the used patchset. The prepended source number or
branch name doesn't add any additional information which would help to identify
problems and can therefore be omitted.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-05 14:48:56 +02:00
Marek Lindner b539e4cd3b batman-adv: aggregation checks should use the primary_if pointer
The packet aggregation needs to ensure that only compatible packets
are aggregated. Some of the checks are based on the interface number
while assuming that the first interface also is the primary interface
which is not always the case.
This patch addresses the issue by using the primary_if pointer.

Reported-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-05 14:28:55 +02:00
Marek Lindner 6a020ab452 batman-adv: broadcast primary OGM on all active hard-interfaces
The primary interface OGM has to be broadcasted on all hard-interfaces
even if the primary interface is not the first interface (if_num = 0).
Therefore the code has to compare the originating interface with the
primary interface instead of checking the if_num.

Reported-by: Linus Luessing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-05 14:28:54 +02:00
Antonio Quartulli ff66c975d5 batman-adv: pass a unique flag arg instead of a sequence of bool ones
now tt_local_event() takes a flags argument instead of a sequence of
boolean values which would grow up with the time.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-05 14:28:54 +02:00
Antonio Quartulli 8698529d20 batman-adv: add_bcast_packet_to_list() takes the sending delay as parameter
In order to make possible to use the broadcast list for delayed sendings
the "delay" parameter is now provided instead of using 1 as hardcoded
value.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-05 14:28:54 +02:00
Antonio Quartulli 5fbc1598c2 batman-adv: unify flags for tt_change/tt_local_entry/tt_global_entry
The tt_local_entry structure now has a 'flags' field. This helps to
unify the flags format to all the client related structures (tt_global_entry
and tt_change). The 'never_purge' field is now encoded in the 'flags' one.
To optimise the usage of this field, its length has been increased to 16bit
in order to use the eight leading bits (from 0 to 7) to store flags that
have to be sent on the wire, while the eight ending ones are used for local
computation only.

Moreover 'enum tt_change_flags' is now called 'enum tt_client_flags' and the
defined values apply to the tt_local_entry, tt_global_entry and the tt_change
'flags' field.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-07-05 14:28:54 +02:00
David S. Miller eac56465b8 Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge 2011-06-20 12:59:37 -07:00
Antonio Quartulli 43676ab590 batman-adv: improved gateway tq-based selection
If a client issues a DHCPREQUEST for renewal, the packet is dropped
if the old destination (the old gateway for the client) TQ is smaller
than the current best gateway TQ less GW_THRESHOLD

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:41 +02:00
Antonio Quartulli 19595e054d batman-adv: throw uevent in userspace on gateway add/change/del event
In case of new default gw, changing the default gw or deleting the default gw a
uevent is triggered with type=gw, action=add/change/del and
data={GW_ORIG_ADDRESS} (if any).

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:38 +02:00
Antonio Quartulli 2265c14108 batman-adv: gateway election code refactoring
The gateway election mechanism has been a little revised. Now the
gw_election is trigered by an atomic_t flag (gw_reselect) which is set
to 1 in case of election needed, avoding to set curr_gw to NULL.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:35 +02:00
Antonio Quartulli c6bda689c2 batman-adv: add wrapper function to throw uevent in userspace
Using throw_uevent() is now possible to trigger uevent signal that can
be recognised in userspace. Uevents will be triggered through the
/devices/virtual/net/{MESH_IFACE} kobject.

A triggered uevent has three properties:
- type: the event class. Who generates the event (only 'gw' is currently
  defined). Corresponds to the BATTYPE uevent variable.
- action: the associated action with the event ('add'/'change'/'del' are
  currently defined). Corresponds to the BATACTION uevent variable.
- data: any useful data for the userspace. Corresponds to the BATDATA
  uevent variable.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:33 +02:00
Antonio Quartulli 7683fdc1e8 batman-adv: protect the local and the global trans-tables with rcu
The local and the global translation-tables are now lock free and rcu
protected.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:30 +02:00
Antonio Quartulli cc47f66e6b batman-adv: improved roaming mechanism
With the current client announcement implementation, in case of roaming,
an update is triggered on the new AP serving the client. At that point
the new information is spread around by means of the OGM broadcasting
mechanism. Until this operations is not executed, no node is able to
correctly route traffic towards the client. This obviously causes packet
drops and introduces a delay in the time needed by the client to recover
its connections.

A new packet type called ROAMING_ADVERTISEMENT is added to account this
issue.

This message is sent in case of roaming from the new AP serving the
client to the old one and will contain the client MAC address. In this
way an out-of-OGM update is immediately committed, so that the old node
can update its global translation table. Traffic reaching this node will
then be redirected to the correct destination utilising the fresher
information. Thus reducing the packet drops and the connection recovery
delay.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:27 +02:00
Antonio Quartulli a73105b8d4 batman-adv: improved client announcement mechanism
The client announcement mechanism informs every mesh node in the network
of any connected non-mesh client, in order to find the path towards that
client from any given point in the mesh.

The old implementation was based on the simple idea of appending a data
buffer to each OGM containing all the client MAC addresses the node is
serving. All other nodes can populate their global translation tables
(table which links client MAC addresses to node addresses) using this
MAC address buffer and linking it to the node's address contained in the
OGM. A node that wants to contact a client has to lookup the node the
client is connected to and its address in the global translation table.

It is easy to understand that this implementation suffers from several
issues:
 - big overhead (each and every OGM contains the entire list of
   connected clients)
 - high latencies for client route updates due to long OGM trip time and
   OGM losses

The new implementation addresses these issues by appending client
changes (new client joined or a client left) to the OGM instead of
filling it with all the client addresses each time. In this way nodes
can modify their global tables by means of "updates", thus reducing the
overhead within the OGMs.

To keep the entire network in sync each node maintains a translation
table version number (ttvn) and a translation table checksum. These
values are spread with the OGM to allow all the network participants to
determine whether or not they need to update their translation table
information.

When a translation table lookup is performed in order to send a packet
to a client attached to another node, the destination's ttvn is added to
the payload packet. Forwarding nodes can compare the packet's ttvn with
their destination's ttvn (this node could have a fresher information
than the source) and re-route the packet if necessary. This greatly
reduces the packet loss of clients roaming from one AP to the next.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:24 +02:00
Antonio Quartulli 3b27ffb00f batman-adv: Unify the first 3 bytes in each packet
The amount of duplicated code in the receive and routing code can be
reduced when all headers provide the packet type, version and ttl in the
same first bytes.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:21 +02:00
Sven Eckelmann b4e1705417 batman-adv: Reduce usage of char
char was used in different places to store information without really
using the characteristics of that data type or by ignoring the fact that
char has not a well defined signedness.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:37:18 +02:00
David Howells b2c44a5383 batman-adv: count_real_packets() in batman-adv assumes char is signed
count_real_packets() in batman-adv assumes char is signed, and returns -1
through it:

net/batman-adv/routing.c: In function 'receive_bat_packet':
net/batman-adv/routing.c:739: warning: comparison is always false due to limited range of data type

Use int instead.

Signed-off-by: David Howells <dhowells@redhat.com>
[sven@narfation.org: Rebase on top of current version]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 11:23:36 +02:00
Sven Eckelmann db69ecfcb0 batman-adv: Keep interface_tx as local function
interface_tx is not used outside of soft-interface.c and thus doesn't
need to be declared inside soft-interface.h

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 10:38:59 +02:00
Sven Eckelmann b8e2dd135c batman-adv: Move compare_orig to originator.c
compare_orig is only used in context of orig_node which is managed
inside originator.c. It is not necessary to keep that function inside
the header originator.h.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-20 10:38:55 +02:00
David S. Miller 6018e1183b Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge 2011-06-09 14:56:13 -07:00
Marek Lindner ecbd532108 batman-adv: use NO_FLAGS define instead of hard-coding 0
The definition NO_FLAGS was introduced to make the code more
readable and shall be used to initialize flag fields.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-09 20:40:38 +02:00
Sven Eckelmann e8958dbf0d batman-adv: Use enums for related constants
CodingStyle "Chapter 12: Macros, Enums and RTL" recommends to use enums
for several related constants. Internal states can be used without
defining the actual value, but all values which are visible to the
outside must be defined as before. Normal values are assigned as usual
and flags are defined by shifts of a bit.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-09 20:40:38 +02:00
Sven Eckelmann 3d222bbaa7 batman-adv: Rewrite debugfs kobj_to_* helpers as functions
CodingStyle "Chapter 12: Macros, Enums and RTL" highly recommends to use
functions instead of macros were possible. This ensures type safety and
prevents shadowing of other variables.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-09 20:40:38 +02:00
Sven Eckelmann e72948eb21 batman-adv: Fix signedness problem in parse_gw_bandwidth
strict_strtoul as used in parse_gw_bandwidth is defined for unsigned
long and strict_strtol should be used instead for long.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-09 20:40:38 +02:00
Sven Eckelmann 6b9aadfa97 batman-adv: Don't return value in void function
gw_node_delete is defined with "void" as return type, but still tries to
return a value. The called function gw_node_delete is also return as
void and thus doesn't provide a value for us.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-09 20:40:38 +02:00
Daniele Furlan d1829fa0c3 batman-adv: accept delayed rebroadcasts to avoid bogus routing under heavy load
When a link is saturated (re)broadcasts of OGMs are delayed. Under heavy
load this delay may exceed the orig interval which leads to OGMs being
dropped (the code would only accept an OGM rebroadcast if it arrived
before the next OGM was broadcasted). With this patch batman-adv will
also accept delayed OGMs in order to avoid a bogus influence on the
routing metric.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-06-09 20:40:37 +02:00
Joe Perches f81c622420 net: Remove unnecessary semicolons
Semicolons are not necessary after switch/while/for/if braces
so remove them.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-06-05 14:33:39 -07:00
Sven Eckelmann bb899b89f4 batman-adv: Ensure that we really have route changes in update_route
The debug output of update_route has tests for "route deleted" and "route
added". All other situations are handled as "route changed". This is not
true because neigh_node and curr_router could be both NULL.

The function is not called in this situation, but the code might be
interpreted wrong when reading it without this test.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:37 +02:00
Antonio Quartulli 4021967248 batman-adv: a multiline comment should precede the variable it is describing
This comment has been wrongly put after the variable it refers to and was also bad indented

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Acked-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:36 +02:00
Antonio Quartulli 44e92bc8d6 batman-adv: use is_broadcast_ether_addr() instead of compare_eth(.., brd_addr)
Instead of comparing mac addresses with the broadcast address by means
of compare_eth(), the is_broadcast_ether_addr() kernel function has to be
used.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Acked-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:36 +02:00
Sven Eckelmann 0bb857511b batman-adv: Check type of x and y in seq_(before|after)
seq_before and seq_after depend on the fact that both sequence numbers
have the same type and thus the same bitwidth. We can ensure that by
compile time checking using a compare between the pointer to the
temporary buffers which were created using the typeof of both
parameters. For example gcc would create a warning like
"warning: comparison of distinct pointer types lacks a cast".

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:35 +02:00
Antonio Quartulli f5d33d3778 batman-adv: move smallest_signed_int(), seq_before() and seq_after() into main.h
smallest_signed_int(), seq_before() and seq_after() are very useful
functions that help to handle comparisons between sequence numbers.
However they were only defined in vis.c. With this patch every
batman-adv function will be able to use them.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:35 +02:00
Sven Eckelmann 728cbc6ac1 batman-adv: Use rcu_dereference_protected by update-side
Usually rcu_dereference isn't necessary in situations were the
RCU-protected data structure cannot change, but sparse and lockdep still
need a similar functionality for analysis. rcu_dereference_protected
implements the reduced version which should be used to support the
dynamic and static analysis.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:34 +02:00
Sven Eckelmann 704509b8d4 batman-adv: Calculate sizeof using variable insead of types
Documentation/CodingStyle recommends to use the form

	p = kmalloc(sizeof(*p), ...);

to calculate the size of a struct and not the version where the struct
name is spelled out to prevent bugs when the type of p changes. This
also seems appropriate for manipulation of buffers when they are
directly associated with p.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:33 +02:00
Sven Eckelmann 958ca59856 batman-adv: Remove casts from type x to type x
Casting from pointer like 'struct orig_node*' to 'struct orig_node *'
doesn't provide any additional functionality and can be savely removed.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:33 +02:00
Sven Eckelmann 5f718c2007 batman-adv: Remove explicit casts cast from void* for store
It is not necessary to cast a void* to the pointer type when we just
store it and don't want to do pointer arithmetic before the actual
assignment.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:32 +02:00
Sven Eckelmann 37a4065ec7 batman-adv: Only use int up and down gw representation
It is not save to provide memory for an int and then cast the pointer to
it to long*. It is better to standardize the up and down gateway
bandwith representation to simple ints and only use long inside
conversation routines.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:32 +02:00
Sven Eckelmann 747e4221a0 batman-adv: Add const type qualifier for pointers
batman-adv uses pointers which are marked as const and should not
violate that type qualifier by passing it to functions which force a
cast to the non-const version.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:31 +02:00
Sven Eckelmann 38e3c5f0da batman-adv: Don't do pointer arithmetic with void*
The size of void is currently set by gcc to 1, but is not well defined
in general. Therefore it is more advisable to cast it to char* before
doing pointer arithmetic.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:30 +02:00
Sven Eckelmann 16f14b45c4 batman-adv: Remove comparising < 0 for unsigned type
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:30 +02:00
Sven Eckelmann f678bc9883 batman-adv: Print jiffies as unsigned long
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:29 +02:00
Sven Eckelmann d3a547be40 batman-adv: Annotate functions with format strings
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:29 +02:00
Sven Eckelmann 1b38bed562 batman-adv: Use kzalloc rather than kmalloc followed by memset with 0
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:28 +02:00
Antonio Quartulli e2cbc11c0e batman-adv: move neigh_node->if_incoming->if_status check in find_router()
Every time that find_router() is invoked, if_status has to be compared with
IF_ACTIVE. Moving this comparison inside find_router() will avoid to write it
each time.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-30 07:39:27 +02:00
Linus Torvalds 06f4e926d2 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1446 commits)
  macvlan: fix panic if lowerdev in a bond
  tg3: Add braces around 5906 workaround.
  tg3: Fix NETIF_F_LOOPBACK error
  macvlan: remove one synchronize_rcu() call
  networking: NET_CLS_ROUTE4 depends on INET
  irda: Fix error propagation in ircomm_lmp_connect_response()
  irda: Kill set but unused variable 'bytes' in irlan_check_command_param()
  irda: Kill set but unused variable 'clen' in ircomm_connect_indication()
  rxrpc: Fix set but unused variable 'usage' in rxrpc_get_transport()
  be2net: Kill set but unused variable 'req' in lancer_fw_download()
  irda: Kill set but unused vars 'saddr' and 'daddr' in irlan_provider_connect_indication()
  atl1c: atl1c_resume() is only used when CONFIG_PM_SLEEP is defined.
  rxrpc: Fix set but unused variable 'usage' in rxrpc_get_peer().
  rxrpc: Kill set but unused variable 'local' in rxrpc_UDP_error_handler()
  rxrpc: Kill set but unused variable 'sp' in rxrpc_process_connection()
  rxrpc: Kill set but unused variable 'sp' in rxrpc_rotate_tx_window()
  pkt_sched: Kill set but unused variable 'protocol' in tc_classify()
  isdn: capi: Use pr_debug() instead of ifdefs.
  tg3: Update version to 3.119
  tg3: Apply rx_discards fix to 5719/5720
  ...

Fix up trivial conflicts in arch/x86/Kconfig and net/mac80211/agg-tx.c
as per Davem.
2011-05-20 13:43:21 -07:00
David S. Miller 4dc6ec26fe Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge 2011-05-14 22:47:51 -04:00
Marek Lindner ca06c6eb9a batman-adv: reset broadcast flood protection on error
The broadcast flood protection should be reset to its original value
if the primary interface could not be retrieved.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-15 00:02:06 +02:00
Sven Eckelmann 6d5808d4ae batman-adv: Add missing hardif_free_ref in forw_packet_free
add_bcast_packet_to_list increases the refcount for if_incoming but the
reference count is never decreased. The reference count must be
increased for all kinds of forwarded packets which have the primary
interface stored and forw_packet_free must decrease them. Also
purge_outstanding_packets has to invoke forw_packet_free when a work
item was really cancelled.

This regression was introduced in
32ae9b221e.

Reported-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-15 00:02:06 +02:00
David S. Miller 02e73c1edc Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge 2011-05-08 15:39:11 -07:00
Daniele Furlan 27aea2128e batman-adv: remove duplicate code from function is_bidirectional_neigh()
In function is_bidirectional_neigh the code that find out the one hop
neighbor is duplicated.

Signed-off-by: Daniele Furlan <daniele.furlan@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:42 +02:00
Sven Eckelmann 6e215fd8eb batman-adv: Remove multiline comments from line ending
It is slightly irritating that comments after a long line span over
multiple lines without any code. It is easier to put them before the
actual code and reduce the number of lines which the eye has to read.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:42 +02:00
Antonio Quartulli 2dafb49d84 batman-adv: rename everything from *hna* into *tt* (translation table)
To be coherent, all the functions/variables/constants have been renamed
to the TranslationTable style

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:42 +02:00
Marek Lindner 01df2b65e9 batman-adv: Fix refcount imbalance in find_router
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:42 +02:00
Sven Eckelmann 3a4375a9f0 batman-adv: Avoid deadlock between rtnl_lock and s_active
The hard_if_event is called by the notifier with rtnl_lock and tries to
remove sysfs entries when a NETDEV_UNREGISTER event is received. This
will automatically take the s_active lock.

The s_active lock is also used when a new interface is added to a meshif
through sysfs. In that situation we cannot wait for the rntl_lock before
creating the actual batman-adv interface to prevent a deadlock. It is
still possible to try to get the rtnl_lock and immediately abort the
current operation when the trylock call failed.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:42 +02:00
Sven Eckelmann c3caf5196c batman-adv: Remove unnecessary hardif_list_lock
hardif_list_lock is unneccessary because we already ensure that no
multiple admin operations can take place through rtnl_lock.
hardif_list_lock only adds additional overhead and complexity.

Critical functions now check whether they are called with rtnl_lock
using ASSERT_RTNL.

It indirectly fixes the problem that orig_hash_del_if() expects that
only one interface is deleted from hardif_list at a time, but
hardif_remove_interfaces() removes all at once and then calls
orig_hash_del_if().

Reported-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:41 +02:00
Marek Lindner 61906ae86d batman-adv: multi vlan support for bridge loop detection
The bridge loop detection for batman-adv allows the bat0 interface
to be bridged into an ethernet segment which other batman-adv nodes
are connected to. In order to also allow multiple VLANs on top of
the bat0 interface to be bridged into the ethernet segment this
patch extends the aforementioned bridge loop detection.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:41 +02:00
Marek Lindner 28f8e546e6 batman-adv: remove misplaced comment
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-08 16:10:07 +02:00
Paul E. McKenney 8e3572cff7 batman,rcu: convert call_rcu(softif_neigh_free_rcu) to kfree_rcu
The RCU callback softif_neigh_free_rcu() just calls kfree(), so we can
use kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Marek Lindner <lindner_marek@yahoo.de>
Cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Acked-by: David S. Miller <davem@davemloft.net>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Sven Eckelmann <sven@narfation.org>
2011-05-07 22:51:15 -07:00
Paul E. McKenney ae179ae433 batman,rcu: convert call_rcu(neigh_node_free_rcu) to kfree()
The RCU callback neigh_node_free_rcu() just calls kfree(), so we can use
kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Marek Lindner <lindner_marek@yahoo.de>
Cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Acked-by: David S. Miller <davem@davemloft.net>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Sven Eckelmann <sven@narfation.org>
2011-05-07 22:51:14 -07:00
Paul E. McKenney eb340b2f80 batman,rcu: convert call_rcu(gw_node_free_rcu) to kfree_rcu
The RCU callback gw_node_free_rcu() just calls kfree(), so we can use
kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Marek Lindner <lindner_marek@yahoo.de>
Cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Acked-by: David S. Miller <davem@davemloft.net>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Sven Eckelmann <sven@narfation.org>
2011-05-07 22:51:13 -07:00
David S. Miller dcfd9cdc12 Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge 2011-05-02 15:04:46 -07:00
Marek Lindner 32ae9b221e batman-adv: Make bat_priv->primary_if an rcu protected pointer
The rcu protected macros rcu_dereference() and rcu_assign_pointer()
for the bat_priv->primary_if need to be used, as well as spin/rcu locking.

Otherwise we might end up using a primary_if pointer pointing to already
freed memory.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-01 22:49:03 +02:00
Antonio Quartulli 71e4aa9c46 batman-adv: fix gw_node_update() and gw_election()
This is a regression from c4aac1ab9b

- gw_node_update() doesn't add a new gw_node in case of empty curr_gw.
This means that at the beginning no gw_node is added, leading to an
empty gateway list.

- gw_election() is terminating in case of curr_gw == NULL. It has to
terminate in case of curr_gw != NULL

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-01 22:49:03 +02:00
Antonio Quartulli 5f657ec0d2 batman-adv: Move definition of atomic_dec_not_zero() into main.h
atomic_dec_not_zero() is very useful and it is currently defined
multiple times. So it is possible to move it in main.h

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-01 22:49:03 +02:00
Antonio Quartulli b5a6f69c5c batman-adv: orig_hash_find() manages rcu_lock/unlock internally
orig_hash_find() manages rcu_lock/unlock internally and doesn't need to
be surrounded by rcu_read_lock() / rcu_read_unlock() anymore

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Acked-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-05-01 22:49:02 +02:00
David Decotigny 7073949720 ethtool: cosmetic: Use ethtool ethtool_cmd_speed API
This updates the network drivers so that they don't access the
ethtool_cmd::speed field directly, but use ethtool_cmd_speed()
instead.

For most of the drivers, these changes are purely cosmetic and don't
fix any problem, such as for those 1GbE/10GbE drivers that indirectly
call their own ethtool get_settings()/mii_ethtool_gset(). The changes
are meant to enforce code consistency and provide robustness with
future larger throughputs, at the expense of a few CPU cycles for each
ethtool operation.

All drivers compiled with make allyesconfig ion x86_64 have been
updated.

Tested: make allyesconfig on x86_64 + e1000e/bnx2x work
Signed-off-by: David Decotigny <decot@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-04-29 14:03:01 -07:00
Michał Mirosław 97dbee7397 net: batman-adv: remove rx_csum ethtool_ops
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-04-20 01:30:40 -07:00
David S. Miller 9c6bc16577 Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge 2011-04-17 17:37:29 -07:00
Andrew Lunn af20b71047 batman-adv: Set the txqueuelen to zero when creating soft interface
Like other virtual interfaces, e.g. br0, we don't need a transmit
queue. Packets should only be queued on real interfaces which are
underneath. In practice this patch makes little difference since the
virtual interfaces can accept packets as fast as they come, but the
patch will avoid bufferbloat questions to the mailling lists in the
future.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:02 +02:00
Simon Wunderlich ba85fac280 batman-adv: protect softif_neigh by rcu
Add get/set wrapper functions for softif_neigh and
use rcu functions to manipulate the pointers.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:02 +02:00
Marek Lindner c4aac1ab9b batman-adv: concentrate all curr_gw related rcu operations in select/deselect functions
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:01 +02:00
Linus Lüssing 68003903e4 batman-adv: Protect global TQ window with a spinlock
Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:01 +02:00
Linus Lüssing e1a5382f97 batman-adv: Make orig_node->router an rcu protected pointer
The rcu protected macros rcu_dereference() and rcu_assign_pointer()
for the orig_node->router need to be used, as well as spin/rcu locking.
Otherwise we might end up using a router pointer pointing to already
freed memory.

Therefore this commit introduces the safe getter method
orig_node_get_router().

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:01 +02:00
Linus Lüssing 57f0c07c4d batman-adv: Simplify gw_check_election(), use gw_get_selected()
gw_get_selected() can get us the desired orig_node directly, therefore
reusing that function in gw_check_election().

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:01 +02:00
Linus Lüssing 4c80485057 batman-adv: Make gateway_get_selected type safe
Make the return value explicit instead of (void *).

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:01 +02:00
Linus Lüssing 551586292b batman-adv: Move bonding / iface alternating router search to own functions
This decreases the size of find_router() by outsourcing the router
search for the bonding and interface alternating modes to their own sub
functions. This shall make it easier to keep track of the correct
refcounting later.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2011-04-17 21:11:00 +02:00
Lucas De Marchi 25985edced Fix common misspellings
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2011-03-31 11:26:23 -03:00
David S. Miller b8cec4a415 Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge 2011-03-07 00:37:13 -08:00
Sven Eckelmann e44d8fe2b5 batman-adv: Disallow regular interface as mesh device
When trying to associate a net_device with another net_device which
already exists, batman-adv assumes that this interface is a fully
initialized batman mesh interface without checking it. The behaviour
when accessing data behind netdev_priv of a random net_device is
undefined and potentially dangerous.

Reported-by: Linus Lüssing <linus.luessing@ascom.ch>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:09 +01:00
Linus Lüssing 7cefb149a6 batman-adv: Remove unused hdr_size variable in route_unicast_packet()
Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:08 +01:00
Marek Lindner e6c10f433a batman-adv: rename batman_if struct to hard_iface
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:06 +01:00
Marek Lindner 4389e47af8 batman-adv: rename global if_list to hardif_list
Batman-adv works with "hard interfaces" as well as "soft interfaces".
The new name should better make clear which kind of interfaces this
list stores.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:05 +01:00
Marek Lindner d0072609ba batman-adv: remove orig_hash spinlock
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:04 +01:00
Marek Lindner 1605d0d60b batman-adv: increase refcount in create_neighbor to be consistent
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:03 +01:00
Marek Lindner 7b36e8eef9 batman-adv: Correct rcu refcounting for orig_node
It might be possible that 2 threads access the same data in the same
rcu grace period. The first thread calls call_rcu() to decrement the
refcount and free the data while the second thread increases the
refcount to use the data. To avoid this race condition all refcount
operations have to be atomic.

Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:01 +01:00
Marek Lindner 7aadf889e8 batman-adv: remove extra layer between hash and hash element - hash bucket
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:52:00 +01:00
Marek Lindner 39901e7162 batman-adv: separate ethernet comparing calls from hash functions
Note: The function compare_ether_addr() provided by the Linux kernel
requires aligned memory.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:14 +01:00
Linus Lüssing 9e0b33c221 batman-adv: Fix possible buffer overflow in softif neigh list output
When printing the soft interface table the number of entries in the
softif neigh list are first being counted and a fitting buffer
allocated. After that the softif neigh list gets locked again and
the buffer printed - which has the following two issues:

For one thing, the softif neigh list might have grown when reacquiring
the rcu lock, which results in writing outside of the allocated buffer.
Furthermore 31 Bytes are not enough for printing an entry with a vid
of more than 2 digits.

The manual buffering is unnecessary, we can safely print to the seq
directly during the rcu_read_lock().

Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:13 +01:00
Linus Lüssing 43c70ad5ce batman-adv: Increase orig_node refcount before releasing rcu read lock
When unicast_send_skb() is increasing the orig_node's refcount another
thread might have been freeing this orig_node already. We need to
increase the refcount in the rcu read lock protected area to avoid that.

Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:12 +01:00
Linus Lüssing 5d02b3cdfa batman-adv: Make bat_priv->curr_gw an rcu protected pointer
The rcu protected macros rcu_dereference() and rcu_assign_pointer()
for the bat_priv->curr_gw need to be used, as well as spin/rcu locking.

Otherwise we might end up using a curr_gw pointer pointing to already
freed memory.

Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:10 +01:00
Marek Lindner f3e0008f01 batman-adv: make broadcast seqno operations atomic
Batman-adv could receive several payload broadcasts at the same time
that would trigger access to the broadcast seqno sliding window to
determine whether this is a new broadcast or not. If these incoming
broadcasts are accessing the sliding window simultaneously it could
be left in an inconsistent state. Therefore it is necessary to make
sure this access is atomic.

Reported-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:09 +01:00
Marek Lindner 0ede9f41b2 batman-adv: protect bit operations to count OGMs with spinlock
Reported-by: Linus Lüssing <linus.luessing@saxnet.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:08 +01:00
Marek Lindner ed75ccbe26 batman-adv: Correct rcu refcounting for batman_if
It might be possible that 2 threads access the same data in the same
rcu grace period. The first thread calls call_rcu() to decrement the
refcount and free the data while the second thread increases the
refcount to use the data. To avoid this race condition all refcount
operations have to be atomic.

Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:07 +01:00
Marek Lindner 7d2b554826 batman-adv: Correct rcu refcounting for softif_neigh
It might be possible that 2 threads access the same data in the same
rcu grace period. The first thread calls call_rcu() to decrement the
refcount and free the data while the second thread increases the
refcount to use the data. To avoid this race condition all refcount
operations have to be atomic.

Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:05 +01:00
Marek Lindner 25b6d3c17e batman-adv: Correct rcu refcounting for gw_node
It might be possible that 2 threads access the same data in the same
rcu grace period. The first thread calls call_rcu() to decrement the
refcount and free the data while the second thread increases the
refcount to use the data. To avoid this race condition all refcount
operations have to be atomic.

Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:04 +01:00
Marek Lindner 44524fcdf6 batman-adv: Correct rcu refcounting for neigh_node
It might be possible that 2 threads access the same data in the same
rcu grace period. The first thread calls call_rcu() to decrement the
refcount and free the data while the second thread increases the
refcount to use the data. To avoid this race condition all refcount
operations have to be atomic.

Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
2011-03-05 12:50:03 +01:00