aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2011-06-26 15:15:13 -0400
committerMarek Lindner <lindner_marek@yahoo.de>2011-07-05 08:28:55 -0400
commitb539e4cd3b08dddbaa2ba0f158eed3c7c2244eaf (patch)
tree59713bdbcf7e5787f65ea3d6c82f3128d23414b7 /net/batman-adv
parent6a020ab452d38b3878903de931c162429072a7d7 (diff)
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>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/aggregation.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/net/batman-adv/aggregation.c b/net/batman-adv/aggregation.c
index c583e049f421..69467fe71ff2 100644
--- a/net/batman-adv/aggregation.c
+++ b/net/batman-adv/aggregation.c
@@ -28,6 +28,7 @@
28 28
29/* return true if new_packet can be aggregated with forw_packet */ 29/* return true if new_packet can be aggregated with forw_packet */
30static bool can_aggregate_with(const struct batman_packet *new_batman_packet, 30static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
31 struct bat_priv *bat_priv,
31 int packet_len, 32 int packet_len,
32 unsigned long send_time, 33 unsigned long send_time,
33 bool directlink, 34 bool directlink,
@@ -37,6 +38,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
37 struct batman_packet *batman_packet = 38 struct batman_packet *batman_packet =
38 (struct batman_packet *)forw_packet->skb->data; 39 (struct batman_packet *)forw_packet->skb->data;
39 int aggregated_bytes = forw_packet->packet_len + packet_len; 40 int aggregated_bytes = forw_packet->packet_len + packet_len;
41 struct hard_iface *primary_if = NULL;
42 bool res = false;
40 43
41 /** 44 /**
42 * we can aggregate the current packet to this aggregated packet 45 * we can aggregate the current packet to this aggregated packet
@@ -61,6 +64,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
61 * packet 64 * packet
62 */ 65 */
63 66
67 primary_if = primary_if_get_selected(bat_priv);
68 if (!primary_if)
69 goto out;
70
64 /* packets without direct link flag and high TTL 71 /* packets without direct link flag and high TTL
65 * are flooded through the net */ 72 * are flooded through the net */
66 if ((!directlink) && 73 if ((!directlink) &&
@@ -70,8 +77,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
70 /* own packets originating non-primary 77 /* own packets originating non-primary
71 * interfaces leave only that interface */ 78 * interfaces leave only that interface */
72 ((!forw_packet->own) || 79 ((!forw_packet->own) ||
73 (forw_packet->if_incoming->if_num == 0))) 80 (forw_packet->if_incoming == primary_if))) {
74 return true; 81 res = true;
82 goto out;
83 }
75 84
76 /* if the incoming packet is sent via this one 85 /* if the incoming packet is sent via this one
77 * interface only - we still can aggregate */ 86 * interface only - we still can aggregate */
@@ -84,11 +93,16 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
84 * (= secondary interface packets in general) */ 93 * (= secondary interface packets in general) */
85 (batman_packet->flags & DIRECTLINK || 94 (batman_packet->flags & DIRECTLINK ||
86 (forw_packet->own && 95 (forw_packet->own &&
87 forw_packet->if_incoming->if_num != 0))) 96 forw_packet->if_incoming != primary_if))) {
88 return true; 97 res = true;
98 goto out;
99 }
89 } 100 }
90 101
91 return false; 102out:
103 if (primary_if)
104 hardif_free_ref(primary_if);
105 return res;
92} 106}
93 107
94/* create a new aggregated packet and add this packet to it */ 108/* create a new aggregated packet and add this packet to it */
@@ -210,6 +224,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
210 hlist_for_each_entry(forw_packet_pos, tmp_node, 224 hlist_for_each_entry(forw_packet_pos, tmp_node,
211 &bat_priv->forw_bat_list, list) { 225 &bat_priv->forw_bat_list, list) {
212 if (can_aggregate_with(batman_packet, 226 if (can_aggregate_with(batman_packet,
227 bat_priv,
213 packet_len, 228 packet_len,
214 send_time, 229 send_time,
215 direct_link, 230 direct_link,