From patchwork Mon Apr 8 23:29:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pradeep Kumar Chitrapu X-Patchwork-Id: 10890267 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7107B1708 for ; Mon, 8 Apr 2019 23:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50D53287BF for ; Mon, 8 Apr 2019 23:29:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EAF1287C3; Mon, 8 Apr 2019 23:29:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D446B287BF for ; Mon, 8 Apr 2019 23:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726938AbfDHX3a (ORCPT ); Mon, 8 Apr 2019 19:29:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39744 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726577AbfDHX3a (ORCPT ); Mon, 8 Apr 2019 19:29:30 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4DE7B60E5F; Mon, 8 Apr 2019 23:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1554766169; bh=2nQcZpFw+WKev/bV3tN0agldOWy4f7uoEzBlfpPsppM=; h=From:To:Cc:Subject:Date:From; b=mkLv+hs0fMP+F6D4vKKL9tnS51fi77zmLyRsB1+b/npxDtVB8BDFyLErCIhOVVjxq hS/ET40kQDsCT3cf+8Sgc6NIC8iaBGBr9pqzr7IuuVrQgzViVcnC1r01wFL22Q/qvw nZrw0fhq9jMgTPZu2O+zV+89JAmK0VX3cxoaBoTY= Received: from pradeepc-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pradeepc@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id AFCCF60E57; Mon, 8 Apr 2019 23:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1554766169; bh=2nQcZpFw+WKev/bV3tN0agldOWy4f7uoEzBlfpPsppM=; h=From:To:Cc:Subject:Date:From; b=mkLv+hs0fMP+F6D4vKKL9tnS51fi77zmLyRsB1+b/npxDtVB8BDFyLErCIhOVVjxq hS/ET40kQDsCT3cf+8Sgc6NIC8iaBGBr9pqzr7IuuVrQgzViVcnC1r01wFL22Q/qvw nZrw0fhq9jMgTPZu2O+zV+89JAmK0VX3cxoaBoTY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AFCCF60E57 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pradeepc@codeaurora.org From: Pradeep Kumar Chitrapu To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Pradeep Kumar Chitrapu Subject: [PATCH] iw: add command to inject a frame via direct mesh link to mesh peer Date: Tue, 9 Apr 2019 04:59:23 +0530 Message-Id: <1554766163-12649-1-git-send-email-pradeepc@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add mpath command to inject ethernet frame over direct mesh link to given peer, bypassing the mpath table lookup. This helps to send data frames over unexcersized direct mesh path, which is not selected as next_hop node. This can be helpful in measuring link metrics. Format: $ iw dev mpath probe frame Example: $ iw wlan0 mpath probe aa:bb:cc:dd:ee:ff frame aa:bb:cc:dd:ee:ff:kk:ll:mm:nn:oo:pp:yy:zz Frame pattern is supplied as hex pattern of the form aa:bb:cc without leading 0x. Frame type and length are expected to be of ethernet frame type. Signed-off-by: Pradeep Kumar Chitrapu --- mpath.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/mpath.c b/mpath.c index ff0b7419fd2b..e39c24ba4403 100644 --- a/mpath.c +++ b/mpath.c @@ -90,6 +90,45 @@ static int print_mpath_handler(struct nl_msg *msg, void *arg) return NL_SKIP; } +static int handle_mpath_probe(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + unsigned char dst[ETH_ALEN]; + unsigned char *frame; + size_t frame_len; + + if (argc < 3) + return 1; + + if (mac_addr_a2n(dst, argv[0])) { + fprintf(stderr, "invalid mac address\n"); + return 2; + } + + if (strcmp("frame", argv[1]) != 0) + return 1; + + frame = parse_hex(argv[2], &frame_len); + if (!frame) { + fprintf(stderr, "invalid frame pattern: %p\n", frame); + return 2; + } + + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst); + NLA_PUT(msg, NL80211_ATTR_FRAME, frame_len, frame); + + return 0; + nla_put_failure: + return -ENOBUFS; +} +COMMAND(mpath, probe, " frame ", + NL80211_CMD_PROBE_MESH_LINK, 0, CIB_NETDEV, handle_mpath_probe, + "Inject ethernet frame to given peer overriding the next hop\n" + "lookup from mpath table.\n." + "Example: iw dev wlan0 mpath probe xx:xx:xx:xx:xx:xx frame 01:xx:xx:00\n"); + static int handle_mpath_get(struct nl80211_state *state, struct nl_msg *msg, int argc, char **argv,