Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2531390ybe; Tue, 3 Sep 2019 14:28:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMLPV3gc5us7hd4ey5OwMUIi8SuZ37IjltEL1juWVnOeU617LsUxoufJhVHs4YZzquTVDD X-Received: by 2002:a65:4808:: with SMTP id h8mr31867807pgs.22.1567546083140; Tue, 03 Sep 2019 14:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567546083; cv=none; d=google.com; s=arc-20160816; b=jaKIo2CxY1WGcfs27aaNiiZ1uTuX2uPBic2QYELvpreOysE+ZXDwhMDRrxtDZoAy4Y LbyEjXO2hcSpTmCkyZGZDe9V8ULqH6FDdiZnCqMyrAkf3GkUCDEQwxoxuygD1Hy/N/H8 BTJKcOGXLBmIhy1d1fxFPWMxjsMPQZKUxpekX9anhzsnHBA1YFrXw3/SnXEXLwVJCs0U rR9bBKs/pjyI0a4rSBUGrXdnVQ754w9bl/kFzfwgGtcRqcMct+Lt1/YlMd8SbQlaS0Y2 7kk2XORAzrPqh8DKsdUb48UUFn3jysVzy8Is7Z4Lg30LL0K2T6w+s94bBCMmEyPdsCDO MDMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=p+tv9dgh3nJPECubHZLTAUqvfbEW3pIpvnS1qGept/o=; b=ZfwRXBmnVVsIOfyHKiLOIxJIS9adHlbscCf3p0L9YYi7/30Sc1sbjTLlDXdQsW1xpo ksmhr0INwwcfD6s0c013igjQ3XUekG7+mMRFB4ESMcH6QAtop1K1PSmRmQMCqusdenim k6K4GtE1tE5KpriLBnT3ipHB/56g+T4ytCCGtYHzRH9pz6cQAI8B7de4xs4eynH2d3hf cgdBU+ICn8hfA8g4QogvmGXUTqzL5QfOQN8DHf7edjgdH/8gGE8DRQD6tOGw1LaZxeIN OBRmau09xMd4ko0wjbwt3fdnzaEPm96AQ2+DaQvrufhxvNknpOlrk8sUh1sYtyLTKcbo JERA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q67si605649pjq.42.2019.09.03.14.27.45; Tue, 03 Sep 2019 14:28:03 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726619AbfICV0q (ORCPT + 99 others); Tue, 3 Sep 2019 17:26:46 -0400 Received: from mga01.intel.com ([192.55.52.88]:58077 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfICV0q (ORCPT ); Tue, 3 Sep 2019 17:26:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2019 14:26:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,464,1559545200"; d="scan'208";a="383234073" Received: from ellie.jf.intel.com (HELO ellie) ([10.24.13.22]) by fmsmga006.fm.intel.com with ESMTP; 03 Sep 2019 14:26:45 -0700 From: Vinicius Costa Gomes To: Vladimir Oltean , Eric Dumazet Cc: "Gustavo A. R. Silva" , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , netdev , lkml Subject: Re: [PATCH] net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte In-Reply-To: References: <20190903010817.GA13595@embeddedor> Date: Tue, 03 Sep 2019 14:26:45 -0700 Message-ID: <8736hd9ilm.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Vladimir Oltean writes: > Right. And while we're at it, there's still the potential > division-by-zero problem which I still don't know how to solve without > implementing a full-blown __ethtool_get_link_ksettings parser that > checks against all the possible outputs it can have under the "no > carrier" condition - see "[RFC PATCH 1/1] phylink: Set speed to > SPEED_UNKNOWN when there is no PHY connected" for details. > And there's also a third fix to be made: the netdev_dbg should be made > to print "speed" instead of "ecmd.base.speed". For the ksettings part I am thinking on adding something like this to ethtool.c. Do you think anything is missing (apart from the documentation)? -> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 95991e43..d37c80b 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -177,6 +177,9 @@ void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, const unsigned long *src); +u32 ethtool_link_ksettings_to_speed(const struct ethtool_link_ksettings *settings, + u32 default_speed); + /** * struct ethtool_ops - optional netdev operations * @get_drvinfo: Report driver/device information. Should only set the diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 6288e69..80e3db3 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -539,6 +539,18 @@ struct ethtool_link_usettings { } link_modes; }; +u32 ethtool_link_ksettings_to_speed(const struct ethtool_link_ksettings *settings, + u32 default_speed) +{ + if (settings->base.speed == SPEED_UNKNOWN) + return default_speed; + + if (settings->base.speed == 0) + return default_speed; + + return settings->base.speed; +} + /* Internal kernel helper to query a device ethtool_link_settings. */ int __ethtool_get_link_ksettings(struct net_device *dev, struct ethtool_link_ksettings *link_ksettings)