Re: [B.A.T.M.A.N.] [PATCHv7 2/4] batman-adv: Announce new capability via multicast TVLV

Marek Lindner
2013-07-06T10:57:44Z

On Thursday, July 04, 2013 06:03:20 Linus Lüssing wrote:
> diff --git a/multicast.c b/multicast.c
> index 7ea19ab..4af4bc9 100644
> --- a/net/batman-adv/multicast.c
> +++ b/net/batman-adv/multicast.c
> @@ -169,13 +169,30 @@ void batadv_mcast_mla_tt_update(struct batadv_priv
> *bat_priv) struct net_device *soft_iface = bat_priv->soft_iface;
> struct hlist_head mcast_list = HLIST_HEAD_INIT;
> int ret;
> + static bool enabled;
> + uint8_t mcast_flags;
>
> /* Avoid attaching MLAs, if multicast optimization is disabled
> * or there is a bridge on top of our soft interface (TODO)
> */
> if (!atomic_read(&bat_priv->multicast_mode) ||
> - bat_priv->soft_iface->priv_flags & IFF_BRIDGE_PORT)
> + bat_priv->soft_iface->priv_flags & IFF_BRIDGE_PORT) {
> + if (enabled) {
> + batadv_tvlv_container_unregister(bat_priv,
> + BATADV_TVLV_MCAST,
> 1); + enabled = false;
> + }
> +
> goto update;
> + }
> +
> + if (!enabled) {
> + mcast_flags = BATADV_MCAST_LISTENER_ANNOUNCEMENT;
> + batadv_tvlv_container_register(bat_priv, BATADV_TVLV_MCAST,
> 1, + &mcast_flags,
> + sizeof(mcast_flags));
> + enabled = true;
> + }
>
> ret = batadv_mcast_mla_softif_get(soft_iface, &mcast_list);
> if (ret < 0)

Is there no better way than using a static variable ? Apart from bad
readibility this totally breaks when using several batX interfaces with
different settings.

> +/* multicast capabilities */
> +enum batadv_mcast_flags {
> + BATADV_MCAST_LISTENER_ANNOUNCEMENT = BIT(0),
> +};

Didn't we discuss that using feature names is better ? We talked about things
like UNICAST, TRACKER, etc ?

Cheers,
Marek