Skip to content

Commit e4f45b7

Browse files
Tom Herbertdavem330
authored andcommitted
net: Call skb_checksum_init in IPv6
Call skb_checksum_init instead of private functions. Signed-off-by: Tom Herbert <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ed70fcf commit e4f45b7

File tree

3 files changed

+9
-30
lines changed

3 files changed

+9
-30
lines changed

include/net/ip6_checksum.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
4141
__wsum csum);
4242
#endif
4343

44+
static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto)
45+
{
46+
return ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
47+
&ipv6_hdr(skb)->daddr,
48+
skb->len, proto, 0));
49+
}
50+
4451
static __inline__ __sum16 tcp_v6_check(int len,
4552
const struct in6_addr *saddr,
4653
const struct in6_addr *daddr,

net/ipv6/ip6_checksum.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,7 @@ int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
8484
&ipv6_hdr(skb)->daddr, ntohs(uh->dest));
8585
return 1;
8686
}
87-
if (skb->ip_summed == CHECKSUM_COMPLETE &&
88-
!csum_ipv6_magic(&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
89-
skb->len, proto, skb->csum))
90-
skb->ip_summed = CHECKSUM_UNNECESSARY;
9187

92-
if (!skb_csum_unnecessary(skb))
93-
skb->csum = ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
94-
&ipv6_hdr(skb)->daddr,
95-
skb->len, proto, 0));
96-
97-
return 0;
88+
return skb_checksum_init(skb, IPPROTO_UDP, ip6_compute_pseudo);
9889
}
9990
EXPORT_SYMBOL(udp6_csum_init);

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,25 +1294,6 @@ static struct sock *tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
12941294
return NULL;
12951295
}
12961296

1297-
static __sum16 tcp_v6_checksum_init(struct sk_buff *skb)
1298-
{
1299-
if (skb->ip_summed == CHECKSUM_COMPLETE) {
1300-
if (!tcp_v6_check(skb->len, &ipv6_hdr(skb)->saddr,
1301-
&ipv6_hdr(skb)->daddr, skb->csum)) {
1302-
skb->ip_summed = CHECKSUM_UNNECESSARY;
1303-
return 0;
1304-
}
1305-
}
1306-
1307-
skb->csum = ~csum_unfold(tcp_v6_check(skb->len,
1308-
&ipv6_hdr(skb)->saddr,
1309-
&ipv6_hdr(skb)->daddr, 0));
1310-
1311-
if (skb->len <= 76)
1312-
return __skb_checksum_complete(skb);
1313-
return 0;
1314-
}
1315-
13161297
/* The socket must have it's spinlock held when we get
13171298
* here.
13181299
*
@@ -1486,7 +1467,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
14861467
if (!pskb_may_pull(skb, th->doff*4))
14871468
goto discard_it;
14881469

1489-
if (!skb_csum_unnecessary(skb) && tcp_v6_checksum_init(skb))
1470+
if (skb_checksum_init(skb, IPPROTO_TCP, ip6_compute_pseudo))
14901471
goto csum_error;
14911472

14921473
th = tcp_hdr(skb);

0 commit comments

Comments
 (0)