From owner-svn-src-all@freebsd.org Wed May 25 22:16:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF1CAB4A832; Wed, 25 May 2016 22:16:12 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 636A71706; Wed, 25 May 2016 22:16:12 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4PMGBnK014919; Wed, 25 May 2016 22:16:11 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4PMGBrb014918; Wed, 25 May 2016 22:16:11 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201605252216.u4PMGBrb014918@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Wed, 25 May 2016 22:16:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300699 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Wed, 25 May 2016 22:16:12 -0000 Author: tuexen Date: Wed May 25 22:16:11 2016 New Revision: 300699 URL: https://svnweb.freebsd.org/changeset/base/300699 Log: When sending in ICMP response to an SCTP packet, * include the SCTP common header, if possible * include the first 8 bytes of the INIT chunk, if possible This provides the necesary information for the receiver of the ICMP packet to process it. MFC after: 1 week Modified: head/sys/netinet/ip_icmp.c Modified: head/sys/netinet/ip_icmp.c ============================================================================== --- head/sys/netinet/ip_icmp.c Wed May 25 20:56:30 2016 (r300698) +++ head/sys/netinet/ip_icmp.c Wed May 25 22:16:11 2016 (r300699) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -249,6 +250,34 @@ icmp_error(struct mbuf *n, int type, int goto freeit; icmpelen = max(tcphlen, min(V_icmp_quotelen, ntohs(oip->ip_len) - oiphlen)); + } else if (oip->ip_p == IPPROTO_SCTP) { + struct sctphdr *sh; + struct sctp_chunkhdr *ch; + + if (ntohs(oip->ip_len) < oiphlen + sizeof(struct sctphdr)) + goto stdreply; + if (oiphlen + sizeof(struct sctphdr) > n->m_len && + n->m_next == NULL) + goto stdreply; + if (n->m_len < oiphlen + sizeof(struct sctphdr) && + (n = m_pullup(n, oiphlen + sizeof(struct sctphdr))) == NULL) + goto freeit; + icmpelen = max(sizeof(struct sctphdr), + min(V_icmp_quotelen, ntohs(oip->ip_len) - oiphlen)); + sh = (struct sctphdr *)((caddr_t)oip + oiphlen); + if (ntohl(sh->v_tag) == 0 && + ntohs(oip->ip_len) >= oiphlen + sizeof(struct sctphdr) + 8 && + (n->m_len >= oiphlen + sizeof(struct sctphdr) + 8 || + n->m_next != NULL)) { + if (n->m_len < oiphlen + sizeof(struct sctphdr) + 8 && + (n = m_pullup(n, oiphlen + sizeof(struct sctphdr) + 8)) == NULL) + goto freeit; + ch = (struct sctp_chunkhdr *)(sh + 1); + if (ch->chunk_type == SCTP_INITIATION) { + icmpelen = max(sizeof(struct sctphdr) + 8, + min(V_icmp_quotelen, ntohs(oip->ip_len) - oiphlen)); + } + } } else stdreply: icmpelen = max(8, min(V_icmp_quotelen, ntohs(oip->ip_len) - oiphlen));