public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@web.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 8/8] batman-adv: add gateway IPv6 support by filtering DHCPv6 messages
Date: Wed, 3 Nov 2010 19:43:33 +0100	[thread overview]
Message-ID: <20101103184333.GA19667@Sellars> (raw)
In-Reply-To: <1287882863-11314-8-git-send-email-lindner_marek@yahoo.de>

Acked-by: Linus Lüssing <linus.luessing@web.de>

Just gave it a go on a basic dhcpv6 setup and works fine. Though
some additional checks will be needed in case of extension headers
like the fragmentation or hop-by-hop (for jumbo frames for example)
headers or ipsec stuff. But this patch should do for most people
for now, the rest can be added with a later one.

Cheers, Linus

On Sun, Oct 24, 2010 at 03:14:23AM +0200, Marek Lindner wrote:
> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
> ---
>  batman-adv/gateway_client.c |   40 +++++++++++++++++++++++++++++++---------
>  1 files changed, 31 insertions(+), 9 deletions(-)
> 
> diff --git a/batman-adv/gateway_client.c b/batman-adv/gateway_client.c
> index e6cd9ac..128f851 100644
> --- a/batman-adv/gateway_client.c
> +++ b/batman-adv/gateway_client.c
> @@ -25,6 +25,7 @@
>  #include "hard-interface.h"
>  #include "compat.h"
>  #include <linux/ip.h>
> +#include <linux/ipv6.h>
>  #include <linux/udp.h>
>  #include <linux/if_vlan.h>
>  
> @@ -404,6 +405,7 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
>  {
>  	struct ethhdr *ethhdr;
>  	struct iphdr *iphdr;
> +	struct ipv6hdr *ipv6hdr;
>  	struct udphdr *udphdr;
>  	unsigned int header_len = 0;
>  
> @@ -425,17 +427,32 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
>  	}
>  
>  	/* check for ip header */
> -	if (ntohs(ethhdr->h_proto) != ETH_P_IP)
> -		return 0;
> +	switch (ntohs(ethhdr->h_proto)) {
> +	case ETH_P_IP:
> +		if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr)))
> +			return 0;
> +		iphdr = (struct iphdr *)(skb->data + header_len);
> +		header_len += iphdr->ihl * 4;
>  
> -	if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr)))
> -		return 0;
> -	iphdr = (struct iphdr *)(skb->data + header_len);
> -	header_len += iphdr->ihl * 4;
> +		/* check for udp header */
> +		if (iphdr->protocol != IPPROTO_UDP)
> +			return 0;
> +
> +		break;
> +	case ETH_P_IPV6:
> +		if (!pskb_may_pull(skb, header_len + sizeof(struct ipv6hdr)))
> +			return 0;
> +		ipv6hdr = (struct ipv6hdr *)(skb->data + header_len);
> +		header_len += sizeof(struct ipv6hdr);
>  
> -	/* check for udp header */
> -	if (iphdr->protocol != IPPROTO_UDP)
> +		/* check for udp header */
> +		if (ipv6hdr->nexthdr != IPPROTO_UDP)
> +			return 0;
> +
> +		break;
> +	default:
>  		return 0;
> +	}
>  
>  	if (!pskb_may_pull(skb, header_len + sizeof(struct udphdr)))
>  		return 0;
> @@ -443,7 +460,12 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
>  	header_len += sizeof(struct udphdr);
>  
>  	/* check for bootp port */
> -	if (ntohs(udphdr->dest) != 67)
> +	if ((ntohs(ethhdr->h_proto) == ETH_P_IP) &&
> +	     (ntohs(udphdr->dest) != 67))
> +		return 0;
> +
> +	if ((ntohs(ethhdr->h_proto) == ETH_P_IPV6) &&
> +	    (ntohs(udphdr->dest) != 547))
>  		return 0;
>  
>  	if (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER)
> -- 
> 1.7.1
> 

  reply	other threads:[~2010-11-03 18:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-24  1:13 [B.A.T.M.A.N.] batman-adv gateway handling Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 1/8] batman-adv: remove redundant gw_node_list_free() function Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 2/8] batman-adv: gateways silently drop DHCP requests Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 3/8] batman-adv: move gateway selection class into its own sysfs file Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 4/8] batman-adv: move gateway bandwidth " Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 5/8] batman-adv: cleanup gw mode sysfs file to only accept one value Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 6/8] batctl: support new gateway sysfs API Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 7/8] batman-adv: document gateway sysfs ABI Marek Lindner
2010-10-24  1:14 ` [B.A.T.M.A.N.] [PATCH 8/8] batman-adv: add gateway IPv6 support by filtering DHCPv6 messages Marek Lindner
2010-11-03 18:43   ` Linus Lüssing [this message]
2010-10-30 12:14 ` [B.A.T.M.A.N.] batman-adv gateway handling Sven Eckelmann
2010-10-31 15:10   ` Marek Lindner
2010-10-31 15:55     ` Sven Eckelmann
2010-11-01 11:14       ` Marek Lindner
  -- strict thread matches above, loose matches on Subject: below --
2010-11-04 17:20 [B.A.T.M.A.N.] batman-adv gateway handling [v2] Marek Lindner
2010-11-04 17:21 ` [B.A.T.M.A.N.] [PATCH 8/8] batman-adv: add gateway IPv6 support by filtering DHCPv6 messages 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=20101103184333.GA19667@Sellars \
    --to=linus.luessing@web.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