batman-adv: forward late OGMs from best next hop
When a packet is received from another node first and later from the best next hop, this packet is dropped. However the first OGM was sent with the BATADV_NOT_BEST_NEXT_HOP flag and thus dropped by neighbors. The late OGM from the best neighbor is then dropped because it is a duplicate. If this situation happens constantly, a node might end up not forwarding the "valid" OGMs anymore, and nodes behind will starve from not getting valid OGMs. Fix this by refining the duplicate checking behaviour: The actions should depend on whether it was a duplicate for a neighbor only or for the originator. OGMs which are not duplicates for a specific neighbor will now be considered in batadv_iv_ogm_forward(), but only actually forwarded for the best next hop. Therefore, late OGMs from the best next hop are forwarded now and not dropped as duplicates anymore. Signed-off-by: Simon Wunderlich <simon@open-mesh.com> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
This commit is contained in:
parent
ac16d1484e
commit
7c24bbbeab
@ -29,6 +29,21 @@
|
|||||||
#include "bat_algo.h"
|
#include "bat_algo.h"
|
||||||
#include "network-coding.h"
|
#include "network-coding.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* batadv_dup_status - duplicate status
|
||||||
|
* @BATADV_NO_DUP: the packet is a duplicate
|
||||||
|
* @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
|
||||||
|
* neighbor)
|
||||||
|
* @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
|
||||||
|
* @BATADV_PROTECTED: originator is currently protected (after reboot)
|
||||||
|
*/
|
||||||
|
enum batadv_dup_status {
|
||||||
|
BATADV_NO_DUP = 0,
|
||||||
|
BATADV_ORIG_DUP,
|
||||||
|
BATADV_NEIGH_DUP,
|
||||||
|
BATADV_PROTECTED,
|
||||||
|
};
|
||||||
|
|
||||||
static struct batadv_neigh_node *
|
static struct batadv_neigh_node *
|
||||||
batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
|
batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
|
||||||
const uint8_t *neigh_addr,
|
const uint8_t *neigh_addr,
|
||||||
@ -650,7 +665,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
|
|||||||
const struct batadv_ogm_packet *batadv_ogm_packet,
|
const struct batadv_ogm_packet *batadv_ogm_packet,
|
||||||
struct batadv_hard_iface *if_incoming,
|
struct batadv_hard_iface *if_incoming,
|
||||||
const unsigned char *tt_buff,
|
const unsigned char *tt_buff,
|
||||||
int is_duplicate)
|
enum batadv_dup_status dup_status)
|
||||||
{
|
{
|
||||||
struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
|
struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
|
||||||
struct batadv_neigh_node *router = NULL;
|
struct batadv_neigh_node *router = NULL;
|
||||||
@ -676,7 +691,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_duplicate)
|
if (dup_status != BATADV_NO_DUP)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
spin_lock_bh(&tmp_neigh_node->lq_update_lock);
|
spin_lock_bh(&tmp_neigh_node->lq_update_lock);
|
||||||
@ -718,7 +733,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
|
|||||||
neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
|
neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
|
||||||
spin_unlock_bh(&neigh_node->lq_update_lock);
|
spin_unlock_bh(&neigh_node->lq_update_lock);
|
||||||
|
|
||||||
if (!is_duplicate) {
|
if (dup_status == BATADV_NO_DUP) {
|
||||||
orig_node->last_ttl = batadv_ogm_packet->header.ttl;
|
orig_node->last_ttl = batadv_ogm_packet->header.ttl;
|
||||||
neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
|
neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
|
||||||
}
|
}
|
||||||
@ -902,15 +917,16 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* processes a batman packet for all interfaces, adjusts the sequence number and
|
/**
|
||||||
* finds out whether it is a duplicate.
|
* batadv_iv_ogm_update_seqnos - process a batman packet for all interfaces,
|
||||||
* returns:
|
* adjust the sequence number and find out whether it is a duplicate
|
||||||
* 1 the packet is a duplicate
|
* @ethhdr: ethernet header of the packet
|
||||||
* 0 the packet has not yet been received
|
* @batadv_ogm_packet: OGM packet to be considered
|
||||||
* -1 the packet is old and has been received while the seqno window
|
* @if_incoming: interface on which the OGM packet was received
|
||||||
* was protected. Caller should drop it.
|
*
|
||||||
|
* Returns duplicate status as enum batadv_dup_status
|
||||||
*/
|
*/
|
||||||
static int
|
static enum batadv_dup_status
|
||||||
batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
|
batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
|
||||||
const struct batadv_ogm_packet *batadv_ogm_packet,
|
const struct batadv_ogm_packet *batadv_ogm_packet,
|
||||||
const struct batadv_hard_iface *if_incoming)
|
const struct batadv_hard_iface *if_incoming)
|
||||||
@ -918,17 +934,18 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
|
|||||||
struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
|
||||||
struct batadv_orig_node *orig_node;
|
struct batadv_orig_node *orig_node;
|
||||||
struct batadv_neigh_node *tmp_neigh_node;
|
struct batadv_neigh_node *tmp_neigh_node;
|
||||||
int is_duplicate = 0;
|
int is_dup;
|
||||||
int32_t seq_diff;
|
int32_t seq_diff;
|
||||||
int need_update = 0;
|
int need_update = 0;
|
||||||
int set_mark, ret = -1;
|
int set_mark;
|
||||||
|
enum batadv_dup_status ret = BATADV_NO_DUP;
|
||||||
uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
|
uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
|
||||||
uint8_t *neigh_addr;
|
uint8_t *neigh_addr;
|
||||||
uint8_t packet_count;
|
uint8_t packet_count;
|
||||||
|
|
||||||
orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
|
orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
|
||||||
if (!orig_node)
|
if (!orig_node)
|
||||||
return 0;
|
return BATADV_NO_DUP;
|
||||||
|
|
||||||
spin_lock_bh(&orig_node->ogm_cnt_lock);
|
spin_lock_bh(&orig_node->ogm_cnt_lock);
|
||||||
seq_diff = seqno - orig_node->last_real_seqno;
|
seq_diff = seqno - orig_node->last_real_seqno;
|
||||||
@ -936,22 +953,29 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
|
|||||||
/* signalize caller that the packet is to be dropped. */
|
/* signalize caller that the packet is to be dropped. */
|
||||||
if (!hlist_empty(&orig_node->neigh_list) &&
|
if (!hlist_empty(&orig_node->neigh_list) &&
|
||||||
batadv_window_protected(bat_priv, seq_diff,
|
batadv_window_protected(bat_priv, seq_diff,
|
||||||
&orig_node->batman_seqno_reset))
|
&orig_node->batman_seqno_reset)) {
|
||||||
|
ret = BATADV_PROTECTED;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
hlist_for_each_entry_rcu(tmp_neigh_node,
|
hlist_for_each_entry_rcu(tmp_neigh_node,
|
||||||
&orig_node->neigh_list, list) {
|
&orig_node->neigh_list, list) {
|
||||||
is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
|
|
||||||
orig_node->last_real_seqno,
|
|
||||||
seqno);
|
|
||||||
|
|
||||||
neigh_addr = tmp_neigh_node->addr;
|
neigh_addr = tmp_neigh_node->addr;
|
||||||
|
is_dup = batadv_test_bit(tmp_neigh_node->real_bits,
|
||||||
|
orig_node->last_real_seqno,
|
||||||
|
seqno);
|
||||||
|
|
||||||
if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
|
if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
|
||||||
tmp_neigh_node->if_incoming == if_incoming)
|
tmp_neigh_node->if_incoming == if_incoming) {
|
||||||
set_mark = 1;
|
set_mark = 1;
|
||||||
else
|
if (is_dup)
|
||||||
|
ret = BATADV_NEIGH_DUP;
|
||||||
|
} else {
|
||||||
set_mark = 0;
|
set_mark = 0;
|
||||||
|
if (is_dup && (ret != BATADV_NEIGH_DUP))
|
||||||
|
ret = BATADV_ORIG_DUP;
|
||||||
|
}
|
||||||
|
|
||||||
/* if the window moved, set the update flag. */
|
/* if the window moved, set the update flag. */
|
||||||
need_update |= batadv_bit_get_packet(bat_priv,
|
need_update |= batadv_bit_get_packet(bat_priv,
|
||||||
@ -971,8 +995,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
|
|||||||
orig_node->last_real_seqno = seqno;
|
orig_node->last_real_seqno = seqno;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = is_duplicate;
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
spin_unlock_bh(&orig_node->ogm_cnt_lock);
|
spin_unlock_bh(&orig_node->ogm_cnt_lock);
|
||||||
batadv_orig_node_free_ref(orig_node);
|
batadv_orig_node_free_ref(orig_node);
|
||||||
@ -994,7 +1016,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
|
|||||||
int is_broadcast = 0, is_bidirect;
|
int is_broadcast = 0, is_bidirect;
|
||||||
bool is_single_hop_neigh = false;
|
bool is_single_hop_neigh = false;
|
||||||
bool is_from_best_next_hop = false;
|
bool is_from_best_next_hop = false;
|
||||||
int is_duplicate, sameseq, simlar_ttl;
|
int sameseq, similar_ttl;
|
||||||
|
enum batadv_dup_status dup_status;
|
||||||
uint32_t if_incoming_seqno;
|
uint32_t if_incoming_seqno;
|
||||||
uint8_t *prev_sender;
|
uint8_t *prev_sender;
|
||||||
|
|
||||||
@ -1138,10 +1161,10 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
|
|||||||
if (!orig_node)
|
if (!orig_node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
|
dup_status = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
|
||||||
if_incoming);
|
if_incoming);
|
||||||
|
|
||||||
if (is_duplicate == -1) {
|
if (dup_status == BATADV_PROTECTED) {
|
||||||
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
||||||
"Drop packet: packet within seqno protection time (sender: %pM)\n",
|
"Drop packet: packet within seqno protection time (sender: %pM)\n",
|
||||||
ethhdr->h_source);
|
ethhdr->h_source);
|
||||||
@ -1211,11 +1234,12 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
|
|||||||
* seqno and similar ttl as the non-duplicate
|
* seqno and similar ttl as the non-duplicate
|
||||||
*/
|
*/
|
||||||
sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
|
sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
|
||||||
simlar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
|
similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
|
||||||
if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl)))
|
if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
|
||||||
|
(sameseq && similar_ttl)))
|
||||||
batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
|
batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
|
||||||
batadv_ogm_packet, if_incoming,
|
batadv_ogm_packet, if_incoming,
|
||||||
tt_buff, is_duplicate);
|
tt_buff, dup_status);
|
||||||
|
|
||||||
/* is single hop (direct) neighbor */
|
/* is single hop (direct) neighbor */
|
||||||
if (is_single_hop_neigh) {
|
if (is_single_hop_neigh) {
|
||||||
@ -1236,7 +1260,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
|
|||||||
goto out_neigh;
|
goto out_neigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_duplicate) {
|
if (dup_status == BATADV_NEIGH_DUP) {
|
||||||
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
||||||
"Drop packet: duplicate packet received\n");
|
"Drop packet: duplicate packet received\n");
|
||||||
goto out_neigh;
|
goto out_neigh;
|
||||||
|
Loading…
Reference in New Issue
Block a user