From a0cb420760e1bc4a8e363136180131ebecc1f0a8 Mon Sep 17 00:00:00 2001 From: henning Date: Sun, 20 Apr 2014 09:38:19 +0000 Subject: [PATCH] move in_cksum_phdr from in.h (under #ifdef _KERNEL, at least) to ip_output.c nothing except in_proto_cksum_out() uses it any more, and that's a good thing. was on tech for 3 months, discussed with many --- sys/netinet/in.h | 33 +-------------------------------- sys/netinet/ip_output.c | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/sys/netinet/in.h b/sys/netinet/in.h index ab8b7649bb8..ac51100f3de 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in.h,v 1.103 2014/04/20 09:30:56 henning Exp $ */ +/* $OpenBSD: in.h,v 1.104 2014/04/20 09:38:19 henning Exp $ */ /* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */ /* @@ -777,37 +777,6 @@ __END_DECLS #endif #else -/* - * in_cksum_phdr: - * - * Compute significant parts of the IPv4 checksum pseudo-header - * for use in a delayed TCP/UDP checksum calculation. - * - * Args: - * - * src Source IP address - * dst Destination IP address - * lenproto htons(proto-hdr-len + proto-number) - */ -static __inline u_int16_t __attribute__((__unused__)) -in_cksum_phdr(u_int32_t src, u_int32_t dst, u_int32_t lenproto) -{ - u_int32_t sum; - - sum = lenproto + - (u_int16_t)(src >> 16) + - (u_int16_t)(src /*& 0xffff*/) + - (u_int16_t)(dst >> 16) + - (u_int16_t)(dst /*& 0xffff*/); - - sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); - - if (sum > 0xffff) - sum -= 0xffff; - - return (sum); -} - extern int inetctlerrmap[]; extern struct ifqueue ipintrq; /* ip packet input queue */ extern struct in_addr zeroin_addr; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 3fd187b9d23..1b63a287d63 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.261 2014/04/14 09:06:42 mpi Exp $ */ +/* $OpenBSD: ip_output.c,v 1.262 2014/04/20 09:38:19 henning Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -74,6 +74,8 @@ struct mbuf *ip_insertoptions(struct mbuf *, struct mbuf *, int *); void ip_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in *); +static __inline u_int16_t __attribute__((__unused__)) + in_cksum_phdr(u_int32_t, u_int32_t, u_int32_t); void in_delayed_cksum(struct mbuf *); /* @@ -2015,6 +2017,29 @@ ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst) } } +/* + * Compute significant parts of the IPv4 checksum pseudo-header + * for use in a delayed TCP/UDP checksum calculation. + */ +static __inline u_int16_t __attribute__((__unused__)) +in_cksum_phdr(u_int32_t src, u_int32_t dst, u_int32_t lenproto) +{ + u_int32_t sum; + + sum = lenproto + + (u_int16_t)(src >> 16) + + (u_int16_t)(src /*& 0xffff*/) + + (u_int16_t)(dst >> 16) + + (u_int16_t)(dst /*& 0xffff*/); + + sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); + + if (sum > 0xffff) + sum -= 0xffff; + + return (sum); +} + /* * Process a delayed payload checksum calculation. */ -- 2.20.1