To avoid loops in the startup phase until the first announcement is sent, send an announcement immediately as soon as a backbone gw is added.
This may happen due to various reasons, e.g. a packet passes the rx or tx path.
Signed-off-by: Simon Wunderlich siwu@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 0921509..c522bdf 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -362,7 +362,7 @@ out: */ static struct batadv_backbone_gw * batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, - short vid) + short vid, bool own_backbone) { struct batadv_backbone_gw *entry; struct batadv_orig_node *orig_node; @@ -409,6 +409,10 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, "became a backbone gateway"); batadv_orig_node_free_ref(orig_node); } + + if (own_backbone) + batadv_bla_send_announce(bat_priv, entry); + return entry; }
@@ -424,7 +428,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
backbone_gw = batadv_bla_get_backbone_gw(bat_priv, primary_if->net_dev->dev_addr, - vid); + vid, true); if (unlikely(!backbone_gw)) return;
@@ -632,7 +636,8 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv, if (memcmp(an_addr, batadv_announce_mac, 4) != 0) return 0;
- backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid); + backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid, + false);
if (unlikely(!backbone_gw)) return 1; @@ -730,7 +735,8 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
/* register the gateway if not yet available, and add the claim. */
- backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid); + backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid, + false);
if (unlikely(!backbone_gw)) return 1;
When adding a backbone gateway for the first time, it might not yet be known in the backbone, and therefore we should not forward broadcasts yet. This behaviour is the same as when sending a request to another backbone gw because of a CRC mismatch. The backbone gw will operate normal after the next periodic bla work.
Signed-off-by: Simon Wunderlich siwu@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index c522bdf..073dd15 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -410,9 +410,14 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, batadv_orig_node_free_ref(orig_node); }
- if (own_backbone) + if (own_backbone) { batadv_bla_send_announce(bat_priv, entry);
+ /* this will be decreased in the worker thread */ + atomic_inc(&entry->request_sent); + atomic_inc(&bat_priv->bla.num_requests); + } + return entry; }
@@ -1146,6 +1151,18 @@ static void batadv_bla_periodic_work(struct work_struct *work) backbone_gw->lasttime = jiffies;
batadv_bla_send_announce(bat_priv, backbone_gw); + + /* request_sent is only set after creation to avoid + * problems when we are not yet known as backbone gw + * in the backbone. + * + * We can reset this now and allow traffic again. */ + + if (atomic_read(&backbone_gw->request_sent) == 0) + continue; + + atomic_dec(&backbone_gw->bat_priv->bla.num_requests); + atomic_set(&backbone_gw->request_sent, 0); } rcu_read_unlock(); }
On Sunday, September 09, 2012 00:02:54 Simon Wunderlich wrote:
/* request_sent is only set after creation to avoid
* problems when we are not yet known as backbone gw
* in the backbone.
*
* We can reset this now and allow traffic again. */
Please use the David comment style here.
Cheers, Marek
When adding a backbone gateway for the first time, it might not yet be known in the backbone, and therefore we should not forward broadcasts yet. This behaviour is the same as when sending a request to another backbone gw because of a CRC mismatch. The backbone gw will operate normal after the next periodic bla work.
Signed-off-by: Simon Wunderlich siwu@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index c522bdf..db046d8 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -410,9 +410,14 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, batadv_orig_node_free_ref(orig_node); }
- if (own_backbone) + if (own_backbone) { batadv_bla_send_announce(bat_priv, entry);
+ /* this will be decreased in the worker thread */ + atomic_inc(&entry->request_sent); + atomic_inc(&bat_priv->bla.num_requests); + } + return entry; }
@@ -1146,6 +1151,19 @@ static void batadv_bla_periodic_work(struct work_struct *work) backbone_gw->lasttime = jiffies;
batadv_bla_send_announce(bat_priv, backbone_gw); + + /* request_sent is only set after creation to avoid + * problems when we are not yet known as backbone gw + * in the backbone. + * + * We can reset this now and allow traffic again. + */ + + if (atomic_read(&backbone_gw->request_sent) == 0) + continue; + + atomic_dec(&backbone_gw->bat_priv->bla.num_requests); + atomic_set(&backbone_gw->request_sent, 0); } rcu_read_unlock(); }
On Monday, September 10, 2012 04:27:57 Simon Wunderlich wrote:
When adding a backbone gateway for the first time, it might not yet be known in the backbone, and therefore we should not forward broadcasts yet. This behaviour is the same as when sending a request to another backbone gw because of a CRC mismatch. The backbone gw will operate normal after the next periodic bla work.
Signed-off-by: Simon Wunderlich siwu@hrz.tu-chemnitz.de
bridge_loop_avoidance.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
Applied in revision e344097.
Thanks, Marek
On Sunday, September 09, 2012 00:02:53 Simon Wunderlich wrote:
To avoid loops in the startup phase until the first announcement is sent, send an announcement immediately as soon as a backbone gw is added.
This may happen due to various reasons, e.g. a packet passes the rx or tx path.
Signed-off-by: Simon Wunderlich siwu@hrz.tu-chemnitz.de
bridge_loop_avoidance.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
Applied in revision 5c28095.
Thanks, Marek
b.a.t.m.a.n@lists.open-mesh.org