From: Antonio Quartulli <ordex@autistici.org>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: detect clients connected through a 802.11 device
Date: Thu, 16 Jun 2011 00:43:55 +0200 [thread overview]
Message-ID: <20110615224355.GA15320@ritirata.org> (raw)
In-Reply-To: <201106152328.29223.lindner_marek@yahoo.de>
On mer, giu 15, 2011 at 11:28:28 +0200, Marek Lindner wrote:
> On Sunday, June 05, 2011 11:01:02 PM Antonio Quartulli wrote:
> > +/* This function returns true if the interface represented by ifindex is a
> > + * 802.11 wireless device */
> > +bool is_wifi_iface(int ifindex)
> > +{
> > + struct net_device *net_device;
> > +
> > + if (ifindex == NULL_IFINDEX)
> > + return false;
> > +
> > + net_device = dev_get_by_index(&init_net, ifindex);
> > + if (!net_device)
> > + return false;
> > +
> > +#ifdef CONFIG_WIRELESS_EXT
> > + /* pre-cfg80211 drivers have to implement WEXT, so it is possible to
> > + * check for wireless_handlers != NULL */
> > + if (net_device->wireless_handlers)
> > + return true;
> > + else
> > +#endif
> > + /* cfg80211 drivers have to set ieee80211_ptr */
> > + if (net_device->ieee80211_ptr)
> > + return true;
> > + return false;
> > +}
>
> If I am not mistaken dev_get_by_index() increases a counter on the returned
> interface. We have to decrease that counter as soon as we don't need the
> interface anymore otherwise the interface can never be freed.
Definitely right!
>
>
> > @@ -108,7 +108,7 @@ int mesh_init(struct net_device *soft_iface)
> > if (tt_init(bat_priv) < 1)
> > goto err;
> >
> > - tt_local_add(soft_iface, soft_iface->dev_addr);
> > + tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);
>
> Are you sure 0 is not a valid index for any interface ?
Yes. You can also check the function dev_new_index() at
http://lxr.linux.no/linux+v2.6.39/net/core/dev.c#L5080
indexes start from 1 :)
>
>
> > static void tt_local_event(struct bat_priv *bat_priv, uint8_t op,
> > - const uint8_t *addr, bool roaming)
> > + const uint8_t *addr, bool roaming, bool wifi)
>
> How about adding a set of flags (TT_CLIENT_ROAM / TT_CLIENT_WIFI / etc)
> instead of adding more and more bool arguments ? In several places the code
> converts one to the other which does not seem necessary.
You mean simply passing a int value which is combination of the used
flags? mught be a good idea, even for further changes.
>
>
> > +void tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
> > + int ifindex)
> > {
> > struct bat_priv *bat_priv = netdev_priv(soft_iface);
> > struct tt_local_entry *tt_local_entry = NULL;
> > @@ -204,21 +231,22 @@ void tt_local_add(struct net_device *soft_iface,
> > const uint8_t *addr) if (!tt_local_entry)
> > goto out;
> >
> > - tt_local_event(bat_priv, NO_FLAGS, addr, false);
> > -
> > bat_dbg(DBG_TT, bat_priv,
> > "Creating new local tt entry: %pM (ttvn: %d)\n", addr,
> > (uint8_t)atomic_read(&bat_priv->ttvn));
> >
> > memcpy(tt_local_entry->addr, addr, ETH_ALEN);
> > tt_local_entry->last_seen = jiffies;
> > + tt_local_entry->flags = 0;
>
> Here you should make use of the NO_FLAGS define you introduced. :-)
Right :)
>
>
> > /* the batman interface mac address should never be purged */
> > if (compare_eth(addr, soft_iface->dev_addr))
> > - tt_local_entry->never_purge = 1;
> > - else
> > - tt_local_entry->never_purge = 0;
> > + tt_local_entry->flags |= TT_LOCAL_NOPURGE;
> > +
> > + tt_local_event(bat_priv, NO_FLAGS, addr, false,
> > + tt_local_entry->flags & TT_CLIENT_WIFI);
>
> Changing "never_purge" to a flag probably is a good idea but should go into a
> separate patch.
Ok, I'll propose a separated patch.
Thank you for reviewing!
Regards,
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
next prev parent reply other threads:[~2011-06-15 22:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-05 21:01 [B.A.T.M.A.N.] [PATCH 0/3] Implement the AP-Isolation mechanism Antonio Quartulli
2011-06-05 21:01 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: detect clients connected through a 802.11 device Antonio Quartulli
2011-06-05 21:42 ` Andrew Lunn
2011-06-05 22:01 ` Antonio Quartulli
2011-06-05 23:22 ` Antonio Quartulli
2011-06-15 21:28 ` Marek Lindner
2011-06-15 22:43 ` Antonio Quartulli [this message]
2011-06-16 10:12 ` Marek Lindner
2011-06-05 21:01 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: implement AP-isolation on the sender side Antonio Quartulli
2011-06-05 21:50 ` Andrew Lunn
2011-06-15 21:38 ` Marek Lindner
2011-06-05 21:01 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: implement AP-isolation on the receiver side Antonio Quartulli
2011-06-05 21:55 ` Andrew Lunn
2011-06-05 22:16 ` Antonio Quartulli
2011-06-15 21:42 ` Marek Lindner
2011-06-15 22:45 ` Antonio Quartulli
2011-06-26 21:00 ` [B.A.T.M.A.N.] [PATCHv2 1/4] batman-adv: detect clients connected through a 802.11 device Antonio Quartulli
2011-06-26 21:00 ` [B.A.T.M.A.N.] [PATCHv2 2/4] batman-adv: implement AP-isolation on the receiver side Antonio Quartulli
2011-06-26 21:00 ` [B.A.T.M.A.N.] [PATCHv2 3/4] batman-adv: implement AP-isolation on the sender side Antonio Quartulli
2011-06-26 21:00 ` [B.A.T.M.A.N.] [PATCHv2 4/4] batman-adv: print client flags in the local/global transtables output Antonio Quartulli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110615224355.GA15320@ritirata.org \
--to=ordex@autistici.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).