[3/3] batman-adv: implement AP-isolation on the receiver side
Commit Message
When a node receives a unicast packet it checks if the source and the
destination client can communicate or not due to the AP isolation
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
soft-interface.c | 3 +++
translation-table.c | 30 ++++++++++++++++++++++++++++++
translation-table.h | 1 +
3 files changed, 34 insertions(+), 0 deletions(-)
Comments
> diff --git a/translation-table.c b/translation-table.c
> index e0c5945..24e48e7 100644
> --- a/translation-table.c
> +++ b/translation-table.c
> @@ -1683,3 +1683,33 @@ void tt_free(struct bat_priv *bat_priv)
>
> kfree(bat_priv->tt_buff);
> }
> +
> +bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst)
Doh!
O.K. The ordering could of been better... but the code at the end is
O.K, which is what matters.
Andrew
On dom, giu 05, 2011 at 11:55:52 +0200, Andrew Lunn wrote:
> > diff --git a/translation-table.c b/translation-table.c
> > index e0c5945..24e48e7 100644
> > --- a/translation-table.c
> > +++ b/translation-table.c
> > @@ -1683,3 +1683,33 @@ void tt_free(struct bat_priv *bat_priv)
> >
> > kfree(bat_priv->tt_buff);
> > }
> > +
> > +bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst)
>
> Doh!
>
> O.K. The ordering could of been better... but the code at the end is
> O.K, which is what matters.
>
:-) I avoided to rename such function...so I directly called it _foobar
from the beginning.
Regards,
On Sunday, June 05, 2011 11:55:52 PM Andrew Lunn wrote:
> > diff --git a/translation-table.c b/translation-table.c
> > index e0c5945..24e48e7 100644
> > --- a/translation-table.c
> > +++ b/translation-table.c
> > @@ -1683,3 +1683,33 @@ void tt_free(struct bat_priv *bat_priv)
> >
> > kfree(bat_priv->tt_buff);
> >
> > }
> >
> > +
> > +bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t
> > *dst)
>
> Doh!
>
> O.K. The ordering could of been better... but the code at the end is
> O.K, which is what matters.
Aarrgh, same here. Let's see how many others fall into this trap.
How about reversing the order of these patches to avoid this "problem" ?
Regards,
Marek
On mer, giu 15, 2011 at 11:42:38 +0200, Marek Lindner wrote:
> On Sunday, June 05, 2011 11:55:52 PM Andrew Lunn wrote:
> > > diff --git a/translation-table.c b/translation-table.c
> > > index e0c5945..24e48e7 100644
> > > --- a/translation-table.c
> > > +++ b/translation-table.c
> > > @@ -1683,3 +1683,33 @@ void tt_free(struct bat_priv *bat_priv)
> > >
> > > kfree(bat_priv->tt_buff);
> > >
> > > }
> > >
> > > +
> > > +bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t
> > > *dst)
> >
> > Doh!
> >
> > O.K. The ordering could of been better... but the code at the end is
> > O.K, which is what matters.
>
> Aarrgh, same here. Let's see how many others fall into this trap.
> How about reversing the order of these patches to avoid this "problem" ?
Mh...the patches should be independent from each other. ok I like your
suggestion :)
Thank you!
Regards,
@@ -733,6 +733,9 @@ void interface_rx(struct net_device *soft_iface,
soft_iface->last_rx = jiffies;
+ if (is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
+ goto dropped;
+
netif_rx(skb);
goto out;
@@ -1683,3 +1683,33 @@ void tt_free(struct bat_priv *bat_priv)
kfree(bat_priv->tt_buff);
}
+
+bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst)
+{
+ struct tt_local_entry *tt_local_entry = NULL;
+ struct tt_global_entry *tt_global_entry = NULL;
+ bool ret = true;
+
+ if (!atomic_read(&bat_priv->ap_isolation))
+ return false;
+
+ tt_local_entry = tt_local_hash_find(bat_priv, dst);
+ if (!tt_local_entry)
+ goto out;
+
+ tt_global_entry = tt_global_hash_find(bat_priv, src);
+ if (!tt_global_entry)
+ goto out;
+
+ if (_is_ap_isolated(tt_local_entry, tt_global_entry))
+ goto out;
+
+ ret = false;
+
+out:
+ if (tt_global_entry)
+ tt_global_entry_free_ref(tt_global_entry);
+ if (tt_local_entry)
+ tt_local_entry_free_ref(tt_local_entry);
+ return ret;
+}
@@ -67,5 +67,6 @@ void handle_tt_response(struct bat_priv *bat_priv,
struct tt_query_packet *tt_response);
void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
struct orig_node *orig_node);
+bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst);
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */