06 Mar, 2018
1 commit
-
All of the conflicts were cases of overlapping changes.
In net/core/devlink.c, we have to make care that the
resouce size_params have become a struct member rather
than a pointer to such an object.Signed-off-by: David S. Miller
27 Feb, 2018
1 commit
-
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
26 Feb, 2018
2 commits
-
batman-adv uses internal indices for each enabled and active interface.
It is currently used by the B.A.T.M.A.N. IV algorithm to identifify the
correct position in the ogm_cnt bitmaps.The type for the number of enabled interfaces (which defines the next
interface index) was set to char. This type can be (depending on the
architecture) either signed (limiting batman-adv to 127 active slave
interfaces) or unsigned (limiting batman-adv to 255 active slave
interfaces).This limit was not correctly checked when an interface was enabled and thus
an overflow happened. This was only catched on systems with the signed char
type when the B.A.T.M.A.N. IV code tried to resize its counter arrays with
a negative size.The if_num interface index was only a s16 and therefore significantly
smaller than the ifindex (int) used by the code net code.Both &batadv_hard_iface->if_num and &batadv_priv->num_ifaces must be
(unsigned) int to support the same number of slave interfaces as the net
core code. And the interface activation code must check the number of
active slave interfaces to avoid integer overflows.Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
The function batadv_iv_gw_dump stops the processing loop when
batadv_iv_gw_dump_entry returns a non-0 return code. This should only
happen when the buffer is full. Otherwise, an empty message may be
returned by batadv_gw_dump. This empty message will then stop the netlink
dumping of gateway entries. At worst, not a single entry is returned to
userspace even when plenty of possible gateways exist.Fixes: efb766af06e3 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations")
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
22 Dec, 2017
1 commit
-
The header file is used by different userspace programs to inject packets
or to decode sniffed packets. It should therefore be available to them as
userspace header.Also other components in the kernel (like the flow dissector) require
access to the packet definitions to be able to decode ETH_P_BATMAN ethernet
packets.Signed-off-by: Sven Eckelmann
Signed-off-by: David S. Miller
21 Dec, 2017
1 commit
-
Simon Wunderlich says:
====================
This feature/cleanup patchset includes the following patches:- bump version strings, by Simon Wunderlich
- de-inline hash functions to save memory footprint, by Denys Vlasenko
- Add License information to various files, by Sven Eckelmann (3 patches)
- Change batman_adv.h from ISC to MIT, by Sven Eckelmann
- Improve various includes, by Sven Eckelmann (5 patches)
- Lots of kernel-doc work by Sven Eckelmann (8 patches)
====================Signed-off-by: David S. Miller
16 Dec, 2017
5 commits
-
According to the kernel-doc documentation, externally visible functions
should be documented. This refers to all all non-static function which can
(and will) be used by functions in other sources files.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
The inline kernel-doc comments make it easier to keep changes to the
struct/enum synchronized with the documentation of the it. And it makes it
easier for larger structures like struct batadv_priv to read the
documentation inside the code.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
The documentation describing kernel-doc comments for functions ("How to
format kernel-doc comments") uses parentheses at the end of the function
name. Using this format allows to use a consistent style when adding
documentation to a function and when referencing this function in a
different kernel-doc section.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
The linux/gfp.h provides the GFP_ATOMIC and GFP_KERNEL define. It should
therefore be included instead of linux/fs.h.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
The "Linux kernel licensing rules" require that each file has a SPDX
license identifier as first line (and sometimes as second line).The FSFE REUSE practices [1] would also require the same tags but have no
restrictions on the placement in the source file. Using the "Linux kernel
licensing rules" is therefore also fulfilling the FSFE REUSE practices
requirements at the same time.[1] https://reuse.software/practices/
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
04 Dec, 2017
1 commit
-
The originator node object orig_neigh_node is used to when accessing the
bcast_own(_sum) and real_packet_count information. The access to them has
to be protected with the spinlock in orig_neigh_node.But the function uses the lock in orig_node instead. This is incorrect
because they could be two different originator node objects.Fixes: 0ede9f41b217 ("batman-adv: protect bit operations to count OGMs with spinlock")
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
28 Sep, 2017
1 commit
-
checkpatch introduced with commit 63b7c73ec86b ("checkpatch: add --strict
check for ifs with unnecessary parentheses") an additional test which
identifies some unnecessary parentheses.Remove these unnecessary parentheses to avoid the warnings and to unify the
coding style slightly more.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
29 Jul, 2017
2 commits
-
skb_put_data makes it unnecessary to store the skb_put return value to copy
some data to the packet. The returned pointer of skb_put_data should
therefore not stored by functions which previously only used it to copy
some data.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
The string representation for a mac address produced by %pM is 17
characters long. Left-aligning the output in a 15 character wide field
width %-15pM is therefore misleading and unnecessary.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
16 Jun, 2017
1 commit
-
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.An spatch similar to the one for skb_put_zero() converts many
of the places using it:@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger
Signed-off-by: Johannes Berg
Signed-off-by: David S. Miller
23 May, 2017
2 commits
-
The function names in batman-adv changed slightly in the past. But some of
the debug messages were not updated correctly and therefore some messages
were incorrect. To avoid this in the future, these kind of messages should
use __func__ to automatically print the correct function name.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
Two single characters (line breaks) should be put into a sequence.
Thus use the corresponding function "seq_putc".This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
07 Apr, 2017
1 commit
-
Simon Wunderlich says:
====================
This feature/cleanup patchset includes the following patches:- bump version strings, by Simon Wunderlich
- Code and Style cleanups, by Sven Eckelmann (5 patches)
- Remove an unneccessary memset, by Tobias Klauser
- DAT and BLA optimizations for various corner cases, by Andreas Pape
(5 patches)- forward/rebroadcast packet restructuring, by Linus Luessing
(2 patches)- ethtool cleanup and remove unncessary code, by Sven Eckelmann
(4 patches)- use net_device_stats from net_device instead of private copy,
by Tobias Klauser
====================Signed-off-by: David S. Miller
26 Mar, 2017
1 commit
-
An skb is assigned to a forw_packet only once, shortly after the
forw_packet allocation.With this patch the assignment is moved into the this allocation
function.Signed-off-by: Linus Lüssing
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
17 Mar, 2017
1 commit
-
Simon Wunderlich says:
====================
Here are two batman-adv bugfixes:- Keep fragments equally sized, avoids some problems with too small fragments,
by Sven Eckelmann- Initialize gateway class correctly when BATMAN V is compiled in,
by Sven Eckelmann
====================Signed-off-by: David S. Miller
05 Mar, 2017
1 commit
-
The gateway selection class variable is shared between different algorithm
versions. But the interpretation of the content is algorithm specific. The
initialization is therefore also algorithm specific.But this was implemented incorrectly and the initialization for BATMAN_V
always overwrote the value previously written for BATMAN_IV. This could
only be avoided when BATMAN_V was disabled during compile time.Using a special batadv_algo hook for this initialization avoids this
problem.Fixes: 50164d8f500f ("batman-adv: B.A.T.M.A.N. V - implement GW selection logic")
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
26 Jan, 2017
1 commit
-
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
09 Nov, 2016
3 commits
-
In rare cases during shutdown the following general protection fault can
happen:general protection fault: 0000 [#1] SMP
Modules linked in: batman_adv(O-) [...]
CPU: 3 PID: 1714 Comm: rmmod Tainted: G O 4.6.0-rc6+ #1
[...]
Call Trace:
[] batadv_hardif_disable_interface+0x29a/0x3a6 [batman_adv]
[] batadv_softif_destroy_netlink+0x4b/0xa4 [batman_adv]
[] __rtnl_link_unregister+0x48/0x92
[] rtnl_link_unregister+0xc1/0xdb
[] ? bit_waitqueue+0x87/0x87
[] batadv_exit+0x1a/0xf48 [batman_adv]
[] SyS_delete_module+0x136/0x1b0
[] entry_SYSCALL_64_fastpath+0x18/0xa8
[] ? trace_hardirqs_off_caller+0x37/0xa6
Code: 89 f7 e8 21 bd 0d e1 4d 85 e4 75 0e 31 f6 48 c7 c7 50 d7 3b a0 e8 50 16 f2 e0 49 8b 9c 24 28 01 00 00 48 85 db 0f 84 b2 00 00 00 8b 03 4d 85 ed 48 89 45 c8 74 09 4c 39 ab f8 00 00 00 75 1c
RIP [] batadv_purge_outstanding_packets+0x1c8/0x291 [batman_adv]
RSP
---[ end trace 803b9bdc6a4a952b ]---
Kernel panic - not syncing: Fatal exception in interrupt
Kernel Offset: disabled
---[ end Kernel panic - not syncing: Fatal exception in interruptIt does not happen often, but may potentially happen when frequently
shutting down and reinitializing an interface. With some carefully
placed msleep()s/mdelay()s it can be reproduced easily.The issue is, that on interface removal, any still running worker thread
of a forwarding packet will race with the interface purging routine to
free a forwarding packet. Temporarily giving up a spin-lock to be able
to sleep in the purging routine is not safe.Furthermore, there is a potential general protection fault not just for
the purging side shown above, but also on the worker side: Temporarily
removing a forw_packet from the according forw_{bcast,bat}_list will make
it impossible for the purging routine to catch and cancel it.# How this patch tries to fix it:
With this patch we split the queue purging into three steps: Step 1),
removing forward packets from the queue of an interface and by that
claim it as our responsibility to free.Step 2), we are either lucky to cancel a pending worker before it starts
to run. Or if it is already running, we wait and let it do its thing,
except two things:Through the claiming in step 1) we prevent workers from a) re-arming
themselves. And b) prevent workers from freeing packets which we still
hold in the interface purging routine.Finally, step 3, we are sure that no forwarding packets are pending or
even running anymore on the interface to remove. We can then safely free
the claimed forwarding packets.Signed-off-by: Linus Lüssing
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
batman-adv is requiring the type of wifi device in different contexts. Some
of them can take the rtnl semaphore and some of them already have the
semaphore taken. But even others don't allow that the semaphore will be
taken.The data has to be retrieved when the hardif is added to batman-adv because
some of the wifi information for an hardif will only be available with rtnl
lock. It can then be cached in the batadv_hard_iface and the functions
is_wifi_netdev and is_cfg80211_netdev can just compare the correct bits
without imposing extra locking requirements.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
Receiving functions in Linux consume the supplied skbuff. Doing the same in
the batadv_rx_handler functions makes the behavior more similar to the rest
of the Linux network code.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
30 Oct, 2016
1 commit
-
kfree_skb assumes that an skb is dropped after an failure and notes that.
consume_skb should be used in non-failure situations. Such information is
important for dropmonitor netlink which tells how many packets were dropped
and where this drop happened.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
19 Oct, 2016
1 commit
-
The batman-adv codebase is using "list" for the list node (prev/next) and
+"_list" for the head of a list. Not using this
naming scheme can up in confusions when reading the code.Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
09 Aug, 2016
8 commits
-
The files provided by batman-adv via debugfs are currently converted to
netlink. Tools which are not yet converted to use the netlink interface may
still rely on the old debugfs files. But systems which already upgraded
their tools can save some space by disabling this feature. The default
configuration of batman-adv on amd64 can reduce the size of the module by
around 11% when this feature is disabled.$ size net/batman-adv/batman-adv.ko*
text data bss dec hex filename
150507 10395 4160 165062 284c6 net/batman-adv/batman-adv.ko.y
137106 7099 2112 146317 23b8d net/batman-adv/batman-adv.ko.nSigned-off-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich -
It is hard to understand why the refcnt is increased when it isn't done
near the actual place the new reference is used. So using kref_get right
before the place which requires the reference and in the same function
helps to avoid accidental problems caused by incorrect reference counting.Signed-off-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich -
Dump the list of gateways via the netlink socket.
Signed-off-by: Andrew Lunn
[sven.eckelmann@open-mesh.com: integrate in batadv_algo_ops]
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
Signed-off-by: Marek Lindner -
Signed-off-by: Matthias Schiffer
Signed-off-by: Andrew Lunn
[sven.eckelmann@open-mesh.com: Fix function parameter alignments,
add policy for attributes, fix includes, fix algo_ops integration]
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
Signed-off-by: Marek Lindner -
This patch abstracts the forward packet creation into the new function
batadv_forw_packet_alloc().The queue counting and interface reference counters are now handled
internally within batadv_forw_packet_alloc() and its
batadv_forw_packet_free() counterpart. This should reduce the risk of
having reference/queue counting bugs again and should increase
code readibility.Signed-off-by: Linus Lüssing
Signed-off-by: Marek Lindner
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich -
The difference between tq1 and tq2 are calculated the same way in two
separate functions.This patch moves the common code to a separate function
'batadv_iv_ogm_neigh_diff' which handles everything necessary. The other
two functions can then handle errors and use the difference directly.Signed-off-by: Markus Pargmann
[sven@narfation.org: rebased on current version, initialize return variable
in batadv_iv_ogm_neigh_diff, add kerneldoc, convert to bool return type]
Signed-off-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich -
Each routing protocol may have its own specific logic about
gateway election which is potentially based on the metric being
used.Create two GW specific API functions and move the current election
logic in the B.A.T.M.A.N. IV specific code.Signed-off-by: Antonio Quartulli
Signed-off-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich -
Fixes: ef0a937f7a14 ("batman-adv: consider outgoing interface in OGM sending")
Signed-off-by: Linus Lüssing
Signed-off-by: Marek Lindner
Signed-off-by: Sven Eckelmann
Signed-off-by: Simon Wunderlich
04 Jul, 2016
1 commit
-
The routing API data structure contains several function
pointers that can easily be grouped together based on the
component they work with.Split the API in subobjects in order to improve definition readability.
At the same time, remove the "bat_" prefix from the API object and
its fields names. These are batman-adv private structs and there is no
need to always prepend such prefix, which only makes function invocations
much much longer.Signed-off-by: Antonio Quartulli
Reviewed-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich
30 Jun, 2016
3 commits
-
The bat_algo.h had some functions declared which were not part of the
bat_algo.c file. These are instead stored in bat_v.c and bat_iv_ogm.c. The
declaration should therefore be also in bat_v.h and bat_iv_ogm,h to make
them easier to find.Signed-off-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich -
There are several places in batman-adv which provide logging related
functions. These should be grouped together in the log.* files to make them
easier to find.Reported-by: Markus Pargmann
Signed-off-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich -
The tvlv functionality in main.c is mostly unrelated to the rest of the
content. It still takes up a large portion of this source file (~45%, 588
lines). Moving it to a separate file makes it better visible as a main
component of the batman-adv implementation and hides it less in the other
helper functions in main.cSigned-off-by: Markus Pargmann
[sven@narfation.org: fix conflicts with current version, fix includes,
rewrote commit message]
Signed-off-by: Sven Eckelmann
Signed-off-by: Marek Lindner
Signed-off-by: Simon Wunderlich