From patchwork Sun Nov 7 16:45:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 561 Return-Path: Received: from fmmailgate01.web.de (fmmailgate01.web.de [217.72.192.221]) by open-mesh.org (Postfix) with ESMTP id 6B65615453A for ; Sun, 7 Nov 2010 16:46:24 +0100 (CET) Received: from smtp03.web.de ( [172.20.0.65]) by fmmailgate01.web.de (Postfix) with ESMTP id 14BD51761EC5F; Sun, 7 Nov 2010 16:46:24 +0100 (CET) Received: from [46.126.246.98] (helo=localhost) by smtp03.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #4) id 1PF7Rn-0004VP-00; Sun, 07 Nov 2010 16:46:23 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 7 Nov 2010 17:45:59 +0100 Message-Id: <1289148361-16019-2-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1289148361-16019-1-git-send-email-linus.luessing@web.de> References: <1289148361-16019-1-git-send-email-linus.luessing@web.de> MIME-Version: 1.0 Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX1+KbGCWVgQme7WINa2Ets8VnDy/o1gCSuENvgUE wQqntQwuJwCy9OUuysthzNFugc4/n9WGESGW7d23Ica6llbod4 1zjUdGiKBjv2pnmrmVQw== Cc: =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Allow promiscuous reception of unicast packets 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, 07 Nov 2010 15:46:24 -0000 From: Linus Lüssing A very mobile node may want to enable this to increase the probability of unicast data reception on the last hop, especially when such a mobile node moves towards the sender. The mobile node needs to place its hard-interfaces utilized by batman-adv into promisc-mode to let this optimization take effect. Be aware, that doing so will cost your devices more processing power. It also increases the probability of succesful reception a lot, if there are (multiple) shorter, alternate but slightly "worse" paths, too. As WiFi is a broadcast medium, there can be a quite good chance to receive a packet from one of the nodes on the path to the receiver already. Luckily batman-adv is running in kernelspace, therefore it does not make much of a performance difference, even on embedded devices. To let this feature take effect, place your WiFi interface in promiscuous mode (e.g. 'ip link set wlan0 promisc on'/'ifconfig wlan0 promisc'). Signed-off-by: Linus Lüssing --- routing.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/routing.c b/routing.c index e75337d..b61821a 100644 --- a/routing.c +++ b/routing.c @@ -1124,7 +1124,7 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size) /* not for me */ if (!is_my_mac(ethhdr->h_dest)) - return -1; + return 1; return 0; } @@ -1214,8 +1214,10 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) { struct unicast_packet *unicast_packet; int hdr_size = sizeof(struct unicast_packet); + int check_ret; - if (check_unicast_packet(skb, hdr_size) < 0) + check_ret = check_unicast_packet(skb, hdr_size); + if (check_ret < 0) return NET_RX_DROP; unicast_packet = (struct unicast_packet *)skb->data; @@ -1226,6 +1228,9 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) return NET_RX_SUCCESS; } + if (check_ret) + return NET_RX_DROP; + return route_unicast_packet(skb, recv_if, hdr_size); } @@ -1235,9 +1240,10 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if) struct unicast_frag_packet *unicast_packet; int hdr_size = sizeof(struct unicast_frag_packet); struct sk_buff *new_skb = NULL; - int ret; + int ret, check_ret; - if (check_unicast_packet(skb, hdr_size) < 0) + check_ret = check_unicast_packet(skb, hdr_size); + if (check_ret < 0) return NET_RX_DROP; unicast_packet = (struct unicast_frag_packet *)skb->data; @@ -1259,6 +1265,9 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if) return NET_RX_SUCCESS; } + if (check_ret) + return NET_RX_DROP; + return route_unicast_packet(skb, recv_if, hdr_size); }