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.] [PATCH 3/6] batman-adv: register batman ogm receive function during protocol init
Date: Sat, 3 Mar 2012 18:59:53 +0100	[thread overview]
Message-ID: <20120303175953.GA15413@pandem0nium> (raw)
In-Reply-To: <1330587321-12177-3-git-send-email-lindner_marek@yahoo.de>

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

On Thu, Mar 01, 2012 at 03:35:18PM +0800, Marek Lindner wrote:
> -static void bat_iv_ogm_receive(struct hard_iface *if_incoming,
> -			       struct sk_buff *skb)
> +static void _bat_iv_ogm_receive(struct sk_buff *skb,
> +				struct hard_iface *if_incoming)

<rant>
Personally, I don't like underscore functions. They are usually created
because of a lack of creativity, but are later called from different places,
do different jobs and in the end everyone is confused. :) Is it possibble to
change the name, e.g. to bat_iv_ogm_handle()?
</rant>


>  {
>  	struct batman_ogm_packet *batman_ogm_packet;
>  	struct ethhdr *ethhdr;
> @@ -1200,6 +1200,39 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming,
>  					batman_ogm_packet->tt_num_changes));
>  }
>  
> +static int bat_iv_ogm_receive(struct sk_buff *skb,
> +			      struct hard_iface *hard_iface)
> +{
> +	struct ethhdr *ethhdr;
> +
> +	/* drop packet if it has not necessary minimum size */
> +	if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_HLEN)))
> +		return NET_RX_DROP;
> +
> +	ethhdr = (struct ethhdr *)skb_mac_header(skb);
> +
> +	/* packet with broadcast indication but unicast recipient */
> +	if (!is_broadcast_ether_addr(ethhdr->h_dest))
> +		return NET_RX_DROP;
> +
> +	/* packet with broadcast sender address */
> +	if (is_broadcast_ether_addr(ethhdr->h_source))
> +		return NET_RX_DROP;
> +
> +	/* create a copy of the skb, if needed, to modify it. */
> +	if (skb_cow(skb, 0) < 0)
> +		return NET_RX_DROP;
> +
> +	/* keep skb linear */
> +	if (skb_linearize(skb) < 0)
> +		return NET_RX_DROP;
> +
> +	_bat_iv_ogm_receive(skb, hard_iface);
> +
> +	kfree_skb(skb);
> +	return NET_RX_SUCCESS;
> +}
> +

We should somewhere add a check whether the hard_iface is actually assigned to
a mesh using the BATMAN IV algorithm. When more algorithms are added, we only want
the assigned protocol to be handled, others should be ignored.

Cheers,
	Simon

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

  reply	other threads:[~2012-03-03 17:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-01  7:35 [B.A.T.M.A.N.] [PATCH 1/6] batman-adv: introduce is_single_hop_neigh variable to increase readability Marek Lindner
2012-03-01  7:35 ` [B.A.T.M.A.N.] [PATCH 2/6] batman-adv: introduce packet type handler array for incoming packets Marek Lindner
2012-03-01  8:32   ` Sven Eckelmann
2012-03-05 19:26   ` Marek Lindner
2012-03-01  7:35 ` [B.A.T.M.A.N.] [PATCH 3/6] batman-adv: register batman ogm receive function during protocol init Marek Lindner
2012-03-03 17:59   ` Simon Wunderlich [this message]
2012-03-04  8:17     ` Marek Lindner
2012-03-04  8:56   ` [B.A.T.M.A.N.] [PATCHv2 " Marek Lindner
2012-03-05 18:21     ` Simon Wunderlich
2012-03-05 19:28     ` Marek Lindner
2012-03-01  7:35 ` [B.A.T.M.A.N.] [PATCH 4/6] batman-adv: rename last_valid to last_seen Marek Lindner
2012-03-05 19:30   ` Marek Lindner
2012-03-01  7:35 ` [B.A.T.M.A.N.] [PATCH 5/6] batman-adv: replace HZ calculations with jiffies_to_msecs() Marek Lindner
2012-03-05 19:33   ` Marek Lindner
2012-03-01  7:35 ` [B.A.T.M.A.N.] [PATCH 6/6] batman-adv: split neigh_new function into generic and batman iv specific parts Marek Lindner
2012-03-05 19:36   ` Marek Lindner
2012-03-03 18:02 ` [B.A.T.M.A.N.] [PATCH 1/6] batman-adv: introduce is_single_hop_neigh variable to increase readability Simon Wunderlich
2012-03-05 19:22 ` Marek Lindner

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=20120303175953.GA15413@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).