Skip to contentSkip to conversation

cxgb3: Correct comparisons and calculations using skb->tail and skb-transport_header

PATCH Applied [email protected] 3 participants 3 messages Jun 4, 2013 – Jun 5, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxgb3: Correct comparisons and calculations using skb->tail and skb-transport_header

From: Li RongQing <[email protected]>

This corrects an regression introduced by "net: Use 16bits for *_headers fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In that case skb->tail will be a pointer whereas skb->transport_header will be an offset from head. This is corrected by using wrappers that ensure that comparisons and calculations are always made using pointers.

---
 drivers/net/ethernet/chelsio/cxgb3/sge.c |    2 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb3/sge.c +1 -1
index 46d1efc..687ec4a 100644
@@ -1583,7 +1583,7 @@ static void deferred_unmap_destructor(struct sk_buff *skb)
 	dui = (struct deferred_unmap_info *)skb->head;
 	p = dui->addr;
 
-	if (skb->tail - skb->transport_header)
+	if (skb_tail_pointer(skb) - skb_transport_header(skb))
 		pci_unmap_single(dui->pdev, *p++, skb_tail_pointer(skb) -
 				 skb_transport_header(skb), PCI_DMA_TODEVICE);
 
drivers/net/ethernet/chelsio/cxgb4/sge.c +1 -1
index 2bfbb20..ac311f5 100644
@@ -1294,7 +1294,7 @@ static inline unsigned int calc_tx_flits_ofld(const struct sk_buff *skb)
 
 	flits = skb_transport_offset(skb) / 8U;   /* headers */
 	cnt = skb_shinfo(skb)->nr_frags;
-	if (skb->tail != skb->transport_header)
+	if (skb_tail_pointer(skb) != skb_transport_header(skb))
 		cnt++;
 	return flits + sgl_len(cnt);
 }
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Tue, Jun 04, 2013 at 04:11:16PM +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

This corrects an regression introduced by "net: Use 16bits for *_headers fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In that case skb->tail will be a pointer whereas skb->transport_header will be an offset from head. This is corrected by using wrappers that ensure that comparisons and calculations are always made using pointers.

Quoted 39 lines
---
 drivers/net/ethernet/chelsio/cxgb3/sge.c |    2 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb3/sge.c +1 -1
index 46d1efc..687ec4a 100644
@@ -1583,7 +1583,7 @@ static void deferred_unmap_destructor(struct sk_buff *skb)
 	dui = (struct deferred_unmap_info *)skb->head;
 	p = dui->addr;
 
-	if (skb->tail - skb->transport_header)
+	if (skb_tail_pointer(skb) - skb_transport_header(skb))
 		pci_unmap_single(dui->pdev, *p++, skb_tail_pointer(skb) -
 				 skb_transport_header(skb), PCI_DMA_TODEVICE);
 
drivers/net/ethernet/chelsio/cxgb4/sge.c +1 -1
index 2bfbb20..ac311f5 100644
@@ -1294,7 +1294,7 @@ static inline unsigned int calc_tx_flits_ofld(const struct sk_buff *skb)
 
 	flits = skb_transport_offset(skb) / 8U;   /* headers */
 	cnt = skb_shinfo(skb)->nr_frags;
-	if (skb->tail != skb->transport_header)
+	if (skb_tail_pointer(skb) != skb_transport_header(skb))
 		cnt++;
 	return flits + sgl_len(cnt);
 }
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer Applied
#2 lore raw

From: Simon Horman <[email protected]>
Date: Tue, 4 Jun 2013 22:23:53 +0900

Quoted 9 lines · On Tue, Jun 04, 2013 at 04:11:16PM +0800, [email protected] wrote:
Quoted 8 lines

From: Li RongQing <[email protected]>

This corrects an regression introduced by "net: Use 16bits for *_headers fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In that case skb->tail will be a pointer whereas skb->transport_header will be an offset from head. This is corrected by using wrappers that ensure that comparisons and calculations are always made using pointers.

Quoted 4 lines
Quoted 2 lines

Applied.