From: Marek Lindner <lindner_marek@yahoo.de>
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: Wed, 15 Jun 2011 23:28:28 +0200 [thread overview]
Message-ID: <201106152328.29223.lindner_marek@yahoo.de> (raw)
In-Reply-To: <1307307664-19910-2-git-send-email-ordex@autistici.org>
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.
> @@ -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 ?
> 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.
> +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. :-)
> /* 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.
Regards,
Marek
next prev parent reply other threads:[~2011-06-15 21:28 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 [this message]
2011-06-15 22:43 ` Antonio Quartulli
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=201106152328.29223.lindner_marek@yahoo.de \
--to=lindner_marek@yahoo.de \
--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