Message ID | 20201008190538.6223-3-dwilder@us.ibm.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | ibmveth gso fix. | expand |
On Thu, Oct 8, 2020 at 3:06 PM David Wilder <dwilder@us.ibm.com> wrote: > > Ingress large send packets are identified by either: > The IBMVETH_RXQ_LRG_PKT flag in the receive buffer > or with a -1 placed in the ip header checksum. > The method used depends on firmware version. > > Signed-off-by: David Wilder <dwilder@us.ibm.com> > Reviewed-by: Thomas Falcon <tlfalcon@linux.ibm.com> > Reviewed-by: Cristobal Forno <cris.forno@ibm.com> > Reviewed-by: Pradeep Satyanarayana <pradeeps@linux.vnet.ibm.com> > --- > drivers/net/ethernet/ibm/ibmveth.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c > index 3935a7e..e357cbe 100644 > --- a/drivers/net/ethernet/ibm/ibmveth.c > +++ b/drivers/net/ethernet/ibm/ibmveth.c > @@ -1349,6 +1349,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) > int offset = ibmveth_rxq_frame_offset(adapter); > int csum_good = ibmveth_rxq_csum_good(adapter); > int lrg_pkt = ibmveth_rxq_large_packet(adapter); > + __sum16 iph_check = 0; > > skb = ibmveth_rxq_get_buffer(adapter); > > @@ -1385,7 +1386,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) > skb_put(skb, length); > skb->protocol = eth_type_trans(skb, netdev); > > - if (length > netdev->mtu + ETH_HLEN) { > + /* PHYP without PLSO support places a -1 in the ip > + * checksum for large send frames. > + */ > + if (be16_to_cpu(skb->protocol) == ETH_P_IP) { > + struct iphdr *iph = (struct iphdr *)skb->data; > + > + iph_check = iph->check; Check against truncated/bad packets.
On Sat, Oct 10, 2020 at 12:40 PM Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote: > > On Thu, Oct 8, 2020 at 3:06 PM David Wilder <dwilder@us.ibm.com> wrote: > > > > Ingress large send packets are identified by either: > > The IBMVETH_RXQ_LRG_PKT flag in the receive buffer > > or with a -1 placed in the ip header checksum. > > The method used depends on firmware version. > > > > Signed-off-by: David Wilder <dwilder@us.ibm.com> > > Reviewed-by: Thomas Falcon <tlfalcon@linux.ibm.com> > > Reviewed-by: Cristobal Forno <cris.forno@ibm.com> > > Reviewed-by: Pradeep Satyanarayana <pradeeps@linux.vnet.ibm.com> > > --- > > drivers/net/ethernet/ibm/ibmveth.c | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c > > index 3935a7e..e357cbe 100644 > > --- a/drivers/net/ethernet/ibm/ibmveth.c > > +++ b/drivers/net/ethernet/ibm/ibmveth.c > > @@ -1349,6 +1349,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) > > int offset = ibmveth_rxq_frame_offset(adapter); > > int csum_good = ibmveth_rxq_csum_good(adapter); > > int lrg_pkt = ibmveth_rxq_large_packet(adapter); > > + __sum16 iph_check = 0; > > > > skb = ibmveth_rxq_get_buffer(adapter); > > > > @@ -1385,7 +1386,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) > > skb_put(skb, length); > > skb->protocol = eth_type_trans(skb, netdev); > > > > - if (length > netdev->mtu + ETH_HLEN) { > > + /* PHYP without PLSO support places a -1 in the ip > > + * checksum for large send frames. > > + */ > > + if (be16_to_cpu(skb->protocol) == ETH_P_IP) { > > + struct iphdr *iph = (struct iphdr *)skb->data; > > + > > + iph_check = iph->check; > > Check against truncated/bad packets. .. unless I missed context. Other code in this driver seems to peek in the network and transport layer headers without additional geometry and integrity checks, too.
On Sat, 10 Oct 2020 12:51:30 -0400 Willem de Bruijn wrote: > > > @@ -1385,7 +1386,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) > > > skb_put(skb, length); > > > skb->protocol = eth_type_trans(skb, netdev); > > > > > > - if (length > netdev->mtu + ETH_HLEN) { > > > + /* PHYP without PLSO support places a -1 in the ip > > > + * checksum for large send frames. > > > + */ > > > + if (be16_to_cpu(skb->protocol) == ETH_P_IP) { You can byteswap the constant, so its done at compilation time. > > > + struct iphdr *iph = (struct iphdr *)skb->data; > > > + > > > + iph_check = iph->check; > > > > Check against truncated/bad packets. > > .. unless I missed context. Other code in this driver seems to peek in > the network and transport layer headers without additional geometry > and integrity checks, too. Good catch, even if we trust the hypervisor to only forward valid frames this needs to be at least mentioned in the commit message. Also please add Fixes tags to both patches.
On 2020-10-11 11:31, Jakub Kicinski wrote: > On Sat, 10 Oct 2020 12:51:30 -0400 Willem de Bruijn wrote: >> > > @@ -1385,7 +1386,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) >> > > skb_put(skb, length); >> > > skb->protocol = eth_type_trans(skb, netdev); >> > > >> > > - if (length > netdev->mtu + ETH_HLEN) { >> > > + /* PHYP without PLSO support places a -1 in the ip >> > > + * checksum for large send frames. >> > > + */ >> > > + if (be16_to_cpu(skb->protocol) == ETH_P_IP) { > > You can byteswap the constant, so its done at compilation time. Thanks for the comments. For V2 of patch I will change above to BE16_TO_CPU() > >> > > + struct iphdr *iph = (struct iphdr *)skb->data; >> > > + >> > > + iph_check = iph->check; >> > >> > Check against truncated/bad packets. >> >> .. unless I missed context. Other code in this driver seems to peek in >> the network and transport layer headers without additional geometry >> and integrity checks, too. > > Good catch, even if we trust the hypervisor to only forward valid > frames this needs to be at least mentioned in the commit message. > > Also please add Fixes tags to both patches. For V2: ( posting soon ) -Will add Fix tags -update commit message re: validity of frames from Hypervisor. -switch be16_to_cpu() to BE16_TO_CPU(). Thanks
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 3935a7e..e357cbe 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -1349,6 +1349,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) int offset = ibmveth_rxq_frame_offset(adapter); int csum_good = ibmveth_rxq_csum_good(adapter); int lrg_pkt = ibmveth_rxq_large_packet(adapter); + __sum16 iph_check = 0; skb = ibmveth_rxq_get_buffer(adapter); @@ -1385,7 +1386,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) skb_put(skb, length); skb->protocol = eth_type_trans(skb, netdev); - if (length > netdev->mtu + ETH_HLEN) { + /* PHYP without PLSO support places a -1 in the ip + * checksum for large send frames. + */ + if (be16_to_cpu(skb->protocol) == ETH_P_IP) { + struct iphdr *iph = (struct iphdr *)skb->data; + + iph_check = iph->check; + } + + if ((length > netdev->mtu + ETH_HLEN) || + lrg_pkt || iph_check == 0xffff) { ibmveth_rx_mss_helper(skb, mss, lrg_pkt); adapter->rx_large_packets++; }