From patchwork Fri Mar 20 10:08:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Jance X-Patchwork-Id: 452549 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 205AB140182 for ; Fri, 20 Mar 2015 21:08:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8627F17C44E; Fri, 20 Mar 2015 06:08:47 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LqYd8OEowor8; Fri, 20 Mar 2015 06:08:47 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 255EA17C456; Fri, 20 Mar 2015 06:08:42 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7830517C456 for ; Fri, 20 Mar 2015 06:08:41 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 94yfcfJ7nqvC for ; Fri, 20 Mar 2015 06:08:36 -0400 (EDT) Received: from mail-gw2-out.broadcom.com (mail-gw2-out.broadcom.com [216.31.210.63]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2A23C17C44E for ; Fri, 20 Mar 2015 06:08:36 -0400 (EDT) X-IronPort-AV: E=Sophos;i="5.11,435,1422950400"; d="scan'208";a="59949334" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw2-out.broadcom.com with ESMTP; 20 Mar 2015 03:10:42 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 20 Mar 2015 03:08:35 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Fri, 20 Mar 2015 03:08:34 -0700 Received: from jithu?broadcom.com (unknown [10.131.24.232]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id C4AEE40FE8 for ; Fri, 20 Mar 2015 03:07:16 -0700 (PDT) Date: Fri, 20 Mar 2015 15:38:32 +0530 From: Jithu Jance To: Subject: [PATCH 1/1] STA: Add support for Virtual Interface creation/deletion Message-ID: References: <68a29a8577a086ae916d9a254b5caf8e962c94f5.1400750960.git.jithu@broadcom.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <68a29a8577a086ae916d9a254b5caf8e962c94f5.1400750960.git.jithu@broadcom.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Hi Jouni, >>> Can some additional checks help to address the safety concern? Like >>> for e.g, adding code to remove the externally added interfaces in case >>> of a terminate signal. >> >> Merging interface_create to interface_add could likely address the >> concern by recording the added interface to the new driver_nl80211 data >> structures related to the new interface rather than the one through >> which it was added. interface_del case would be even clearer since there >> would be no command for removing an arbitrary netdev, but it would >> always be through interface_remove that would remove state from both >> driver_nl80211 and core wpa_supplicant for the dynamically added >> interface. >Thanks Jouni for inputs!! I will post a patch after integrating >interface_create, >interface_del functionality to interface_add, interface_remove respectively. Sorry for a delayed follow-up mail. Got stuck with other tasks. :( Please find the modified patch below. Kindly see whether this is fine. Adding support for virtual interface creation and deletion for interface_add and interface_remove commands respectively (via optional argument). Signed-off-by: Jithu Jance --- wpa_supplicant/ctrl_iface.c | 54 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) -- 1.7.9.5 diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 4ebc3a1..7d3c0fa 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -8488,9 +8488,11 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global, { struct wpa_interface iface; char *pos; + int create_iface = 0; + u8 mac_addr[ETH_ALEN]; /* - * TABTABTABTAB + * TAB[TAB]TABTABTAB * TAB */ wpa_printf(MSG_DEBUG, "CTRL_IFACE GLOBAL INTERFACE_ADD '%s'", cmd); @@ -8507,6 +8509,15 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global, if (pos == NULL) break; + if (os_strncmp(pos, "create", 6) == 0) { + create_iface = 1; + pos = os_strchr(pos, '\t'); + if (pos) + pos++; + if (pos == NULL) + break; + } + iface.confname = pos; pos = os_strchr(pos, '\t'); if (pos) @@ -8553,6 +8564,19 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global, break; } while (0); + if (create_iface) { + wpa_printf(MSG_DEBUG, "CTRL_IFACE Creating interface '%s'", iface.ifname); + if (wpa_drv_if_add(global->ifaces, WPA_IF_STATION, iface.ifname, + NULL, NULL, NULL , mac_addr, NULL) < 0) + { + wpa_printf(MSG_ERROR, "CTRL_IFACE Interface creation failed"); + return -1; + } + + wpa_printf(MSG_DEBUG, "CTRL_IFACE Interface '%s' is created with mac addr:" MACSTR, + iface.ifname, MAC2STR(mac_addr)); + } + if (wpa_supplicant_get_iface(global, iface.ifname)) return -1; @@ -8564,13 +8588,35 @@ static int wpa_supplicant_global_iface_remove(struct wpa_global *global, char *cmd) { struct wpa_supplicant *wpa_s; + int ret; + char *ifname; + char *pos; + int delete_iface = 0; + + wpa_printf(MSG_ERROR, "CTRL_IFACE GLOBAL INTERFACE_REMOVE '%s'", cmd); + + /* + * TAB[] + */ + ifname = cmd; + pos = os_strchr(cmd, '\t'); + if (pos) + *pos++ = '\0'; - wpa_printf(MSG_DEBUG, "CTRL_IFACE GLOBAL INTERFACE_REMOVE '%s'", cmd); + if (os_strstr(pos, "delete")) { + /* Interface need to be deleted after de-initialization */ + delete_iface = 1; + } - wpa_s = wpa_supplicant_get_iface(global, cmd); + wpa_s = wpa_supplicant_get_iface(global, ifname); if (wpa_s == NULL) return -1; - return wpa_supplicant_remove_iface(global, wpa_s, 0); + ret = wpa_supplicant_remove_iface(global, wpa_s, 0); + if (!ret && delete_iface) { + wpa_printf(MSG_DEBUG, "CTRL_IFACE Deleting the interface '%s'", ifname); + ret = wpa_drv_if_remove(global->ifaces, WPA_IF_STATION, ifname); + } + return ret; }