Commit b539e4cd authored by Marek Lindner's avatar Marek Lindner

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: default avatarAntonio Quartulli <ordex@autistici.org>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
parent 6a020ab4
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
/* return true if new_packet can be aggregated with forw_packet */ /* return true if new_packet can be aggregated with forw_packet */
static bool can_aggregate_with(const struct batman_packet *new_batman_packet, static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
struct bat_priv *bat_priv,
int packet_len, int packet_len,
unsigned long send_time, unsigned long send_time,
bool directlink, bool directlink,
...@@ -37,6 +38,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, ...@@ -37,6 +38,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
struct batman_packet *batman_packet = struct batman_packet *batman_packet =
(struct batman_packet *)forw_packet->skb->data; (struct batman_packet *)forw_packet->skb->data;
int aggregated_bytes = forw_packet->packet_len + packet_len; int aggregated_bytes = forw_packet->packet_len + packet_len;
struct hard_iface *primary_if = NULL;
bool res = false;
/** /**
* we can aggregate the current packet to this aggregated packet * 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,6 +64,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
* packet * packet
*/ */
primary_if = primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;
/* packets without direct link flag and high TTL /* packets without direct link flag and high TTL
* are flooded through the net */ * are flooded through the net */
if ((!directlink) && if ((!directlink) &&
...@@ -70,8 +77,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, ...@@ -70,8 +77,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
/* own packets originating non-primary /* own packets originating non-primary
* interfaces leave only that interface */ * interfaces leave only that interface */
((!forw_packet->own) || ((!forw_packet->own) ||
(forw_packet->if_incoming->if_num == 0))) (forw_packet->if_incoming == primary_if))) {
return true; res = true;
goto out;
}
/* if the incoming packet is sent via this one /* if the incoming packet is sent via this one
* interface only - we still can aggregate */ * interface only - we still can aggregate */
...@@ -84,11 +93,16 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, ...@@ -84,11 +93,16 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
* (= secondary interface packets in general) */ * (= secondary interface packets in general) */
(batman_packet->flags & DIRECTLINK || (batman_packet->flags & DIRECTLINK ||
(forw_packet->own && (forw_packet->own &&
forw_packet->if_incoming->if_num != 0))) forw_packet->if_incoming != primary_if))) {
return true; res = true;
goto out;
}
} }
return false; out:
if (primary_if)
hardif_free_ref(primary_if);
return res;
} }
/* create a new aggregated packet and add this packet to it */ /* 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,6 +224,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
hlist_for_each_entry(forw_packet_pos, tmp_node, hlist_for_each_entry(forw_packet_pos, tmp_node,
&bat_priv->forw_bat_list, list) { &bat_priv->forw_bat_list, list) {
if (can_aggregate_with(batman_packet, if (can_aggregate_with(batman_packet,
bat_priv,
packet_len, packet_len,
send_time, send_time,
direct_link, direct_link,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment