From patchwork Sun May 24 07:36:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 475947 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DFE061402B2 for ; Sun, 24 May 2015 17:48:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=S5rivL/W; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 57C8A287BA5; Sun, 24 May 2015 09:46:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id D3DE9289D01 for ; Sun, 24 May 2015 09:46:25 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 24 May 2015 09:46:25 +0200 (CEST) Received: by pdea3 with SMTP id a3so49215941pde.2 for ; Sun, 24 May 2015 00:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=CuaFB59l9KOgvZxlHwBpLJ2qZXz9IZObE3xfmg+2XGc=; b=S5rivL/WC/JtocXDjuqWe4pFi0OzWb/UfrrdsJ7S9APz7mS9deScxlH2jur4GOdW5j Mx+T7e6D6zPbFtw2ewtDqENo+uaRz09lTXOvsacQ0YvrMBVoAeiWNn0uwxI3iGCWmwQH k4zDvcPHdjAvNKIgp2MTKGF30oT/yANDKtnbgpF9xWudBeiE4pjyTOCmTLJIugNRgu2c Y+apU8RG1MbPkZU4KdC1jSZ5Wd0lvkc3nYXlXQ2n776XH1aTo9jCUgGb0Yfm7ppUj0kv EMYFhq3wjkWshATKiodfD1vxFe6NkSDqDMfmQ83K0KoZftPxD9PUBPHrKy9aRAIjlaav Kp8Q== X-Received: by 10.66.161.102 with SMTP id xr6mr30090577pab.8.1432453666161; Sun, 24 May 2015 00:47:46 -0700 (PDT) Received: from debian.corp.sankuai.com ([103.29.140.56]) by mx.google.com with ESMTPSA id rt8sm6610026pbb.37.2015.05.24.00.47.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 May 2015 00:47:44 -0700 (PDT) From: Yousong Zhou To: nbd@openwrt.org Date: Sun, 24 May 2015 15:36:37 +0800 Message-Id: <1432452997-12589-1-git-send-email-yszhou4tech@gmail.com> X-Mailer: git-send-email 1.7.10.4 Cc: openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH v2] [netifd] Changes for more readability. X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" - "ifname" for Linux interface name. - "interface" for netifd defined logical interface names as in /etc/config/network. - A few comments and variable renames for better readability. Signed-off-by: Yousong Zhou --- v2 <- v1 - Drop the ev (type cast + pointer dereference) change in v1. - Reword the comment for alias interface. device.h | 3 +++ interface.c | 4 ++-- interface.h | 1 + proto-shell.c | 8 ++++---- ubus.c | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/device.h b/device.h index 3001f10..7f0f9d1 100644 --- a/device.h +++ b/device.h @@ -154,8 +154,11 @@ struct device { struct blob_attr *config; bool config_pending; bool sys_present; + /* DEV_EVENT_ADD */ bool present; + /* DEV_EVENT_UP */ int active; + /* DEV_EVENT_LINK_UP */ bool link_active; bool external; diff --git a/interface.c b/interface.c index 5166c0c..baf521a 100644 --- a/interface.c +++ b/interface.c @@ -647,7 +647,7 @@ interface_handle_config_change(struct interface *iface) } static void -interface_proto_cb(struct interface_proto_state *state, enum interface_proto_event ev) +interface_proto_event_cb(struct interface_proto_state *state, enum interface_proto_event ev) { struct interface *iface = state->iface; @@ -706,7 +706,7 @@ void interface_set_proto_state(struct interface *iface, struct interface_proto_s if (!state) return; - state->proto_event = interface_proto_cb; + state->proto_event = interface_proto_event_cb; state->iface = iface; } diff --git a/interface.h b/interface.h index 8eeb7db..6f9112c 100644 --- a/interface.h +++ b/interface.h @@ -120,6 +120,7 @@ struct interface { struct list_head users; + /* for alias interface */ const char *parent_ifname; struct interface_user parent_iface; diff --git a/proto-shell.c b/proto-shell.c index bac57e0..bb6edc8 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -52,7 +52,7 @@ struct proto_shell_handler { struct proto_shell_dependency { struct list_head list; - char *interface; + char *ifname; struct proto_shell_state *proto; struct interface_user dep; @@ -111,8 +111,8 @@ proto_shell_update_host_dep(struct proto_shell_dependency *dep) if (dep->dep.iface) goto out; - if (dep->interface[0]) - iface = vlist_find(&interfaces, dep->interface, iface, node); + if (dep->ifname[0]) + iface = vlist_find(&interfaces, dep->ifname, iface, node); iface = interface_ip_add_target_route(&dep->host, dep->v6, iface); if (!iface) @@ -695,7 +695,7 @@ proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att } dep->proto = state; - dep->interface = strcpy(ifname, ifname_str); + dep->ifname = strcpy(ifname, ifname_str); dep->dep.cb = proto_shell_if_up_cb; interface_add_user(&dep->dep, NULL); diff --git a/ubus.c b/ubus.c index 422b652..c7a329a 100644 --- a/ubus.c +++ b/ubus.c @@ -843,7 +843,7 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj, cur = tb[DEV_LINK_EXT]; if (cur) - link_ext = !!blobmsg_get_u8(cur); + link_ext = blobmsg_get_bool(cur); return interface_handle_link(iface, blobmsg_data(tb[DEV_LINK_NAME]), add, link_ext); }