Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3160371ybf; Tue, 3 Mar 2020 00:24:26 -0800 (PST) X-Google-Smtp-Source: ADFU+vvsNj87H1ku7zCSgDtaRAzIIbf/CZUOpYp54+j/dGQMM6qG873xDFtlbwJu+cZBgywUlnSE X-Received: by 2002:a9d:7c85:: with SMTP id q5mr2558888otn.341.1583223866362; Tue, 03 Mar 2020 00:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583223866; cv=none; d=google.com; s=arc-20160816; b=rBJDmCDIcccxOmmK56sBtv8d4axOC21PXv7u7rVQ07eKIndvRhQqHLd/ebcBCTXImV U8rJaxCKA+kdfAazEQqfcnb3sppVN+PkNdIFMMR4LtnsreWue4PcLZNuBPl/iCPKLf8K aJAMaziF2C9YmVwxeUtnkYvMUBGS/bJXP59lMrsPcNHe/XfhVtkgzVj5vtZOBQi6HLoP L0hgMMX3gtl+sQ2wlVxG5bB6RxTZ9Maq4Pgw28fPBNAJCfAOr7OUZ46CnGrP8LdCa8f4 RzGoHBobF1L2zYtaOlK7gakfwRDUwtW2yGq/8pcR6oWZgiCJkKQkGssVeFtwnw2BBMTK 6DHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:cc:to:subject:from; bh=ufp3lFks5e6BCen6b9UjbkCjuYiIU0QqPFmdvWacJEU=; b=ccvlMuICgVprYeJGxjPapGSgaDtIdZ/NuEcn/tw1eA0Tq0EUnRMrAwu+7at7rSuA18 3qeZo9kB13WFHofP8ZJD4fzSLkXk2lrZMcuAMfG+RMj/tuhPhUZQfzQpSvKZdt3FevIb 9Bfz3n/u7vM/0cXouuWsqpe/s8WK1e4/QIzB1eOLEE1qc2i60jHxOsJTboqaMG+fVAE9 NlJhPJRPZAyeY5+EnXnnI70mZNZu5YoPU9oTlyqk/xHEmz5dvCb4Fo6A60ZoYygMA7aZ PLY8lnWbVGyzvcun/VKWgUHbHEfGuDiSYV8HwYcyxNeWNU8a82iVwxIUnb7k9xzoGvFC qCYQ== ARC-Authentication-Results: i=1; mx.google.com; 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 w65si8139759oif.134.2020.03.03.00.24.14; Tue, 03 Mar 2020 00:24:26 -0800 (PST) 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; 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 S1727774AbgCCIWz (ORCPT + 99 others); Tue, 3 Mar 2020 03:22:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:55336 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbgCCIWz (ORCPT ); Tue, 3 Mar 2020 03:22:55 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6472FBA48; Tue, 3 Mar 2020 08:22:53 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 81F7FE1F46; Tue, 3 Mar 2020 09:22:52 +0100 (CET) From: Michal Kubecek Subject: [PATCH net] tun: fix ethtool_ops get_msglvl and set_msglvl handlers To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Message-Id: <20200303082252.81F7FE1F46@unicorn.suse.cz> Date: Tue, 3 Mar 2020 09:22:52 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The get_msglvl and setmsglvl handlers only work as expected if TUN_DEBUG is defined (which required editing the source). Otherwise tun_get_msglvl() returns -EOPNOTSUPP but as this handler is not supposed to return error code, it is not recognized as one and passed to userspace as is, resulting in bogus output of ethtool command. The set_msglvl handler ignores its argument and does nothing if TUN_DEBUG is left undefined. The way to return EOPNOTSUPP to userspace for both requests is not to provide these ethtool_ops callbacks at all if TUN_DEBUG is left undefined. Signed-off-by: Michal Kubecek --- drivers/net/tun.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 650c937ed56b..0aae2d208398 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -3557,23 +3557,21 @@ static void tun_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info } } +#ifdef TUN_DEBUG static u32 tun_get_msglevel(struct net_device *dev) { -#ifdef TUN_DEBUG struct tun_struct *tun = netdev_priv(dev); + return tun->debug; -#else - return -EOPNOTSUPP; -#endif } static void tun_set_msglevel(struct net_device *dev, u32 value) { -#ifdef TUN_DEBUG struct tun_struct *tun = netdev_priv(dev); + tun->debug = value; -#endif } +#endif /* TUN_DEBUG */ static int tun_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) @@ -3600,8 +3598,10 @@ static int tun_set_coalesce(struct net_device *dev, static const struct ethtool_ops tun_ethtool_ops = { .get_drvinfo = tun_get_drvinfo, +#ifdef TUN_DEBUG .get_msglevel = tun_get_msglevel, .set_msglevel = tun_set_msglevel, +#endif .get_link = ethtool_op_get_link, .get_ts_info = ethtool_op_get_ts_info, .get_coalesce = tun_get_coalesce, -- 2.25.1