aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2011-09-06 09:52:47 -0400
committerDavid S. Miller <davem@davemloft.net>2011-09-16 19:25:10 -0400
commit473e64ee4603671efa1e0785418e56e9ffdfc47b (patch)
treeff40ee34b7ac14c920993bb655527338419dea63
parent815c7db5c809ea3d5735de3131ecdf758b0e14ff (diff)
ethtool: Update ethtool_rxnfc::rule_cnt on return from ETHTOOL_GRXCLSRLALL
A user-space process must use ETHTOOL_GRXCLSRLCNT to find the number of classification rules, then allocate a buffer of the right size, then use ETHTOOL_GRXCLSRLALL to fill the buffer. If some other process inserts or deletes a rule between those two operations, the user buffer might turn out to be the wrong size. If it's too small, the return value will be -EMSGSIZE. But if it's too large, there is no indication of this. Fix this by updating the rule_cnt field on return. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ethtool.c1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c2
-rw-r--r--drivers/net/ethernet/sun/niu.c2
-rw-r--r--include/linux/ethtool.h6
4 files changed, 8 insertions, 3 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 42238301c425..f30b96fee840 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -1676,6 +1676,7 @@ static int gfar_get_cls_all(struct gfar_private *priv,
1676 } 1676 }
1677 1677
1678 cmd->data = MAX_FILER_IDX; 1678 cmd->data = MAX_FILER_IDX;
1679 cmd->rule_cnt = i;
1679 1680
1680 return 0; 1681 return 0;
1681} 1682}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index c0003babc06b..b8410bcaa898 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -2283,6 +2283,8 @@ static int ixgbe_get_ethtool_fdir_all(struct ixgbe_adapter *adapter,
2283 cnt++; 2283 cnt++;
2284 } 2284 }
2285 2285
2286 cmd->rule_cnt = cnt;
2287
2286 return 0; 2288 return 0;
2287} 2289}
2288 2290
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 5e1e1d2748ae..d1338885dc8b 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -7299,6 +7299,8 @@ static int niu_get_ethtool_tcam_all(struct niu *np,
7299 } 7299 }
7300 niu_unlock_parent(np, flags); 7300 niu_unlock_parent(np, flags);
7301 7301
7302 nfc->rule_cnt = cnt;
7303
7302 return ret; 7304 return ret;
7303} 7305}
7304 7306
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 5d4a06accd82..45f00b61c096 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -496,9 +496,9 @@ struct ethtool_rx_flow_spec {
496 * 496 *
497 * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the 497 * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
498 * user buffer for @rule_locs on entry. On return, @data is the size 498 * user buffer for @rule_locs on entry. On return, @data is the size
499 * of the rule table and @rule_locs contains the locations of the 499 * of the rule table, @rule_cnt is the number of defined rules, and
500 * defined rules. Drivers must use the second parameter to get_rxnfc() 500 * @rule_locs contains the locations of the defined rules. Drivers
501 * instead of @rule_locs. 501 * must use the second parameter to get_rxnfc() instead of @rule_locs.
502 * 502 *
503 * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update. 503 * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update.
504 * @fs.@location specifies the location to use and must not be ignored. 504 * @fs.@location specifies the location to use and must not be ignored.