Author: tuexen Date: Wed Mar 28 08:11:46 2012 New Revision: 233597 URL: http://svn.freebsd.org/changeset/base/233597
Log: Honor the net.inet.udp.checksum sysctl when using SCTP/UDP/IPv4 encapsulation. MFCing requires MFCing http://svn.freebsd.org/changeset/base/233554 MFC after: 2 weeks Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Wed Mar 28 06:49:29 2012 (r233596) +++ head/sys/netinet/sctp_output.c Wed Mar 28 08:11:46 2012 (r233597) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/sctp_input.h> #include <netinet/sctp_crc32.h> #include <netinet/udp.h> +#include <netinet/udp_var.h> #include <machine/in_cksum.h> @@ -4064,7 +4065,11 @@ sctp_lowlevel_chunk_output(struct sctp_i udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); udp->uh_dport = port; udp->uh_ulen = htons(packet_length - sizeof(struct ip)); - udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } sctphdr = (struct sctphdr *)((caddr_t)udp + sizeof(struct udphdr)); } else { sctphdr = (struct sctphdr *)((caddr_t)ip + sizeof(struct ip)); @@ -4127,7 +4132,9 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTP_STAT_INCR(sctps_sendnocrc); } #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -11007,8 +11014,13 @@ sctp_send_shutdown_complete2(struct mbuf udp->uh_dport = port; udp->uh_ulen = htons(sizeof(struct sctp_shutdown_complete_msg) + sizeof(struct udphdr)); #ifdef INET - if (iph_out) - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (iph_out) { + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } + } #endif offset_out += sizeof(struct udphdr); comp_cp = (struct sctp_shutdown_complete_msg *)((caddr_t)comp_cp + sizeof(struct udphdr)); @@ -11047,7 +11059,9 @@ sctp_send_shutdown_complete2(struct mbuf comp_cp->sh.checksum = sctp_calculate_cksum(mout, offset_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(mout); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(mout); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -12024,7 +12038,11 @@ sctp_send_abort(struct mbuf *m, int iphl bzero(&ro, sizeof ro); if (port) { udp->uh_ulen = htons(len - sizeof(struct ip)); - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } } SCTPDBG(SCTP_DEBUG_OUTPUT2, "sctp_send_abort calling ip_output:\n"); SCTPDBG_PKT(SCTP_DEBUG_OUTPUT2, iph_out, &abm->sh); @@ -12043,7 +12061,9 @@ sctp_send_abort(struct mbuf *m, int iphl abm->sh.checksum = sctp_calculate_cksum(mout, iphlen_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); @@ -12286,7 +12306,11 @@ sctp_send_operr_to(struct mbuf *m, int i bzero(&ro, sizeof ro); if (port) { udp->uh_ulen = htons(len - sizeof(struct ip)); - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } } /* set IPv4 length */ iph_out->ip_len = len; @@ -12303,7 +12327,9 @@ sctp_send_operr_to(struct mbuf *m, int i sh_out->checksum = sctp_calculate_cksum(mout, iphlen_out); SCTP_STAT_INCR(sctps_sendswcrc); #endif - SCTP_ENABLE_UDP_CSUM(o_pak); + if (V_udp_cksum) { + SCTP_ENABLE_UDP_CSUM(o_pak); + } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"