From cb032eac0d5ad9f655f516a6db983374c970f8aa Mon Sep 17 00:00:00 2001 From: lteo Date: Sat, 12 Jul 2014 19:05:45 +0000 Subject: [PATCH] Remove the redundant csum_flag variable and just set the checksum flag in the pkthdr directly. ok henning@ --- sys/netinet/ip_divert.c | 13 +++++-------- sys/netinet6/ip6_divert.c | 12 ++++-------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index d87dcd11fa6..3c24d143b4e 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.25 2014/07/12 19:04:29 lteo Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.26 2014/07/12 19:05:45 lteo Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -87,7 +87,7 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, struct ifaddr *ifa; int s, error = 0, p_hdrlen = 0, dir; struct ip *ip; - u_int16_t off, csum_flag = 0; + u_int16_t off; m->m_pkthdr.rcvif = NULL; m->m_nextpkt = NULL; @@ -120,15 +120,15 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, switch (ip->ip_p) { case IPPROTO_TCP: p_hdrlen = sizeof(struct tcphdr); - csum_flag = M_TCP_CSUM_OUT; + m->m_pkthdr.csum_flags |= M_TCP_CSUM_OUT; break; case IPPROTO_UDP: p_hdrlen = sizeof(struct udphdr); - csum_flag = M_UDP_CSUM_OUT; + m->m_pkthdr.csum_flags |= M_UDP_CSUM_OUT; break; case IPPROTO_ICMP: p_hdrlen = sizeof(struct icmp); - csum_flag = M_ICMP_CSUM_OUT; + m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT; break; default: /* nothing */ @@ -137,9 +137,6 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, if (p_hdrlen && m->m_pkthdr.len < off + p_hdrlen) goto fail; - if (csum_flag) - m->m_pkthdr.csum_flags |= csum_flag; - m->m_pkthdr.pf.flags |= PF_TAG_DIVERTED_PACKET; if (dir == PF_IN) { diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 5efbbd71db6..a718218d5ff 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.26 2014/07/12 19:04:29 lteo Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.27 2014/07/12 19:05:45 lteo Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -91,7 +91,6 @@ divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, struct ifaddr *ifa; int s, error = 0, p_hdrlen = 0, nxt = 0, off, dir; struct ip6_hdr *ip6; - u_int16_t csum_flag = 0; m->m_pkthdr.rcvif = NULL; m->m_nextpkt = NULL; @@ -130,15 +129,15 @@ divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, switch (nxt) { case IPPROTO_TCP: p_hdrlen = sizeof(struct tcphdr); - csum_flag = M_TCP_CSUM_OUT; + m->m_pkthdr.csum_flags |= M_TCP_CSUM_OUT; break; case IPPROTO_UDP: p_hdrlen = sizeof(struct udphdr); - csum_flag = M_UDP_CSUM_OUT; + m->m_pkthdr.csum_flags |= M_UDP_CSUM_OUT; break; case IPPROTO_ICMPV6: p_hdrlen = sizeof(struct icmp6_hdr); - csum_flag = M_ICMP_CSUM_OUT; + m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT; break; default: /* nothing */ @@ -147,9 +146,6 @@ divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, if (p_hdrlen && m->m_pkthdr.len < off + p_hdrlen) goto fail; - if (csum_flag) - m->m_pkthdr.csum_flags |= csum_flag; - m->m_pkthdr.pf.flags |= PF_TAG_DIVERTED_PACKET; if (dir == PF_IN) { -- 2.20.1