提交 be8b678c 编写于 作者: S Simon Horman 提交者: David S. Miller

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

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.
Signed-off-by: NSimon Horman <horms@verge.net.au>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 25b6e148
...@@ -1584,9 +1584,8 @@ static void deferred_unmap_destructor(struct sk_buff *skb) ...@@ -1584,9 +1584,8 @@ static void deferred_unmap_destructor(struct sk_buff *skb)
p = dui->addr; p = dui->addr;
if (skb->tail - skb->transport_header) if (skb->tail - skb->transport_header)
pci_unmap_single(dui->pdev, *p++, pci_unmap_single(dui->pdev, *p++, skb_tail_pointer(skb) -
skb->tail - skb->transport_header, skb_transport_header(skb), PCI_DMA_TODEVICE);
PCI_DMA_TODEVICE);
si = skb_shinfo(skb); si = skb_shinfo(skb);
for (i = 0; i < si->nr_frags; i++) for (i = 0; i < si->nr_frags; i++)
...@@ -1647,8 +1646,8 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb, ...@@ -1647,8 +1646,8 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
flits = skb_transport_offset(skb) / 8; flits = skb_transport_offset(skb) / 8;
sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl; sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
sgl_flits = write_sgl(skb, sgp, skb_transport_header(skb), sgl_flits = write_sgl(skb, sgp, skb_transport_header(skb),
skb->tail - skb->transport_header, skb_tail_pointer(skb) -
addr); skb_transport_header(skb), addr);
if (need_skb_unmap()) { if (need_skb_unmap()) {
setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits); setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
skb->destructor = deferred_unmap_destructor; skb->destructor = deferred_unmap_destructor;
...@@ -1674,7 +1673,7 @@ static inline unsigned int calc_tx_descs_ofld(const struct sk_buff *skb) ...@@ -1674,7 +1673,7 @@ static inline unsigned int calc_tx_descs_ofld(const struct sk_buff *skb)
flits = skb_transport_offset(skb) / 8; /* headers */ flits = skb_transport_offset(skb) / 8; /* headers */
cnt = skb_shinfo(skb)->nr_frags; cnt = skb_shinfo(skb)->nr_frags;
if (skb->tail != skb->transport_header) if (skb_tail_pointer(skb) != skb_transport_header(skb))
cnt++; cnt++;
return flits_to_desc(flits + sgl_len(cnt)); return flits_to_desc(flits + sgl_len(cnt));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册