ethtool: Fix filter addition when caching n-tuple filters
Subsystems (2)
PATCH 1/3 ethtool: Fix filter addition when caching n-tuple filters
From: Peter Waskiewicz <[email protected]>
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.
---
net/core/ethtool.c | 40 ++++++++++++++++++++++++---------------- 1 files changed, 24 insertions(+), 16 deletions(-)
net/core/ethtool.c +24 -16
@@ -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; }
PATCH 2/3 ethtool: Move n-tuple capability check into set_flags
From: Peter Waskiewicz <[email protected]>
set_flags should check if the underlying device supports n-tuple filter programming before setting the device flags on the netdevice.
---
net/core/ethtool.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
net/core/ethtool.c +8 -5
@@ -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 Ð_FLAG_LRO ) dev->features |=NETIF_F_LRO ;else dev->features &= ~NETIF_F_LRO ; -if (data Ð_FLAG_NTUPLE ) +if (data Ð_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 ;
Re: [net-next-2.6 PATCH 2/3] ethtool: Move n-tuple capability check into set_flags
From: Jeff Kirsher <[email protected]>
Date: Fri, 12 Feb 2010 15:48:25 -0800
Quoted 8 lines
From: Peter Waskiewicz <[email protected]>
set_flagsshould 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 <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 3/3 ixgbe: Cleanup incorrect header comments
In reply to Jeff KirsherFrom: Peter Waskiewicz <[email protected]>
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.
---
drivers/net/ixgbe/ixgbe_82599.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_82599.c +0 -5
@@ -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) {
Re: [net-next-2.6 PATCH 3/3] ixgbe: Cleanup incorrect header comments
From: Jeff Kirsher <[email protected]>
Date: Fri, 12 Feb 2010 15:48:44 -0800
Quoted 8 lines
From: Peter Waskiewicz <[email protected]>
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 <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
From: Jeff Kirsher <[email protected]>
Date: Fri, 12 Feb 2010 15:48:05 -0800
Quoted 8 lines
From: Peter Waskiewicz <[email protected]>
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 <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.