diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2014-04-18 15:13:02 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2014-04-18 15:13:02 +0000 |
commit | f3256a7425430dc0b3b8093dcda2f33d9c44ade4 (patch) | |
tree | 229f37cb49611f6ac9c37f1dcb6a60a8f2a4e823 /sys | |
parent | 00455d47d349e82fd280026ea5e471de9e052984 (diff) |
pf_send_tcp: ask the stack to do the cksum instead of doing it manually
ok benno lteo naddy (back in january)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/pf.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c index c2a1fa554dc..662957d30de 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.871 2014/04/14 09:06:42 mpi Exp $ */ +/* $OpenBSD: pf.c,v 1.872 2014/04/18 15:13:01 henning Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -2377,15 +2377,21 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af, m->m_data += max_linkhdr; m->m_pkthdr.len = m->m_len = len; m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.csum_flags |= M_TCP_CSUM_OUT; bzero(m->m_data, len); switch (af) { #ifdef INET case AF_INET: h = mtod(m, struct ip *); - - /* IP header fields included in the TCP checksum */ h->ip_p = IPPROTO_TCP; h->ip_len = htons(tlen); + h->ip_v = 4; + h->ip_hl = sizeof(*h) >> 2; + h->ip_tos = IPTOS_LOWDELAY; + h->ip_len = htons(len); + h->ip_off = htons(ip_mtudisc ? IP_DF : 0); + h->ip_ttl = ttl ? ttl : ip_defttl; + h->ip_sum = 0; h->ip_src.s_addr = saddr->v4.s_addr; h->ip_dst.s_addr = daddr->v4.s_addr; @@ -2395,10 +2401,10 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af, #ifdef INET6 case AF_INET6: h6 = mtod(m, struct ip6_hdr *); - - /* IP header fields included in the TCP checksum */ h6->ip6_nxt = IPPROTO_TCP; h6->ip6_plen = htons(tlen); + h6->ip6_vfc |= IPV6_VERSION; + h6->ip6_hlim = IPV6_DEFHLIM; memcpy(&h6->ip6_src, &saddr->v6, sizeof(struct in6_addr)); memcpy(&h6->ip6_dst, &daddr->v6, sizeof(struct in6_addr)); @@ -2427,17 +2433,6 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af, switch (af) { #ifdef INET case AF_INET: - /* TCP checksum */ - th->th_sum = in_cksum(m, len); - - /* Finish the IP header */ - h->ip_v = 4; - h->ip_hl = sizeof(*h) >> 2; - h->ip_tos = IPTOS_LOWDELAY; - h->ip_len = htons(len); - h->ip_off = htons(ip_mtudisc ? IP_DF : 0); - h->ip_ttl = ttl ? ttl : ip_defttl; - h->ip_sum = 0; if (eh == NULL) { ip_output(m, (void *)NULL, (void *)NULL, 0, (void *)NULL, (void *)NULL); @@ -2464,13 +2459,6 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af, #endif /* INET */ #ifdef INET6 case AF_INET6: - /* TCP checksum */ - th->th_sum = in6_cksum(m, IPPROTO_TCP, - sizeof(struct ip6_hdr), tlen); - - h6->ip6_vfc |= IPV6_VERSION; - h6->ip6_hlim = IPV6_DEFHLIM; - ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL); break; #endif /* INET6 */ |