Skip to content

Commit fb82fd2

Browse files
antonblancharddavem330
authored andcommitted
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: Anton Blanchard <anton@samba.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 91aae1e commit fb82fd2

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

‎drivers/net/ibmveth.c‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
757757
struct ibmveth_adapter *adapter = netdev_priv(dev);
758758
unsigned long set_attr, clr_attr, ret_attr;
759759
unsigned long set_attr6, clr_attr6;
760-
long ret, ret6;
760+
long ret, ret4, ret6;
761761
int rc1 = 0, rc2 = 0;
762762
int restart = 0;
763763

@@ -770,6 +770,8 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
770770

771771
set_attr = 0;
772772
clr_attr = 0;
773+
set_attr6 = 0;
774+
clr_attr6 = 0;
773775

774776
if (data) {
775777
set_attr = IBMVETH_ILLAN_IPV4_TCP_CSUM;
@@ -784,16 +786,20 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
784786
if (ret == H_SUCCESS && !(ret_attr & IBMVETH_ILLAN_ACTIVE_TRUNK) &&
785787
!(ret_attr & IBMVETH_ILLAN_TRUNK_PRI_MASK) &&
786788
(ret_attr & IBMVETH_ILLAN_PADDED_PKT_CSUM)) {
787-
ret = h_illan_attributes(adapter->vdev->unit_address, clr_attr,
789+
ret4 = h_illan_attributes(adapter->vdev->unit_address, clr_attr,
788790
set_attr, &ret_attr);
789791

790-
if (ret != H_SUCCESS) {
792+
if (ret4 != H_SUCCESS) {
791793
netdev_err(dev, "unable to change IPv4 checksum "
792794
"offload settings. %d rc=%ld\n",
793-
data, ret);
795+
data, ret4);
796+
797+
h_illan_attributes(adapter->vdev->unit_address,
798+
set_attr, clr_attr, &ret_attr);
799+
800+
if (data == 1)
801+
dev->features &= ~NETIF_F_IP_CSUM;
794802

795-
ret = h_illan_attributes(adapter->vdev->unit_address,
796-
set_attr, clr_attr, &ret_attr);
797803
} else {
798804
adapter->fw_ipv4_csum_support = data;
799805
}
@@ -804,15 +810,18 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data)
804810
if (ret6 != H_SUCCESS) {
805811
netdev_err(dev, "unable to change IPv6 checksum "
806812
"offload settings. %d rc=%ld\n",
807-
data, ret);
813+
data, ret6);
814+
815+
h_illan_attributes(adapter->vdev->unit_address,
816+
set_attr6, clr_attr6, &ret_attr);
817+
818+
if (data == 1)
819+
dev->features &= ~NETIF_F_IPV6_CSUM;
808820

809-
ret = h_illan_attributes(adapter->vdev->unit_address,
810-
set_attr6, clr_attr6,
811-
&ret_attr);
812821
} else
813822
adapter->fw_ipv6_csum_support = data;
814823

815-
if (ret == H_SUCCESS || ret6 == H_SUCCESS)
824+
if (ret4 == H_SUCCESS || ret6 == H_SUCCESS)
816825
adapter->rx_csum = data;
817826
else
818827
rc1 = -EIO;

0 commit comments

Comments
 (0)