From patchwork Thu Nov 4 17:20:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 520 Return-Path: Received: from nm19-vm0.bullet.mail.ukl.yahoo.com (nm19-vm0.bullet.mail.ukl.yahoo.com [217.146.183.113]) by open-mesh.org (Postfix) with SMTP id DA919154561 for ; Thu, 4 Nov 2010 18:23:23 +0100 (CET) Received: from [217.146.183.215] by nm19.bullet.mail.ukl.yahoo.com with NNFMP; 04 Nov 2010 17:23:23 -0000 Received: from [217.146.183.177] by tm8.bullet.mail.ukl.yahoo.com with NNFMP; 04 Nov 2010 17:23:23 -0000 Received: from [127.0.0.1] by omp1018.mail.ukl.yahoo.com with NNFMP; 04 Nov 2010 17:23:23 -0000 X-Yahoo-Newman-Id: 373779.7220.bm@omp1018.mail.ukl.yahoo.com Received: (qmail 69077 invoked from network); 4 Nov 2010 17:23:23 -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=o9/feoF9gAc5iMESv2haRz503s0o2MsOPF3JnO1Bfd+z4Vp36h6VH5VIkrEIushI10hM9iqZegCFH/yQ6LHpHT3QcHuwITQ/gPwUTcTO1UiCMaKAzRJcJBlJTUnsTb9SiNl+jixvdnKO+TieShT1NlTXLAQyk0rv/yCCvUIrwOQ= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1288891403; bh=AoXM4Vv2UrkvFNCAGCPEgKzGuBjXuhzdSpS+l48oeAM=; 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=yQY3hOpBqZQlPuHwBkHqFjOlgGZ0aMw3I/skYG+9NoMNahXN+CnHKIjCM8VVtoqmt8SJ7B5L9K0MARMX/vdgx8hzwAVERBEwSrZuV5yFdClsfiu5Vb4H1KeVtlzKB+gPYKYYlUCXI9SQbKtX6JJbpkCaoap+Qyz6IV0zUOsABio= Received: from localhost (lindner_marek@78.225.40.81 with plain) by smtp132.mail.ukl.yahoo.com with SMTP; 04 Nov 2010 17:23:22 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: 3OlK_lcVM1mgyJbVYplmlm9xcaNylh26O46buyM6dN10Yp1 yRgASOBFThbSaTkAZS.z0FKgvj.DsIPhpndrj3jn1DOS74VssYsZcxSUgvOT M29Xq7AmDDXw73c.tSGUmW855NpZYtEEfnyj0PY23TvXHwRFrmqaPGu5bea6 mG0SO_rpVJgMEtYaWkkuc1SDO7UcwC08PEc18r66q8snZNAzBs4JVBadiLqf g38mE.IbvOedffVvnklJyyTMf.NfXFvZvNTx1s8z25yYz02cE X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 4 Nov 2010 18:20:59 +0100 Message-Id: <1288891265-16035-2-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <201011041820.44518.lindner_marek@yahoo.de> References: <201011041820.44518.lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 2/8] batman-adv: gateways silently drop DHCP requests 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: Thu, 04 Nov 2010 17:23:24 -0000 Signed-off-by: Marek Lindner --- batman-adv/gateway_client.c | 31 +++++++++++++++++-------------- batman-adv/gateway_client.h | 2 +- batman-adv/soft-interface.c | 16 ++++++++++------ 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/batman-adv/gateway_client.c b/batman-adv/gateway_client.c index e10dc90..2e05dd4 100644 --- a/batman-adv/gateway_client.c +++ b/batman-adv/gateway_client.c @@ -399,54 +399,57 @@ int gw_client_seq_print_text(struct seq_file *seq, void *offset) return 0; } -bool gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb) +int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb) { struct ethhdr *ethhdr; struct iphdr *iphdr; struct udphdr *udphdr; unsigned int header_len = 0; - if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT) - return false; - - if (!bat_priv->curr_gw) - return false; + if (atomic_read(&bat_priv->gw_mode) == GW_MODE_OFF) + return 0; /* check for ethernet header */ if (!pskb_may_pull(skb, header_len + ETH_HLEN)) - return false; + return 0; ethhdr = (struct ethhdr *)skb->data; header_len += ETH_HLEN; /* check for initial vlan header */ if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) { if (!pskb_may_pull(skb, header_len + VLAN_HLEN)) - return false; + return 0; ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN); header_len += VLAN_HLEN; } /* check for ip header */ if (ntohs(ethhdr->h_proto) != ETH_P_IP) - return false; + return 0; if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr))) - return false; + return 0; iphdr = (struct iphdr *)(skb->data + header_len); header_len += iphdr->ihl * 4; /* check for udp header */ if (iphdr->protocol != IPPROTO_UDP) - return false; + return 0; if (!pskb_may_pull(skb, header_len + sizeof(struct udphdr))) - return false; + return 0; udphdr = (struct udphdr *)(skb->data + header_len); header_len += sizeof(struct udphdr); /* check for bootp port */ if (ntohs(udphdr->dest) != 67) - return false; + return 0; + + if (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER) + return -1; + + if (!bat_priv->curr_gw) + return 0; - return true; + return 1; } diff --git a/batman-adv/gateway_client.h b/batman-adv/gateway_client.h index 38699ba..4585e65 100644 --- a/batman-adv/gateway_client.h +++ b/batman-adv/gateway_client.h @@ -31,6 +31,6 @@ void gw_node_update(struct bat_priv *bat_priv, void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node); void gw_node_purge(struct bat_priv *bat_priv); int gw_client_seq_print_text(struct seq_file *seq, void *offset); -bool gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb); +int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb); #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ diff --git a/batman-adv/soft-interface.c b/batman-adv/soft-interface.c index e16c61b..836c452 100644 --- a/batman-adv/soft-interface.c +++ b/batman-adv/soft-interface.c @@ -347,7 +347,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) struct vlan_ethhdr *vhdr; int data_len = skb->len, ret; short vid = -1; - bool bcast_dst = false, do_bcast = true; + bool do_bcast = false; if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) goto dropped; @@ -378,14 +378,18 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) /* TODO: check this for locks */ hna_local_add(soft_iface, ethhdr->h_source); - if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest)) - bcast_dst = true; + if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest)) { + ret = gw_is_target(bat_priv, skb); - if ((bcast_dst) && gw_is_target(bat_priv, skb)) - do_bcast = false; + if (ret < 0) + goto dropped; + + if (ret == 0) + do_bcast = true; + } /* ethernet packet should be broadcasted */ - if (bcast_dst && do_bcast) { + if (do_bcast) { if (!bat_priv->primary_if) goto dropped;