b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.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.] [PATCHv7 4/4] batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support
Date: Fri, 12 Jul 2013 11:12:16 +0200	[thread overview]
Message-ID: <20130712091215.GA9077@pandem0nium> (raw)
In-Reply-To: <1372889002-6767-5-git-send-email-linus.luessing@web.de>

[-- Attachment #1: Type: text/plain, Size: 3195 bytes --]

On Thu, Jul 04, 2013 at 12:03:22AM +0200, Linus Lüssing wrote:
> [...]
> +enum batadv_forw_mode
> +batadv_mcast_forw_mode(struct sk_buff *skb, struct batadv_priv *bat_priv)
> +{
> +	struct ethhdr *ethhdr = (struct ethhdr *)(skb->data);
> +	int ret;
> +
> +	ret = batadv_mcast_forw_mode_check(skb, bat_priv);
> +	if (ret == -ENOMEM)
> +		return BATADV_FORW_NONE;
> +	else if (ret == -EINVAL)

Shouldn't this better be "ret < 0", in case you add more error cases later? 

>  		return BATADV_FORW_ALL;
>  
> -	count = batadv_tt_global_hash_count(bat_priv, ethhdr->h_dest,
> +	ret = batadv_tt_global_hash_count(bat_priv, ethhdr->h_dest,
>  					    BATADV_NO_FLAGS);
>  
> -	switch (count) {
> +	switch (ret) {
>  	case 0:
>  		return BATADV_FORW_NONE;
>  	case 1:
> @@ -263,6 +348,28 @@ batadv_mcast_forw_mode(struct sk_buff *skb, struct batadv_priv *bat_priv)
>  }
>  
>  /**
> + * batadv_mcast_tvlv_update_flag_counter - update the counter of a flag
> + * @flag: the flag we want to update counters for
> + * @flag_counter: the counter we might update
> + * @new_flags: the new capability bitset of a node
> + * @old_flags: the current, to be updated bitset of a node
> + *
> + * Update the given flag_counter with the help of the new flag information
> + * of a node to reflect how many nodes have the given flag unset.
> + */
> +static void batadv_mcast_tvlv_update_flag_counter(uint8_t flag,
> +						  atomic_t *flag_counter,
> +						  uint8_t new_flags,
> +						  int old_flags)

Why are parts of the bitsets uint8_t, some int?

Also, this function should go into one of the previous patches, this has nothing to do with
IPv4 but is just a refactoring.

> +{
> +	if (!(new_flags & flag) &&
> +	    (old_flags & flag || old_flags & BATADV_UNINIT_FLAGS))
> +		atomic_inc(flag_counter);
> +	else if (new_flags & flag && !(old_flags & flag))
> +		atomic_dec(flag_counter);
> +}
> +
> +/**
>   * batadv_mcast_tvlv_ogm_handler_v1 - process incoming multicast tvlv container
>   * @bat_priv: the bat priv with all the soft interface information
>   * @orig: the orig_node of the ogm
> @@ -285,13 +392,14 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
>  	    (tvlv_value) && (tvlv_value_len == sizeof(mcast_flags)))
>  		mcast_flags = *(uint8_t *)tvlv_value;
>  
> -	if (!(mcast_flags & BATADV_MCAST_LISTENER_ANNOUNCEMENT) &&
> -	    (orig->mcast_flags & BATADV_MCAST_LISTENER_ANNOUNCEMENT ||
> -	     orig->mcast_flags & BATADV_UNINIT_FLAGS))
> -		atomic_inc(&bat_priv->mcast.num_no_mla);
> -	else if (mcast_flags & BATADV_MCAST_LISTENER_ANNOUNCEMENT &&
> -		   !(orig->mcast_flags & BATADV_MCAST_LISTENER_ANNOUNCEMENT))
> -		atomic_dec(&bat_priv->mcast.num_no_mla);
> +	batadv_mcast_tvlv_update_flag_counter(
> +					BATADV_MCAST_LISTENER_ANNOUNCEMENT,
> +					&bat_priv->mcast.num_no_mla,
> +					mcast_flags, orig->mcast_flags);
> +	batadv_mcast_tvlv_update_flag_counter(
> +					BATADV_MCAST_HAS_NO_BRIDGE,
> +					&bat_priv->mcast.num_has_bridge,
> +					mcast_flags, orig->mcast_flags);

You should find a shorter name, the alignment looks really ugly. :)

Cheers,
	Simon

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-07-12  9:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03 22:03 [B.A.T.M.A.N.] Basic Multicast Optimizations Linus Lüssing
2013-07-03 22:03 ` [B.A.T.M.A.N.] [PATCHv7 1/4] batman-adv: Multicast Listener Announcements via Translation Table Linus Lüssing
2013-07-03 22:03 ` [B.A.T.M.A.N.] [PATCHv7 2/4] batman-adv: Announce new capability via multicast TVLV Linus Lüssing
2013-07-06 10:57   ` Marek Lindner
2013-07-06 12:38     ` Linus Lüssing
2013-07-03 22:03 ` [B.A.T.M.A.N.] [PATCHv7 3/4] batman-adv: Modified forwarding behaviour for multicast packets Linus Lüssing
2013-07-03 22:03 ` [B.A.T.M.A.N.] [PATCHv7 4/4] batman-adv: Add IPv4 link-local/IPv6-ll-all-nodes multicast support Linus Lüssing
2013-07-12  9:12   ` Simon Wunderlich [this message]
2013-07-14 16:25     ` Linus Lüssing
2013-07-04  5:06 ` [B.A.T.M.A.N.] Basic Multicast Optimizations Linus Lüssing

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=20130712091215.GA9077@pandem0nium \
    --to=simon.wunderlich@s2003.tu-chemnitz.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;
as well as URLs for NNTP newsgroup(s).