udp: Generic functions to set checksum
Added udp_set_csum and udp6_set_csum functions to set UDP checksums in packets. These are for simple UDP packets such as those that might be created in UDP tunnels. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
6579867c8b
commit
af5fcba7f3
@@ -82,5 +82,17 @@ static inline void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline __sum16 udp_v6_check(int len,
|
||||
const struct in6_addr *saddr,
|
||||
const struct in6_addr *daddr,
|
||||
__wsum base)
|
||||
{
|
||||
return csum_ipv6_magic(saddr, daddr, len, IPPROTO_UDP, base);
|
||||
}
|
||||
|
||||
void udp6_set_csum(bool nocheck, struct sk_buff *skb,
|
||||
const struct in6_addr *saddr,
|
||||
const struct in6_addr *daddr, int len);
|
||||
|
||||
int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto);
|
||||
#endif
|
||||
|
@@ -147,6 +147,15 @@ static inline __wsum udp_csum(struct sk_buff *skb)
|
||||
return csum;
|
||||
}
|
||||
|
||||
static inline __sum16 udp_v4_check(int len, __be32 saddr,
|
||||
__be32 daddr, __wsum base)
|
||||
{
|
||||
return csum_tcpudp_magic(saddr, daddr, len, IPPROTO_UDP, base);
|
||||
}
|
||||
|
||||
void udp_set_csum(bool nocheck, struct sk_buff *skb,
|
||||
__be32 saddr, __be32 daddr, int len);
|
||||
|
||||
/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
|
||||
static inline void udp_lib_hash(struct sock *sk)
|
||||
{
|
||||
|
Reference in New Issue
Block a user