提交 81f02683 编写于 作者: S Simon Wunderlich 提交者: Antonio Quartulli

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: NSimon Wunderlich <simon@open-mesh.com>
Signed-off-by: NMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: NAntonio Quartulli <a@unstable.cc>
上级 140ed8e8
...@@ -1315,7 +1315,8 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -1315,7 +1315,8 @@ 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_ifinfo->batman_seqno_reset)) { BATADV_TQ_LOCAL_WINDOW_SIZE,
&orig_ifinfo->batman_seqno_reset, NULL)) {
ret = BATADV_PROTECTED; ret = BATADV_PROTECTED;
goto out; goto out;
} }
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
/* Time To Live of broadcast messages */ /* Time To Live of broadcast messages */
#define BATADV_TTL 50 #define BATADV_TTL 50
/* maximum sequence number age of broadcast messages */
#define BATADV_BCAST_MAX_AGE 64
/* purge originators after time in seconds if no valid packet comes in /* purge originators after time in seconds if no valid packet comes in
* -> TODO: check influence on BATADV_TQ_LOCAL_WINDOW_SIZE * -> TODO: check influence on BATADV_TQ_LOCAL_WINDOW_SIZE
*/ */
......
...@@ -146,23 +146,29 @@ void batadv_update_route(struct batadv_priv *bat_priv, ...@@ -146,23 +146,29 @@ void batadv_update_route(struct batadv_priv *bat_priv,
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @seq_num_diff: difference between the current/received sequence number and * @seq_num_diff: difference between the current/received sequence number and
* the last sequence number * 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 * @last_reset: jiffies timestamp of the last reset, will be updated when reset
* is detected * is detected
* @protection_started: is set to true if the protection window was started,
* doesn't change otherwise.
* *
* Return: * Return:
* 0 if the packet is to be accepted. * 0 if the packet is to be accepted.
* 1 if the packet is to be ignored. * 1 if the packet is to be ignored.
*/ */
int batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff, 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) { seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
if (!batadv_has_timed_out(*last_reset, if (!batadv_has_timed_out(*last_reset,
BATADV_RESET_PROTECTION_MS)) BATADV_RESET_PROTECTION_MS))
return 1; return 1;
*last_reset = jiffies; *last_reset = jiffies;
if (protection_started)
*protection_started = true;
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"old packet received, start protection\n"); "old packet received, start protection\n");
} }
...@@ -1073,7 +1079,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, ...@@ -1073,7 +1079,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
/* check whether the packet is old and the host just restarted. */ /* check whether the packet is old and the host just restarted. */
if (batadv_window_protected(bat_priv, seq_diff, 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; goto spin_unlock;
/* mark broadcast in flood history, update window position /* mark broadcast in flood history, update window position
......
...@@ -52,6 +52,7 @@ batadv_find_router(struct batadv_priv *bat_priv, ...@@ -52,6 +52,7 @@ batadv_find_router(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
struct batadv_hard_iface *recv_if); struct batadv_hard_iface *recv_if);
int batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff, 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);
#endif /* _NET_BATMAN_ADV_ROUTING_H_ */ #endif /* _NET_BATMAN_ADV_ROUTING_H_ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册