From patchwork Wed Oct 11 05:54:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 824234 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="ow+qVrJg"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="oWyolAUr"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yBjqm2Lb3z9t5C for ; Wed, 11 Oct 2017 16:55:00 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756550AbdJKFyn (ORCPT ); Wed, 11 Oct 2017 01:54:43 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:37755 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750959AbdJKFym (ORCPT ); Wed, 11 Oct 2017 01:54:42 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 78EE320B1E; Wed, 11 Oct 2017 01:54:41 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Wed, 11 Oct 2017 01:54:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=YX/9G5gtXvAFmq/Nd xH2Reeq75YGZJ6pITrlNSJ26rU=; b=ow+qVrJg4artton6mOkyWwqao6yUS0V04 k+sZpM11A0rwqbJs+5ZSiyC+wfjxJZ7fPADcvnbjaPEY7UlUQ3LwTBFI2QSGIQbb e9fsWmp2K/599j1va92A/wckhE28wS/wxGx7MLLZ9iytj1FwEV4umpxsBgvtAQr3 kINkGTXDiBQF5RE4Hy/LFXNUaCeU+l+YzKdv+UMtZNqeVp8878zlsZ0LNgXUsZAj JSvOAdtJQQmUfjVK6Qm/9sJeZo5jQzg3jNaOO/wxutvFel60BuM28KD2Jb/OuNZw rch5t9sFwoaG7NLLa1aR90gA4CmnxPMeUnUPbFc3WULHUmoHCSBBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=YX/9G5gtXvAFmq/Nd xH2Reeq75YGZJ6pITrlNSJ26rU=; b=oWyolAUr3I78GdJHX1YfE/qtdJEZ826tS JPqIUNxwJjNyDlKden35n4RjM0aG32bMy9QTYyZtOIj1YujZ5NgTkyLd7Ia//Jlv imyr1+tFuEN/+kpGKm5nX19tz3woX+9mHz407PnZK8g976W+79F0WSS3WiJzAMQl Y6kWgz0T2UTowOimbiAOcqbg5ACRr4Umg7iM5QFrDVyx0ucqNirDTmhjSv/f5X10 yB1AB+QRhDzRM0WWNhzlarWoT9hDl6EvbgY1K9eVqfaV1V6ZukwwFq6hIQclwPWJ FkIh5qusi/gK/py9uTx+pln6QwGYt270qq3CmDHzLzfLu6Xpzrr4A== X-ME-Sender: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id B8DA47E674; Wed, 11 Oct 2017 01:54:39 -0400 (EDT) From: Samuel Mendoza-Jonas To: netdev@vger.kernel.org Cc: Samuel Mendoza-Jonas , "David S . Miller" , linux-kernel@vger.kernel.org Subject: [PATCH net] net/ncsi: Don't limit vids based on hot_channel Date: Wed, 11 Oct 2017 16:54:27 +1100 Message-Id: <20171011055427.30227-1-sam@mendozajonas.com> X-Mailer: git-send-email 2.14.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently we drop any new VLAN ids if there are more than the current (or last used) channel can support. Most importantly this is a problem if no channel has been selected yet, resulting in a segfault. Secondly this does not necessarily reflect the capabilities of any other channels. Instead only drop a new VLAN id if we are already tracking the maximum allowed by the NCSI specification. Per-channel limits are already handled by ncsi_add_filter(), but add a message to set_one_vid() to make it obvious that the channel can not support any more VLAN ids. Signed-off-by: Samuel Mendoza-Jonas --- net/ncsi/internal.h | 1 + net/ncsi/ncsi-manage.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index af3d636534ef..d30f7bd741d0 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h @@ -286,6 +286,7 @@ struct ncsi_dev_priv { struct work_struct work; /* For channel management */ struct packet_type ptype; /* NCSI packet Rx handler */ struct list_head node; /* Form NCSI device list */ +#define NCSI_MAX_VLAN_VIDS 15 struct list_head vlan_vids; /* List of active VLAN IDs */ }; diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index 3fd3c39e6278..b6a449aa9d4b 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -732,6 +732,10 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, if (index < 0) { netdev_err(ndp->ndev.dev, "Failed to add new VLAN tag, error %d\n", index); + if (index == -ENOSPC) + netdev_err(ndp->ndev.dev, + "Channel %u already has all VLAN filters set\n", + nc->id); return -1; } @@ -1403,7 +1407,6 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp) int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { - struct ncsi_channel_filter *ncf; struct ncsi_dev_priv *ndp; unsigned int n_vids = 0; struct vlan_vid *vlan; @@ -1420,7 +1423,6 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) } ndp = TO_NCSI_DEV_PRIV(nd); - ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN]; /* Add the VLAN id to our internal list */ list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) { @@ -1431,12 +1433,11 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) return 0; } } - - if (n_vids >= ncf->total) { - netdev_info(dev, - "NCSI Channel supports up to %u VLAN tags but %u are already set\n", - ncf->total, n_vids); - return -EINVAL; + if (n_vids >= NCSI_MAX_VLAN_VIDS) { + netdev_warn(dev, + "tried to add vlan id %u but NCSI max already registered (%u)\n", + vid, NCSI_MAX_VLAN_VIDS); + return -ENOSPC; } vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);