From patchwork Wed Nov 2 08:22:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 690297 X-Patchwork-Delegate: blogic@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 3t81LS4Tjfz9vDV for ; Wed, 2 Nov 2016 19:22:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=tTB/bsQY; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id A7658B8090D; Wed, 2 Nov 2016 09:22:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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 autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Wed, 2 Nov 2016 09:22:27 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 6D443B80908 for ; Wed, 2 Nov 2016 09:22:26 +0100 (CET) X-policyd-weight: using cached result; rate: -7 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 2 Nov 2016 09:22:26 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id p190so1722020wmp.1 for ; Wed, 02 Nov 2016 01:22:26 -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=sjSlr4yqU6dHYN+qlpnrBofvde7F74bKs4w7zm6Uox4=; b=tTB/bsQYvwnMC0K9ZRe5Tr5zuMIiEsN2mbHEdKHyMu69y1ZX7JcEEj3rlgw4o7QfZ5 4GsuYtFn7+f1KLvxYK0gEx6qBg/6/EJbqVH1mHhv0pbTs8BGI4VHb6viHVtW+5T99iuA sM0mt7PJfGlak+P+doPk5wLur58p2k5AUiTXCxuU1pcxmQ8J55ddKXT8Smi5eCydkk3R p7VzGH4+Hf5VFTAHUTuGzJ02E9dG26ry1W+enDR3Cq0cg7OsZuZJNDisoe9ifdO+Ug8Q onfuQzO0c70c4QN5oPRJ8ktzISG74fesU00auSJhN+xSsIAU8BovFtP+pG6T/Trft1F1 6HOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sjSlr4yqU6dHYN+qlpnrBofvde7F74bKs4w7zm6Uox4=; b=TS4risat2XL8AoDbKnwHVGuidAzvoZ1XL0ytDoVzyM8og0CqVLVPOlrWfagNktKX17 xL3N9XQEYhIm6DYVrUbsk/iTpiWYo3uM2Jr8IuM+V1QrN7paL8JZP0R7NnZ4JRfjuhHT fBW5grm3ME46dgUCwA5jja9H2yLRh057GduI7LBAI6PjoXb1cqpuSrYzHKSGX0HLtSPN wqTWE218mv3Vs5zFOn82uL+tjRgNqDmA1fhlWh99qS+3HFU2V5OntcrYUPQ66DLSWxRo uqse2hZlCr1CcicswAUak+xKZp/Th2/YVQ/1FdOBts4G5nMN+GSoIMyX5oysmucsn/Y7 6d+g== X-Gm-Message-State: ABUngvffECb/ZG3l+9xUQYaDUDtSYTe3GBam43llfBJiwN1Fv39gMkvgNlIvLZ9f2jTbMg== X-Received: by 10.28.27.23 with SMTP id b23mr1744703wmb.82.1478074945116; Wed, 02 Nov 2016 01:22:25 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id n72sm34865073wmd.11.2016.11.02.01.22.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Nov 2016 01:22:24 -0700 (PDT) From: Hans Dedecker To: nbd@nbd.name Date: Wed, 2 Nov 2016 09:22:10 +0100 Message-Id: <1478074930-18993-1-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [OpenWrt-Devel] [PATCH netifd] interface: Fix triggering of interface update event X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker , lede-dev@lists.infradead.org, openwrt-devel@lists.openwrt.org MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" In case the keep flag is set in proto_shell_update_link no interface update event is triggered when IPv4/6 addresses/routes/... are updated as the proto_event callback is not called due to keep being set. Unconditionally call the proto_event callback handler in proto_shell_update_link but let the proto_event callback handler; in this case interface_proto_event_cb, decide which actions need to be taken dependant on the interface state. In case the interface is already in the up state trigger an update event only if the interface updated flag actually indicates either an IP address/ route/data change; before interface update events were actually sent wihtout any parameter change. Signed-off-by: Hans Dedecker --- interface.c | 9 ++++++--- interface.h | 2 +- proto-shell.c | 7 +++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/interface.c b/interface.c index 5870422..a014111 100644 --- a/interface.c +++ b/interface.c @@ -693,7 +693,8 @@ interface_proto_event_cb(struct interface_proto_state *state, enum interface_pro switch (ev) { case IFPEV_UP: if (iface->state != IFS_SETUP) { - interface_event(iface, IFEV_UPDATE); + if (iface->state == IFS_UP && iface->updated) + interface_event(iface, IFEV_UPDATE); return; } @@ -1091,10 +1092,12 @@ set_config_state(struct interface *iface, enum interface_config_state s) } void -interface_update_start(struct interface *iface) +interface_update_start(struct interface *iface, const bool keep_old) { iface->updated = 0; - interface_ip_update_start(&iface->proto_ip); + + if (!keep_old) + interface_ip_update_start(&iface->proto_ip); } void diff --git a/interface.h b/interface.h index aa2085d..7d5b309 100644 --- a/interface.h +++ b/interface.h @@ -199,7 +199,7 @@ void interface_add_error(struct interface *iface, const char *subsystem, int interface_add_data(struct interface *iface, const struct blob_attr *data); int interface_parse_data(struct interface *iface, const struct blob_attr *attr); -void interface_update_start(struct interface *iface); +void interface_update_start(struct interface *iface, const bool keep_old); void interface_update_complete(struct interface *iface); void interface_start_pending(void); diff --git a/proto-shell.c b/proto-shell.c index 998a44c..ef56aa8 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -538,10 +538,10 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, return UBUS_STATUS_UNKNOWN_ERROR; device_set_present(dev, true); - - interface_update_start(iface); } + interface_update_start(iface, keep); + proto_apply_ip_settings(iface, data, addr_ext); if ((cur = tb[NOTIFY_ROUTES]) != NULL) @@ -562,8 +562,7 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, interface_update_complete(state->proto.iface); if ((state->sm != S_SETUP_ABORT) && (state->sm != S_TEARDOWN)) { - if (!keep) - state->proto.proto_event(&state->proto, IFPEV_UP); + state->proto.proto_event(&state->proto, IFPEV_UP); state->sm = S_IDLE; }