From patchwork Mon Dec 3 18:40:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 152724 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7150395ljp; Mon, 3 Dec 2018 10:40:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/VrTQxdHXAh7B7kyHt1CJZgnLtJKGczY25z2R6ZP5QywOUsninnproFPACkktLp3z14PY2M X-Received: by 2002:a63:5346:: with SMTP id t6mr14510785pgl.40.1543862436607; Mon, 03 Dec 2018 10:40:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543862436; cv=none; d=google.com; s=arc-20160816; b=GK/fYY9ByDFHKK4v08P1Poe+pd9BX4zmfcu4v8DQttCXTnp59aAobX3Ay+acMAIK0w HhGHkgQ6Y9bEvi+kmXWEOWofilTLUZ26hhKeLdm+Z5RqZcxy887PFEzIfk12SKQDZJI8 WA0y+JuyXbfQEBrxwjxdJC358xvImj9aBZqxGw8u2EDttbLEKscxh5le4d5Wro8Ib9mE m2U9RhmKfky7QNCE0xIzk1BY1Lo/MNrJBTmyhQBW7DlKyyQwqYYnS5auEnMCaV3wrwET ief6sV9VncTurViIZwgdi53nAv5Vj4N4vuc54WidQ6B24foDE9/M42a0+6rowLICwEir tUaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=1E86stckhUJo7da4us/DFsrz1EGMsvbFJsbqAY8mK7A=; b=sdosdYk9epEqWdxtIAG5NpWXXjgMQMV6E6zDWjp70btFPkQUKA/mgw8lCjV2x4qIE3 /JHRpO4rr03LhF2m8Q2HcjtE7fvArv5ZdCHP+TuQNdCTkXBIvjF5pbdPvdFuhyoIIbNw fRnrSeD44pn60ix8jgaLurX8+cFIRArnNHqfNW+8j5H/m3XKqurXZbz3ufn9Q6dkN1rJ PIzhQo00VwnSBoaasjEQgJ+zTQehdGi/+qvtgFCrdFrkD9j7knE0JwRyV/tuSPNZtY2T 2VlRjfJdy4LBqIJXOARSsMO8qnA0VLNSpoeBcyUFVGsdXgDL33quWSfu9SxI0vDFYYgd Y+GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dl7feYKd; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9si16701319pll.63.2018.12.03.10.40.36; Mon, 03 Dec 2018 10:40:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dl7feYKd; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726893AbeLCSkh (ORCPT + 5 others); Mon, 3 Dec 2018 13:40:37 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:32994 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbeLCSkg (ORCPT ); Mon, 3 Dec 2018 13:40:36 -0500 Received: by mail-lf1-f66.google.com with SMTP id i26so9970204lfc.0 for ; Mon, 03 Dec 2018 10:40:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1E86stckhUJo7da4us/DFsrz1EGMsvbFJsbqAY8mK7A=; b=dl7feYKdeaM+O8AnqZ1Nb8PutI4XBUzUWe4OjNJU5cMiolmF+HMTsuIN1Uq31gspUz gPV/Biqk8jkzwkmvEY9Q3zx1bSs1akAQsFoxcBrJDyPZUpaJ+eUQHE34EY/q8Dr75G0L zz6r4pHOzUT6eYSKQkTQz61/xglQ8c13Wfb9E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1E86stckhUJo7da4us/DFsrz1EGMsvbFJsbqAY8mK7A=; b=P7D1n7bj93RFKArZFK6cuS4P90XpQMaqtIMCukGBrdSUFOK6OvGynNx/GDqTKY1XY9 t5vuHDIGy+gYxuhvkS8YXeN76CamkXDp9x741YqH4vc4gI0reAh+NgQ7oEcETizXD1g+ R3gOK5y2FtXF9y4YQTKAEK8Fdom5GW9CV3QVq2QyVZRUWgrk+3WsIaNzdcXZ1hWh6ifz jhmqfF55Hr63/PQf6Ofmwygrg63B8T9Ri2JoiebIuaMe1nweYOw/ZSHn0+/CicSZiPTX SnsYaTdeSncKcr9kwyn227sKEqjs+yOjZpR6KtFgvhWeD7Yz2O+dUDh1efEjc0LingYq zv7w== X-Gm-Message-State: AA+aEWYvVO05hLBHy7soB0es3aNR/Uk+ATsCrZ93YudUnCy2v4Rxaog+ Iw733HrxvSughZPCSC/91wGwRQ== X-Received: by 2002:a19:f510:: with SMTP id j16mr9345394lfb.35.1543862430451; Mon, 03 Dec 2018 10:40:30 -0800 (PST) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id d23sm2518513lfc.11.2018.12.03.10.40.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 10:40:29 -0800 (PST) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jiri@mellanox.com, Ivan Khoronzhuk Subject: [RFC PATCH net-next 2/5] net: 8021q: vlan_dev: add vid tag for uc and mc address lists Date: Mon, 3 Dec 2018 20:40:20 +0200 Message-Id: <20181203184023.3430-3-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181203184023.3430-1-ivan.khoronzhuk@linaro.org> References: <20181203184023.3430-1-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Update vlan mc and uc addresses with VID tag while propagating address set to lower devices, do this only if address is not synched. It allows on end driver level to distinguish address belonging to vlans. Signed-off-by: Ivan Khoronzhuk --- include/linux/if_vlan.h | 1 + net/8021q/vlan_core.c | 10 ++++++++++ net/8021q/vlan_dev.c | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) -- 2.17.1 diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 4cca4da7a6de..94657f3c483a 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -136,6 +136,7 @@ extern struct net_device *__vlan_find_dev_deep_rcu(struct net_device *real_dev, extern int vlan_for_each(struct net_device *dev, int (*action)(struct net_device *dev, int vid, void *arg), void *arg); +extern u16 vlan_dev_get_addr_vid(struct net_device *dev, const u8 *addr); extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); extern u16 vlan_dev_vlan_id(const struct net_device *dev); extern __be16 vlan_dev_vlan_proto(const struct net_device *dev); diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index a313165e7a67..5d17947d6988 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -454,6 +454,16 @@ bool vlan_uses_dev(const struct net_device *dev) } EXPORT_SYMBOL(vlan_uses_dev); +u16 vlan_dev_get_addr_vid(struct net_device *dev, const u8 *addr) +{ + u16 vid = 0; + + vid = addr[dev->addr_len]; + vid |= (addr[dev->addr_len + 1] & 0xf) << 8; + return vid; +} +EXPORT_SYMBOL(vlan_dev_get_addr_vid); + static struct sk_buff *vlan_gro_receive(struct list_head *head, struct sk_buff *skb) { diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index b2d9c8f27cd7..c05b313314b7 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -250,6 +250,14 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result) strncpy(result, vlan_dev_priv(dev)->real_dev->name, 23); } +static void vlan_dev_set_addr_vid(struct net_device *vlan_dev, u8 *addr) +{ + u16 vid = vlan_dev_vlan_id(vlan_dev); + + addr[vlan_dev->addr_len] = vid & 0xff; + addr[vlan_dev->addr_len + 1] = (vid >> 8) & 0xf; +} + bool vlan_dev_inherit_address(struct net_device *dev, struct net_device *real_dev) { @@ -481,8 +489,26 @@ static void vlan_dev_change_rx_flags(struct net_device *dev, int change) } } +static void vlan_dev_align_addr_vid(struct net_device *vlan_dev) +{ + struct net_device *real_dev = vlan_dev_real_dev(vlan_dev); + struct netdev_hw_addr *ha; + + if (!real_dev->vid_len) + return; + + netdev_for_each_mc_addr(ha, vlan_dev) + if (!ha->sync_cnt) + vlan_dev_set_addr_vid(vlan_dev, ha->addr); + + netdev_for_each_uc_addr(ha, vlan_dev) + if (!ha->sync_cnt) + vlan_dev_set_addr_vid(vlan_dev, ha->addr); +} + static void vlan_dev_set_rx_mode(struct net_device *vlan_dev) { + vlan_dev_align_addr_vid(vlan_dev); dev_mc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); }