netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Jacob Keller <jacob.e.keller@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 10/17] fm10k: fix documentation of fm10k_tlv_parse_attr
Date: Wed, 20 Apr 2016 23:09:22 -0700	[thread overview]
Message-ID: <1461218969-68578-11-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1461218969-68578-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>

fm10k_tlv_parse_attr is supposed to return FM10K_NOT_IMPLEMENTED for any
TLV who's attribute id lies outside the range of results. It does not do
this today. In addition, the documentation does not indicate that other
attributes which are not implemented for a given TLV will be silently
ignored. Fix this. Clean up the logic so that we don't rely on the fact
that FM10K_NOT_IMPLEMENTED is greater than zero, as this can easily
cause confusion.

A future extension could look into some way of reporting unknown TLVs
in order to make issues more easily discoverable. We can't just return
FM10K_NOT_IMPLEMENTED here because we don't want to drop the entire
message if it has an unknown TLV.

While here, update the copyright year.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_tlv.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c b/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
index b999897..6b500a63 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
@@ -1,5 +1,5 @@
 /* Intel Ethernet Switch Host Interface Driver
- * Copyright(c) 2013 - 2015 Intel Corporation.
+ * Copyright(c) 2013 - 2016 Intel Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -481,7 +481,8 @@ static s32 fm10k_tlv_attr_validate(u32 *attr,
  *  up into an array of pointers stored in results.  The function will
  *  return FM10K_ERR_PARAM on any input or message error,
  *  FM10K_NOT_IMPLEMENTED for any attribute that is outside of the array
- *  and 0 on success.
+ *  and 0 on success. Any attributes not found in tlv_attr will be silently
+ *  ignored.
  **/
 static s32 fm10k_tlv_attr_parse(u32 *attr, u32 **results,
 				const struct fm10k_tlv_attr *tlv_attr)
@@ -518,14 +519,15 @@ static s32 fm10k_tlv_attr_parse(u32 *attr, u32 **results,
 	while (offset < len) {
 		attr_id = *attr & FM10K_TLV_ID_MASK;
 
-		if (attr_id < FM10K_TLV_RESULTS_MAX)
-			err = fm10k_tlv_attr_validate(attr, tlv_attr);
-		else
-			err = FM10K_NOT_IMPLEMENTED;
+		if (attr_id >= FM10K_TLV_RESULTS_MAX)
+			return FM10K_NOT_IMPLEMENTED;
 
-		if (err < 0)
+		err = fm10k_tlv_attr_validate(attr, tlv_attr);
+		if (err == FM10K_NOT_IMPLEMENTED)
+			; /* silently ignore non-implemented attributes */
+		else if (err)
 			return err;
-		if (!err)
+		else
 			results[attr_id] = attr;
 
 		/* update offset */
-- 
2.5.5

  parent reply	other threads:[~2016-04-21  6:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21  6:09 [net-next 00/17][pull request] 100GbE Intel Wired LAN Driver Updates 2016-04-20 Jeff Kirsher
2016-04-21  6:09 ` [net-next 01/17] fm10k: add helper functions to set strings and data for ethtool stats Jeff Kirsher
2016-04-21  6:09 ` [net-next 02/17] fm10k: remove debug-statistics support Jeff Kirsher
2016-04-21  6:09 ` [net-next 03/17] fm10k: Add support for bulk Tx cleanup & cleanup boolean logic Jeff Kirsher
2016-04-21  6:09 ` [net-next 04/17] fm10k: use DRV_SUMMARY to reduce code duplication Jeff Kirsher
2016-04-21  6:09 ` [net-next 05/17] fm10k: prevent RCU issues during AER events Jeff Kirsher
2016-04-21  6:09 ` [net-next 06/17] fm10k: drop 1588 support Jeff Kirsher
2016-04-21  6:09 ` [net-next 07/17] fm10k: Fix multicast mode sync issues Jeff Kirsher
2016-04-21  6:09 ` [net-next 08/17] fm10k: correctly handle LPORT_MAP error Jeff Kirsher
2016-04-21  6:09 ` [net-next 09/17] fm10k: do not disable PCI device in fm10k_io_error_detected Jeff Kirsher
2016-04-21  6:09 ` Jeff Kirsher [this message]
2016-04-21  6:09 ` [net-next 11/17] fm10k: use 8bit notation instead of 10bit notation for diagram Jeff Kirsher
2016-04-21  6:09 ` [net-next 12/17] fm10k: use different name than FM10K_VLAN_CLEAR for override bit Jeff Kirsher
2016-04-21  6:09 ` [net-next 13/17] fm10k: update comment regarding reserved bits check Jeff Kirsher
2016-04-21  6:09 ` [net-next 14/17] fm10k: Reset multicast mode when deleting lport Jeff Kirsher
2016-04-21  6:09 ` [net-next 15/17] fm10k: fix possible null pointer deref after kcalloc Jeff Kirsher
2016-04-21 19:44   ` Keller, Jacob E
2016-04-21 19:47     ` David Miller
2016-04-21 19:48       ` Jeff Kirsher
2016-04-21 20:09         ` Keller, Jacob E
2016-04-21  6:09 ` [net-next 16/17] fm10k: consistently use Intel(R) for driver names Jeff Kirsher
2016-04-21  6:09 ` [net-next 17/17] fm10k: fix incorrect IPv6 extended header checksum Jeff Kirsher
2016-04-21 16:21 ` [net-next 00/17][pull request] 100GbE Intel Wired LAN Driver Updates 2016-04-20 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461218969-68578-11-git-send-email-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=jacob.e.keller@intel.com \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).