From patchwork Mon Nov 2 10:16:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 538955 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 4AB2D1402B7 for ; Mon, 2 Nov 2015 21:18:00 +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=t3bgz1uw; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 4C60828BB92; Mon, 2 Nov 2015 11:14:52 +0100 (CET) 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 7A2E5281482 for ; Mon, 2 Nov 2015 11:14:43 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 2 Nov 2015 11:14:43 +0100 (CET) Received: by wicll6 with SMTP id ll6so46562976wic.0 for ; Mon, 02 Nov 2015 02:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xkYrbkKlcWY7CM5OqCp0Gyq8TbgFCeV82Uxmrb5LJPk=; b=t3bgz1uwXTf9eexCddacEpr1hfKHwI6jp3/BGYyd7QWB1xoKZDCILReIM5dAdokq4A QDKrALNEdWZp1d01zLMkf2WjdqneLe2J+Wv1pfvefCPJygQt5LhD36eDmzh+kWC5SRs1 SruMySzAuDABgrW7uECNRuHxCR8rJPYbowalWohDXT8jp0OLqRM4F+QgRcJaF+dOLpdp /hWMdxC17HFlFmW7zmZX4KXjgve6rE8ROdq9PAqxjZp9dkeBm6W78ycqm0RYwkg2Aa/m OgI9F2MP6WvHr2jq7C4FmbDrf6GIj0dI6gDzymxAflwqFQGFXcBzULoAZ2d9k2Ki6OMs YccQ== X-Received: by 10.194.187.14 with SMTP id fo14mr22598830wjc.104.1446459388869; Mon, 02 Nov 2015 02:16:28 -0800 (PST) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id e189sm17298743wma.4.2015.11.02.02.16.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Nov 2015 02:16:28 -0800 (PST) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Mon, 2 Nov 2015 11:16:12 +0100 Message-Id: <1446459372-19588-3-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446459372-19588-1-git-send-email-dedeckeh@gmail.com> References: <1446459372-19588-1-git-send-email-dedeckeh@gmail.com> Cc: Hans Dedecker , cyrus@openwrt.org Subject: [OpenWrt-Devel] [PATCH netifd] device: Don't process link events anymore in device user specific callback handlers 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" Set link_state for all device types via the device_set_link API as all devices are registered in the device tree list making it possible to always get the device via device_get. The decice link state parameter will now actually reflect the corresponding kernel device carrier state in all cases. Before this change a vlan/macvlan device could still have link_state enabled if an interface was brought down; this was the case when the parent vlan/macvlan device was still enabled as the netlink link_state event would be dropped for vlan/macvlan devices due to keep_link_state in the function cb_rtnl_event. Signed-off-by: Hans Dedecker --- device.h | 2 -- macvlan.c | 8 -------- system-linux.c | 2 +- vlan.c | 6 ------ vlandev.c | 8 -------- 5 files changed, 1 insertion(+), 25 deletions(-) diff --git a/device.h b/device.h index 37814c8..4ff335d 100644 --- a/device.h +++ b/device.h @@ -58,8 +58,6 @@ struct device_type { struct list_head list; const char *name; - bool keep_link_status; - const struct uci_blob_param_list *config_params; struct device *(*create)(const char *name, struct blob_attr *attr); diff --git a/macvlan.c b/macvlan.c index 051fe05..a0f11ae 100644 --- a/macvlan.c +++ b/macvlan.c @@ -72,12 +72,6 @@ macvlan_base_cb(struct device_user *dev, enum device_event ev) case DEV_EVENT_REMOVE: device_set_present(&mvdev->dev, false); break; - case DEV_EVENT_LINK_UP: - device_set_link(&mvdev->dev, true); - break; - case DEV_EVENT_LINK_DOWN: - device_set_link(&mvdev->dev, false); - break; default: return; } @@ -261,8 +255,6 @@ macvlan_create(const char *name, struct blob_attr *attr) const struct device_type macvlan_device_type = { .name = "MAC VLAN", .config_params = &macvlan_attr_list, - .keep_link_status = true, - .create = macvlan_create, .config_init = macvlan_config_init, .reload = macvlan_reload, diff --git a/system-linux.c b/system-linux.c index f51c078..38f43fe 100644 --- a/system-linux.c +++ b/system-linux.c @@ -424,7 +424,7 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) goto out; struct device *dev = device_get(nla_data(nla[IFLA_IFNAME]), false); - if (!dev || dev->type->keep_link_status) + if (!dev) goto out; if (!system_get_dev_sysctl("/sys/class/net/%s/carrier", dev->ifname, buf, sizeof(buf))) diff --git a/vlan.c b/vlan.c index 3d0a4cf..8e7141f 100644 --- a/vlan.c +++ b/vlan.c @@ -79,11 +79,6 @@ static void vlan_dev_cb(struct device_user *dep, enum device_event ev) case DEV_EVENT_REMOVE: device_set_present(&vldev->dev, new_state); break; - case DEV_EVENT_LINK_UP: - new_state = true; - case DEV_EVENT_LINK_DOWN: - device_set_link(&vldev->dev, new_state); - break; case DEV_EVENT_UPDATE_IFNAME: vlan_dev_set_name(vldev, dep->dev); device_broadcast_event(&vldev->dev, ev); @@ -102,7 +97,6 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create) static const struct device_type vlan_type = { .name = "VLAN", .config_params = &device_attr_list, - .keep_link_status = true, .free = free_vlan_if, }; struct vlan_device *vldev; diff --git a/vlandev.c b/vlandev.c index 884e6ef..b93527c 100644 --- a/vlandev.c +++ b/vlandev.c @@ -63,12 +63,6 @@ vlandev_base_cb(struct device_user *dev, enum device_event ev) case DEV_EVENT_REMOVE: device_set_present(&mvdev->dev, false); break; - case DEV_EVENT_LINK_UP: - device_set_link(&mvdev->dev, true); - break; - case DEV_EVENT_LINK_DOWN: - device_set_link(&mvdev->dev, false); - break; default: return; } @@ -249,8 +243,6 @@ vlandev_create(const char *name, struct blob_attr *attr) const struct device_type vlandev_device_type = { .name = "VLANDEV", .config_params = &vlandev_attr_list, - .keep_link_status = true, - .create = vlandev_create, .config_init = vlandev_config_init, .reload = vlandev_reload,