|
@@ -789,6 +789,55 @@ err:
|
|
|
return NETDEV_TX_BUSY;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * batadv_forw_packet_bcasts_left - check if a retransmission is necessary
|
|
|
+ * @forw_packet: the forwarding packet to check
|
|
|
+ * @hard_iface: the interface to check on
|
|
|
+ *
|
|
|
+ * Checks whether a given packet has any (re)transmissions left on the provided
|
|
|
+ * interface.
|
|
|
+ *
|
|
|
+ * hard_iface may be NULL: In that case the number of transmissions this skb had
|
|
|
+ * so far is compared with the maximum amount of retransmissions independent of
|
|
|
+ * any interface instead.
|
|
|
+ *
|
|
|
+ * Return: True if (re)transmissions are left, false otherwise.
|
|
|
+ */
|
|
|
+static bool
|
|
|
+batadv_forw_packet_bcasts_left(struct batadv_forw_packet *forw_packet,
|
|
|
+ struct batadv_hard_iface *hard_iface)
|
|
|
+{
|
|
|
+ unsigned int max;
|
|
|
+
|
|
|
+ if (hard_iface)
|
|
|
+ max = hard_iface->num_bcasts;
|
|
|
+ else
|
|
|
+ max = BATADV_NUM_BCASTS_MAX;
|
|
|
+
|
|
|
+ return BATADV_SKB_CB(forw_packet->skb)->num_bcasts < max;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * batadv_forw_packet_bcasts_inc - increment retransmission counter of a packet
|
|
|
+ * @forw_packet: the packet to increase the counter for
|
|
|
+ */
|
|
|
+static void
|
|
|
+batadv_forw_packet_bcasts_inc(struct batadv_forw_packet *forw_packet)
|
|
|
+{
|
|
|
+ BATADV_SKB_CB(forw_packet->skb)->num_bcasts++;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * batadv_forw_packet_is_rebroadcast - check packet for previous transmissions
|
|
|
+ * @forw_packet: the packet to check
|
|
|
+ *
|
|
|
+ * Return: True if this packet was transmitted before, false otherwise.
|
|
|
+ */
|
|
|
+bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet)
|
|
|
+{
|
|
|
+ return BATADV_SKB_CB(forw_packet->skb)->num_bcasts > 0;
|
|
|
+}
|
|
|
+
|
|
|
static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
|
|
|
{
|
|
|
struct batadv_hard_iface *hard_iface;
|
|
@@ -829,7 +878,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
|
|
|
if (hard_iface->soft_iface != soft_iface)
|
|
|
continue;
|
|
|
|
|
|
- if (forw_packet->num_packets >= hard_iface->num_bcasts)
|
|
|
+ if (!batadv_forw_packet_bcasts_left(forw_packet, hard_iface))
|
|
|
continue;
|
|
|
|
|
|
if (forw_packet->own) {
|
|
@@ -887,10 +936,10 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
|
|
|
}
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- forw_packet->num_packets++;
|
|
|
+ batadv_forw_packet_bcasts_inc(forw_packet);
|
|
|
|
|
|
/* if we still have some more bcasts to send */
|
|
|
- if (forw_packet->num_packets < BATADV_NUM_BCASTS_MAX) {
|
|
|
+ if (batadv_forw_packet_bcasts_left(forw_packet, NULL)) {
|
|
|
batadv_forw_packet_bcast_queue(bat_priv, forw_packet,
|
|
|
send_time);
|
|
|
return;
|