From owner-svn-src-all@FreeBSD.ORG Mon Feb 7 15:04:23 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85873106566B; Mon, 7 Feb 2011 15:04:23 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73C418FC16; Mon, 7 Feb 2011 15:04:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p17F4NEL012984; Mon, 7 Feb 2011 15:04:23 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p17F4NIZ012978; Mon, 7 Feb 2011 15:04:23 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201102071504.p17F4NIZ012978@svn.freebsd.org> From: Michael Tuexen Date: Mon, 7 Feb 2011 15:04:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218400 - in head/sys: netinet netinet6 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Feb 2011 15:04:23 -0000 Author: tuexen Date: Mon Feb 7 15:04:23 2011 New Revision: 218400 URL: http://svn.freebsd.org/changeset/base/218400 Log: Fix bugs related to M_FLOWID: * Store the flowid when receiving an SCTP/IPv6 packet. * Store the flowid when receiving an SCTP packet with wrong CRC. * Initilize flowid correctly. * Put test code under INVARIANTS. MFC after: 3 months. Modified: head/sys/netinet/sctp_input.c head/sys/netinet/sctp_output.c head/sys/netinet/sctp_pcb.c head/sys/netinet/sctp_structs.h head/sys/netinet6/sctp6_usrreq.c Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Mon Feb 7 14:58:29 2011 (r218399) +++ head/sys/netinet/sctp_input.c Mon Feb 7 15:04:23 2011 (r218400) @@ -2617,7 +2617,9 @@ sctp_handle_cookie_echo(struct mbuf *m, } if ((*netp != NULL) && (m->m_flags & M_FLOWID)) { (*netp)->flowid = m->m_pkthdr.flowid; +#ifdef INVARIANTS (*netp)->flowidset = 1; +#endif } /* * Ok, we built an association so confirm the address we sent the @@ -5815,6 +5817,12 @@ sctp_input_with_port(struct mbuf *i_pak, } net->port = port; } + if ((net != NULL) && (m->m_flags & M_FLOWID)) { + net->flowid = m->m_pkthdr.flowid; +#ifdef INVARIANTS + net->flowidset = 1; +#endif + } if ((inp) && (stcb)) { sctp_send_packet_dropped(stcb, net, m, iphlen, 1); sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_INPUT_ERROR, SCTP_SO_NOT_LOCKED); @@ -5846,7 +5854,9 @@ sctp_skip_csum_4: } if ((net != NULL) && (m->m_flags & M_FLOWID)) { net->flowid = m->m_pkthdr.flowid; +#ifdef INVARIANTS net->flowidset = 1; +#endif } /* inp's ref-count increased && stcb locked */ if (inp == NULL) { Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Mon Feb 7 14:58:29 2011 (r218399) +++ head/sys/netinet/sctp_output.c Mon Feb 7 15:04:23 2011 (r218400) @@ -3485,12 +3485,11 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTP_BUF_NEXT(newm) = m; m = newm; if (net != NULL) { +#ifdef INVARIANTS if (net->flowidset == 0) { - net->flowid = stcb->asoc.my_vtag ^ - ntohs(stcb->rport) ^ - ntohs(stcb->sctp_ep->sctp_lport); - net->flowidset = 1; + panic("Flow ID not set"); } +#endif m->m_pkthdr.flowid = net->flowid; m->m_flags |= M_FLOWID; } else { @@ -3821,12 +3820,11 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTP_BUF_NEXT(newm) = m; m = newm; if (net != NULL) { +#ifdef INVARIANTS if (net->flowidset == 0) { - net->flowid = stcb->asoc.my_vtag ^ - ntohs(stcb->rport) ^ - ntohs(stcb->sctp_ep->sctp_lport); - net->flowidset = 1; + panic("Flow ID not set"); } +#endif m->m_pkthdr.flowid = net->flowid; m->m_flags |= M_FLOWID; } else { Modified: head/sys/netinet/sctp_pcb.c ============================================================================== --- head/sys/netinet/sctp_pcb.c Mon Feb 7 14:58:29 2011 (r218399) +++ head/sys/netinet/sctp_pcb.c Mon Feb 7 15:04:23 2011 (r218400) @@ -3962,6 +3962,13 @@ sctp_add_remote_addr(struct sctp_tcb *st net->find_pseudo_cumack = 1; net->find_rtx_pseudo_cumack = 1; net->src_addr_selected = 0; + /* Choose an initial flowid. */ + net->flowid = stcb->asoc.my_vtag ^ + ntohs(stcb->rport) ^ + ntohs(stcb->sctp_ep->sctp_lport); +#ifdef INVARIANTS + net->flowidset = 1; +#endif netfirst = TAILQ_FIRST(&stcb->asoc.nets); if (net->ro.ro_rt == NULL) { /* Since we have no route put it at the back */ @@ -4035,11 +4042,6 @@ sctp_add_remote_addr(struct sctp_tcb *st TAILQ_INSERT_HEAD(&stcb->asoc.nets, stcb->asoc.primary_destination, sctp_next); } - /* Choose an initial flowid. */ - net->flowid = stcb->asoc.my_vtag ^ - ntohs(stcb->rport) ^ - ntohs(stcb->sctp_ep->sctp_lport); - net->flowidset = 1; return (0); } Modified: head/sys/netinet/sctp_structs.h ============================================================================== --- head/sys/netinet/sctp_structs.h Mon Feb 7 14:58:29 2011 (r218399) +++ head/sys/netinet/sctp_structs.h Mon Feb 7 15:04:23 2011 (r218400) @@ -351,7 +351,9 @@ struct sctp_nets { /* JRS - struct used in HTCP algorithm */ struct htcp htcp_ca; uint32_t flowid; +#ifdef INVARIANTS uint8_t flowidset; +#endif }; Modified: head/sys/netinet6/sctp6_usrreq.c ============================================================================== --- head/sys/netinet6/sctp6_usrreq.c Mon Feb 7 14:58:29 2011 (r218399) +++ head/sys/netinet6/sctp6_usrreq.c Mon Feb 7 15:04:23 2011 (r218400) @@ -170,6 +170,12 @@ sctp6_input(struct mbuf **i_pak, int *of } net->port = port; } + if ((net != NULL) && (m->m_flags & M_FLOWID)) { + net->flowid = m->m_pkthdr.flowid; +#ifdef INVARIANTS + net->flowidset = 1; +#endif + } /* in6p's ref-count increased && stcb locked */ if ((in6p) && (stcb)) { sctp_send_packet_dropped(stcb, net, m, iphlen, 1); @@ -198,6 +204,12 @@ sctp_skip_csum: } net->port = port; } + if ((net != NULL) && (m->m_flags & M_FLOWID)) { + net->flowid = m->m_pkthdr.flowid; +#ifdef INVARIANTS + net->flowidset = 1; +#endif + } /* in6p's ref-count increased */ if (in6p == NULL) { struct sctp_init_chunk *init_chk, chunk_buf;