Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1873925ybi; Thu, 4 Jul 2019 01:07:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLxTKxIeVYWY9jeb525ihxz6pl3PvnTwnjSqFPjPO/eXH87jEwyV+CTLedMEudMbDWV0zt X-Received: by 2002:a17:902:d88e:: with SMTP id b14mr46887517plz.153.1562227651213; Thu, 04 Jul 2019 01:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562227651; cv=none; d=google.com; s=arc-20160816; b=pXg5dt4eY95r+BT7qURFmkGrFpAZNFZdIOiVCFRwdmieSEZ3ttqBaOjurdIxmNfFjR R8bBctTvNfgM8Ce2x52sXmGdzI5RSlXFiUoJZVBu4wWdyrWmDQyUzofiMU4CiqExYzoB dO6dLrEd3P0cpBhLkYDsagP2a/D86PDsayZAHHdBq9iYvvgbeXNkFxFQzv2yaYdwV0jR 44cTcEV2SX66iAjZfqzbBFN/AvQJU37QrQgiqv4026HrYYLSx+Oac7ozZfnXiAXXFEpZ 5q7tIz184LjcajqTCPpaOJperalXhuYOCKjrN4jHVUo+RDo/02Ton5WoMeIRd3QoiCZG k5wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7U8PUS9qeOEnu5XyHEv9AyKWyWyvdTGDvMPE5z/vTV4=; b=eLc6lNb1Hu+8tX8UpC2KkgeU4W3M1JZYnBfa3sl8qIY8sleCsqz6dvlxYLEp19SZFb pRszQnqlejI4GAwRtK4jsCryQ3pfamFRQwxPqamCN7k416FrhzO+qWqZCVk5XTa2mphb sKh0Egpz2/ApQO8dVWhzNrIuUKx8JMUMyzhzFYh8mGNQYayHJr2u/PjPwiPZA7/WUzuh MJ/4MlEGrIPJz2+kRwMaBql5RJsTt/fpw4foIdpxI5narw+9Ndyn78+BupFjfiUMypB6 FVYIPf5MAZGqGxnD0lxPqsh+D3Q1dM2Cj/oNbRKaX+u4ELhOI5cgjW+QfOEWuTQJo0wL E/Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=lDQiYQGT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q14si4697332pgq.588.2019.07.04.01.07.16; Thu, 04 Jul 2019 01:07:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=lDQiYQGT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727079AbfGDIGC (ORCPT + 99 others); Thu, 4 Jul 2019 04:06:02 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50712 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726957AbfGDIGC (ORCPT ); Thu, 4 Jul 2019 04:06:02 -0400 Received: by mail-wm1-f65.google.com with SMTP id n9so4756114wmi.0 for ; Thu, 04 Jul 2019 01:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7U8PUS9qeOEnu5XyHEv9AyKWyWyvdTGDvMPE5z/vTV4=; b=lDQiYQGTJywYz1M49aN4htdUio8wJiZoNk0UFRG2Qp89ahNYYFRAIFKNngGvPx30ZJ 68rb6xm9N2tPRwjlQGo35YR4zNIbwMD3X/hMwxDrenqh/bLUW9CWk58jIYR4GOMyH47l UVIoKb5MrhOfcsFtkxkICTuYQI7N1E2Jjz5DNvxWUPNOmY2+aC+C+kdelbY0nK2iA5Xy qRYJexEvscpdMjx1QxF0bfQ3PdBp1xAttUY6YDp46b6sYnCsknOwQzMIVOI4LpePH/Ei j6x09CrtLH3Oq68T6+FKRItmkfjgS8lnCPrt0EmWUNJ91BtNUcgjwPxexRez2jzEU8ky 93fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7U8PUS9qeOEnu5XyHEv9AyKWyWyvdTGDvMPE5z/vTV4=; b=LVtur39GB5346GFUXLPlsTKdOEN+q0wF24xmSfPBUJxgn58qK0ol8zc4D6vtrGn2es 5gu79O55k7eefeqTA7avvw6B8F/V8uAX3rdfCDJc948JHWsnBMVxTy1maW+J/KOnPDQe Pi1W7ZDSdv0lYPIZ9sHmyGVIFVhU34qXhgMzLCH6NkeryGbyzk4NJX7O29t3X/beXEXO ykQj02kyBgMyL8BiNqV/Yo8Fs1f+zt0TidUwUmHPLyoAZRQDgtDynaN+bZPO4jBl/PF5 irt2kMRk2eGuGqpQ63Q490z9HAtwGpuwBRfU3q2ne26Jwz5D401cdu65eTktc0MCPPOs pQWw== X-Gm-Message-State: APjAAAWn4ceUZUTwtMUHCuHSk57vKN0VulB0Aeiu5kPgXvtHmh2dbxWJ 0hojqPq1uvhDeq7wudCkoBQYfQ== X-Received: by 2002:a05:600c:2218:: with SMTP id z24mr11398628wml.84.1562227560803; Thu, 04 Jul 2019 01:06:00 -0700 (PDT) Received: from localhost (ip-213-220-235-213.net.upcbroadband.cz. [213.220.235.213]) by smtp.gmail.com with ESMTPSA id w24sm3387938wmc.30.2019.07.04.01.06.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 04 Jul 2019 01:06:00 -0700 (PDT) Date: Thu, 4 Jul 2019 10:06:00 +0200 From: Jiri Pirko To: Michal Kubecek Cc: netdev@vger.kernel.org, David Miller , Jakub Kicinski , Andrew Lunn , Florian Fainelli , John Linville , Stephen Hemminger , Johannes Berg , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v6 07/15] ethtool: support for netlink notifications Message-ID: <20190704080600.GG2250@nanopsycho> References: <4dcac81783de8686edefa262a1db75f9e961b123.1562067622.git.mkubecek@suse.cz> <20190703133352.GY2250@nanopsycho> <20190703141614.GL20101@unicorn.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190703141614.GL20101@unicorn.suse.cz> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wed, Jul 03, 2019 at 04:16:14PM CEST, mkubecek@suse.cz wrote: >On Wed, Jul 03, 2019 at 03:33:52PM +0200, Jiri Pirko wrote: >> >+/* notifications */ >> >+ >> >+typedef void (*ethnl_notify_handler_t)(struct net_device *dev, >> >+ struct netlink_ext_ack *extack, >> >+ unsigned int cmd, u32 req_mask, >> >+ const void *data); >> >+ >> >+static const ethnl_notify_handler_t ethnl_notify_handlers[] = { >> >+}; >> >+ >> >+void ethtool_notify(struct net_device *dev, struct netlink_ext_ack *extack, >> >+ unsigned int cmd, u32 req_mask, const void *data) >> >> What's "req_mask" ? > >It's infomask to interpret the same way as if it came from request >header (the notification triggered by a SET request or its ioctl >equivalent uses the same format as corresponding GET_REPLY message and >is created by the same code). But it could be called infomask, I have no >strong opinion about that. The name should be same all along the code so the reader can track it. > >> >+{ >> >+ if (unlikely(!ethnl_ok)) >> >+ return; >> >+ ASSERT_RTNL(); >> >+ >> >+ if (likely(cmd < ARRAY_SIZE(ethnl_notify_handlers) && >> >+ ethnl_notify_handlers[cmd])) >> >> How it could be null? > >Notification message types share the enum with other kernel messages: > >/* message types - kernel to userspace */ >enum { > ETHTOOL_MSG_KERNEL_NONE, > ETHTOOL_MSG_STRSET_GET_REPLY, > ETHTOOL_MSG_SETTINGS_GET_REPLY, > ETHTOOL_MSG_SETTINGS_NTF, > ETHTOOL_MSG_SETTINGS_SET_REPLY, > ETHTOOL_MSG_INFO_GET_REPLY, > ETHTOOL_MSG_PARAMS_GET_REPLY, > ETHTOOL_MSG_PARAMS_NTF, > ETHTOOL_MSG_NWAYRST_NTF, > ETHTOOL_MSG_PHYSID_NTF, > ETHTOOL_MSG_RESET_NTF, > ETHTOOL_MSG_RESET_ACT_REPLY, > ETHTOOL_MSG_RXFLOW_GET_REPLY, > ETHTOOL_MSG_RXFLOW_NTF, > ETHTOOL_MSG_RXFLOW_SET_REPLY, > > /* add new constants above here */ > __ETHTOOL_MSG_KERNEL_CNT, > ETHTOOL_MSG_KERNEL_MAX = (__ETHTOOL_MSG_KERNEL_CNT - 1) >}; > >Only entries for *_NTF types are non-null in ethnl_notify_handlers[]: > >static const ethnl_notify_handler_t ethnl_notify_handlers[] = { > [ETHTOOL_MSG_SETTINGS_NTF] = ethnl_std_notify, > [ETHTOOL_MSG_PARAMS_NTF] = ethnl_std_notify, > [ETHTOOL_MSG_NWAYRST_NTF] = ethnl_nwayrst_notify, > [ETHTOOL_MSG_PHYSID_NTF] = ethnl_physid_notify, > [ETHTOOL_MSG_RESET_NTF] = ethnl_reset_notify, > [ETHTOOL_MSG_RXFLOW_NTF] = ethnl_rxflow_notify, >}; > >If the check above fails, it means that kernel code tried to send >a notification with type which does not exist or is not a notification, >i.e. a bug in kernel; that's why the WARN_ONCE. Got it, thanks! > >Michal > >> >+ ethnl_notify_handlers[cmd](dev, extack, cmd, req_mask, data); >> >+ else >> >+ WARN_ONCE(1, "notification %u not implemented (dev=%s, req_mask=0x%x)\n", >> >+ cmd, netdev_name(dev), req_mask); >> >+} >> >+EXPORT_SYMBOL(ethtool_notify);