b.a.t.m.a.n.lists.open-mesh.org archive mirror
 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>
Subject: Re: [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: improved gateway tq-based selection
Date: Mon, 9 May 2011 16:48:12 +0200	[thread overview]
Message-ID: <20110509144812.GB31070@lunn.ch> (raw)
In-Reply-To: <1304946150-6026-3-git-send-email-ordex@autistici.org>

On Mon, May 09, 2011 at 03:02:30PM +0200, Antonio Quartulli wrote:
> If a client issues a DHCPREQUEST for renewal, the packet is dropped
> if the old destination (the old gateway for the client) TQ is smaller
> than the current best gateway TQ less GW_THRESHOLD
> 
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> ---
>  gateway_client.c |   94 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  gateway_client.h |    3 +-
>  main.h           |    3 +-
>  soft-interface.c |   10 ++++-
>  4 files changed, 104 insertions(+), 6 deletions(-)
> 
> diff --git a/gateway_client.c b/gateway_client.c
> index 761dcfb..33bceee 100644
> --- a/gateway_client.c
> +++ b/gateway_client.c
> @@ -25,11 +25,17 @@
>  #include "gateway_common.h"
>  #include "hard-interface.h"
>  #include "originator.h"
> +#include "routing.h"
>  #include <linux/ip.h>
>  #include <linux/ipv6.h>
>  #include <linux/udp.h>
>  #include <linux/if_vlan.h>
>  
> +/* This is the offset of the options field in a dhcp packet starting at
> + * the beginning of the dhcp header */
> +#define DHCP_OPTIONS_OFFSET 240
> +#define DHCP_REQUEST 3
> +
>  static void gw_node_free_rcu(struct rcu_head *rcu)
>  {
>  	struct gw_node *gw_node;
> @@ -509,14 +515,75 @@ out:
>  	return ret;
>  }
>  
> -int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
> +static bool is_type_dhcprequest(struct sk_buff *skb, int header_len)
> +{
> +	int ret = false;
> +	unsigned char *p;
> +	int pkt_len;
> +
> +	if (skb_linearize(skb) < 0)
> +		goto out;
> +
> +	pkt_len = skb_headlen(skb);
> +
> +	if (pkt_len < header_len + DHCP_OPTIONS_OFFSET + 1)
> +		goto out;
> +
> +	p = skb->data + header_len + DHCP_OPTIONS_OFFSET;
> +	pkt_len -= header_len + DHCP_OPTIONS_OFFSET + 1;
> +
> +	/* Access the dhcp option lists. Each entry is made up by:
> +	 * - octect 1: option type
> +	 * - octect 2: option data len (only if type != 255 and 0)
> +	 * - octect 3: option data */
> +	while (*p != 255 && !ret) {
> +		/* p now points to the first octect: option type */
> +		if (*p == 53) {
> +			/* type 53 is the message type option.
> +			 * Jump the len octect and go to the data octect */
> +			if (pkt_len < 2)
> +				goto out;
> +			pkt_len -= 2;
> +			p += 2;
> +
> +			/* check if the message type is what we need */
> +			if (*p == DHCP_REQUEST)
> +				ret = true;

Why do you continue parsing the options if it is not a DHCP_REQUEST?
Do you think there will be a second, third, fourth option information
element 53?

	Andrew

  reply	other threads:[~2011-05-09 14:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05  7:13 [B.A.T.M.A.N.] batman-adv: added uevent support for gw and gw propagation for clients Antonio Quartulli
2011-05-05  7:13 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: add wrapper function to throw uevent in userspace Antonio Quartulli
2011-05-05 13:34   ` Andrew Lunn
2011-05-08 19:21     ` Antonio Quartulli
2011-05-08 20:11       ` Andrew Lunn
2011-05-08 20:13         ` Antonio Quartulli
2011-05-05  7:13 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: throw uevent in userspace on gateway add/change/del event Antonio Quartulli
2011-05-05  7:13 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: improved gateway tq-based selection Antonio Quartulli
2011-05-05 13:46   ` Andrew Lunn
2011-05-08 20:57     ` Antonio Quartulli
2011-05-09  9:52 ` [B.A.T.M.A.N.] [PATCHv2 1/3] batman-adv: add wrapper function to throw uevent in userspace Antonio Quartulli
2011-05-09  9:52 ` [B.A.T.M.A.N.] [PATCHv2 2/3] batman-adv: throw uevent in userspace on gateway add/change/del event Antonio Quartulli
2011-05-09  9:52 ` [B.A.T.M.A.N.] [PATCHv2 3/3] batman-adv: improved gateway tq-based selection Antonio Quartulli
2011-05-09 13:02 ` [B.A.T.M.A.N.] [PATCHv3 1/3] batman-adv: add wrapper function to throw uevent in userspace Antonio Quartulli
2011-05-10  5:08   ` Andrew Lunn
2011-05-10  6:29     ` Antonio Quartulli
2011-06-11 10:10       ` Marek Lindner
2011-06-11 12:45         ` Antonio Quartulli
2011-06-11 10:07   ` Marek Lindner
2011-05-09 13:02 ` [B.A.T.M.A.N.] [PATCHv3 2/3] batman-adv: throw uevent in userspace on gateway add/change/del event Antonio Quartulli
2011-06-11 10:15   ` [B.A.T.M.A.N.] [PATCHv4 " Marek Lindner
2011-06-11 10:21     ` [B.A.T.M.A.N.] [PATCHv5 " Marek Lindner
2011-06-12 10:09       ` Marek Lindner
2011-05-09 13:02 ` [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: improved gateway tq-based selection Antonio Quartulli
2011-05-09 14:48   ` Andrew Lunn [this message]
2011-05-09 20:26     ` Antonio Quartulli
2011-05-09 20:30 ` [B.A.T.M.A.N.] [PATCHv4 " Antonio Quartulli
2011-05-09 21:15 ` [B.A.T.M.A.N.] [PATCHv5 " Antonio Quartulli
2011-06-11 10:25   ` [B.A.T.M.A.N.] [PATCHv6 " Marek Lindner
2011-06-12 10:11     ` 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=20110509144812.GB31070@lunn.ch \
    --to=andrew@lunn.ch \
    --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).