Merge pull request #136 from HRogge/master
[feed/routing.git] / batman-adv / patches / 0002-batman-adv-Add-lower-layer-needed_-head-tail-room-to.patch
1 From e2b4301f4e2d3695ed2024880d2295223cb2f857 Mon Sep 17 00:00:00 2001
2 From: Sven Eckelmann <sven@narfation.org>
3 Date: Fri, 7 Aug 2015 19:28:42 +0200
4 Subject: [PATCH 2/9] batman-adv: Add lower layer needed_(head|tail)room to own
5 ones
6
7 The maximum of hard_header_len and maximum of all needed_(head|tail)room of
8 all slave interfaces of a batman-adv device must be used to define the
9 batman-adv device needed_(head|tail)room. This is required to avoid too
10 small buffer problems when these slave devices try to send the encapsulated
11 packet in a tx path without the possibility to resize the skbuff.
12
13 Signed-off-by: Sven Eckelmann <sven@narfation.org>
14 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
15 ---
16 net/batman-adv/hard-interface.c | 41 +++++++++++++++++++++++++++++++++++++++++
17 net/batman-adv/soft-interface.c | 2 --
18 2 files changed, 41 insertions(+), 2 deletions(-)
19
20 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
21 index 0565b20..f11345e 100644
22 --- a/net/batman-adv/hard-interface.c
23 +++ b/net/batman-adv/hard-interface.c
24 @@ -252,6 +252,44 @@ static void batadv_check_known_mac_addr(const struct net_device *net_dev)
25 rcu_read_unlock();
26 }
27
28 +/**
29 + * batadv_hardif_recalc_extra_skbroom() - Recalculate skbuff extra head/tailroom
30 + * @soft_iface: netdev struct of the mesh interface
31 + */
32 +static void batadv_hardif_recalc_extra_skbroom(struct net_device *soft_iface)
33 +{
34 + const struct batadv_hard_iface *hard_iface;
35 + unsigned short lower_header_len = ETH_HLEN;
36 + unsigned short lower_headroom = 0;
37 + unsigned short lower_tailroom = 0;
38 + unsigned short needed_headroom;
39 +
40 + rcu_read_lock();
41 + list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
42 + if (hard_iface->if_status == BATADV_IF_NOT_IN_USE)
43 + continue;
44 +
45 + if (hard_iface->soft_iface != soft_iface)
46 + continue;
47 +
48 + lower_header_len = max_t(unsigned short, lower_header_len,
49 + hard_iface->net_dev->hard_header_len);
50 +
51 + lower_headroom = max_t(unsigned short, lower_headroom,
52 + hard_iface->net_dev->needed_headroom);
53 +
54 + lower_tailroom = max_t(unsigned short, lower_tailroom,
55 + hard_iface->net_dev->needed_tailroom);
56 + }
57 + rcu_read_unlock();
58 +
59 + needed_headroom = lower_headroom + (lower_header_len - ETH_HLEN);
60 + needed_headroom += batadv_max_header_len();
61 +
62 + soft_iface->needed_headroom = needed_headroom;
63 + soft_iface->needed_tailroom = lower_tailroom;
64 +}
65 +
66 int batadv_hardif_min_mtu(struct net_device *soft_iface)
67 {
68 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
69 @@ -474,6 +512,8 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
70 "Not using interface %s (retrying later): interface not active\n",
71 hard_iface->net_dev->name);
72
73 + batadv_hardif_recalc_extra_skbroom(soft_iface);
74 +
75 /* begin scheduling originator messages on that interface */
76 batadv_schedule_bat_ogm(hard_iface);
77
78 @@ -529,6 +569,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
79 dev_put(hard_iface->soft_iface);
80
81 netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface);
82 + batadv_hardif_recalc_extra_skbroom(hard_iface->soft_iface);
83
84 /* nobody uses this interface anymore */
85 if (!bat_priv->num_ifaces) {
86 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
87 index 51cda3a..10f6448 100644
88 --- a/net/batman-adv/soft-interface.c
89 +++ b/net/batman-adv/soft-interface.c
90 @@ -947,8 +947,6 @@ static void batadv_softif_init_early(struct net_device *dev)
91 * have not been initialized yet
92 */
93 dev->mtu = ETH_DATA_LEN;
94 - /* reserve more space in the skbuff for our header */
95 - dev->hard_header_len = batadv_max_header_len();
96
97 /* generate random address */
98 eth_hw_addr_random(dev);
99 --
100 2.5.0
101