Commit fb82fd20 authored by Anton Blanchard's avatar Anton Blanchard Committed by David S. Miller

ibmveth: Fix checksum offload failure handling

Fix a number of issues in ibmveth_set_csum_offload:

- set_attr6 and clr_attr6 may be used uninitialised

- We store the result of the IPV4 checksum change in ret but overwrite
  it in a couple of places before checking it again later. Add ret4
  to make it obvious what we are doing.

- We weren't clearing the NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM flags
  if the enable of that hypervisor feature failed.
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 91aae1e5
...@@ -757,7 +757,7 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) ...@@ -757,7 +757,7 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
struct ibmveth_adapter *adapter = netdev_priv(dev); struct ibmveth_adapter *adapter = netdev_priv(dev);
unsigned long set_attr, clr_attr, ret_attr; unsigned long set_attr, clr_attr, ret_attr;
unsigned long set_attr6, clr_attr6; unsigned long set_attr6, clr_attr6;
long ret, ret6; long ret, ret4, ret6;
int rc1 = 0, rc2 = 0; int rc1 = 0, rc2 = 0;
int restart = 0; int restart = 0;
...@@ -770,6 +770,8 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) ...@@ -770,6 +770,8 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
set_attr = 0; set_attr = 0;
clr_attr = 0; clr_attr = 0;
set_attr6 = 0;
clr_attr6 = 0;
if (data) { if (data) {
set_attr = IBMVETH_ILLAN_IPV4_TCP_CSUM; set_attr = IBMVETH_ILLAN_IPV4_TCP_CSUM;
...@@ -784,16 +786,20 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) ...@@ -784,16 +786,20 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
if (ret == H_SUCCESS && !(ret_attr & IBMVETH_ILLAN_ACTIVE_TRUNK) && if (ret == H_SUCCESS && !(ret_attr & IBMVETH_ILLAN_ACTIVE_TRUNK) &&
!(ret_attr & IBMVETH_ILLAN_TRUNK_PRI_MASK) && !(ret_attr & IBMVETH_ILLAN_TRUNK_PRI_MASK) &&
(ret_attr & IBMVETH_ILLAN_PADDED_PKT_CSUM)) { (ret_attr & IBMVETH_ILLAN_PADDED_PKT_CSUM)) {
ret = h_illan_attributes(adapter->vdev->unit_address, clr_attr, ret4 = h_illan_attributes(adapter->vdev->unit_address, clr_attr,
set_attr, &ret_attr); set_attr, &ret_attr);
if (ret != H_SUCCESS) { if (ret4 != H_SUCCESS) {
netdev_err(dev, "unable to change IPv4 checksum " netdev_err(dev, "unable to change IPv4 checksum "
"offload settings. %d rc=%ld\n", "offload settings. %d rc=%ld\n",
data, ret); data, ret4);
h_illan_attributes(adapter->vdev->unit_address,
set_attr, clr_attr, &ret_attr);
if (data == 1)
dev->features &= ~NETIF_F_IP_CSUM;
ret = h_illan_attributes(adapter->vdev->unit_address,
set_attr, clr_attr, &ret_attr);
} else { } else {
adapter->fw_ipv4_csum_support = data; adapter->fw_ipv4_csum_support = data;
} }
...@@ -804,15 +810,18 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) ...@@ -804,15 +810,18 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
if (ret6 != H_SUCCESS) { if (ret6 != H_SUCCESS) {
netdev_err(dev, "unable to change IPv6 checksum " netdev_err(dev, "unable to change IPv6 checksum "
"offload settings. %d rc=%ld\n", "offload settings. %d rc=%ld\n",
data, ret); data, ret6);
h_illan_attributes(adapter->vdev->unit_address,
set_attr6, clr_attr6, &ret_attr);
if (data == 1)
dev->features &= ~NETIF_F_IPV6_CSUM;
ret = h_illan_attributes(adapter->vdev->unit_address,
set_attr6, clr_attr6,
&ret_attr);
} else } else
adapter->fw_ipv6_csum_support = data; adapter->fw_ipv6_csum_support = data;
if (ret == H_SUCCESS || ret6 == H_SUCCESS) if (ret4 == H_SUCCESS || ret6 == H_SUCCESS)
adapter->rx_csum = data; adapter->rx_csum = data;
else else
rc1 = -EIO; rc1 = -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment