]> git.baikalelectronics.ru Git - kernel.git/commit
batman-adv: Fix out-of-order fragmentation support
authorSven Eckelmann <sven@narfation.org>
Mon, 26 May 2014 15:21:39 +0000 (17:21 +0200)
committerAntonio Quartulli <antonio@meshcoding.com>
Tue, 5 Aug 2014 07:12:16 +0000 (09:12 +0200)
commitc768d1587dd00e7599f9ea4b40c71cb581b5fc8a
treed7fde990c3b172d0f85d2d78e8662556d97c5c15
parente7ad54d51efee506fccca350c1eeaa5a4c49a59f
batman-adv: Fix out-of-order fragmentation support

batadv_frag_insert_packet was unable to handle out-of-order packets because it
dropped them directly. This is caused by the way the fragmentation lists is
checked for the correct place to insert a fragmentation entry.

The fragmentation code keeps the fragments in lists. The fragmentation entries
are kept in descending order of sequence number. The list is traversed and each
entry is compared with the new fragment. If the current entry has a smaller
sequence number than the new fragment then the new one has to be inserted
before the current entry. This ensures that the list is still in descending
order.

An out-of-order packet with a smaller sequence number than all entries in the
list still has to be added to the end of the list. The used hlist has no
information about the last entry in the list inside hlist_head and thus the
last entry has to be calculated differently. Currently the code assumes that
the iterator variable of hlist_for_each_entry can be used for this purpose
after the hlist_for_each_entry finished. This is obviously wrong because the
iterator variable is always NULL when the list was completely traversed.

Instead the information about the last entry has to be stored in a different
variable.

This problem was introduced in 25a425e2db0a0ef13e80f92ec6637431f44f9fd9
("batman-adv: Receive fragmented packets and merge").

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
net/batman-adv/fragmentation.c