Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158965
b: refs/heads/master
c: 493c6be
h: refs/heads/master
i:
  158963: 84124be
v: v3
  • Loading branch information
Sridhar Samudrala authored and David S. Miller committed Jul 12, 2009
1 parent 0e0afb5 commit 649e9ac
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d7ca4cc01fd154f2da30ae6dae160fa5800af758
refs/heads/master: 493c6be3fedfe24aa676949b237b9b104d911abf
48 changes: 47 additions & 1 deletion trunk/net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,47 @@ static void udp_v6_flush_pending_frames(struct sock *sk)
}
}

/**
* udp6_hwcsum_outgoing - handle outgoing HW checksumming
* @sk: socket we are sending on
* @skb: sk_buff containing the filled-in UDP header
* (checksum field must be zeroed out)
*/
static void udp6_hwcsum_outgoing(struct sock *sk, struct sk_buff *skb,
const struct in6_addr *saddr,
const struct in6_addr *daddr, int len)
{
unsigned int offset;
struct udphdr *uh = udp_hdr(skb);
__wsum csum = 0;

if (skb_queue_len(&sk->sk_write_queue) == 1) {
/* Only one fragment on the socket. */
skb->csum_start = skb_transport_header(skb) - skb->head;
skb->csum_offset = offsetof(struct udphdr, check);
uh->check = ~csum_ipv6_magic(saddr, daddr, len, IPPROTO_UDP, 0);
} else {
/*
* HW-checksum won't work as there are two or more
* fragments on the socket so that all csums of sk_buffs
* should be together
*/
offset = skb_transport_offset(skb);
skb->csum = skb_checksum(skb, offset, skb->len - offset, 0);

skb->ip_summed = CHECKSUM_NONE;

skb_queue_walk(&sk->sk_write_queue, skb) {
csum = csum_add(csum, skb->csum);
}

uh->check = csum_ipv6_magic(saddr, daddr, len, IPPROTO_UDP,
csum);
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;
}
}

/*
* Sending
*/
Expand Down Expand Up @@ -668,7 +709,11 @@ static int udp_v6_push_pending_frames(struct sock *sk)

if (is_udplite)
csum = udplite_csum_outgoing(sk, skb);
else
else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* UDP hardware csum */
udp6_hwcsum_outgoing(sk, skb, &fl->fl6_src, &fl->fl6_dst,
up->len);
goto send;
} else
csum = udp_csum_outgoing(sk, skb);

/* add protocol-dependent pseudo-header */
Expand All @@ -677,6 +722,7 @@ static int udp_v6_push_pending_frames(struct sock *sk)
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;

send:
err = ip6_push_pending_frames(sk);
out:
up->len = 0;
Expand Down

0 comments on commit 649e9ac

Please sign in to comment.