mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-06 03:06:50 -04:00
net: ravb: Simplify types in RX csum validation
The hardware checksum value is used as a 16-bit flag, it is zero when the checksum has been validated and non-zero otherwise. Therefore we don't need to treat this as an actual __wsum type or call csum_unfold(), we can just use a u16 pointer. Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
This commit is contained in:
@@ -749,11 +749,11 @@ static void ravb_get_tx_tstamp(struct net_device *ndev)
|
||||
static void ravb_rx_csum_gbeth(struct sk_buff *skb)
|
||||
{
|
||||
struct skb_shared_info *shinfo = skb_shinfo(skb);
|
||||
__wsum csum_proto;
|
||||
u8 *hw_csum;
|
||||
size_t csum_len;
|
||||
u16 *hw_csum;
|
||||
|
||||
/* The hardware checksum status is contained in sizeof(__sum16) * 2 = 4
|
||||
* bytes appended to packet data.
|
||||
/* The hardware checksum status is contained in 4 bytes appended to
|
||||
* packet data.
|
||||
*
|
||||
* For ipv4, the first 2 bytes are the ip header checksum status. We can
|
||||
* ignore this as it will always be re-checked in inet_gro_receive().
|
||||
@@ -761,24 +761,22 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb)
|
||||
* The last 2 bytes are the protocol checksum status which will be zero
|
||||
* if the checksum has been validated.
|
||||
*/
|
||||
if (unlikely(skb->len < sizeof(__sum16) * 2))
|
||||
csum_len = sizeof(*hw_csum) * 2;
|
||||
if (unlikely(skb->len < csum_len))
|
||||
return;
|
||||
|
||||
if (skb_is_nonlinear(skb)) {
|
||||
skb_frag_t *last_frag = &shinfo->frags[shinfo->nr_frags - 1];
|
||||
|
||||
hw_csum = skb_frag_address(last_frag) +
|
||||
skb_frag_size(last_frag);
|
||||
skb_frag_size_sub(last_frag, 2 * sizeof(__sum16));
|
||||
hw_csum = (u16 *)(skb_frag_address(last_frag) +
|
||||
skb_frag_size(last_frag));
|
||||
skb_frag_size_sub(last_frag, csum_len);
|
||||
} else {
|
||||
hw_csum = skb_tail_pointer(skb);
|
||||
skb_trim(skb, skb->len - 2 * sizeof(__sum16));
|
||||
hw_csum = (u16 *)skb_tail_pointer(skb);
|
||||
skb_trim(skb, skb->len - csum_len);
|
||||
}
|
||||
|
||||
hw_csum -= sizeof(__sum16);
|
||||
csum_proto = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum));
|
||||
|
||||
if (!csum_proto)
|
||||
if (!get_unaligned(--hw_csum))
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user