netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters
@ 2010-02-12 23:48 Jeff Kirsher
  2010-02-12 23:48 ` [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags Jeff Kirsher
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jeff Kirsher @ 2010-02-12 23:48 UTC (permalink / raw)
  To: davem; +Cc: netdev, gospo, Peter P Waskiewicz Jr, Jeff Kirsher

From: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>

We can allow a filter to be added successfully to the underlying
hardware, but still return an error if the cached list memory
allocation fails.  This patch fixes that condition.

Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 net/core/ethtool.c |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index a1280f6..fbbe4b4 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -283,18 +283,17 @@ err_out:
 	return ret;
 }
 
-static int __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
-                                  struct ethtool_rx_ntuple_flow_spec *spec)
+static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
+                              struct ethtool_rx_ntuple_flow_spec *spec,
+                              struct ethtool_rx_ntuple_flow_spec_container *fsc)
 {
-	struct ethtool_rx_ntuple_flow_spec_container *fsc;
 
 	/* don't add filters forever */
-	if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY)
-		return 0;
-
-	fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC);
-	if (!fsc)
-		return -ENOMEM;
+	if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY) {
+		/* free the container */
+		kfree(fsc);
+		return;
+	}
 
 	/* Copy the whole filter over */
 	fsc->fs.flow_type = spec->flow_type;
@@ -310,14 +309,13 @@ static int __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
 	/* add to the list */
 	list_add_tail_rcu(&fsc->list, &list->list);
 	list->count++;
-
-	return 0;
 }
 
 static int ethtool_set_rx_ntuple(struct net_device *dev, void __user *useraddr)
 {
 	struct ethtool_rx_ntuple cmd;
 	const struct ethtool_ops *ops = dev->ethtool_ops;
+	struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL;
 	int ret;
 
 	if (!ops->set_rx_ntuple)
@@ -329,16 +327,26 @@ static int ethtool_set_rx_ntuple(struct net_device *dev, void __user *useraddr)
 	if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
 		return -EFAULT;
 
-	ret = ops->set_rx_ntuple(dev, &cmd);
-
 	/*
 	 * Cache filter in dev struct for GET operation only if
 	 * the underlying driver doesn't have its own GET operation, and
-	 * only if the filter was added successfully.
+	 * only if the filter was added successfully.  First make sure we
+	 * can allocate the filter, then continue if successful.
 	 */
-	if (!ops->get_rx_ntuple && !ret)
-		if (__rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs))
+	if (!ops->get_rx_ntuple) {
+		fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC);
+		if (!fsc)
 			return -ENOMEM;
+	}
+
+	ret = ops->set_rx_ntuple(dev, &cmd);
+	if (ret) {
+		kfree(fsc);
+		return ret;
+	}
+
+	if (!ops->get_rx_ntuple)
+		__rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs, fsc);
 
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags
  2010-02-12 23:48 [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters Jeff Kirsher
@ 2010-02-12 23:48 ` Jeff Kirsher
  2010-02-16  5:52   ` David Miller
  2010-02-12 23:48 ` [net-next-2.6 PATCH 3/3] ixgbe: Cleanup incorrect header comments Jeff Kirsher
  2010-02-16  5:52 ` [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Jeff Kirsher @ 2010-02-12 23:48 UTC (permalink / raw)
  To: davem; +Cc: netdev, gospo, Peter P Waskiewicz Jr, Jeff Kirsher

From: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>

set_flags should check if the underlying device supports
n-tuple filter programming before setting the device flags
on the netdevice.

Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 net/core/ethtool.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index fbbe4b4..794cf57 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -134,15 +134,21 @@ u32 ethtool_op_get_flags(struct net_device *dev)
 
 int ethtool_op_set_flags(struct net_device *dev, u32 data)
 {
+	const struct ethtool_ops *ops = dev->ethtool_ops;
+
 	if (data & ETH_FLAG_LRO)
 		dev->features |= NETIF_F_LRO;
 	else
 		dev->features &= ~NETIF_F_LRO;
 
-	if (data & ETH_FLAG_NTUPLE)
+	if (data & ETH_FLAG_NTUPLE) {
+		if (!ops->set_rx_ntuple)
+			return -EOPNOTSUPP;
 		dev->features |= NETIF_F_NTUPLE;
-	else
+	} else {
+		/* safe to clear regardless */
 		dev->features &= ~NETIF_F_NTUPLE;
+	}
 
 	return 0;
 }
@@ -318,9 +324,6 @@ static int ethtool_set_rx_ntuple(struct net_device *dev, void __user *useraddr)
 	struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL;
 	int ret;
 
-	if (!ops->set_rx_ntuple)
-		return -EOPNOTSUPP;
-
 	if (!(dev->features & NETIF_F_NTUPLE))
 		return -EINVAL;
 


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net-next-2.6 PATCH 3/3] ixgbe: Cleanup incorrect header comments
  2010-02-12 23:48 [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters Jeff Kirsher
  2010-02-12 23:48 ` [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags Jeff Kirsher
@ 2010-02-12 23:48 ` Jeff Kirsher
  2010-02-16  5:52   ` David Miller
  2010-02-16  5:52 ` [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Jeff Kirsher @ 2010-02-12 23:48 UTC (permalink / raw)
  To: davem; +Cc: netdev, gospo, Peter P Waskiewicz Jr, Jeff Kirsher

From: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>

The recent n-tuple patches added some comments to the headers
of the Flow Director functions that aren't accurate.  This
cleans them up, and is a purely cosmetic patch.

Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 drivers/net/ixgbe/ixgbe_82599.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 4fa8633..1f30e16 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -1631,7 +1631,6 @@ static u16 ixgbe_atr_compute_hash_82599(struct ixgbe_atr_input *atr_input,
  *  ixgbe_atr_set_vlan_id_82599 - Sets the VLAN id in the ATR input stream
  *  @input: input stream to modify
  *  @vlan: the VLAN id to load
- *  @vlan_mask: bitwise mask for the VLAN
  **/
 s32 ixgbe_atr_set_vlan_id_82599(struct ixgbe_atr_input *input, u16 vlan)
 {
@@ -1645,7 +1644,6 @@ s32 ixgbe_atr_set_vlan_id_82599(struct ixgbe_atr_input *input, u16 vlan)
  *  ixgbe_atr_set_src_ipv4_82599 - Sets the source IPv4 address
  *  @input: input stream to modify
  *  @src_addr: the IP address to load
- *  @src_addr_mask: bitwise mask for the source IP address
  **/
 s32 ixgbe_atr_set_src_ipv4_82599(struct ixgbe_atr_input *input, u32 src_addr)
 {
@@ -1663,7 +1661,6 @@ s32 ixgbe_atr_set_src_ipv4_82599(struct ixgbe_atr_input *input, u32 src_addr)
  *  ixgbe_atr_set_dst_ipv4_82599 - Sets the destination IPv4 address
  *  @input: input stream to modify
  *  @dst_addr: the IP address to load
- *  @dst_addr_mask: bitwise mask for the destination IP address
  **/
 s32 ixgbe_atr_set_dst_ipv4_82599(struct ixgbe_atr_input *input, u32 dst_addr)
 {
@@ -1767,7 +1764,6 @@ s32 ixgbe_atr_set_dst_ipv6_82599(struct ixgbe_atr_input *input,
  *  ixgbe_atr_set_src_port_82599 - Sets the source port
  *  @input: input stream to modify
  *  @src_port: the source port to load
- *  @src_port_mask: bitwise mask for the source port
  **/
 s32 ixgbe_atr_set_src_port_82599(struct ixgbe_atr_input *input, u16 src_port)
 {
@@ -1781,7 +1777,6 @@ s32 ixgbe_atr_set_src_port_82599(struct ixgbe_atr_input *input, u16 src_port)
  *  ixgbe_atr_set_dst_port_82599 - Sets the destination port
  *  @input: input stream to modify
  *  @dst_port: the destination port to load
- *  @dst_port_mask: bitwise mask for the destination port
  **/
 s32 ixgbe_atr_set_dst_port_82599(struct ixgbe_atr_input *input, u16 dst_port)
 {


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters
  2010-02-12 23:48 [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters Jeff Kirsher
  2010-02-12 23:48 ` [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags Jeff Kirsher
  2010-02-12 23:48 ` [net-next-2.6 PATCH 3/3] ixgbe: Cleanup incorrect header comments Jeff Kirsher
@ 2010-02-16  5:52 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2010-02-16  5:52 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, gospo, peter.p.waskiewicz.jr

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Fri, 12 Feb 2010 15:48:05 -0800

> From: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>
> 
> We can allow a filter to be added successfully to the underlying
> hardware, but still return an error if the cached list memory
> allocation fails.  This patch fixes that condition.
> 
> Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags
  2010-02-12 23:48 ` [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags Jeff Kirsher
@ 2010-02-16  5:52   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2010-02-16  5:52 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, gospo, peter.p.waskiewicz.jr

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Fri, 12 Feb 2010 15:48:25 -0800

> From: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>
> 
> set_flags should check if the underlying device supports
> n-tuple filter programming before setting the device flags
> on the netdevice.
> 
> Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next-2.6 PATCH 3/3] ixgbe: Cleanup incorrect header comments
  2010-02-12 23:48 ` [net-next-2.6 PATCH 3/3] ixgbe: Cleanup incorrect header comments Jeff Kirsher
@ 2010-02-16  5:52   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2010-02-16  5:52 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, gospo, peter.p.waskiewicz.jr

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Fri, 12 Feb 2010 15:48:44 -0800

> From: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>
> 
> The recent n-tuple patches added some comments to the headers
> of the Flow Director functions that aren't accurate.  This
> cleans them up, and is a purely cosmetic patch.
> 
> Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-16  5:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-12 23:48 [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters Jeff Kirsher
2010-02-12 23:48 ` [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags Jeff Kirsher
2010-02-16  5:52   ` David Miller
2010-02-12 23:48 ` [net-next-2.6 PATCH 3/3] ixgbe: Cleanup incorrect header comments Jeff Kirsher
2010-02-16  5:52   ` David Miller
2010-02-16  5:52 ` [net-next-2.6 PATCH 1/3] ethtool: Fix filter addition when caching n-tuple filters David Miller

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).