All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Cc: Linus L??ssing <linus.luessing@saxnet.de>
Subject: Re: [B.A.T.M.A.N.] [PATCH 13/20] batman-adv: Send own BAT_MCAST packets in proact_tracking multicast mode
Date: Wed, 8 Dec 2010 19:12:08 +0100	[thread overview]
Message-ID: <20101208181208.GC11267@lunn.ch> (raw)
In-Reply-To: <1291761150-29818-13-git-send-email-linus.luessing@saxnet.de>

On Tue, Dec 07, 2010 at 11:32:23PM +0100, Linus L??ssing wrote:
> This patch adds the capability to encapsulate and send a node's own
> multicast data packets. Based on the previously established multicast
> forwarding table, the sender can decide wheather it actually has to send
> the multicast data to one or more of its interfaces or not.
> 
> Furthermore, the sending procedure also decides whether to broadcast or
> unicast a multicast data packet to its next-hops, depending on the
> configured mcast_fanout (default: < 3 next hops on an interface, send
> seperate unicast packets).
> 
> Signed-off-by: Linus L??ssing <linus.luessing@saxnet.de>
> ---
>  multicast.c      |  133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  multicast.h      |    1 +
>  soft-interface.c |   25 +++++++++--
>  types.h          |    1 +
>  4 files changed, 156 insertions(+), 4 deletions(-)
> 
> diff --git a/multicast.c b/multicast.c
> index 2b1bfde..72249ef 100644
> --- a/multicast.c
> +++ b/multicast.c
> @@ -23,6 +23,7 @@
>  #include "multicast.h"
>  #include "hash.h"
>  #include "send.h"
> +#include "soft-interface.h"
>  #include "compat.h"
>  
>  /* If auto mode for tracker timeout has been selected,
> @@ -1058,6 +1059,138 @@ int mcast_forw_table_seq_print_text(struct seq_file *seq, void *offset)
>  	return 0;
>  }
>  
> +static void route_mcast_packet(struct sk_buff *skb, struct bat_priv *bat_priv)
> +{
> +	struct sk_buff *skb1;
> +	struct mcast_packet *mcast_packet;
> +	struct ethhdr *ethhdr;
> +	struct batman_if *batman_if;
> +	unsigned long flags;
> +	struct mcast_forw_table_entry *table_entry;
> +	struct mcast_forw_orig_entry *orig_entry;
> +	struct mcast_forw_if_entry *if_entry;
> +	struct mcast_forw_nexthop_entry *nexthop_entry;
> +	int mcast_fanout = atomic_read(&bat_priv->mcast_fanout);
> +	int num_bcasts = 3, i;
> +	struct dest_entries_list dest_list, *dest_entry, *tmp;
> +
> +	mcast_packet = (struct mcast_packet*)skb->data;
> +	ethhdr = (struct ethhdr*)(mcast_packet + 1);
> +
> +	INIT_LIST_HEAD(&dest_list.list);
> +
> +	mcast_packet->ttl--;
> +
> +	rcu_read_lock();
> +	spin_lock_irqsave(&bat_priv->mcast_forw_table_lock, flags);
> +	list_for_each_entry(table_entry, &bat_priv->mcast_forw_table, list) {
> +		if (memcmp(ethhdr->h_dest, table_entry->mcast_addr, ETH_ALEN))
> +			continue;
> +
> +		list_for_each_entry(orig_entry, &table_entry->mcast_orig_list,
> +				    list) {
> +			if (memcmp(mcast_packet->orig,
> +				   orig_entry->orig, ETH_ALEN))
> +				continue;
> +
> +			list_for_each_entry(if_entry,
> +					    &orig_entry->mcast_if_list, list) {
> +				batman_if = if_num_to_batman_if(
> +							if_entry->if_num);
> +
> +				/* send via broadcast */
> +				if (if_entry->num_nexthops > mcast_fanout) {
> +					dest_entry = kmalloc(sizeof(struct
> +							dest_entries_list),
> +							GFP_ATOMIC);
> +					memcpy(dest_entry->dest,
> +					       broadcast_addr, ETH_ALEN);
> +					dest_entry->batman_if = batman_if;
> +					list_add(&dest_entry->list,
> +						 &dest_list.list);
> +					continue;
> +				}
> +
> +				/* send seperate unicast packets */
> +				list_for_each_entry(nexthop_entry,
> +						&if_entry->mcast_nexthop_list,
> +						list) {
> +					if (!get_remaining_timeout(
> +								nexthop_entry,
> +								bat_priv))
> +						continue;
> +

Again, refactor this into four functions. 

       Andrew

  reply	other threads:[~2010-12-08 18:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-07 22:13 [B.A.T.M.A.N.] B.A.T.M.A.N.-Advanced Multicast Optimizations Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 01/20] batman-adv: Add packet structures for multicast optimizations Linus Lüssing
2010-12-08  8:18   ` Andrew Lunn
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 02/20] batman-adv: Adding configurable variables " Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 03/20] batman-adv: compat macros/defines for local multicast group fetching Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 04/20] batman-adv: Attach local MCAs to OGMs Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 05/20] batman-adv: Add periodic multicast tracker timer Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 06/20] batman-adv: Buffer other originator's received MCA entries Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 07/20] batman-adv: Prepare and send own multicast tracker packets Linus Lüssing
2010-12-08  9:06   ` Andrew Lunn
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 08/20] batman-adv: Add length check for (received) " Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 09/20] batman-adv: Route multicast " Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 10/20] batman-adv: Add/refresh entries to/in mcast forwarding table Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 11/20] batman-adv: Output mcast forw table in debugfs Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 12/20] batman-adv: Purge timeouted entries in mcast forw table Linus Lüssing
2010-12-08 18:08   ` Andrew Lunn
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 13/20] batman-adv: Send own BAT_MCAST packets in proact_tracking multicast mode Linus Lüssing
2010-12-08 18:12   ` Andrew Lunn [this message]
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 14/20] batman-adv: Export broadcast packet ethernet header checks Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 15/20] batman-adv: Receive multicast data packets BAT_MCAST Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 16/20] batman-adv: Forward multicast data in proact_tracking mode Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 17/20] batman-adv: Add duplicate checks for multicast data Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 18/20] batman-adv: Still flood multicast packets we are not a receiver of Linus Lüssing
2010-12-10 13:07   ` Andrew Lunn
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 19/20] batman-adv: Make number of (re)broadcasts configurable via sysfs Linus Lüssing
2010-12-07 22:32 ` [B.A.T.M.A.N.] [PATCH 20/20] batman-adv: Do not disable irqs for spinlocks in multicast specific code Linus Lüssing
2010-12-08  7:29 ` [B.A.T.M.A.N.] B.A.T.M.A.N.-Advanced Multicast Optimizations Andrew Lunn
2010-12-09 21:02   ` Simon Wunderlich

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=20101208181208.GC11267@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=linus.luessing@saxnet.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.