diff options
author | Simon Wunderlich <simon@open-mesh.com> | 2015-11-23 21:57:22 +0300 |
---|---|---|
committer | Antonio Quartulli <a@unstable.cc> | 2016-02-10 18:23:57 +0300 |
commit | 81f02683504dc5590204c3fa059eac86fbfa0927 (patch) | |
tree | 0a017bb5c39f36af77c9bd9c2922788e23daee8f /net/batman-adv/routing.c | |
parent | 140ed8e87ca8f4875c2b146cdb2cdbf0c9ac6080 (diff) | |
download | linux-81f02683504dc5590204c3fa059eac86fbfa0927.tar.xz |
batman-adv: add seqno maximum age and protection start flag parameters
To allow future use of the window protected function with different
maximum sequence numbers, add a parameter to set this value which
was previously hardcoded. Another parameter added for future use is a
flag to return whether the protection window has started.
While at it, also fix the kerneldoc.
Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r-- | net/batman-adv/routing.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index f4b60b1fb50e..1c8b35df50cf 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -146,23 +146,29 @@ out: * @bat_priv: the bat priv with all the soft interface information * @seq_num_diff: difference between the current/received sequence number and * the last sequence number + * @seq_old_max_diff: maximum age of sequence number not considered as restart * @last_reset: jiffies timestamp of the last reset, will be updated when reset * is detected + * @protection_started: is set to true if the protection window was started, + * doesn't change otherwise. * * Return: * 0 if the packet is to be accepted. * 1 if the packet is to be ignored. */ int batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff, - unsigned long *last_reset) + s32 seq_old_max_diff, unsigned long *last_reset, + bool *protection_started) { - if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || + if (seq_num_diff <= -seq_old_max_diff || seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) { if (!batadv_has_timed_out(*last_reset, BATADV_RESET_PROTECTION_MS)) return 1; *last_reset = jiffies; + if (protection_started) + *protection_started = true; batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "old packet received, start protection\n"); } @@ -1073,7 +1079,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, /* check whether the packet is old and the host just restarted. */ if (batadv_window_protected(bat_priv, seq_diff, - &orig_node->bcast_seqno_reset)) + BATADV_BCAST_MAX_AGE, + &orig_node->bcast_seqno_reset, NULL)) goto spin_unlock; /* mark broadcast in flood history, update window position |