From owner-p4-projects@FreeBSD.ORG Tue Aug 18 12:52:48 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7B8F61065696; Tue, 18 Aug 2009 12:52:48 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FBEB1065694 for ; Tue, 18 Aug 2009 12:52:48 +0000 (UTC) (envelope-from anchie@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 127908FC45 for ; Tue, 18 Aug 2009 12:52:48 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n7ICql4D055849 for ; Tue, 18 Aug 2009 12:52:47 GMT (envelope-from anchie@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n7ICqltb055847 for perforce@freebsd.org; Tue, 18 Aug 2009 12:52:47 GMT (envelope-from anchie@FreeBSD.org) Date: Tue, 18 Aug 2009 12:52:47 GMT Message-Id: <200908181252.n7ICqltb055847@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to anchie@FreeBSD.org using -f From: Ana Kukec To: Perforce Change Reviews Cc: Subject: PERFORCE change 167470 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Aug 2009 12:52:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=167470 Change 167470 by anchie@anchie_malimis on 2009/08/18 12:52:38 - Bug fixes in handling the incoming packets coming from the user land into kernel (netinet6/send.c: send_output()). - Added calls of nd6_??_input() functions. - Added call of icmp6_rip6_input() function with appropriate arguments. Affected files ... .. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#25 edit Differences ... ==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#25 (text+ko) ==== @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -29,7 +30,7 @@ struct ip6_hdr *ip6; struct sockaddr_in6 dst; struct icmp6_hdr *icmp6; - int icmp6len; + int icmp6len, *offp = NULL; printf("send.c: send_output()\n"); @@ -41,26 +42,58 @@ switch (direction) { case SND_IN: - icmp6len = m->m_pkthdr.len - sizeof(struct ip6_hdr); - printf("send_output: m_pkthdr.len = %d\n", m->m_pkthdr.len); + /* XXX-BZ can there be extension headers? */ + if (m->m_len < (sizeof(struct ip6_hdr) + + sizeof(struct icmp6_hdr))) { + m = m_pullup(m, sizeof(struct ip6_hdr) + + sizeof(struct icmp6_hdr)); + if (!m) + return (ENOBUFS); + } + + if (m->m_flags & M_PKTHDR) + icmp6len = m->m_pkthdr.len - sizeof(struct ip6_hdr); + else + panic("Doh! not the first mbuf."); ip6 = mtod(m, struct ip6_hdr *); icmp6 = (struct icmp6_hdr *)(ip6 + 1); - switch (icmp6->icmp6_code) { + + /* + * Output the packet as icmp6.c:incpm6_input() would do. + * The mbuf is always consumed, so we do not have to + * care about that. + */ + switch (icmp6->icmp6_type) { case ND_NEIGHBOR_SOLICIT: - /* From icmp6.c: incpm6_input(). */ - //nd6_ns_input(m, sizeof(struct ip6_hdr), icmp6len); + nd6_ns_input(m, sizeof(struct ip6_hdr), icmp6len); + break; + case ND_NEIGHBOR_ADVERT: + nd6_na_input(m, sizeof(struct ip6_hdr), icmp6len); break; + default: + /* XXX-BZ TODO */ + printf("%s:%d: icmp6_code=%u\n", + __func__, __LINE__, icmp6->icmp6_code); + m_print(m, m->m_pkthdr.len); + return (ENOSYS); } + *offp = sizeof (struct ip6_hdr); //icmp6_rip6_input(&m, *offp); - /* XXX-BZ TODO */ - return (ENOSYS); + + /* + * No error returned from nd6_??_input() so the only thing + * we can do is to pretend that it worked. + */ + return (0); case SND_OUT: - m = m_pullup(m, sizeof(struct ip6_hdr)); - if (!m) - return (ENOBUFS); + if (m->m_len < sizeof(struct ip6_hdr)) { + m = m_pullup(m, sizeof(struct ip6_hdr)); + if (!m) + return (ENOBUFS); + } ip6 = mtod(m, struct ip6_hdr *); if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) m->m_flags |= M_MCAST;