Instead of calculating the ICMPv6 checksum here, just set the flag that
is needed and the lower parts of the stack will take care of it.

I have tested the general ICMPv6, ICMPv6 redirect, and neighbor
discovery parts.  I have not tested the MLD part.

Index: icmp6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.139
diff -u -p -r1.139 icmp6.c
--- icmp6.c     13 Jan 2014 23:03:52 -0000      1.139
+++ icmp6.c     23 Jan 2014 01:02:41 -0000
@@ -2100,8 +2100,7 @@ icmp6_reflect(struct mbuf *m, size_t off
                ip6->ip6_hlim = ip6_defhlim;
 
        icmp6->icmp6_cksum = 0;
-       icmp6->icmp6_cksum = in6_cksum(m, IPPROTO_ICMPV6,
-                                       sizeof(struct ip6_hdr), plen);
+       m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT;
 
        /*
         * XXX option handling
@@ -2611,8 +2610,7 @@ noredhdropt:
        ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(struct ip6_hdr));
 
        nd_rd->nd_rd_cksum = 0;
-       nd_rd->nd_rd_cksum
-               = in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), 
ntohs(ip6->ip6_plen));
+       m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT;
 
        /* send the packet to outside... */
        if (ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL) != 0)
Index: mld6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/mld6.c,v
retrieving revision 1.36
diff -u -p -r1.36 mld6.c
--- mld6.c      21 Jan 2014 10:18:26 -0000      1.36
+++ mld6.c      23 Jan 2014 22:55:41 -0000
@@ -435,8 +435,7 @@ mld6_sendpkt(struct in6_multi *in6m, int
        mldh->mld_addr = in6m->in6m_addr;
        if (IN6_IS_ADDR_MC_LINKLOCAL(&mldh->mld_addr))
                mldh->mld_addr.s6_addr16[1] = 0; /* XXX */
-       mldh->mld_cksum = in6_cksum(mh, IPPROTO_ICMPV6, sizeof(struct ip6_hdr),
-           sizeof(struct mld_hdr));
+       mh->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT;
 
        /* construct multicast option */
        bzero(&im6o, sizeof(im6o));
Index: nd6_nbr.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6_nbr.c,v
retrieving revision 1.74
diff -u -p -r1.74 nd6_nbr.c
--- nd6_nbr.c   13 Jan 2014 23:03:52 -0000      1.74
+++ nd6_nbr.c   23 Jan 2014 22:47:44 -0000
@@ -520,8 +520,7 @@ nd6_ns_output(struct ifnet *ifp, struct 
 
        ip6->ip6_plen = htons((u_short)icmp6len);
        nd_ns->nd_ns_cksum = 0;
-       nd_ns->nd_ns_cksum =
-           in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), icmp6len);
+       m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT;
 
        ip6_output(m, NULL, &ro, dad ? IPV6_UNSPECSRC : 0, &im6o, NULL, NULL);
        icmp6_ifstat_inc(ifp, ifs6_out_msg);
@@ -1034,8 +1033,7 @@ nd6_na_output(struct ifnet *ifp, struct 
        ip6->ip6_plen = htons((u_short)icmp6len);
        nd_na->nd_na_flags_reserved = flags;
        nd_na->nd_na_cksum = 0;
-       nd_na->nd_na_cksum =
-           in6_cksum(m, IPPROTO_ICMPV6, sizeof(struct ip6_hdr), icmp6len);
+       m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT;
 
        ip6_output(m, NULL, &ro, 0, &im6o, NULL, NULL);
 
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to