From patchwork Sun Oct 24 01:14:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 491 Return-Path: Received: from nm2.bullet.mail.ukl.yahoo.com (nm2.bullet.mail.ukl.yahoo.com [217.146.183.219]) by open-mesh.org (Postfix) with SMTP id CC8B51545F8 for ; Sun, 24 Oct 2010 03:16:40 +0200 (CEST) Received: from [217.146.183.181] by nm2.bullet.mail.ukl.yahoo.com with NNFMP; 24 Oct 2010 01:16:40 -0000 Received: from [217.146.183.72] by tm12.bullet.mail.ukl.yahoo.com with NNFMP; 24 Oct 2010 01:16:40 -0000 Received: from [127.0.0.1] by omp1033.mail.ukl.yahoo.com with NNFMP; 24 Oct 2010 01:16:40 -0000 X-Yahoo-Newman-Id: 110908.84402.bm@omp1033.mail.ukl.yahoo.com Received: (qmail 31346 invoked from network); 24 Oct 2010 01:16:40 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=RETvRb1hOiikQfxDutRRhyE+j7QUmIbN976N19cCPsTK3lRLVwd940MQfjKKM+NrVSiVjCoVdUzzj/cj+SsNKvD+5lDk2kVd0UJg9e1d2kBJCNsWC1/Zxwv3oWDE+tZqJDcebpzaHeWl0PkDMpehKbR0OZ64sEu85LCJ+XNsCCU= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1287883000; bh=JvO+uO4Z4/+CVL+pO3lbyeZzP+eDBDndsGdiFFzDp1k=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=V10mg/w7Q6SJbf5w9yt2nuX9xkR9q8f0El7UY/s4YxV8akq2VVYNh/d5IO2denUimzTpbBfPiIJtN4qc8EW90E44uRMSJ3kT8Jwfd0I40bjAcYAMRYYiJILCkFhC68KDm6pow/DT3pwS653CZ1HM0vMzkVxC0P/1DLekaCxGNug= Received: from localhost (lindner_marek@78.225.40.81 with plain) by smtp124.mail.ukl.yahoo.com with SMTP; 23 Oct 2010 18:16:39 -0700 PDT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: usvUSIwVM1kJL.sEfQBc1.YiOrgS8UeZRJhVOQQbp8FKQpU QitSp2f7RKNhtiBBJz07dEDJCD9K4H6zNmiz7OulbCtbmsNeseyXa6rYmTZ5 LGL7t3ulfT3PdIwHsyhGV8oLvCDlzOc03KZtNgdwQmo46GI_MBgE9R6Ka6FH sx6kZUnYCZii21SUGcCjv7i966XEcgSk8kREZ1eeZPtCaFkqLEmkuhmU30R0 cp_3XKxrKFFkNv6wzrB42IF5HOkvdGhXL.Q9QQ_UlnQGcylER X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 24 Oct 2010 03:14:23 +0200 Message-Id: <1287882863-11314-8-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <201010240313.35215.lindner_marek@yahoo.de> References: <201010240313.35215.lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 8/8] batman-adv: add gateway IPv6 support by filtering DHCPv6 messages X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Oct 2010 01:16:41 -0000 Signed-off-by: Marek Lindner Acked-by: Linus Lüssing --- 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 +#include #include #include @@ -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)