ipvs: Use frag walker helper in SCTP proto support.

Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
David S. Miller 2010-10-05 00:27:05 -07:00
parent 24824a09e3
commit 13f5bf18ba
1 changed files with 10 additions and 9 deletions

View File

@ -61,6 +61,7 @@ sctp_snat_handler(struct sk_buff *skb,
{ {
sctp_sctphdr_t *sctph; sctp_sctphdr_t *sctph;
unsigned int sctphoff; unsigned int sctphoff;
struct sk_buff *iter;
__be32 crc32; __be32 crc32;
#ifdef CONFIG_IP_VS_IPV6 #ifdef CONFIG_IP_VS_IPV6
@ -89,8 +90,8 @@ sctp_snat_handler(struct sk_buff *skb,
/* Calculate the checksum */ /* Calculate the checksum */
crc32 = sctp_start_cksum((u8 *) sctph, skb_headlen(skb) - sctphoff); crc32 = sctp_start_cksum((u8 *) sctph, skb_headlen(skb) - sctphoff);
for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) skb_walk_frags(skb, iter)
crc32 = sctp_update_cksum((u8 *) skb->data, skb_headlen(skb), crc32 = sctp_update_cksum((u8 *) iter->data, skb_headlen(iter),
crc32); crc32);
crc32 = sctp_end_cksum(crc32); crc32 = sctp_end_cksum(crc32);
sctph->checksum = crc32; sctph->checksum = crc32;
@ -102,9 +103,9 @@ static int
sctp_dnat_handler(struct sk_buff *skb, sctp_dnat_handler(struct sk_buff *skb,
struct ip_vs_protocol *pp, struct ip_vs_conn *cp) struct ip_vs_protocol *pp, struct ip_vs_conn *cp)
{ {
sctp_sctphdr_t *sctph; sctp_sctphdr_t *sctph;
unsigned int sctphoff; unsigned int sctphoff;
struct sk_buff *iter;
__be32 crc32; __be32 crc32;
#ifdef CONFIG_IP_VS_IPV6 #ifdef CONFIG_IP_VS_IPV6
@ -133,8 +134,8 @@ sctp_dnat_handler(struct sk_buff *skb,
/* Calculate the checksum */ /* Calculate the checksum */
crc32 = sctp_start_cksum((u8 *) sctph, skb_headlen(skb) - sctphoff); crc32 = sctp_start_cksum((u8 *) sctph, skb_headlen(skb) - sctphoff);
for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) skb_walk_frags(skb, iter)
crc32 = sctp_update_cksum((u8 *) skb->data, skb_headlen(skb), crc32 = sctp_update_cksum((u8 *) iter->data, skb_headlen(iter),
crc32); crc32);
crc32 = sctp_end_cksum(crc32); crc32 = sctp_end_cksum(crc32);
sctph->checksum = crc32; sctph->checksum = crc32;
@ -145,9 +146,9 @@ sctp_dnat_handler(struct sk_buff *skb,
static int static int
sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp) sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp)
{ {
struct sk_buff *list = skb_shinfo(skb)->frag_list;
unsigned int sctphoff; unsigned int sctphoff;
struct sctphdr *sh, _sctph; struct sctphdr *sh, _sctph;
struct sk_buff *iter;
__le32 cmp; __le32 cmp;
__le32 val; __le32 val;
__u32 tmp; __u32 tmp;
@ -166,9 +167,9 @@ sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp)
cmp = sh->checksum; cmp = sh->checksum;
tmp = sctp_start_cksum((__u8 *) sh, skb_headlen(skb)); tmp = sctp_start_cksum((__u8 *) sh, skb_headlen(skb));
for (; list; list = list->next) skb_walk_frags(skb, iter)
tmp = sctp_update_cksum((__u8 *) list->data, tmp = sctp_update_cksum((__u8 *) iter->data,
skb_headlen(list), tmp); skb_headlen(iter), tmp);
val = sctp_end_cksum(tmp); val = sctp_end_cksum(tmp);