forked from mirrors/linux
		
	net: Call skb_checksum_init in IPv6
Call skb_checksum_init instead of private functions. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									ed70fcfcee
								
							
						
					
					
						commit
						e4f45b7f40
					
				
					 3 changed files with 9 additions and 30 deletions
				
			
		|  | @ -41,6 +41,13 @@ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, | ||||||
| 			__wsum csum); | 			__wsum csum); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto) | ||||||
|  | { | ||||||
|  | 	return ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr, | ||||||
|  | 					    &ipv6_hdr(skb)->daddr, | ||||||
|  | 					    skb->len, proto, 0)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static __inline__ __sum16 tcp_v6_check(int len, | static __inline__ __sum16 tcp_v6_check(int len, | ||||||
| 				   const struct in6_addr *saddr, | 				   const struct in6_addr *saddr, | ||||||
| 				   const struct in6_addr *daddr, | 				   const struct in6_addr *daddr, | ||||||
|  |  | ||||||
|  | @ -84,16 +84,7 @@ int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto) | ||||||
| 			       &ipv6_hdr(skb)->daddr, ntohs(uh->dest)); | 			       &ipv6_hdr(skb)->daddr, ntohs(uh->dest)); | ||||||
| 		return 1; | 		return 1; | ||||||
| 	} | 	} | ||||||
| 	if (skb->ip_summed == CHECKSUM_COMPLETE && |  | ||||||
| 	    !csum_ipv6_magic(&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, |  | ||||||
| 			     skb->len, proto, skb->csum)) |  | ||||||
| 		skb->ip_summed = CHECKSUM_UNNECESSARY; |  | ||||||
| 
 | 
 | ||||||
| 	if (!skb_csum_unnecessary(skb)) | 	return skb_checksum_init(skb, IPPROTO_UDP, ip6_compute_pseudo); | ||||||
| 		skb->csum = ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr, |  | ||||||
| 							 &ipv6_hdr(skb)->daddr, |  | ||||||
| 							 skb->len, proto, 0)); |  | ||||||
| 
 |  | ||||||
| 	return 0; |  | ||||||
| } | } | ||||||
| EXPORT_SYMBOL(udp6_csum_init); | EXPORT_SYMBOL(udp6_csum_init); | ||||||
|  |  | ||||||
|  | @ -1294,25 +1294,6 @@ static struct sock *tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | ||||||
| 	return NULL; | 	return NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static __sum16 tcp_v6_checksum_init(struct sk_buff *skb) |  | ||||||
| { |  | ||||||
| 	if (skb->ip_summed == CHECKSUM_COMPLETE) { |  | ||||||
| 		if (!tcp_v6_check(skb->len, &ipv6_hdr(skb)->saddr, |  | ||||||
| 				  &ipv6_hdr(skb)->daddr, skb->csum)) { |  | ||||||
| 			skb->ip_summed = CHECKSUM_UNNECESSARY; |  | ||||||
| 			return 0; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	skb->csum = ~csum_unfold(tcp_v6_check(skb->len, |  | ||||||
| 					      &ipv6_hdr(skb)->saddr, |  | ||||||
| 					      &ipv6_hdr(skb)->daddr, 0)); |  | ||||||
| 
 |  | ||||||
| 	if (skb->len <= 76) |  | ||||||
| 		return __skb_checksum_complete(skb); |  | ||||||
| 	return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /* The socket must have it's spinlock held when we get
 | /* The socket must have it's spinlock held when we get
 | ||||||
|  * here. |  * here. | ||||||
|  * |  * | ||||||
|  | @ -1486,7 +1467,7 @@ static int tcp_v6_rcv(struct sk_buff *skb) | ||||||
| 	if (!pskb_may_pull(skb, th->doff*4)) | 	if (!pskb_may_pull(skb, th->doff*4)) | ||||||
| 		goto discard_it; | 		goto discard_it; | ||||||
| 
 | 
 | ||||||
| 	if (!skb_csum_unnecessary(skb) && tcp_v6_checksum_init(skb)) | 	if (skb_checksum_init(skb, IPPROTO_TCP, ip6_compute_pseudo)) | ||||||
| 		goto csum_error; | 		goto csum_error; | ||||||
| 
 | 
 | ||||||
| 	th = tcp_hdr(skb); | 	th = tcp_hdr(skb); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Tom Herbert
						Tom Herbert