From patchwork Thu Jan 30 13:20:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Gundersen X-Patchwork-Id: 315342 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B75402C014B for ; Fri, 31 Jan 2014 00:20:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753109AbaA3NTw (ORCPT ); Thu, 30 Jan 2014 08:19:52 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:45767 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752728AbaA3NTv (ORCPT ); Thu, 30 Jan 2014 08:19:51 -0500 Received: by mail-ee0-f45.google.com with SMTP id b15so1560476eek.18 for ; Thu, 30 Jan 2014 05:19:50 -0800 (PST) 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=9hjrcFXwNbo1RMfqLSJZZMstRZHVhfoaV2U9aghhZTw=; b=ThFeKBDfzHxK+Am/wEAwnMD59xmCScePNxO9Zxa94iNpli9v5fHJgGkgUnjSgBY/Cm JfIi4x9/ddxSXuhjpoewTl5ray6eqjdCuSKXr2EXF4McQHj6uL56tnaueb6K5h70Y93a JXSiaXixhXaYEZuAufi6vYlUotkwvabcUyrH+HreY4yq+4MkB4q/m53JZNVCZX79GRr5 EUhisc//x94Yd+7vM3o6pmLtuzuvT7NAkH2t9+iL7kV5NDIFyW0Nz+GrRdA9hmB1g4Po cZ1g/Piztsjia9H9F1czd1sX9gLQ8o2bZF68yFNdD11K4cwKwWnWzLlqxV5JUf65LKAj j0MA== X-Gm-Message-State: ALoCoQl3AAPeTkh9glIlkTYDEHeKDvlbKwxzOVkWXqWzldD+7m3xfjGxM+IV7yXyE8mTU9vzHH1E X-Received: by 10.14.220.193 with SMTP id o41mr17356872eep.22.1391087990381; Thu, 30 Jan 2014 05:19:50 -0800 (PST) Received: from tomegun-air.space.hackerspace.be (ip-62-235-135-131.dsl.scarlet.be. [62.235.135.131]) by mx.google.com with ESMTPSA id o43sm22355493eef.12.2014.01.30.05.19.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jan 2014 05:19:49 -0800 (PST) From: Tom Gundersen To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Stephen Hemminger , Avinash Kumar , Mauro Carvalho Chehab , Simon Horman , Tom Gundersen , Marcel Holtmann , Greg KH , Kay Sievers Subject: [PATCH] net: set default DEVTYPE for all ethernet based devices Date: Thu, 30 Jan 2014 14:20:02 +0100 Message-Id: <1391088002-15650-1-git-send-email-teg@jklm.no> X-Mailer: git-send-email 1.8.5.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In systemd's networkd and udevd, we would like to give the administrator a simple way to filter net devices by their DEVTYPE [0][1]. Other software such as ConnMan and NetworkManager uses a similar filtering already. Currently, plain ethernet devices have DEVTYPE=(null). This patch sets the devtype to "ethernet" instead. This avoids the need for special-casing the DEVTYPE=(null) case in userspace, and also avoids false positives, as there are several other types of netdevs that also have DEVTYPE=(null). Notice that this is done, as suggested by Marcel, in alloc_etherdev_mqs(), and as best I can tell it will not give any false positives. I considered doing it in ether_setup() instead as that seemed more intuitive, but that would give a lot of false positives indeed. [0]: [1]: Signed-off-by: Tom Gundersen Cc: Marcel Holtmann Cc: Greg KH Cc: Kay Sievers --- net/ethernet/eth.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 8f032ba..b76dc17 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -369,6 +369,10 @@ void ether_setup(struct net_device *dev) } EXPORT_SYMBOL(ether_setup); +static const struct device_type eth_type = { + .name = "ethernet", +}; + /** * alloc_etherdev_mqs - Allocates and sets up an Ethernet device * @sizeof_priv: Size of additional driver-private structure to be allocated @@ -387,7 +391,13 @@ EXPORT_SYMBOL(ether_setup); struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs, unsigned int rxqs) { - return alloc_netdev_mqs(sizeof_priv, "eth%d", ether_setup, txqs, rxqs); + struct net_device* dev; + + dev = alloc_netdev_mqs(sizeof_priv, "eth%d", ether_setup, txqs, rxqs); + if (dev) + dev->dev.type = ð_type; + + return dev; } EXPORT_SYMBOL(alloc_etherdev_mqs);