From owner-svn-src-user@FreeBSD.ORG Sun Jul 10 16:05:51 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 732C2106566C; Sun, 10 Jul 2011 16:05:51 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 58FD78FC0C; Sun, 10 Jul 2011 16:05:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6AG5pEJ052554; Sun, 10 Jul 2011 16:05:51 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6AG5peY052550; Sun, 10 Jul 2011 16:05:51 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107101605.p6AG5peY052550@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 10 Jul 2011 16:05:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223910 - in user/gabor/tre-integration/tools/test/regex: . regmatch tests X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jul 2011 16:05:51 -0000 Author: gabor Date: Sun Jul 10 16:05:51 2011 New Revision: 223910 URL: http://svn.freebsd.org/changeset/base/223910 Log: - Add a small test program and Makefile to test standard-conformance of the regex code. It uses a simple file format to store a string, a pattern and the expected matching offsets. The expected matches are compared to the actual ones. Added: user/gabor/tre-integration/tools/test/regex/ user/gabor/tre-integration/tools/test/regex/Makefile (contents, props changed) user/gabor/tre-integration/tools/test/regex/regmatch/ user/gabor/tre-integration/tools/test/regex/regmatch/Makefile (contents, props changed) user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c (contents, props changed) user/gabor/tre-integration/tools/test/regex/tests/ user/gabor/tre-integration/tools/test/regex/tests/basic.tests Added: user/gabor/tre-integration/tools/test/regex/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/tools/test/regex/Makefile Sun Jul 10 16:05:51 2011 (r223910) @@ -0,0 +1,23 @@ +# $FreeBSD$ + +SUBDIR= regmatch + +TESTS=basic.tests + +test: regmatch +.for t in ${TESTS} + @echo "=== Running test ${t} ===" + @for l in `cat tests/${t} | grep -ve '^#'`; do \ + str=`echo $${l} | cut -d \; -f 2`; \ + pat=`echo $${l} | cut -d \; -f 1`; \ + match=`echo $${l} | cut -d \; -f 3`; \ + result=`./regmatch/regmatch $${pat} $${str}`; \ + if [ "$${match}" != "$${result}" ]; then \ + echo "Failed matching pattern $${pat} to string $${str}"; \ + else \ + echo "PASSED matching pattern $${pat} to string $${str}"; \ + fi \ + done +.endfor + +.include Added: user/gabor/tre-integration/tools/test/regex/regmatch/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/tools/test/regex/regmatch/Makefile Sun Jul 10 16:05:51 2011 (r223910) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +PROG= regmatch +NO_MAN= yes + +WARNS?= 6 + +.include Added: user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c Sun Jul 10 16:05:51 2011 (r223910) @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include + +static void +usage(void) +{ + printf("Usage: %s pattern string\n", getprogname()); + exit(EXIT_FAILURE); +} + +int +main(int argc, char *argv[]) +{ + regex_t pattern; + regmatch_t pmatch; + ssize_t len; + int cflags = 0, ret; + int eflags = REG_STARTEND; + + if (argc != 3) + usage(); + + ret = regcomp(&pattern, argv[1], cflags); + if (ret != 0) + errx(1, NULL); + + len = strlen(argv[2]); + pmatch.rm_so = 0; + pmatch.rm_eo = len; + putchar('('); + for (bool first = true;;) { + ret = regexec(&pattern, argv[2], 1, &pmatch, eflags); + if (ret == REG_NOMATCH) + break; + if (!first) + putchar(','); + printf("(%lu,%lu)", (unsigned long)pmatch.rm_so, + (unsigned long)pmatch.rm_eo); + if (pmatch.rm_eo == len) + break; + pmatch.rm_so = pmatch.rm_eo; + pmatch.rm_eo = len; + first = false; + } + printf(")\n"); + regfree(&pattern); +} Added: user/gabor/tre-integration/tools/test/regex/tests/basic.tests ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/tools/test/regex/tests/basic.tests Sun Jul 10 16:05:51 2011 (r223910) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +foo;foobarfoobar;((0,3),(6,9)) From owner-svn-src-user@FreeBSD.ORG Wed Jul 13 17:38:43 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 084CA1065675; Wed, 13 Jul 2011 17:38:43 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E259D8FC1B; Wed, 13 Jul 2011 17:38:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6DHcgFt093633; Wed, 13 Jul 2011 17:38:42 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6DHcgpP093629; Wed, 13 Jul 2011 17:38:42 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107131738.p6DHcgpP093629@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 13 Jul 2011 17:38:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223983 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2011 17:38:43 -0000 Author: gabor Date: Wed Jul 13 17:38:42 2011 New Revision: 223983 URL: http://svn.freebsd.org/changeset/base/223983 Log: - Fix REG_STARTEND Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c user/gabor/tre-integration/contrib/tre/lib/tre.h Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Wed Jul 13 17:09:15 2011 (r223982) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Wed Jul 13 17:38:42 2011 (r223983) @@ -155,10 +155,11 @@ tre_match(const tre_tnfa_t *tnfa, const { reg_errcode_t status; int *tags = NULL, eo; + int ret; /* Check if we can cheat with a fixed string */ if (shortcut != NULL) - return tre_fastexec(shortcut, string, len, type, nmatch, pmatch); + return tre_fastexec(shortcut, string, len, type, nmatch, pmatch); if (tnfa->num_tags > 0 && nmatch > 0) { @@ -230,9 +231,11 @@ tre_regnexec(const regex_t *preg, const str = &str[offset]; int ret = tre_match(tnfa, str, slen, type, nmatch, pmatch, eflags, preg->shortcut); + pmatch[0].rm_so += offset; + pmatch[0].rm_eo += offset; if (!(eflags & REG_NOSUB)) { - for (unsigned i = 0; i < nmatch; i++) + for (unsigned i = 1; i < nmatch; i++) { pmatch[i].rm_so += offset; pmatch[i].rm_eo += offset; @@ -270,6 +273,8 @@ tre_regwnexec(const regex_t *preg, const str = &str[offset]; int ret = tre_match(tnfa, str, slen, STR_WIDE, nmatch, pmatch, eflags, preg->shortcut); + pmatch[0].rm_so += offset; + pmatch[0].rm_eo += offset; if (!(eflags & REG_NOSUB)) { for (unsigned i = 0; i < nmatch; i++) Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Jul 13 17:09:15 2011 (r223982) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Jul 13 17:38:42 2011 (r223983) @@ -1876,8 +1876,8 @@ tre_compile(regex_t *preg, const tre_cha if (!shortcut) return REG_ESPACE; ret = (cflags & REG_LITERAL) - ? tre_fastcomp_literal(shortcut, regex, n, cflags) - : tre_fastcomp(shortcut, regex, n, cflags); + ? tre_fastcomp_literal(shortcut, regex, n) + : tre_fastcomp(shortcut, regex, n); if (!ret) { preg->shortcut = shortcut; Modified: user/gabor/tre-integration/contrib/tre/lib/tre.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre.h Wed Jul 13 17:09:15 2011 (r223982) +++ user/gabor/tre-integration/contrib/tre/lib/tre.h Wed Jul 13 17:38:42 2011 (r223983) @@ -93,11 +93,11 @@ typedef enum { /* POSIX tre_regexec() flags. */ #define REG_NOTBOL 1 #define REG_NOTEOL (REG_NOTBOL << 1) -#define REG_STARTEND (REG_NOTEOL << 1) /* Extra tre_regexec() flags. */ #define REG_APPROX_MATCHER (REG_NOTEOL << 1) #define REG_BACKTRACKING_MATCHER (REG_APPROX_MATCHER << 1) +#define REG_STARTEND (REG_BACKTRACKING_MATCHER << 1) /* REG_NOSPEC and REG_LITERAL mean the same thing. */ #if defined(REG_LITERAL) && !defined(REG_NOSPEC) From owner-svn-src-user@FreeBSD.ORG Wed Jul 13 21:06:47 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D26C106566C; Wed, 13 Jul 2011 21:06:47 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1EB38FC0C; Wed, 13 Jul 2011 21:06:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6DL6kBk099795; Wed, 13 Jul 2011 21:06:46 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6DL6ktV099793; Wed, 13 Jul 2011 21:06:46 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107132106.p6DL6ktV099793@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 13 Jul 2011 21:06:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223987 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2011 21:06:47 -0000 Author: gabor Date: Wed Jul 13 21:06:46 2011 New Revision: 223987 URL: http://svn.freebsd.org/changeset/base/223987 Log: - Remove unused variable Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Wed Jul 13 18:52:11 2011 (r223986) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Wed Jul 13 21:06:46 2011 (r223987) @@ -155,7 +155,6 @@ tre_match(const tre_tnfa_t *tnfa, const { reg_errcode_t status; int *tags = NULL, eo; - int ret; /* Check if we can cheat with a fixed string */ if (shortcut != NULL) From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 00:15:26 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78F0C106566B; Thu, 14 Jul 2011 00:15:26 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 694438FC12; Thu, 14 Jul 2011 00:15:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6E0FQrO005484; Thu, 14 Jul 2011 00:15:26 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6E0FQd7005482; Thu, 14 Jul 2011 00:15:26 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107140015.p6E0FQd7005482@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 14 Jul 2011 00:15:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223990 - user/gabor/tre-integration/tools/test/regex/tests X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 00:15:26 -0000 Author: gabor Date: Thu Jul 14 00:15:26 2011 New Revision: 223990 URL: http://svn.freebsd.org/changeset/base/223990 Log: - Add some test cases for basic POSIX regexes Modified: user/gabor/tre-integration/tools/test/regex/tests/basic.tests Modified: user/gabor/tre-integration/tools/test/regex/tests/basic.tests ============================================================================== --- user/gabor/tre-integration/tools/test/regex/tests/basic.tests Wed Jul 13 21:07:50 2011 (r223989) +++ user/gabor/tre-integration/tools/test/regex/tests/basic.tests Thu Jul 14 00:15:26 2011 (r223990) @@ -1,3 +1,20 @@ # $FreeBSD$ +# Fixed string and simple expressions foo;foobarfoobar;((0,3),(6,9)) +ba.;foobarfoobaz;((3,6),(9,12)) +ba[rz];foobarfoobaz;((3,6),(9,12)) +ba[rz];foobahfoobav;() +ba[^r];foobarfoobaz;((9,12)) + +# Collating elements +[[=a=]];bbbbabbbb;((4,5)) + +# Character classes +[[:alnum:]];__a____4_;((2,3),(7,8)) +[[:alpha:]];012345a67890b;((6,7),(12,13)) +[[:blank:]];0123456789abcdefghijklmnopqrstuvwxyz;() +[[:cntrl:]];012346789;() +[[:digit:]];abcdefgh1ijklmn2opqrstuv3wxyz4;((8,9),(15,16),(24,25),(29,30)) +#[[:graph:]];" 5 ";((5,6)) +[[:lower:]];ABCDEFg0123456hIJKL;((6,7),(14,15)) From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 03:09:49 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7C6D106564A; Thu, 14 Jul 2011 03:09:49 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8F1F28FC12; Thu, 14 Jul 2011 03:09:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6E39nLp010775; Thu, 14 Jul 2011 03:09:49 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6E39nw9010774; Thu, 14 Jul 2011 03:09:49 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107140309.p6E39nw9010774@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 14 Jul 2011 03:09:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223993 - user/jchandra/xlp-merge X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 03:09:49 -0000 Author: jchandra Date: Thu Jul 14 03:09:49 2011 New Revision: 223993 URL: http://svn.freebsd.org/changeset/base/223993 Log: Remove the old xlp-merge branch and start over Deleted: user/jchandra/xlp-merge/ From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 03:16:44 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83362106566B; Thu, 14 Jul 2011 03:16:44 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 228B18FC13; Thu, 14 Jul 2011 03:16:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6E3GiUd011173; Thu, 14 Jul 2011 03:16:44 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6E3GiXe011172; Thu, 14 Jul 2011 03:16:44 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107140316.p6E3GiXe011172@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 14 Jul 2011 03:16:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223994 - user/jchandra/mips-xlp-support X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 03:16:44 -0000 Author: jchandra Date: Thu Jul 14 03:16:43 2011 New Revision: 223994 URL: http://svn.freebsd.org/changeset/base/223994 Log: Branch to test addition of XLP SoC support to MIPS Added: - copied from r223993, head/ Directory Properties: user/jchandra/mips-xlp-support/ (props changed) From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 05:28:33 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8291F106566B; Thu, 14 Jul 2011 05:28:33 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 728428FC12; Thu, 14 Jul 2011 05:28:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6E5SXSN015092; Thu, 14 Jul 2011 05:28:33 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6E5SX6r015089; Thu, 14 Jul 2011 05:28:33 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107140528.p6E5SX6r015089@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 14 Jul 2011 05:28:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223997 - in user/jchandra/mips-xlp-support/sys: conf mips/mips X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 05:28:33 -0000 Author: jchandra Date: Thu Jul 14 05:28:33 2011 New Revision: 223997 URL: http://svn.freebsd.org/changeset/base/223997 Log: Support compiling MIPS elf trampoline with a different ABI. Allow changing the trampoline ABI with makeoptions, this will allow us to have a trampoline with a different ABI from the kernel. This is useful in cases where we have to boot a 64 bit kernel from a bootloader which supports only 32 bit or vice versa. Modified: user/jchandra/mips-xlp-support/sys/conf/Makefile.mips user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c Modified: user/jchandra/mips-xlp-support/sys/conf/Makefile.mips ============================================================================== --- user/jchandra/mips-xlp-support/sys/conf/Makefile.mips Thu Jul 14 05:19:28 2011 (r223996) +++ user/jchandra/mips-xlp-support/sys/conf/Makefile.mips Thu Jul 14 05:28:33 2011 (r223997) @@ -50,7 +50,13 @@ HACK_EXTRA_FLAGS=-shared # is extremely poor, as well as -mno-abicalls to force no ABI usage. CFLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS) HACK_EXTRA_FLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS) -TRAMP_EXTRA_FLAGS=${EXTRA_FLAGS} $(ARCH_FLAGS) +TRAMP_ARCH_FLAGS?=$(ARCH_FLAGS) +TRAMP_EXTRA_FLAGS=${EXTRA_FLAGS} ${TRAMP_ARCH_FLAGS} +.if ${MACHINE_ARCH:Mmips64*} != "" +TRAMP_ELFSIZE=64 +.else +TRAMP_ELFSIZE=32 +.endif # XXX hardcoded kernel entry point ASM_CFLAGS+=${CFLAGS} -D_LOCORE -DLOCORE @@ -64,11 +70,12 @@ ${KERNEL_KO}.tramp.bin: ${KERNEL_KO} $S/ sed -e s/${KERNLOADADDR}/${TRAMPLOADADDR}/ -e s/" + SIZEOF_HEADERS"// \ ${LDSCRIPT_NAME} > ${LDSCRIPT_NAME}.tramp.noheader ${CC} -O -nostdlib -I. -I$S ${TRAMP_EXTRA_FLAGS} ${TRAMP_LDFLAGS} -Xlinker \ - -T -Xlinker ${LDSCRIPT_NAME}.tramp.noheader \ - -DKERNNAME="\"${KERNEL_KO}.tmp\"" $S/$M/$M/elf_trampoline.c \ - $S/$M/$M/inckern.S -o ${KERNEL_KO}.tramp.noheader - ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \ - ${KERNEL_KO}.tramp.bin \ + -T -Xlinker ${LDSCRIPT_NAME}.tramp.noheader \ + -DKERNNAME="\"${KERNEL_KO}.tmp\"" -DELFSIZE=${TRAMP_ELFSIZE} \ + $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \ + -o ${KERNEL_KO}.tramp.elf + ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.elf \ + ${KERNEL_KO}.tramp.bin %BEFORE_DEPEND @@ -83,7 +90,7 @@ ${KERNEL_KO}.tramp.bin: ${KERNEL_KO} $S/ %CLEAN CLEAN+= ${LDSCRIPT_NAME} ${LDSCRIPT_NAME}.tramp.noheader \ - ${KERNEL_KO}.tramp.noheader ${KERNEL_KO}.tramp.bin + ${KERNEL_KO}.tramp.elf ${KERNEL_KO}.tramp.bin ${LDSCRIPT_NAME}: $S/conf/${LDSCRIPT_NAME} sed s/KERNLOADADDR/${KERNLOADADDR}/g $S/conf/${LDSCRIPT_NAME} \ Modified: user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c Thu Jul 14 05:19:28 2011 (r223996) +++ user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c Thu Jul 14 05:28:33 2011 (r223997) @@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef __mips_n64 +#if ELFSIZE == 64 #include #else #include @@ -96,7 +96,7 @@ bzero(void *addr, size_t count) void * load_kernel(void * kstart) { -#ifdef __mips_n64 +#if ELFSIZE == 64 Elf64_Ehdr *eh; Elf64_Phdr phdr[64] /* XXX */; Elf64_Shdr shdr[64] /* XXX */; @@ -107,17 +107,19 @@ load_kernel(void * kstart) #endif int i, j; void *entry_point; - vm_offset_t lastaddr = 0; + vm_offset_t loadend = 0; + intptr_t lastaddr; int symtabindex = -1; int symstrindex = -1; + Elf_Size tmp; -#ifdef __mips_n64 +#if ELFSIZE == 64 eh = (Elf64_Ehdr *)kstart; #else eh = (Elf32_Ehdr *)kstart; #endif - entry_point = (void*)eh->e_entry; - memcpy(phdr, (void *)(kstart + eh->e_phoff ), + entry_point = (void*)(intptr_t)(int)eh->e_entry; + memcpy(phdr, (void *)(kstart + eh->e_phoff), eh->e_phnum * sizeof(phdr[0])); memcpy(shdr, (void *)(kstart + eh->e_shoff), @@ -147,27 +149,31 @@ load_kernel(void * kstart) if (phdr[i].p_type != PT_LOAD) continue; - memcpy((void *)(phdr[i].p_vaddr), + memcpy((void *)(intptr_t)(int)(phdr[i].p_vaddr), (void*)(kstart + phdr[i].p_offset), phdr[i].p_filesz); /* Clean space from oversized segments, eg: bss. */ if (phdr[i].p_filesz < phdr[i].p_memsz) - bzero((void *)(phdr[i].p_vaddr + phdr[i].p_filesz), + bzero((void *)(intptr_t)(int)(phdr[i].p_vaddr + phdr[i].p_filesz), phdr[i].p_memsz - phdr[i].p_filesz); - if (lastaddr < phdr[i].p_vaddr + phdr[i].p_memsz) - lastaddr = phdr[i].p_vaddr + phdr[i].p_memsz; + if (loadend < phdr[i].p_vaddr + phdr[i].p_memsz) + loadend = phdr[i].p_vaddr + phdr[i].p_memsz; } /* Now grab the symbol tables. */ + lastaddr = (intptr_t)(int)loadend; if (symtabindex >= 0 && symstrindex >= 0) { - *(Elf_Size *)lastaddr = SYMTAB_MAGIC; + tmp = SYMTAB_MAGIC; + memcpy((void *)lastaddr, &tmp, sizeof(tmp)); lastaddr += sizeof(Elf_Size); - *(Elf_Size *)lastaddr = shdr[symtabindex].sh_size + + tmp = shdr[symtabindex].sh_size + shdr[symstrindex].sh_size + 2*sizeof(Elf_Size); + memcpy((void *)lastaddr, &tmp, sizeof(tmp)); lastaddr += sizeof(Elf_Size); /* .symtab size */ - *(Elf_Size *)lastaddr = shdr[symtabindex].sh_size; + tmp = shdr[symtabindex].sh_size; + memcpy((void *)lastaddr, &tmp, sizeof(tmp)); lastaddr += sizeof(shdr[symtabindex].sh_size); /* .symtab data */ memcpy((void*)lastaddr, @@ -176,16 +182,19 @@ load_kernel(void * kstart) lastaddr += shdr[symtabindex].sh_size; /* .strtab size */ - *(Elf_Size *)lastaddr = shdr[symstrindex].sh_size; + tmp = shdr[symstrindex].sh_size; + memcpy((void *)lastaddr, &tmp, sizeof(tmp)); lastaddr += sizeof(shdr[symstrindex].sh_size); /* .strtab data */ memcpy((void*)lastaddr, shdr[symstrindex].sh_offset + kstart, shdr[symstrindex].sh_size); - } else + } else { /* Do not take any chances */ - *(Elf_Size *)lastaddr = 0; + tmp = 0; + memcpy((void *)lastaddr, &tmp, sizeof(tmp)); + } return entry_point; } From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 06:27:50 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A206D1065670; Thu, 14 Jul 2011 06:27:50 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9308C8FC13; Thu, 14 Jul 2011 06:27:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6E6Rord016909; Thu, 14 Jul 2011 06:27:50 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6E6RoUt016907; Thu, 14 Jul 2011 06:27:50 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107140627.p6E6RoUt016907@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 14 Jul 2011 06:27:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223999 - user/jchandra/mips-xlp-support/sys/mips/mips X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 06:27:50 -0000 Author: jchandra Date: Thu Jul 14 06:27:50 2011 New Revision: 223999 URL: http://svn.freebsd.org/changeset/base/223999 Log: Make int to ptr conversion a macro. Modified: user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c Modified: user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c Thu Jul 14 05:49:35 2011 (r223998) +++ user/jchandra/mips-xlp-support/sys/mips/mips/elf_trampoline.c Thu Jul 14 06:27:50 2011 (r223999) @@ -90,6 +90,12 @@ bzero(void *addr, size_t count) } /* + * Convert number to pointer, truncate on 64->32 case, sign extend + * in 32->64 case + */ +#define mkptr(x) ((void *)(intptr_t)(int)(x)) + +/* * Relocate PT_LOAD segements of kernel ELF image to their respective * virtual addresses and return entry point */ @@ -118,7 +124,7 @@ load_kernel(void * kstart) #else eh = (Elf32_Ehdr *)kstart; #endif - entry_point = (void*)(intptr_t)(int)eh->e_entry; + entry_point = mkptr(eh->e_entry); memcpy(phdr, (void *)(kstart + eh->e_phoff), eh->e_phnum * sizeof(phdr[0])); @@ -149,12 +155,12 @@ load_kernel(void * kstart) if (phdr[i].p_type != PT_LOAD) continue; - memcpy((void *)(intptr_t)(int)(phdr[i].p_vaddr), + memcpy(mkptr(phdr[i].p_vaddr), (void*)(kstart + phdr[i].p_offset), phdr[i].p_filesz); /* Clean space from oversized segments, eg: bss. */ if (phdr[i].p_filesz < phdr[i].p_memsz) - bzero((void *)(intptr_t)(int)(phdr[i].p_vaddr + phdr[i].p_filesz), + bzero(mkptr(phdr[i].p_vaddr + phdr[i].p_filesz), phdr[i].p_memsz - phdr[i].p_filesz); if (loadend < phdr[i].p_vaddr + phdr[i].p_memsz) From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 07:19:30 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CE6A106564A; Thu, 14 Jul 2011 07:19:30 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F03F68FC0C; Thu, 14 Jul 2011 07:19:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6E7JTOj018408; Thu, 14 Jul 2011 07:19:29 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6E7JTQ6018402; Thu, 14 Jul 2011 07:19:29 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107140719.p6E7JTQ6018402@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 14 Jul 2011 07:19:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224000 - in user/jchandra/mips-xlp-support/sys/mips/nlm: . hal X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 07:19:30 -0000 Author: jchandra Date: Thu Jul 14 07:19:29 2011 New Revision: 224000 URL: http://svn.freebsd.org/changeset/base/224000 Log: Add XLP platform files. Processor, UART, PIC and Messaging Network code Added: user/jchandra/mips-xlp-support/sys/mips/nlm/ user/jchandra/mips-xlp-support/sys/mips/nlm/board.c user/jchandra/mips-xlp-support/sys/mips/nlm/board.h user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi.c user/jchandra/mips-xlp-support/sys/mips/nlm/clock.h user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp user/jchandra/mips-xlp-support/sys/mips/nlm/hal/ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/bridge.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop0.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cpucontrol.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/iomap.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mips-extns.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmio.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmu.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pic.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/sys.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/uart.h user/jchandra/mips-xlp-support/sys/mips/nlm/interrupt.h user/jchandra/mips-xlp-support/sys/mips/nlm/intr_machdep.c user/jchandra/mips-xlp-support/sys/mips/nlm/iodi.c user/jchandra/mips-xlp-support/sys/mips/nlm/mpreset.S user/jchandra/mips-xlp-support/sys/mips/nlm/msgring.h user/jchandra/mips-xlp-support/sys/mips/nlm/std.xlp user/jchandra/mips-xlp-support/sys/mips/nlm/tick.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_bus_xlp_iodi.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_mips_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/xlp.h user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c Added: user/jchandra/mips-xlp-support/sys/mips/nlm/board.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/board.c Thu Jul 14 07:19:29 2011 (r224000) @@ -0,0 +1,77 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +struct xlp_board_info xlp_board_info; + +int nlm_setup_xlp_board(void); + +/* + * All our knowledge of chip and board that cannot be detected by probing + * at run-time goes here + */ + +int +nlm_setup_xlp_board(void) +{ + struct xlp_board_info *boardp; + int node; + + /* start with a clean slate */ + boardp = &xlp_board_info; + memset(boardp, 0, sizeof(xlp_board_info)); + boardp->nodemask = 0x1; /* only node 0 */ + + for (node = 0; node < XLP_MAX_NODES; node++) { + if ((boardp->nodemask & (1 << node)) == 0) + continue; + } + return 0; +} + +int nlm_board_info_setup() +{ + nlm_setup_xlp_board(); + return 0; +} Added: user/jchandra/mips-xlp-support/sys/mips/nlm/board.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/board.h Thu Jul 14 07:19:29 2011 (r224000) @@ -0,0 +1,74 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#ifndef __NLM_BOARD_H__ +#define __NLM_BOARD_H__ + +#define XLP_NAE_NBLOCKS 5 +#define XLP_NAE_NPORTS 4 +#define XLP_I2C_MAXDEVICES 8 + +struct xlp_i2c_devinfo { + u_int addr; /* keep first, for i2c ivars to work */ + int bus; + char *device; +}; + +struct xlp_port_ivars { + int port; + int block; + int type; + int phy_addr; +}; + +struct xlp_block_ivars { + int block; + int type; + u_int portmask; + struct xlp_port_ivars port_ivars[XLP_NAE_NPORTS]; +}; + +struct xlp_nae_ivars { + int node; + u_int blockmask; + struct xlp_block_ivars block_ivars[XLP_NAE_NBLOCKS]; +}; + +struct xlp_board_info { + u_int nodemask; + struct xlp_node_info { + struct xlp_i2c_devinfo i2c_devs[XLP_I2C_MAXDEVICES]; + struct xlp_nae_ivars nae_ivars; + } nodes[XLP_MAX_NODES]; +}; + +extern struct xlp_board_info xlp_board_info; +int nlm_board_info_setup(void); + +#endif Added: user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi.c Thu Jul 14 07:19:29 2011 (r224000) @@ -0,0 +1,688 @@ +/* + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#include +__FBSDID("$FreeBSD: head/sys/mips/rmi/bus_space_rmi.c 204131 2010-02-20 16:32:33Z rrs $"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +static int +rmi_bus_space_map(void *t, bus_addr_t addr, + bus_size_t size, int flags, + bus_space_handle_t *bshp); + +static void +rmi_bus_space_unmap(void *t, bus_space_handle_t bsh, + bus_size_t size); + +static int +rmi_bus_space_subregion(void *t, + bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size, + bus_space_handle_t *nbshp); + +static u_int8_t +rmi_bus_space_read_1(void *t, + bus_space_handle_t handle, + bus_size_t offset); + +static u_int16_t +rmi_bus_space_read_2(void *t, + bus_space_handle_t handle, + bus_size_t offset); + +static u_int32_t +rmi_bus_space_read_4(void *t, + bus_space_handle_t handle, + bus_size_t offset); + +static void +rmi_bus_space_read_multi_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int8_t *addr, + size_t count); + +static void +rmi_bus_space_read_multi_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int16_t *addr, + size_t count); + +static void +rmi_bus_space_read_multi_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int32_t *addr, + size_t count); + +static void +rmi_bus_space_read_region_1(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int8_t *addr, + size_t count); + +static void +rmi_bus_space_read_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t *addr, + size_t count); + +static void +rmi_bus_space_read_region_4(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t *addr, + size_t count); + +static void +rmi_bus_space_write_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int8_t value); + +static void +rmi_bus_space_write_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int16_t value); + +static void +rmi_bus_space_write_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int32_t value); + +static void +rmi_bus_space_write_multi_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int8_t *addr, + size_t count); + +static void +rmi_bus_space_write_multi_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int16_t *addr, + size_t count); + +static void +rmi_bus_space_write_multi_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int32_t *addr, + size_t count); + +static void +rmi_bus_space_write_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int16_t *addr, + size_t count); + +static void +rmi_bus_space_write_region_4(void *t, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int32_t *addr, + size_t count); + + +static void +rmi_bus_space_set_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value, + size_t count); +static void +rmi_bus_space_set_region_4(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value, + size_t count); + +static void +rmi_bus_space_barrier(void *tag __unused, bus_space_handle_t bsh __unused, + bus_size_t offset __unused, bus_size_t len __unused, int flags); + +static void +rmi_bus_space_copy_region_2(void *t, + bus_space_handle_t bsh1, + bus_size_t off1, + bus_space_handle_t bsh2, + bus_size_t off2, size_t count); + +u_int8_t +rmi_bus_space_read_stream_1(void *t, bus_space_handle_t handle, + bus_size_t offset); + +static u_int16_t +rmi_bus_space_read_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset); + +static u_int32_t +rmi_bus_space_read_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset); +static void +rmi_bus_space_read_multi_stream_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int8_t *addr, + size_t count); + +static void +rmi_bus_space_read_multi_stream_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int16_t *addr, + size_t count); + +static void +rmi_bus_space_read_multi_stream_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int32_t *addr, + size_t count); + +void +rmi_bus_space_write_stream_1(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t value); +static void +rmi_bus_space_write_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int16_t value); + +static void +rmi_bus_space_write_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int32_t value); + +static void +rmi_bus_space_write_multi_stream_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int8_t *addr, + size_t count); +static void +rmi_bus_space_write_multi_stream_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int16_t *addr, + size_t count); + +static void +rmi_bus_space_write_multi_stream_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int32_t *addr, + size_t count); + +#define TODO() printf("XLP bus space: '%s' unimplemented\n", __func__) + +static struct bus_space local_rmi_bus_space = { + /* cookie */ + (void *)0, + + /* mapping/unmapping */ + rmi_bus_space_map, + rmi_bus_space_unmap, + rmi_bus_space_subregion, + + /* allocation/deallocation */ + NULL, + NULL, + + /* barrier */ + rmi_bus_space_barrier, + + /* read (single) */ + rmi_bus_space_read_1, + rmi_bus_space_read_2, + rmi_bus_space_read_4, + NULL, + + /* read multiple */ + rmi_bus_space_read_multi_1, + rmi_bus_space_read_multi_2, + rmi_bus_space_read_multi_4, + NULL, + + /* read region */ + rmi_bus_space_read_region_1, + rmi_bus_space_read_region_2, + rmi_bus_space_read_region_4, + NULL, + + /* write (single) */ + rmi_bus_space_write_1, + rmi_bus_space_write_2, + rmi_bus_space_write_4, + NULL, + + /* write multiple */ + rmi_bus_space_write_multi_1, + rmi_bus_space_write_multi_2, + rmi_bus_space_write_multi_4, + NULL, + + /* write region */ + NULL, + rmi_bus_space_write_region_2, + rmi_bus_space_write_region_4, + NULL, + + /* set multiple */ + NULL, + NULL, + NULL, + NULL, + + /* set region */ + NULL, + rmi_bus_space_set_region_2, + rmi_bus_space_set_region_4, + NULL, + + /* copy */ + NULL, + rmi_bus_space_copy_region_2, + NULL, + NULL, + + /* read (single) stream */ + rmi_bus_space_read_stream_1, + rmi_bus_space_read_stream_2, + rmi_bus_space_read_stream_4, + NULL, + + /* read multiple stream */ + rmi_bus_space_read_multi_stream_1, + rmi_bus_space_read_multi_stream_2, + rmi_bus_space_read_multi_stream_4, + NULL, + + /* read region stream */ + rmi_bus_space_read_region_1, + rmi_bus_space_read_region_2, + rmi_bus_space_read_region_4, + NULL, + + /* write (single) stream */ + rmi_bus_space_write_stream_1, + rmi_bus_space_write_stream_2, + rmi_bus_space_write_stream_4, + NULL, + + /* write multiple stream */ + rmi_bus_space_write_multi_stream_1, + rmi_bus_space_write_multi_stream_2, + rmi_bus_space_write_multi_stream_4, + NULL, + + /* write region stream */ + NULL, + rmi_bus_space_write_region_2, + rmi_bus_space_write_region_4, + NULL, +}; + +/* generic bus_space tag */ +bus_space_tag_t rmi_bus_space = &local_rmi_bus_space; + +/* + * Map a region of device bus space into CPU virtual address space. + */ +static int +rmi_bus_space_map(void *t __unused, bus_addr_t addr, + bus_size_t size __unused, int flags __unused, + bus_space_handle_t *bshp) +{ + + *bshp = addr; + return (0); +} + +/* + * Unmap a region of device bus space. + */ +static void +rmi_bus_space_unmap(void *t __unused, bus_space_handle_t bsh __unused, + bus_size_t size __unused) +{ +} + +/* + * Get a new handle for a subregion of an already-mapped area of bus space. + */ + +static int +rmi_bus_space_subregion(void *t __unused, bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size __unused, + bus_space_handle_t *nbshp) +{ + *nbshp = bsh + offset; + return (0); +} + +/* + * Read a 1, 2, 4, or 8 byte quantity from bus space + * described by tag/handle/offset. + */ + +static u_int8_t +rmi_bus_space_read_1(void *tag, bus_space_handle_t handle, + bus_size_t offset) +{ + return (u_int8_t) (*(volatile u_int32_t *)(handle + offset)); +} + +static u_int16_t +rmi_bus_space_read_2(void *tag, bus_space_handle_t handle, + bus_size_t offset) +{ + return (u_int16_t)(*(volatile u_int32_t *)(handle + offset)); +} + +static u_int32_t +rmi_bus_space_read_4(void *tag, bus_space_handle_t handle, + bus_size_t offset) +{ + return (*(volatile u_int32_t *)(handle + offset)); +} + + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle/offset and copy into buffer provided. + */ +static void +rmi_bus_space_read_multi_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int8_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_read_multi_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int16_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_read_multi_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int32_t *addr, size_t count) +{ + TODO(); +} + +/* + * Write the 1, 2, 4, or 8 byte value `value' to bus space + * described by tag/handle/offset. + */ + +static void +rmi_bus_space_write_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int8_t value) +{ + *(volatile u_int32_t *)(handle + offset) = (u_int32_t)value; +} + +static void +rmi_bus_space_write_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int16_t value) +{ + *(volatile u_int32_t *)(handle + offset) = (u_int32_t)value; +} + +static void +rmi_bus_space_write_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int32_t value) +{ + *(volatile u_int32_t *)(handle + offset) = value; +} + + +/* + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer + * provided to bus space described by tag/handle/offset. + */ + + +static void +rmi_bus_space_write_multi_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int8_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_write_multi_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int16_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_write_multi_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int32_t *addr, size_t count) +{ + TODO(); +} + +/* + * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle starting at `offset'. + */ + +static void +rmi_bus_space_set_region_2(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + + for (; count != 0; count--, addr += 2) + (*(volatile u_int32_t *)(addr)) = value; +} + +static void +rmi_bus_space_set_region_4(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + + for (; count != 0; count--, addr += 4) + (*(volatile u_int32_t *)(addr)) = value; +} + + +/* + * Copy `count' 1, 2, 4, or 8 byte values from bus space starting + * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. + */ +static void +rmi_bus_space_copy_region_2(void *t, bus_space_handle_t bsh1, + bus_size_t off1, bus_space_handle_t bsh2, + bus_size_t off2, size_t count) +{ + printf("bus_space_copy_region_2 - unimplemented\n"); +} + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle/offset and copy into buffer provided. + */ + +u_int8_t +rmi_bus_space_read_stream_1(void *t, bus_space_handle_t handle, + bus_size_t offset) +{ + + return *((volatile u_int8_t *)(handle + offset)); +} + + +static u_int16_t +rmi_bus_space_read_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset) +{ + return *(volatile u_int16_t *)(handle + offset); +} + + +static u_int32_t +rmi_bus_space_read_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset) +{ + return (*(volatile u_int32_t *)(handle + offset)); +} + + +static void +rmi_bus_space_read_multi_stream_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int8_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_read_multi_stream_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int16_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_read_multi_stream_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int32_t *addr, size_t count) +{ + TODO(); +} + + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle and starting at `offset' and copy into + * buffer provided. + */ +void +rmi_bus_space_read_region_1(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t *addr, size_t count) +{ + TODO(); +} + +void +rmi_bus_space_read_region_2(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t *addr, size_t count) +{ + TODO(); +} + +void +rmi_bus_space_read_region_4(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t *addr, size_t count) +{ + bus_addr_t baddr = bsh + offset; + + while (count--) { + *addr++ = (*(volatile u_int32_t *)(baddr)); + baddr += 4; + } +} + +void +rmi_bus_space_write_stream_1(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int8_t value) +{ + TODO(); +} + + +static void +rmi_bus_space_write_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int16_t value) +{ + TODO(); +} + + +static void +rmi_bus_space_write_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int32_t value) +{ + TODO(); +} + + +static void +rmi_bus_space_write_multi_stream_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int8_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_write_multi_stream_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int16_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_write_multi_stream_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int32_t *addr, size_t count) +{ + TODO(); +} + +void +rmi_bus_space_write_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int16_t *addr, + size_t count) +{ + TODO(); +} + +void +rmi_bus_space_write_region_4(void *t, bus_space_handle_t bsh, + bus_size_t offset, const u_int32_t *addr, size_t count) +{ + TODO(); +} + +static void +rmi_bus_space_barrier(void *tag __unused, bus_space_handle_t bsh __unused, + bus_size_t offset __unused, bus_size_t len __unused, int flags) +{ +} Added: user/jchandra/mips-xlp-support/sys/mips/nlm/clock.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/clock.h Thu Jul 14 07:19:29 2011 (r224000) @@ -0,0 +1,40 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#ifndef _RMI_CLOCK_H_ +#define _RMI_CLOCK_H_ + +#define XLP_PIC_HZ 133000000U +#define XLP_CPU_HZ (nlm_cpu_frequency) + +void count_compare_clockhandler(struct trapframe *); +void pic_hardclockhandler(struct trapframe *); +void pic_timecounthandler(struct trapframe *); + +#endif /* _RMI_CLOCK_H_ */ Added: user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c Thu Jul 14 07:19:29 2011 (r224000) @@ -0,0 +1,451 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#include +__FBSDID("$FreeBSD: head/sys/mips/rmi/fmn.c 213474 2010-10-06 08:09:39Z jchandra $"); +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define MSGRNG_NSTATIONS 1024 +/* + * Keep track of our message ring handler threads, each core has a + * different message station. Ideally we will need to start a few + * message handling threads every core, and wake them up depending on + * load + */ +struct msgring_thread { + struct thread *thread; /* msgring handler threads */ + int needed; /* thread needs to wake up */ +}; +static struct msgring_thread msgring_threads[XLP_MAX_CORES * XLP_MAX_THREADS]; +static struct proc *msgring_proc; /* all threads are under a proc */ + +/* + * The device drivers can register a handler for the the messages sent + * from a station (corresponding to the device). + */ +struct tx_stn_handler { + msgring_handler action; + void *arg; +}; +static struct tx_stn_handler msgmap[MSGRNG_NSTATIONS]; +static struct mtx msgmap_lock; +uint64_t xlp_cms_base; +uint32_t xlp_msg_thread_mask; +static int xlp_msg_threads_per_core = 3; /* Make tunable */ + +static void create_msgring_thread(int hwtid); +static int msgring_process_fast_intr(void *arg); +/* + * Boot time init, called only once + */ +void +xlp_msgring_config(void) +{ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 10:09:59 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FC451065672; Thu, 14 Jul 2011 10:09:59 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1EFA88FC1C; Thu, 14 Jul 2011 10:09:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EA9xo7023617; Thu, 14 Jul 2011 10:09:59 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EA9xtZ023609; Thu, 14 Jul 2011 10:09:59 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107141009.p6EA9xtZ023609@svn.freebsd.org> From: Hiroki Sato Date: Thu, 14 Jul 2011 10:09:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224006 - in user/hrs/ipv6/usr.sbin: . rtadvctl rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 10:09:59 -0000 Author: hrs Date: Thu Jul 14 10:09:58 2011 New Revision: 224006 URL: http://svn.freebsd.org/changeset/base/224006 Log: - Refactoring the interface list. It now supports dynamically added/removed interfaces in a more consistent manner and reloading the configuration file. - Add initial support for control socket. RA information in the daemon can be obtained by rtadvctl(8) instead of SIGUSR1 in a similar manner to ifconfig(8). The information dump has been removed in favor of it. (reload the configuration file) # rtadvctl reload (show RA messages being sent on each interfaces) # rtadvctl show em0: flags= status= mtu 1280 DefaultLifetime: 30m MinAdvInterval/MaxAdvInterval: 3m20s/3m20s AdvLinkMTU: , Flags: O, Preference: medium ReachableTime: 0s, RetransTimer: 0s, CurHopLimit: 64 AdvIfPrefixes: yes (show RA messages being sent only on em0) # rtadvctl show em0 (rtadvctl -v show provides additional information) # rtadvctl -v show em0 em0: flags= status= mtu 1280 DefaultLifetime: 30m MinAdvInterval/MaxAdvInterval: 3m20s/3m20s AdvLinkMTU: , Flags: O, Preference: medium ReachableTime: 0s, RetransTimer: 0s, CurHopLimit: 64 AdvIfPrefixes: yes Prefixes (1): 2001:db8:1::/64 (CONFIG, vltime=30d, pltime=7d, flags=LA) RDNSS entries: 2001:db8:1::128 (ltime=2m40s) (stop rtadvd) # rtadvctl shutdown A remaining issue when reloading the configuration file is that during that period rtadvd cannot communicate with rtadvctl due to some additional RA sending for graceful shutdown. This will be fixed later. Added: user/hrs/ipv6/usr.sbin/rtadvctl/ user/hrs/ipv6/usr.sbin/rtadvctl/Makefile user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c user/hrs/ipv6/usr.sbin/rtadvd/control.c user/hrs/ipv6/usr.sbin/rtadvd/control.h user/hrs/ipv6/usr.sbin/rtadvd/control_client.c user/hrs/ipv6/usr.sbin/rtadvd/control_client.h user/hrs/ipv6/usr.sbin/rtadvd/control_server.c user/hrs/ipv6/usr.sbin/rtadvd/control_server.h user/hrs/ipv6/usr.sbin/rtadvd/timer_subr.c user/hrs/ipv6/usr.sbin/rtadvd/timer_subr.h Deleted: user/hrs/ipv6/usr.sbin/rtadvd/dump.c user/hrs/ipv6/usr.sbin/rtadvd/dump.h Modified: user/hrs/ipv6/usr.sbin/Makefile user/hrs/ipv6/usr.sbin/rtadvd/Makefile user/hrs/ipv6/usr.sbin/rtadvd/config.c user/hrs/ipv6/usr.sbin/rtadvd/config.h user/hrs/ipv6/usr.sbin/rtadvd/if.c user/hrs/ipv6/usr.sbin/rtadvd/if.h user/hrs/ipv6/usr.sbin/rtadvd/pathnames.h user/hrs/ipv6/usr.sbin/rtadvd/rrenum.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.8 user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h user/hrs/ipv6/usr.sbin/rtadvd/timer.c user/hrs/ipv6/usr.sbin/rtadvd/timer.h Modified: user/hrs/ipv6/usr.sbin/Makefile ============================================================================== --- user/hrs/ipv6/usr.sbin/Makefile Thu Jul 14 10:05:28 2011 (r224005) +++ user/hrs/ipv6/usr.sbin/Makefile Thu Jul 14 10:09:58 2011 (r224006) @@ -174,6 +174,7 @@ SUBDIR+= rip6query SUBDIR+= route6d SUBDIR+= rrenumd SUBDIR+= rtadvd +SUBDIR+= rtadvctl SUBDIR+= rtsold SUBDIR+= traceroute6 .endif Added: user/hrs/ipv6/usr.sbin/rtadvctl/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/ipv6/usr.sbin/rtadvctl/Makefile Thu Jul 14 10:09:58 2011 (r224006) @@ -0,0 +1,13 @@ +# $FreeBSD$ +# +.PATH: ${.CURDIR}/../rtadvd + +PROG= rtadvctl +MAN= rtadvctl.8 + +SRCS= rtadvctl.c control.c control_client.c if.c timer_subr.c + +CFLAGS+= -DROUTEINFO -I${.CURDIR} -I${.CURDIR}/../rtadvd +WARNS?= 3 + +.include Added: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Thu Jul 14 10:09:58 2011 (r224006) @@ -0,0 +1,92 @@ +.\" Copyright (C) 2011 Hiroki Sato . +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS +.\" IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +.\" PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd July 14, 2011 +.Dt RTADVCTL 8 +.Os +.Sh NAME +.Nm rtadvctl +.Nd control program for +.Xr rtadvd 8 daemon +.Sh SYNOPSIS +.Nm +.Op Fl v +.Ar subcommand +.Op Ar interface ... +.Sh DESCRIPTION +.Nm +is a utility that communicates +.Xr rtadvd 8 +daemon and displays information on Router Advertisement messages being +sent on each interfaces. +.Pp +This utility provides several options and subcommands. +The options are as follows: +.Bl -tag -width indent +.\" +.It Fl v +Increase verbose level. When specified once, the +.Nm +utility shows additional information on prefixes, RDNSS, and DNSSL +options. +When twice, it shows information on inactive interfaces and +some statistics. +.El +.Pp +The subcommands are as follows: +.Bl -tag -width indent +.\" +.It reload +Specifies reloading the configuration file. +.It shutdown +Makes +.Xr rtadvd 8 +daemon shut down immediately. +.It show Op interfaces... +Displays information on Router Advertisement messages being sent +on each interfaces. +.Sh SEE ALSO +.Xr rtadv 8 , +.Xr rtadvd.conf 5 +.Sh HISTORY +The +.Nm +command first appeared in +.Fx 9.0 . +.Sh BUGS +The +.Xr rtadvd 8 +daemon stops responding to +.Nm +for a while just after reloading the configuration file by the reload +subcommand. +This is because in the current implementation it cannot communicate +with +.Nm +during sending some additional RAs for graceful transition from one +configuration to another. +It will take at most nine seconds for each interface. Added: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Thu Jul 14 10:09:58 2011 (r224006) @@ -0,0 +1,833 @@ +/*- + * Copyright (C) 2011 Hiroki Sato + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pathnames.h" +#include "rtadvd.h" +#include "if.h" +#include "timer_subr.h" +#include "control.h" +#include "control_client.h" + +#define RA_IFSTATUS_INACTIVE 0 +#define RA_IFSTATUS_RA_RECV 1 +#define RA_IFSTATUS_RA_SEND 2 + +static int vflag = LOG_ERR; + +static void usage(void); + +static int action_propset(char *); +static int action_propget(char *, struct ctrl_msg_pl *); +static int action_plgeneric(int, char *, char *); + +static int action_enable(int, char **); +static int action_disable(int, char **); +static int action_reload(int, char **); +static int action_echo(int, char **); +static int action_version(int, char **); +static int action_shutdown(int, char **); + +static int action_show(int, char **); +static int action_show_prefix(struct prefix *); +#ifdef ROUTEINFO +static int action_show_rtinfo(struct rtinfo *); +#endif +static int action_show_rdnss(void *); +static int action_show_dnssl(void *); + +static int csock_client_open(struct sockinfo *); +static size_t dname_labeldec(char *, size_t, const char *); +static void mysyslog(int, const char *, ...); + +static const char *rtpref_str[] = { + "medium", /* 00 */ + "high", /* 01 */ + "rsv", /* 10 */ + "low" /* 11 */ +}; + +static struct dispatch_table { + const char *dt_comm; + int (*dt_act)(int, char **); +} dtable[] = { + { "show", action_show }, + { "reload", action_reload }, + { "shutdown", action_shutdown }, + { NULL, NULL }, + { "enable", action_enable }, + { "disable", action_disable }, + { "echo", action_echo }, + { "version", action_version }, + { NULL, NULL }, +}; + +static void +mysyslog(int priority, const char * restrict fmt, ...) +{ + va_list ap; + + if (vflag >= priority) { + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); + } +} + +static void +usage(void) +{ + int i; + + for (i = 0; (size_t)i < sizeof(dtable)/sizeof(dtable[0]); i++) { + if (dtable[i].dt_comm == NULL) + break; + printf("%s\n", dtable[i].dt_comm); + } + + exit(1); +} + +int +main(int argc, char *argv[]) +{ + int i; + int ch; + int (*action)(int, char **) = NULL; + int error; + + while ((ch = getopt(argc, argv, "Dv")) != -1) { + switch (ch) { + case 'D': + vflag = LOG_DEBUG; + break; + case 'v': + vflag++; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc == 0) + usage(); + + for (i = 0; (size_t)i < sizeof(dtable)/sizeof(dtable[0]); i++) { + if (dtable[i].dt_comm == NULL || + strcmp(dtable[i].dt_comm, argv[0]) == 0) { + action = dtable[i].dt_act; + break; + } + } + + if (action != NULL) { + error = (dtable[i].dt_act)(--argc, ++argv); + if (error) + fprintf(stderr, "%s failed.\n", dtable[i].dt_comm); + } else + usage(); + + return (error); +} + +static int +csock_client_open(struct sockinfo *s) +{ + struct sockaddr_un sun; + + if ((s->si_fd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) + err(1, "cannot open control socket."); + + memset(&sun, 0, sizeof(sun)); + sun.sun_family = AF_UNIX; + sun.sun_len = sizeof(sun); + strlcpy(sun.sun_path, s->si_name, sizeof(sun.sun_path)); + + if (connect(s->si_fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) + err(1, "connect: %s", s->si_name); + + mysyslog(LOG_DEBUG, + "<%s> connected to %s", __func__, sun.sun_path); + + return (0); +} + +static int +action_plgeneric(int action, char *plstr, char *buf) +{ + struct ctrl_msg_hdr *cm; + struct ctrl_msg_pl cp; + struct sockinfo *s; + char *msg; + char *p; + char *q; + + s = &ctrlsock; + csock_client_open(s); + + cm = (struct ctrl_msg_hdr *)buf; + msg = (char *)buf + sizeof(*cm); + + cm->cm_version = CM_VERSION; + cm->cm_type = action; + cm->cm_len = sizeof(*cm); + + if (plstr != NULL) { + memset(&cp, 0, sizeof(cp)); + p = strchr(plstr, ':'); + q = strchr(plstr, '='); + if (p != NULL && q != NULL && p > q) + return (1); + + if (p == NULL) { /* No : */ + cp.cp_ifname = NULL; + cp.cp_key = plstr; + } else if (p == plstr) { /* empty */ + cp.cp_ifname = NULL; + cp.cp_key = plstr + 1; + } else { + *p++ = '\0'; + cp.cp_ifname = plstr; + cp.cp_key = p; + } + if (q == NULL) + cp.cp_val = NULL; + else { + *q++ = '\0'; + cp.cp_val = q; + } + cm->cm_len += cmsg_pl2bin(msg, &cp); + + mysyslog(LOG_DEBUG, "<%s> key=%s, val_len=%d, ifname=%s", + __func__,cp.cp_key, cp.cp_val_len, cp.cp_ifname); + } + + return (cmsg_handler_client(s->si_fd, CM_STATE_MSG_DISPATCH, buf)); +} + +static int +action_propget(char *argv, struct ctrl_msg_pl *cp) +{ + int error; + struct ctrl_msg_hdr *cm; + char buf[CM_MSG_MAXLEN]; + char *msg; + + memset(cp, 0, sizeof(*cp)); + cm = (struct ctrl_msg_hdr *)buf; + msg = (char *)buf + sizeof(*cm); + + error = action_plgeneric(CM_TYPE_REQ_GET_PROP, argv, buf); + if (error || cm->cm_len <= sizeof(*cm)) + return (1); + + cmsg_bin2pl(msg, cp); + mysyslog(LOG_DEBUG, "<%s> type=%d, len=%d", + __func__, cm->cm_type, cm->cm_len); + mysyslog(LOG_DEBUG, "<%s> key=%s, val_len=%d, ifname=%s", + __func__,cp->cp_key, cp->cp_val_len, cp->cp_ifname); + + return (0); +} + +static int +action_propset(char *argv) +{ + char buf[CM_MSG_MAXLEN]; + + return (action_plgeneric(CM_TYPE_REQ_SET_PROP, argv, buf)); +} + +/* XXX */ +static int +action_enable(int argc, char **argv) +{ + argc = argc; + argv = argv; + + return (0); +} + +/* XXX */ +static int +action_disable(int argc, char **argv) +{ + argc = argc; + argv = argv; + + return (0); +} + +static int +action_reload(int argc __unused, char **argv __unused) +{ + char *action_argv; + + action_argv = strdup("reload"); + return(action_propset(action_argv)); +} + +static int +action_echo(int argc __unused, char **argv __unused) +{ + char *action_argv; + + action_argv = strdup("echo"); + return(action_propset(action_argv)); +} + +static int +action_shutdown(int argc __unused, char **argv __unused) +{ + char *action_argv; + + action_argv = strdup("shutdown"); + return(action_propset(action_argv)); +} + +/* XXX */ +static int +action_version(int argc __unused, char **argv __unused) +{ + char *action_argv; + struct ctrl_msg_pl cp; + int error; + + action_argv = strdup(":version="); + error = action_propget(action_argv, &cp); + if (error) + return (error); + + printf("version=%s\n", cp.cp_val); + return (0); +} + +static int +action_show(int argc, char **argv) +{ + char *action_argv; + char argv_ifilist[sizeof(":ifilist=")] = ":ifilist="; + char argv_ifi[IFNAMSIZ + sizeof(":ifi=")]; + char argv_rai[IFNAMSIZ + sizeof(":rai=")]; +#ifdef ROUTEINFO + char argv_rti[IFNAMSIZ + sizeof(":rti=")]; +#endif + char argv_pfx[IFNAMSIZ + sizeof(":pfx=")]; + char argv_rdnss[IFNAMSIZ + sizeof(":rdnss=")]; + char argv_dnssl[IFNAMSIZ + sizeof(":dnssl=")]; + char ssbuf[SSBUFLEN]; + + struct ctrl_msg_pl cp; + struct ifinfo *ifi; + TAILQ_HEAD(, ifinfo) ifl = TAILQ_HEAD_INITIALIZER(ifl); + char *endp; + char *p; + int error; + int i; + int len; + + if (argc == 0) { + action_argv = argv_ifilist; + error = action_propget(action_argv, &cp); + if (error) + return (error); + + p = cp.cp_val; + endp = p + cp.cp_val_len; + while (p < endp) { + ifi = malloc(sizeof(*ifi)); + if (ifi == NULL) + exit(1); + memset(ifi, 0, sizeof(*ifi)); + + strcpy(ifi->ifi_ifname, p); + ifi->ifi_ifindex = if_nametoindex(ifi->ifi_ifname); + TAILQ_INSERT_TAIL(&ifl, ifi, ifi_next); + p += strlen(ifi->ifi_ifname) + 1; + } + } else { + for (i = 0; i < argc; i++) { + ifi = malloc(sizeof(*ifi)); + if (ifi == NULL) + exit(1); + memset(ifi, 0, sizeof(*ifi)); + + strcpy(ifi->ifi_ifname, argv[i]); + ifi->ifi_ifindex = if_nametoindex(ifi->ifi_ifname); + if (ifi->ifi_ifindex == 0) + exit(1); + TAILQ_INSERT_TAIL(&ifl, ifi, ifi_next); + } + } + + TAILQ_FOREACH(ifi, &ifl, ifi_next) { + struct ifinfo *ifi_s; + struct rainfo *rai; +#ifdef ROUTEINFO + struct rtinfo *rti; +#endif + struct prefix *pfx; + int c; + int ra_ifstatus; + + sprintf(argv_ifi, "%s:ifi=", ifi->ifi_ifname); + action_argv = argv_ifi; + error = action_propget(action_argv, &cp); + if (error) + return (error); + ifi_s = (struct ifinfo *)cp.cp_val; + + if (!(ifi_s->ifi_persist) && vflag < LOG_NOTICE) + continue; + + printf("%s: flags=<", ifi->ifi_ifname); + + /* + * RA_RECV = UP + CONFIGURED + ACCEPT_RTADV + * RA_SEND = UP + CONFIGURED + IPV6FORWARDING + */ + + c = 0; + if (ifi_s->ifi_ifindex == 0) + c += printf("NONEXISTENT"); + else + c += printf("%s", (ifi_s->ifi_flags & IFF_UP) ? + "UP" : "DOWN"); + if (ifi_s->ifi_state == IFI_STATE_CONFIGURED) + c += printf("%s%s", (c) ? "," : "", "CONFIGURED"); + + if (ifi_s->ifi_persist) + c += printf("%s%s", (c) ? "," : "", "PERSIST"); + printf(">"); + + ra_ifstatus = RA_IFSTATUS_INACTIVE; + if ((ifi_s->ifi_flags & IFF_UP) && + (ifi_s->ifi_state == IFI_STATE_CONFIGURED)) { + if (ifi_s->ifi_nd_flags & ND6_IFF_ACCEPT_RTADV) + ra_ifstatus = RA_IFSTATUS_RA_RECV; + else if (getinet6sysctl(IPV6CTL_FORWARDING)) + ra_ifstatus = RA_IFSTATUS_RA_SEND; + else + ra_ifstatus = RA_IFSTATUS_INACTIVE; + } + + c = 0; + printf(" status=<"); + if (ra_ifstatus == RA_IFSTATUS_INACTIVE) + printf("%s%s", (c) ? "," : "", "INACTIVE"); + else if (ra_ifstatus == RA_IFSTATUS_RA_RECV) + printf("%s%s", (c) ? "," : "", "RA_RECV"); + else if (ra_ifstatus == RA_IFSTATUS_RA_SEND) + printf("%s%s", (c) ? "," : "", "RA_SEND"); + printf("> "); + + if (ifi_s->ifi_state != IFI_STATE_CONFIGURED) { + printf("\n"); + continue; + } + + printf("mtu %d\n", ifi_s->ifi_phymtu); + + sprintf(argv_rai, "%s:rai=", ifi->ifi_ifname); + action_argv = argv_rai; + + error = action_propget(action_argv, &cp); + if (error) + continue; + + rai = (struct rainfo *)cp.cp_val; + + printf("\tDefaultLifetime: %s", + sec2str(rai->rai_lifetime, ssbuf)); + if (ra_ifstatus != RA_IFSTATUS_RA_SEND && + rai->rai_lifetime == 0) + printf(" (RAs will be sent with zero lifetime)"); + + printf("\n"); + + printf("\tMinAdvInterval/MaxAdvInterval: %s/%s\n", + sec2str(rai->rai_mininterval, ssbuf), + sec2str(rai->rai_maxinterval, ssbuf)); + if (rai->rai_linkmtu) + printf("\tAdvLinkMTU: %d", rai->rai_linkmtu); + else + printf("\tAdvLinkMTU: "); + + printf(", "); + + printf("Flags: "); + if (rai->rai_managedflg || rai->rai_otherflg) { + printf("%s", rai->rai_managedflg ? "M" : ""); + printf("%s", rai->rai_otherflg ? "O" : ""); + } else + printf(""); + + printf(", "); + + printf("Preference: %s\n", + rtpref_str[(rai->rai_rtpref >> 3) & 0xff]); + + printf("\t" + "ReachableTime: %s, " + "RetransTimer: %s, " + "CurHopLimit: %d\n", + sec2str(rai->rai_reachabletime, ssbuf), + sec2str(rai->rai_retranstimer, ssbuf), + rai->rai_hoplimit); + printf("\tAdvIfPrefixes: %s\n", + rai->rai_advifprefix ? "yes" : "no"); + if (rai->rai_clockskew) + printf("\tClock skew: %ldsec\n", + rai->rai_clockskew); + + if (vflag < LOG_WARNING) + continue; + +#ifdef ROUTEINFO + /* route information */ + sprintf(argv_rti, "%s:rti=", ifi->ifi_ifname); + action_argv = argv_rti; + error = action_propget(action_argv, &cp); + if (error) + return (error); + + rti = (struct rtinfo *)cp.cp_val; + len = cp.cp_val_len / sizeof(*rti); + if (len > 0) { + printf("\tRoute Info:\n"); + + for (i = 0; i < len; i++) + action_show_rtinfo(&rti[i]); + } +#endif + /* prefix information */ + sprintf(argv_pfx, "%s:pfx=", ifi->ifi_ifname); + action_argv = argv_pfx; + + error = action_propget(action_argv, &cp); + if (error) + continue; + + pfx = (struct prefix *)cp.cp_val; + len = cp.cp_val_len / sizeof(*pfx); + + if (len > 0) { + printf("\tPrefixes (%d):\n", len); + + for (i = 0; i < len; i++) + action_show_prefix(&pfx[i]); + } + + /* RDNSS information */ + sprintf(argv_rdnss, "%s:rdnss=", ifi->ifi_ifname); + action_argv = argv_rdnss; + + error = action_propget(action_argv, &cp); + if (error) + continue; + + len = *((u_int16_t *)cp.cp_val); + + if (len > 0) { + printf("\tRDNSS entries:\n"); + action_show_rdnss(cp.cp_val); + } + + /* DNSSL information */ + sprintf(argv_dnssl, "%s:dnssl=", ifi->ifi_ifname); + action_argv = argv_dnssl; + + error = action_propget(action_argv, &cp); + if (error) + continue; + + len = *((u_int16_t *)cp.cp_val); + + if (len > 0) { + printf("\tDNSSL entries:\n"); + action_show_dnssl(cp.cp_val); + } + + if (vflag < LOG_NOTICE) + continue; + + printf("\n"); + + printf("\tLast RA sent: %s", + (rai->rai_lastsent.tv_sec == 0) ? "never\n" : + ctime((time_t *)&rai->rai_lastsent.tv_sec)); + printf("\tRA initcounts/waits: %d/%d\n", + rai->rai_initcounter, + rai->rai_waiting); + printf("\tRA out/in/inconsistent: %llu/%llu/%llu\n", + ifi_s->ifi_raoutput, + ifi_s->ifi_rainput, + ifi_s->ifi_rainconsistent); + printf("\tRS in: %llu\n", + ifi_s->ifi_rsinput); + + printf("\n"); + + printf("\tReceived RAs:\n"); + } + + return (0); +} + +#ifdef ROUTEINFO +static int +action_show_rtinfo(struct rtinfo *rti) +{ + char ntopbuf[INET6_ADDRSTRLEN]; + char ssbuf[SSBUFLEN]; + + printf("\t %s/%d (pref: %s, ltime: %s)\n", + inet_ntop(AF_INET6, &rti->rti_prefix, + ntopbuf, sizeof(ntopbuf)), + rti->rti_prefixlen, + rtpref_str[0xff & (rti->rti_rtpref >> 3)], + (rti->rti_ltime == ND6_INFINITE_LIFETIME) ? + "infinity" : sec2str(rti->rti_ltime, ssbuf)); + + return (0); +} +#endif + +static int +action_show_prefix(struct prefix *pfx) +{ + char ntopbuf[INET6_ADDRSTRLEN]; + char ssbuf[SSBUFLEN]; + struct timeval now; + + gettimeofday(&now, NULL); + printf("\t %s/%d", inet_ntop(AF_INET6, &pfx->pfx_prefix, + ntopbuf, sizeof(ntopbuf)), pfx->pfx_prefixlen); + + printf(" ("); + switch (pfx->pfx_origin) { + case PREFIX_FROM_KERNEL: + printf("KERNEL"); + break; + case PREFIX_FROM_CONFIG: + printf("CONFIG"); + break; + case PREFIX_FROM_DYNAMIC: + printf("DYNAMIC"); + break; + } + + printf(","); + + printf(" vltime=%s", + (pfx->pfx_validlifetime == ND6_INFINITE_LIFETIME) ? + "infinity" : sec2str(pfx->pfx_validlifetime, ssbuf)); + + if (pfx->pfx_vltimeexpire > 0) + printf("(expire: %s)", + ((long)pfx->pfx_vltimeexpire > now.tv_sec) ? + sec2str(pfx->pfx_vltimeexpire - now.tv_sec, ssbuf) : + "0"); + + printf(","); + + printf(" pltime=%s", + (pfx->pfx_preflifetime == ND6_INFINITE_LIFETIME) ? + "infinity" : sec2str(pfx->pfx_preflifetime, ssbuf)); + + if (pfx->pfx_pltimeexpire > 0) + printf("(expire %s)", + ((long)pfx->pfx_pltimeexpire > now.tv_sec) ? + sec2str(pfx->pfx_pltimeexpire - now.tv_sec, ssbuf) : + "0"); + + printf(","); + + printf(" flags="); + if (pfx->pfx_onlinkflg || pfx->pfx_autoconfflg) { + printf("%s", pfx->pfx_onlinkflg ? "L" : ""); + printf("%s", pfx->pfx_autoconfflg ? "A" : ""); + } else + printf(""); + + if (pfx->pfx_timer) { + struct timeval *rest; + + rest = rtadvd_timer_rest(pfx->pfx_timer); + if (rest) { /* XXX: what if not? */ + printf(" expire=%s", sec2str(rest->tv_sec, ssbuf)); + } + } + + printf(")\n"); + + return (0); +} + +static int +action_show_rdnss(void *msg) +{ + struct rdnss *rdn; + struct rdnss_addr *rda; + u_int16_t *rdn_cnt; + u_int16_t *rda_cnt; + int i; + int j; + char *p; + u_int32_t ltime; + char ntopbuf[INET6_ADDRSTRLEN]; + char ssbuf[SSBUFLEN]; + + p = msg; + rdn_cnt = (u_int16_t *)p; + p += sizeof(*rdn_cnt); + + if (*rdn_cnt > 0) { + for (i = 0; i < *rdn_cnt; i++) { + rdn = (struct rdnss *)p; + ltime = rdn->rd_ltime; + p += sizeof(*rdn); + + rda_cnt = (u_int16_t *)p; + p += sizeof(*rda_cnt); + if (*rda_cnt > 0) + for (j = 0; j < *rda_cnt; j++) { + rda = (struct rdnss_addr *)p; + printf("\t %s (ltime=%s)\n", + inet_ntop(AF_INET6, + &rda->ra_dns, + ntopbuf, + sizeof(ntopbuf)), + sec2str(ltime, ssbuf)); + p += sizeof(*rda); + } + } + } + + return (0); +} + +static int +action_show_dnssl(void *msg) +{ + struct dnssl *dns; + struct dnssl_addr *dna; + u_int16_t *dns_cnt; + u_int16_t *dna_cnt; + int i; + int j; + char *p; + u_int32_t ltime; + char hbuf[NI_MAXHOST]; + char ssbuf[SSBUFLEN]; + + p = msg; + dns_cnt = (u_int16_t *)p; + p += sizeof(*dns_cnt); + + if (*dns_cnt > 0) { + for (i = 0; i < *dns_cnt; i++) { + dns = (struct dnssl *)p; + ltime = dns->dn_ltime; + p += sizeof(*dns); + + dna_cnt = (u_int16_t *)p; + p += sizeof(*dna_cnt); + if (*dna_cnt > 0) + for (j = 0; j < *dna_cnt; j++) { + dna = (struct dnssl_addr *)p; + dname_labeldec(hbuf, sizeof(hbuf), + dna->da_dom); + printf("\t %s (ltime=%s)\n", + hbuf, sec2str(ltime, ssbuf)); + p += sizeof(*dna); + } + } + } + + return (0); +} + +/* Decode domain name label encoding in RFC 1035 Section 3.1 */ +static size_t +dname_labeldec(char *dst, size_t dlen, const char *src) +{ + size_t len; + const char *src_origin; + const char *src_last; + const char *dst_origin; + + src_origin = src; + src_last = strchr(src, '\0'); + dst_origin = dst; + memset(dst, '\0', dlen); + while (src && (len = (uint8_t)(*src++) & 0x3f) && + (src + len) <= src_last) { + if (dst != dst_origin) + *dst++ = '.'; + mysyslog(LOG_DEBUG, "<%s> labellen = %zd", __func__, len); + memcpy(dst, src, len); + src += len; + dst += len; + } + *dst = '\0'; + + return (src - src_origin); +} Modified: user/hrs/ipv6/usr.sbin/rtadvd/Makefile ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/Makefile Thu Jul 14 10:05:28 2011 (r224005) +++ user/hrs/ipv6/usr.sbin/rtadvd/Makefile Thu Jul 14 10:09:58 2011 (r224006) @@ -16,7 +16,8 @@ PROG= rtadvd MAN= rtadvd.conf.5 rtadvd.8 -SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c +SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c timer_subr.c \ + control.c control_server.c DPADD= ${LIBUTIL} LDADD= -lutil Modified: user/hrs/ipv6/usr.sbin/rtadvd/config.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/config.c Thu Jul 14 10:05:28 2011 (r224005) +++ user/hrs/ipv6/usr.sbin/rtadvd/config.c Thu Jul 14 10:09:58 2011 (r224006) @@ -3,6 +3,7 @@ /* * Copyright (C) 1998 WIDE Project. + * Copyright (C) 2011 Hiroki Sato * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -130,41 +131,65 @@ dname_labelenc(char *dst, const char *sr var = def; \ } while (0) -#define ELM_MALLOC(p,error_action) \ - do { \ - p = malloc(sizeof(*p)); \ - if (p == NULL) { \ - syslog(LOG_ERR, "<%s> malloc failed: %s", \ - __func__, strerror(errno)); \ - error_action; \ - } \ - memset(p, 0, sizeof(*p)); \ - } while(0) +int +loadconfig_index(int idx) +{ + char ifname[IFNAMSIZ]; + + syslog(LOG_DEBUG, "<%s> enter", __func__); + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 10:31:39 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64705106564A; Thu, 14 Jul 2011 10:31:39 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 536628FC15; Thu, 14 Jul 2011 10:31:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EAVdru024344; Thu, 14 Jul 2011 10:31:39 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EAVdbd024327; Thu, 14 Jul 2011 10:31:39 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107141031.p6EAVdbd024327@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 14 Jul 2011 10:31:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224007 - in user/jchandra/mips-xlp-support/sys: conf mips/conf mips/include mips/mips mips/nlm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 10:31:39 -0000 Author: jchandra Date: Thu Jul 14 10:31:38 2011 New Revision: 224007 URL: http://svn.freebsd.org/changeset/base/224007 Log: MIPS changes and conf files for XLP CPU_NLM added to XLP family Added: user/jchandra/mips-xlp-support/sys/mips/conf/XLP user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 user/jchandra/mips-xlp-support/sys/mips/conf/XLPN32 Modified: user/jchandra/mips-xlp-support/sys/conf/options.mips user/jchandra/mips-xlp-support/sys/mips/include/bus.h user/jchandra/mips-xlp-support/sys/mips/include/cpufunc.h user/jchandra/mips-xlp-support/sys/mips/include/intr_machdep.h user/jchandra/mips-xlp-support/sys/mips/mips/cache.c user/jchandra/mips-xlp-support/sys/mips/mips/cache_mipsNN.c user/jchandra/mips-xlp-support/sys/mips/mips/cpu.c user/jchandra/mips-xlp-support/sys/mips/mips/exception.S user/jchandra/mips-xlp-support/sys/mips/mips/locore.S user/jchandra/mips-xlp-support/sys/mips/mips/machdep.c user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c user/jchandra/mips-xlp-support/sys/mips/nlm/std.xlp user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c Modified: user/jchandra/mips-xlp-support/sys/conf/options.mips ============================================================================== --- user/jchandra/mips-xlp-support/sys/conf/options.mips Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/conf/options.mips Thu Jul 14 10:31:38 2011 (r224007) @@ -36,6 +36,7 @@ CPU_HAVEFPU opt_global.h CPU_SB1 opt_global.h CPU_CNMIPS opt_global.h CPU_RMI opt_global.h +CPU_NLM opt_global.h ISA_MIPS1 opt_cputype.h ISA_MIPS3 opt_cputype.h Added: user/jchandra/mips-xlp-support/sys/mips/conf/XLP ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/conf/XLP Thu Jul 14 10:31:38 2011 (r224007) @@ -0,0 +1,93 @@ +# XLP -- Generic kernel configuration file for FreeBSD/mips +# +# For more information on this file, please read the handbook section on +# Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD: head/sys/mips/conf/XLR 215270 2010-11-13 22:34:12Z imp $ + +machine mips mipseb +ident XLP + +options ISA_MIPS32 +makeoptions KERNLOADADDR=0x80100000 + +include "../nlm/std.xlp" +makeoptions MODULES_OVERRIDE="" +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +#profile 2 +makeoptions TRAMPLOADADDR=0xffffffff85000000 +makeoptions TRAMP_ARCH_FLAGS="-mabi=64 -march=mips64" + +options SCHED_ULE # ULE scheduler +#options VERBOSE_SYSINIT +#options SCHED_4BSD # 4BSD scheduler +options SMP +options PREEMPTION # Enable kernel thread preemption +#options FULL_PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options FFS # Berkeley Fast Filesystem +#options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options NFSCL +options NFS_ROOT +options MSDOSFS #MSDOS Filesystem +# +#options BOOTP +#options BOOTP_NFSROOT +#options BOOTP_NFSV3 +#options BOOTP_WIRED_TO=nlge0 +#options BOOTP_COMPAT +#options ROOTDEVNAME=\"nfs:10.1.1.8:/usr/extra/nfsroot\" +# +options MD_ROOT # MD is a potential root device +options MD_ROOT_SIZE=27000 +options ROOTDEVNAME=\"ufs:md0\" +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options HZ=1000 +options NO_SWAPPING + +#Debugging options +options KTRACE # ktrace(1) support +options DDB +options KDB +options GDB +options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER +#options DEADLKRES #Enable the deadlock resolver +#options INVARIANTS #Enable calls of extra sanity checking +#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS #Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed +#options KTR # ktr(4) and ktrdump(8) support +#options KTR_COMPILE=(KTR_LOCK|KTR_PROC|KTR_INTR|KTR_CALLOUT|KTR_UMA|KTR_SYSC) +#options KTR_ENTRIES=131072 +#options LOCK_DEBUG +#options LOCK_PROFILING + + +# Pseudo +device loop +device random +device md +device pty +device bpf + +# UART +device uart + +# Network +device ether Added: user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 Thu Jul 14 10:31:38 2011 (r224007) @@ -0,0 +1,95 @@ +# XLP64 -- Generic kernel configuration file for FreeBSD/mips +# +# For more information on this file, please read the handbook section on +# Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD: head/sys/mips/conf/XLR 215270 2010-11-13 22:34:12Z imp $ + +machine mips mips64eb +ident XLP64 + +options ISA_MIPS64 +makeoptions ARCH_FLAGS="-march=mips64 -mabi=64" +makeoptions KERNLOADADDR=0xffffffff80100000 + +include "../nlm/std.xlp" + +makeoptions MODULES_OVERRIDE="" +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +#profile 2 +makeoptions TRAMPLOADADDR=0xffffffff85000000 +makeoptions TRAMP_ARCH_FLAGS="-mabi=64 -march=mips64" + +options SCHED_ULE # ULE scheduler +#options VERBOSE_SYSINIT +#options SCHED_4BSD # 4BSD scheduler +options SMP +options PREEMPTION # Enable kernel thread preemption +#options FULL_PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options FFS # Berkeley Fast Filesystem +#options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options NFSCL +options NFS_ROOT +options MSDOSFS #MSDOS Filesystem +# +#options BOOTP +#options BOOTP_NFSROOT +#options BOOTP_NFSV3 +#options BOOTP_WIRED_TO=nlge0 +#options BOOTP_COMPAT +#options ROOTDEVNAME=\"nfs:10.1.1.8:/usr/extra/nfsroot\" +# +options MD_ROOT # MD is a potential root device +options MD_ROOT_SIZE=27000 +options ROOTDEVNAME=\"ufs:md0\" +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options HZ=1000 +options NO_SWAPPING + +#Debugging options +options KTRACE # ktrace(1) support +options DDB +options KDB +options GDB +options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER +#options DEADLKRES #Enable the deadlock resolver +#options INVARIANTS #Enable calls of extra sanity checking +#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS #Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed +#options KTR # ktr(4) and ktrdump(8) support +#options KTR_COMPILE=(KTR_LOCK|KTR_PROC|KTR_INTR|KTR_CALLOUT|KTR_UMA|KTR_SYSC) +#options KTR_ENTRIES=131072 +#options LOCK_DEBUG +#options LOCK_PROFILING + + +# Pseudo +device loop +device random +device md +device pty +device bpf + +# UART +device uart + +# Network +device ether Added: user/jchandra/mips-xlp-support/sys/mips/conf/XLPN32 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/conf/XLPN32 Thu Jul 14 10:31:38 2011 (r224007) @@ -0,0 +1,94 @@ +# XLPN32 -- Generic kernel configuration file for FreeBSD/mips +# +# For more information on this file, please read the handbook section on +# Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD: head/sys/mips/conf/XLR 215270 2010-11-13 22:34:12Z imp $ + +machine mips mipsn32eb +ident XLPN32 + +options ISA_MIPS64 +makeoptions ARCH_FLAGS="-march=mips64 -mabi=n32" +makeoptions KERNLOADADDR=0x80100000 + +include "../nlm/std.xlp" +makeoptions MODULES_OVERRIDE="" +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +#profile 2 +makeoptions TRAMPLOADADDR=0xffffffff85000000 +makeoptions TRAMP_ARCH_FLAGS="-mabi=64 -march=mips64" + +options SCHED_ULE # ULE scheduler +#options VERBOSE_SYSINIT +#options SCHED_4BSD # 4BSD scheduler +options SMP +options PREEMPTION # Enable kernel thread preemption +#options FULL_PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options FFS # Berkeley Fast Filesystem +#options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options NFSCL +options NFS_ROOT +options MSDOSFS #MSDOS Filesystem +# +#options BOOTP +#options BOOTP_NFSROOT +#options BOOTP_NFSV3 +#options BOOTP_WIRED_TO=nlge0 +#options BOOTP_COMPAT +#options ROOTDEVNAME=\"nfs:10.1.1.8:/usr/extra/nfsroot\" +# +options MD_ROOT # MD is a potential root device +options MD_ROOT_SIZE=27000 +options ROOTDEVNAME=\"ufs:md0\" +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options HZ=1000 +options NO_SWAPPING + +#Debugging options +options KTRACE # ktrace(1) support +options DDB +options KDB +options GDB +options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER +#options DEADLKRES #Enable the deadlock resolver +#options INVARIANTS #Enable calls of extra sanity checking +#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS #Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed +#options KTR # ktr(4) and ktrdump(8) support +#options KTR_COMPILE=(KTR_LOCK|KTR_PROC|KTR_INTR|KTR_CALLOUT|KTR_UMA|KTR_SYSC) +#options KTR_ENTRIES=131072 +#options LOCK_DEBUG +#options LOCK_PROFILING + + +# Pseudo +device loop +device random +device md +device pty +device bpf + +# UART +device uart + +# Network +device ether Modified: user/jchandra/mips-xlp-support/sys/mips/include/bus.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/include/bus.h Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/include/bus.h Thu Jul 14 10:31:38 2011 (r224007) @@ -721,7 +721,7 @@ void __bs_c(f,_bs_c_8) (void *t, bus_spa DECLARE_BUS_SPACE_PROTOTYPES(generic); extern bus_space_tag_t mips_bus_space_generic; /* Special bus space for RMI processors */ -#ifdef CPU_RMI +#if defined(CPU_RMI) || defined (CPU_NLM) extern bus_space_tag_t rmi_bus_space; extern bus_space_tag_t rmi_pci_bus_space; #endif Modified: user/jchandra/mips-xlp-support/sys/mips/include/cpufunc.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/include/cpufunc.h Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/include/cpufunc.h Thu Jul 14 10:31:38 2011 (r224007) @@ -254,6 +254,10 @@ MIPS_RW32_COP0_SEL(config3, MIPS_COP_0_C #ifdef CPU_CNMIPS MIPS_RW32_COP0_SEL(config4, MIPS_COP_0_CONFIG, 4); #endif +#ifdef CPU_NLM +MIPS_RW32_COP0_SEL(config6, MIPS_COP_0_CONFIG, 6); +MIPS_RW32_COP0_SEL(config7, MIPS_COP_0_CONFIG, 7); +#endif MIPS_RW32_COP0(count, MIPS_COP_0_COUNT); MIPS_RW32_COP0(index, MIPS_COP_0_TLB_INDEX); MIPS_RW32_COP0(wired, MIPS_COP_0_TLB_WIRED); Modified: user/jchandra/mips-xlp-support/sys/mips/include/intr_machdep.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/include/intr_machdep.h Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/include/intr_machdep.h Thu Jul 14 10:31:38 2011 (r224007) @@ -29,7 +29,7 @@ #ifndef _MACHINE_INTR_MACHDEP_H_ #define _MACHINE_INTR_MACHDEP_H_ -#ifdef CPU_RMI +#if defined(CPU_RMI) || defined(CPU_NLM) #define XLR_MAX_INTR 64 #else #define NHARD_IRQS 6 Modified: user/jchandra/mips-xlp-support/sys/mips/mips/cache.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/cache.c Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/mips/cache.c Thu Jul 14 10:31:38 2011 (r224007) @@ -80,6 +80,11 @@ __FBSDID("$FreeBSD$"); struct mips_cache_ops mips_cache_ops; +static void +cache_noop(vm_offset_t va, vm_size_t size) +{ +} + void mips_config_cache(struct mips_cpuinfo * cpuinfo) { @@ -94,8 +99,13 @@ mips_config_cache(struct mips_cpuinfo * break; case 32: mips_cache_ops.mco_icache_sync_all = mipsNN_icache_sync_all_32; +#ifdef CPU_NLM + mips_cache_ops.mco_icache_sync_range = + mipsNN_icache_sync_range_index_32; +#else mips_cache_ops.mco_icache_sync_range = mipsNN_icache_sync_range_32; +#endif mips_cache_ops.mco_icache_sync_range_index = mipsNN_icache_sync_range_index_32; break; @@ -143,16 +153,26 @@ mips_config_cache(struct mips_cpuinfo * mips_cache_ops.mco_pdcache_wbinv_all = mips_cache_ops.mco_intern_pdcache_wbinv_all = mipsNN_pdcache_wbinv_all_32; +#ifdef CPU_NLM + mips_cache_ops.mco_pdcache_wbinv_range = + mipsNN_pdcache_wbinv_range_index_32; +#else mips_cache_ops.mco_pdcache_wbinv_range = mipsNN_pdcache_wbinv_range_32; +#endif mips_cache_ops.mco_pdcache_wbinv_range_index = mips_cache_ops.mco_intern_pdcache_wbinv_range_index = mipsNN_pdcache_wbinv_range_index_32; mips_cache_ops.mco_pdcache_inv_range = mipsNN_pdcache_inv_range_32; +#if defined(CPU_RMI) || defined(CPU_NLM) + mips_cache_ops.mco_pdcache_wb_range = + mips_cache_ops.mco_intern_pdcache_wb_range = cache_noop; +#else mips_cache_ops.mco_pdcache_wb_range = mips_cache_ops.mco_intern_pdcache_wb_range = mipsNN_pdcache_wb_range_32; +#endif break; #ifdef CPU_CNMIPS case 128: Modified: user/jchandra/mips-xlp-support/sys/mips/mips/cache_mipsNN.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/cache_mipsNN.c Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/mips/cache_mipsNN.c Thu Jul 14 10:31:38 2011 (r224007) @@ -54,15 +54,36 @@ __FBSDID("$FreeBSD$"); #define round_line32(x) (((x) + 31) & ~31) #define trunc_line32(x) ((x) & ~31) +#if defined(CPU_NLM) +static __inline void +xlp_sync(void) +{ + __asm __volatile ( + ".set push \n" + ".set noreorder \n" + ".set mips64 \n" + "dla $8, 1f \n" + "/* jr.hb $8 */ \n" + ".word 0x1000408 \n" + "nop \n" + "1: nop \n" + ".set pop \n" + : : : "$8"); +} +#endif -#ifdef SB1250_PASS1 +#if defined(SB1250_PASS1) #define SYNC __asm volatile("sync; sync") +#elif defined(CPU_NLM) +#define SYNC xlp_sync() #else #define SYNC __asm volatile("sync") #endif -#ifdef CPU_CNMIPS +#if defined(CPU_CNMIPS) #define SYNCI mips_sync_icache(); +#elif defined(CPU_NLM) +#define SYNCI xlp_sync() #else #define SYNCI #endif Modified: user/jchandra/mips-xlp-support/sys/mips/mips/cpu.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/cpu.c Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/mips/cpu.c Thu Jul 14 10:31:38 2011 (r224007) @@ -101,8 +101,14 @@ mips_get_identity(struct mips_cpuinfo *c /* Learn TLB size and L1 cache geometry. */ cfg1 = mips_rd_config1(); +#ifndef CPU_NLM cpuinfo->tlb_nentries = ((cfg1 & MIPS_CONFIG1_TLBSZ_MASK) >> MIPS_CONFIG1_TLBSZ_SHIFT) + 1; +#else + /* Account for Extended TLB entries in XLP */ + tmp = mips_rd_config6(); + cpuinfo->tlb_nentries = ((tmp >> 16) & 0xffff) + 1; +#endif /* Add extended TLB size information from config4. */ #if defined(CPU_CNMIPS) Modified: user/jchandra/mips-xlp-support/sys/mips/mips/exception.S ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/exception.S Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/mips/exception.S Thu Jul 14 10:31:38 2011 (r224007) @@ -228,7 +228,7 @@ SlowFault: and a0, a0, a2 ; \ mtc0 a0, MIPS_COP_0_STATUS ; \ ITLBNOPFIX -#elif defined(CPU_RMI) +#elif defined(CPU_RMI) || defined(CPU_NLM) #define CLEAR_STATUS \ mfc0 a0, MIPS_COP_0_STATUS ;\ li a2, (MIPS_SR_KX | MIPS_SR_UX | MIPS_SR_COP_2_BIT) ; \ @@ -470,7 +470,7 @@ NNON_LEAF(MipsUserGenException, CALLFRAM and t0, a0, ~(MIPS_SR_COP_1_BIT | MIPS_SR_EXL | MIPS3_SR_KSU_MASK | MIPS_SR_INT_IE) #if defined(CPU_CNMIPS) or t0, t0, (MIPS_SR_KX | MIPS_SR_SX | MIPS_SR_UX | MIPS_SR_PX) -#elif defined(CPU_RMI) +#elif defined(CPU_RMI) || defined(CPU_NLM) or t0, t0, (MIPS_SR_KX | MIPS_SR_UX | MIPS_SR_COP_2_BIT) #endif mtc0 t0, MIPS_COP_0_STATUS @@ -688,7 +688,7 @@ NNON_LEAF(MipsUserIntr, CALLFRAME_SIZ, r and t0, a0, ~(MIPS_SR_COP_1_BIT | MIPS_SR_EXL | MIPS_SR_INT_IE | MIPS3_SR_KSU_MASK) #ifdef CPU_CNMIPS or t0, t0, (MIPS_SR_KX | MIPS_SR_SX | MIPS_SR_UX | MIPS_SR_PX) -#elif defined(CPU_RMI) +#elif defined(CPU_RMI) || defined(CPU_NLM) or t0, t0, (MIPS_SR_KX | MIPS_SR_UX | MIPS_SR_COP_2_BIT) #endif mtc0 t0, MIPS_COP_0_STATUS Modified: user/jchandra/mips-xlp-support/sys/mips/mips/locore.S ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/locore.S Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/mips/locore.S Thu Jul 14 10:31:38 2011 (r224007) @@ -99,7 +99,7 @@ VECTOR(_locore, unknown) /* Reset these bits */ li t0, ~(MIPS_SR_DE | MIPS_SR_SOFT_RESET | MIPS_SR_ERL | MIPS_SR_EXL | MIPS_SR_INT_IE) -#elif defined (CPU_RMI) +#elif defined (CPU_RMI) || defined (CPU_NLM) /* Set these bits */ li t1, (MIPS_SR_COP_2_BIT | MIPS_SR_COP_0_BIT | MIPS_SR_KX | MIPS_SR_UX) Modified: user/jchandra/mips-xlp-support/sys/mips/mips/machdep.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/mips/machdep.c Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/mips/machdep.c Thu Jul 14 10:31:38 2011 (r224007) @@ -338,7 +338,7 @@ mips_vector_init(void) bcopy(MipsTLBMiss, (void *)MIPS_UTLB_MISS_EXC_VEC, MipsTLBMissEnd - MipsTLBMiss); -#if defined(CPU_CNMIPS) || defined(CPU_RMI) +#if defined(CPU_CNMIPS) || defined(CPU_RMI) || defined(CPU_NLM) /* Fake, but sufficient, for the 32-bit with 64-bit hardware addresses */ bcopy(MipsTLBMiss, (void *)MIPS3_XTLB_MISS_EXC_VEC, MipsTLBMissEnd - MipsTLBMiss); Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c Thu Jul 14 10:31:38 2011 (r224007) @@ -257,13 +257,14 @@ xlp_handle_msg_vc(int vc, int max_msgs) continue; } he = &msgmap[srcid]; - if(he->action == NULL) { + if(he->action != NULL) + (he->action)(vc, size, code, srcid, &msg, he->arg); +#if 0 /* debug */ + else printf("[%s]: No Handler for message from stn_id=%d," " vc=%d, size=%d, msg0=%jx, dropping message\n", __func__, srcid, vc, size, (uintmax_t)msg.msg[0]); - continue; - } - (he->action)(vc, size, code, srcid, &msg, he->arg); +#endif } return (i); Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/std.xlp ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/std.xlp Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/std.xlp Thu Jul 14 10:31:38 2011 (r224007) @@ -1,12 +1,4 @@ # $FreeBSD$ files "../nlm/files.xlp" -cpu CPU_NLMXLP +cpu CPU_NLM -# -# XXXMIPS: It's a stub, isn't it? -# -#option HW_PAGEWALKER -#option MMU_HASH_MODE # enables hash based lookup into extended TLBs -#option MMU_CLOCK_GATING # enables clock gating on MMU -#option MMU_GLOBAL_MODE # enables global mode of sharing all TLBs with all h/w threads -#option NOFPU Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c Thu Jul 14 10:09:58 2011 (r224006) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c Thu Jul 14 10:31:38 2011 (r224007) @@ -214,8 +214,7 @@ xlp_parse_mmu_options(void) unsupp: printf("ERROR : Unsupported CPU mask [use 1,2 or 4 threads per core].\n" - "\tcore0 thread mask [%lx], boot cpu mask [%lx]\n" - "\tUsing default, 16 TLB entries per CPU, split mode\n", + "\tcore0 thread mask [%lx], boot cpu mask [%lx].\n", (u_long)core0_thr_mask, (u_long)cpu_map); panic("Invalid CPU mask - halting.\n"); return; @@ -495,8 +494,6 @@ platform_start(__register_t a0 __unused, xlp_pic_init(); mips_timer_init_params(xlp_cpu_frequency, 0); - - printf("Platform specific startup now completes\n"); } void @@ -630,6 +627,7 @@ platform_ipi_intrnum(void) void platform_ipi_send(int cpuid) { + nlm_pic_send_ipi(xlp_pic_base, 0, xlp_cpuid_to_hwtid[cpuid], platform_ipi_intrnum(), 0); } From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 14:15:22 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54D3C106564A; Thu, 14 Jul 2011 14:15:22 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3AB808FC17; Thu, 14 Jul 2011 14:15:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EEFMQk032859; Thu, 14 Jul 2011 14:15:22 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EEFM1X032851; Thu, 14 Jul 2011 14:15:22 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107141415.p6EEFM1X032851@svn.freebsd.org> From: Hiroki Sato Date: Thu, 14 Jul 2011 14:15:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224015 - in user/hrs/ipv6/usr.sbin: rtadvctl rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 14:15:22 -0000 Author: hrs Date: Thu Jul 14 14:15:21 2011 New Revision: 224015 URL: http://svn.freebsd.org/changeset/base/224015 Log: Remove ROUTEINFO and HAVE_POLL_H ifdefs to make things easy. Modified: user/hrs/ipv6/usr.sbin/rtadvctl/Makefile user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c user/hrs/ipv6/usr.sbin/rtadvd/Makefile user/hrs/ipv6/usr.sbin/rtadvd/config.c user/hrs/ipv6/usr.sbin/rtadvd/control_server.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Modified: user/hrs/ipv6/usr.sbin/rtadvctl/Makefile ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/Makefile Thu Jul 14 14:01:36 2011 (r224014) +++ user/hrs/ipv6/usr.sbin/rtadvctl/Makefile Thu Jul 14 14:15:21 2011 (r224015) @@ -7,7 +7,7 @@ MAN= rtadvctl.8 SRCS= rtadvctl.c control.c control_client.c if.c timer_subr.c -CFLAGS+= -DROUTEINFO -I${.CURDIR} -I${.CURDIR}/../rtadvd +CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../rtadvd WARNS?= 3 .include Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Thu Jul 14 14:01:36 2011 (r224014) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Thu Jul 14 14:15:21 2011 (r224015) @@ -84,9 +84,7 @@ static int action_shutdown(int, char **) static int action_show(int, char **); static int action_show_prefix(struct prefix *); -#ifdef ROUTEINFO static int action_show_rtinfo(struct rtinfo *); -#endif static int action_show_rdnss(void *); static int action_show_dnssl(void *); @@ -366,9 +364,7 @@ action_show(int argc, char **argv) char argv_ifilist[sizeof(":ifilist=")] = ":ifilist="; char argv_ifi[IFNAMSIZ + sizeof(":ifi=")]; char argv_rai[IFNAMSIZ + sizeof(":rai=")]; -#ifdef ROUTEINFO char argv_rti[IFNAMSIZ + sizeof(":rti=")]; -#endif char argv_pfx[IFNAMSIZ + sizeof(":pfx=")]; char argv_rdnss[IFNAMSIZ + sizeof(":rdnss=")]; char argv_dnssl[IFNAMSIZ + sizeof(":dnssl=")]; @@ -420,9 +416,7 @@ action_show(int argc, char **argv) TAILQ_FOREACH(ifi, &ifl, ifi_next) { struct ifinfo *ifi_s; struct rainfo *rai; -#ifdef ROUTEINFO struct rtinfo *rti; -#endif struct prefix *pfx; int c; int ra_ifstatus; @@ -540,7 +534,6 @@ action_show(int argc, char **argv) if (vflag < LOG_WARNING) continue; -#ifdef ROUTEINFO /* route information */ sprintf(argv_rti, "%s:rti=", ifi->ifi_ifname); action_argv = argv_rti; @@ -556,7 +549,7 @@ action_show(int argc, char **argv) for (i = 0; i < len; i++) action_show_rtinfo(&rti[i]); } -#endif + /* prefix information */ sprintf(argv_pfx, "%s:pfx=", ifi->ifi_ifname); action_argv = argv_pfx; @@ -631,7 +624,6 @@ action_show(int argc, char **argv) return (0); } -#ifdef ROUTEINFO static int action_show_rtinfo(struct rtinfo *rti) { @@ -648,7 +640,6 @@ action_show_rtinfo(struct rtinfo *rti) return (0); } -#endif static int action_show_prefix(struct prefix *pfx) Modified: user/hrs/ipv6/usr.sbin/rtadvd/Makefile ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/Makefile Thu Jul 14 14:01:36 2011 (r224014) +++ user/hrs/ipv6/usr.sbin/rtadvd/Makefile Thu Jul 14 14:15:21 2011 (r224015) @@ -22,7 +22,7 @@ SRCS= rtadvd.c rrenum.c advcap.c if.c co DPADD= ${LIBUTIL} LDADD= -lutil -CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H -DROUTEINFO +CFLAGS+= -DHAVE_ARC4RANDOM WARNS?= 3 Modified: user/hrs/ipv6/usr.sbin/rtadvd/config.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/config.c Thu Jul 14 14:01:36 2011 (r224014) +++ user/hrs/ipv6/usr.sbin/rtadvd/config.c Thu Jul 14 14:15:21 2011 (r224015) @@ -316,9 +316,7 @@ getconfig(int idx) ELM_MALLOC(rai, exit(1)); TAILQ_INIT(&rai->rai_prefix); -#ifdef ROUTEINFO TAILQ_INIT(&rai->rai_route); -#endif TAILQ_INIT(&rai->rai_rdnss); TAILQ_INIT(&rai->rai_dnssl); TAILQ_INIT(&rai->rai_soliciter); @@ -609,7 +607,6 @@ getconfig_free_pfx: #endif /* route information */ -#ifdef ROUTEINFO rai->rai_routes = 0; for (i = -1; i < MAXROUTE; i++) { struct rtinfo *rti; @@ -750,7 +747,7 @@ getconfig_free_pfx: getconfig_free_rti: free(rti); } -#endif + /* DNS server and DNS search list information */ for (i = -1; i < MAXRDNSSENT ; i++) { struct rdnss *rdn; @@ -1192,10 +1189,8 @@ make_packet(struct rainfo *rai) struct nd_router_advert *ra; struct nd_opt_prefix_info *ndopt_pi; struct nd_opt_mtu *ndopt_mtu; -#ifdef ROUTEINFO struct nd_opt_route_info *ndopt_rti; struct rtinfo *rti; -#endif struct nd_opt_rdnss *ndopt_rdnss; struct rdnss *rdn; struct nd_opt_dnssl *ndopt_dnssl; @@ -1221,11 +1216,11 @@ make_packet(struct rainfo *rai) packlen += sizeof(struct nd_opt_prefix_info) * rai->rai_pfxs; if (rai->rai_linkmtu) packlen += sizeof(struct nd_opt_mtu); -#ifdef ROUTEINFO + TAILQ_FOREACH(rti, &rai->rai_route, rti_next) packlen += sizeof(struct nd_opt_route_info) + ((rti->rti_prefixlen + 0x3f) >> 6) * 8; -#endif + TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) { struct rdnss_addr *rdna; @@ -1348,7 +1343,6 @@ make_packet(struct rainfo *rai) buf += sizeof(struct nd_opt_prefix_info); } -#ifdef ROUTEINFO TAILQ_FOREACH(rti, &rai->rai_route, rti_next) { u_int8_t psize = (rti->rti_prefixlen + 0x3f) >> 6; @@ -1361,7 +1355,7 @@ make_packet(struct rainfo *rai) memcpy(ndopt_rti + 1, &rti->rti_prefix, psize * 8); buf += sizeof(struct nd_opt_route_info) + psize * 8; } -#endif + TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) { struct rdnss_addr *rdna; @@ -1382,6 +1376,7 @@ make_packet(struct rainfo *rai) syslog(LOG_DEBUG, "<%s>: nd_opt_dnss_len = %d", __func__, ndopt_rdnss->nd_opt_rdnss_len); } + TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) { struct dnssl_addr *dnsa; Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Thu Jul 14 14:01:36 2011 (r224014) +++ user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Thu Jul 14 14:15:21 2011 (r224015) @@ -76,9 +76,7 @@ static int cmsg_getprop_rai_timer(struct static int cmsg_getprop_pfx(struct ctrl_msg_pl *); static int cmsg_getprop_rdnss(struct ctrl_msg_pl *); static int cmsg_getprop_dnssl(struct ctrl_msg_pl *); -#ifdef ROUTEINFO static int cmsg_getprop_rti(struct ctrl_msg_pl *); -#endif static struct dispatch_table { const char *dt_comm; @@ -91,9 +89,7 @@ static struct dispatch_table { DEF_PL_HANDLER(ifi), DEF_PL_HANDLER(rai), DEF_PL_HANDLER(rai_timer), -#ifdef ROUTEINFO DEF_PL_HANDLER(rti), -#endif DEF_PL_HANDLER(pfx), DEF_PL_HANDLER(rdnss), DEF_PL_HANDLER(dnssl), @@ -277,7 +273,6 @@ cmsg_getprop_rai_timer(struct ctrl_msg_p return (0); } -#ifdef ROUTEINFO static int cmsg_getprop_rti(struct ctrl_msg_pl *cp) { @@ -326,7 +321,6 @@ cmsg_getprop_rti(struct ctrl_msg_pl *cp) return (0); } -#endif static int cmsg_getprop_pfx(struct ctrl_msg_pl *cp) Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Thu Jul 14 14:01:36 2011 (r224014) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Thu Jul 14 14:15:21 2011 (r224015) @@ -67,9 +67,7 @@ #include #include #include -#ifdef HAVE_POLL_H #include -#endif #include "pathnames.h" #include "rtadvd.h" @@ -98,12 +96,10 @@ const char *conffile = _PATH_RTADVDCONF; static struct pidfh *pfh; int dflag = 0, sflag = 0; -#ifdef HAVE_POLL_H #define PFD_RAWSOCK 0 #define PFD_RTSOCK 1 #define PFD_CSOCK 2 #define PFD_MAX 3 -#endif struct railist_head_t railist = TAILQ_HEAD_INITIALIZER(railist); @@ -171,13 +167,7 @@ static int check_accept_rtadv(int); int main(int argc, char *argv[]) { -#ifdef HAVE_POLL_H struct pollfd set[PFD_MAX]; -#else - fd_set *fdsetp, *selectfdp; - int fdmasks; - int maxfd = 0; -#endif struct timeval *timeout; int i, ch; int fflag = 0, logopt; @@ -281,7 +271,6 @@ main(int argc, char *argv[]) pid = getpid(); pidfile_write(pfh); -#ifdef HAVE_POLL_H set[PFD_RAWSOCK].fd = sock.si_fd; set[PFD_RAWSOCK].events = POLLIN; if (sflag == 0) { @@ -292,32 +281,6 @@ main(int argc, char *argv[]) set[PFD_RTSOCK].fd = -1; set[PFD_CSOCK].fd = ctrlsock.si_fd; set[PFD_CSOCK].events = POLLIN; -#else - maxfd = sock.si_fd; - if (sflag == 0) { - rtsock_open(); - if (rtsock.si_fd > sock.si_fd) - maxfd = rtsock.si_fd; - } else - rtsock.si_fd = -1; - if (maxfd < ctrlsock.si_fd) - maxfd = ctrlsock.si_fd; - - fdmasks = howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask); - if ((fdsetp = malloc(fdmasks)) == NULL) { - err(1, "malloc"); - /*NOTREACHED*/ - } - if ((selectfdp = malloc(fdmasks)) == NULL) { - err(1, "malloc"); - /*NOTREACHED*/ - } - memset(fdsetp, 0, fdmasks); - FD_SET(sock.si_fd, fdsetp); - if (rtsock.si_fd >= 0) - FD_SET(rtsock.si_fd, fdsetp); - FD_SET(ctrlsock.si_fd, fdsetp); -#endif signal(SIGTERM, set_do_die); signal(SIGINT, set_do_die); signal(SIGHUP, set_do_reload); @@ -332,9 +295,6 @@ main(int argc, char *argv[]) set_do_reload(0); while (1) { -#ifndef HAVE_POLL_H - memcpy(selectfdp, fdsetp, fdmasks); /* reinitialize */ -#endif if (do_die()) die(); @@ -362,15 +322,9 @@ main(int argc, char *argv[]) "<%s> there's no timer. waiting for inputs", __func__); } -#ifdef HAVE_POLL_H if ((i = poll(set, sizeof(set)/sizeof(set[0]), timeout ? (timeout->tv_sec * 1000 + - timeout->tv_usec / 1000) : INFTIM)) < 0) -#else - if ((i = select(maxfd + 1, selectfdp, NULL, NULL, - timeout)) < 0) -#endif - { + timeout->tv_usec / 1000) : INFTIM)) < 0) { /* EINTR would occur upon SIGUSR1 for status dump */ if (errno != EINTR) syslog(LOG_ERR, "<%s> select: %s", @@ -379,24 +333,13 @@ main(int argc, char *argv[]) } if (i == 0) /* timeout */ continue; -#ifdef HAVE_POLL_H if (rtsock.si_fd != -1 && set[PFD_RTSOCK].revents & POLLIN) -#else - if (rtsock.si_fd != -1 && FD_ISSET(rtsock.si_fd, selectfdp)) -#endif rtmsg_input(&rtsock); -#ifdef HAVE_POLL_H + if (set[PFD_RAWSOCK].revents & POLLIN) -#else - if (FD_ISSET(sock.si_fd, selectfdp)) -#endif rtadvd_input(&sock); -#ifdef HAVE_POLL_H - if (set[PFD_CSOCK].revents & POLLIN) -#else - if (FD_ISSET(ctrlsock.si_fd, selectfdp)) -#endif - { + + if (set[PFD_CSOCK].revents & POLLIN) { int fd; fd = csock_accept(&ctrlsock); Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Thu Jul 14 14:01:36 2011 (r224014) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Thu Jul 14 14:15:21 2011 (r224015) @@ -125,7 +125,6 @@ struct prefix { struct in6_addr pfx_prefix; }; -#ifdef ROUTEINFO struct rtinfo { TAILQ_ENTRY(rtinfo) rti_next; @@ -134,7 +133,6 @@ struct rtinfo { int rti_prefixlen; struct in6_addr rti_prefix; }; -#endif struct rdnss_addr { TAILQ_ENTRY(rdnss_addr) ra_next; @@ -220,10 +218,8 @@ struct rainfo { TAILQ_HEAD(, rdnss) rai_rdnss; /* DNS server list */ TAILQ_HEAD(, dnssl) rai_dnssl; /* search domain list */ -#ifdef ROUTEINFO TAILQ_HEAD(, rtinfo) rai_route; /* route information option (link head) */ int rai_routes; /* number of route information options */ -#endif /* actual RA packet data and its length */ size_t rai_ra_datalen; u_char *rai_ra_data; From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 14:24:20 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DA591065679; Thu, 14 Jul 2011 14:24:20 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6F2AD8FC18; Thu, 14 Jul 2011 14:24:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EEOK62033245; Thu, 14 Jul 2011 14:24:20 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EEOKAt033243; Thu, 14 Jul 2011 14:24:20 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107141424.p6EEOKAt033243@svn.freebsd.org> From: Hiroki Sato Date: Thu, 14 Jul 2011 14:24:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224018 - user/hrs/ipv6/usr.sbin/rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 14:24:20 -0000 Author: hrs Date: Thu Jul 14 14:24:20 2011 New Revision: 224018 URL: http://svn.freebsd.org/changeset/base/224018 Log: Fix memory leak. Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Thu Jul 14 14:23:48 2011 (r224017) +++ user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Thu Jul 14 14:24:20 2011 (r224018) @@ -640,6 +640,8 @@ cmsg_handler_server(int fd) cm->cm_len = sizeof(*cm); cm->cm_len += cmsg_pl2bin(msg, &cp); } + if (cp.cp_val != NULL) + free(cp.cp_val); break; case CM_TYPE_REQ_SET_PROP: cmsg_bin2pl(msg, &cp); From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 17:33:09 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7258D1065673; Thu, 14 Jul 2011 17:33:09 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4994A8FC1B; Thu, 14 Jul 2011 17:33:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EHX9Rr038784; Thu, 14 Jul 2011 17:33:09 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EHX9N1038782; Thu, 14 Jul 2011 17:33:09 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107141733.p6EHX9N1038782@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 14 Jul 2011 17:33:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224021 - user/gabor/tre-integration/tools/test/regex/tests X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 17:33:09 -0000 Author: gabor Date: Thu Jul 14 17:33:08 2011 New Revision: 224021 URL: http://svn.freebsd.org/changeset/base/224021 Log: - Add more BRE tests Modified: user/gabor/tre-integration/tools/test/regex/tests/basic.tests Modified: user/gabor/tre-integration/tools/test/regex/tests/basic.tests ============================================================================== --- user/gabor/tre-integration/tools/test/regex/tests/basic.tests Thu Jul 14 17:19:00 2011 (r224020) +++ user/gabor/tre-integration/tools/test/regex/tests/basic.tests Thu Jul 14 17:33:08 2011 (r224021) @@ -7,6 +7,10 @@ ba[rz];foobarfoobaz;((3,6),(9,12)) ba[rz];foobahfoobav;() ba[^r];foobarfoobaz;((9,12)) +# Collating ranges +[a-c]12;a12z12b12u12c12;((0,3),(6,9),(12,15)) +[-a-c]12;a12z12b12u12c12-12;((0,3),(6,9),(12,15),(15,18)) + # Collating elements [[=a=]];bbbbabbbb;((4,5)) @@ -18,3 +22,43 @@ ba[^r];foobarfoobaz;((9,12)) [[:digit:]];abcdefgh1ijklmn2opqrstuv3wxyz4;((8,9),(15,16),(24,25),(29,30)) #[[:graph:]];" 5 ";((5,6)) [[:lower:]];ABCDEFg0123456hIJKL;((6,7),(14,15)) +#[[:print:]]; +[[:punct:]];01234,6789.abcd:efgh_;((5,6),(10,11),(15,16),(20,21)) +#[[:space:]]; +[[:upper:]];abcdEfghIjkLmnoPqrstU;((4,5),(8,9),(11,12),(15,16),(20,21)) +[[:xdigit:]];mmmm5mmmfmmmCmmmm3mmmd;((4,5),(8,9),(12,13),(17,18),(21,22)) + +# Matching multiple character +#a*;aaaabbbaa;((0,4),(7,9)) +a*b;aaaabbbaa;((0,5),(5,6),(6,7)) +a\{3\};aaabbaabaaaa;((0,3),(8,11)) +a\{1,3\};abbaaabaaaab;((0,1),(3,6),(7,10),(10,11)) +a\{2,\};abbaabbaaab;((3,5),(7,10)) + +# Backreferences +\(a\)\1;aazz;((0,2)) +\(a\)\1;aabbaazz;((0,2),(4,6)) +\(a\)*\1;aazz;((0,2)) +\(a\)*\1;aaaaazz;((0,5)) +\(a\(b\)*\)*\2;abababbbbzz;((0,9)) +\(a\(b\)*\)*\2;abababzz;((0,6)) +\(a\(b\)*\)*\2;ababazz;((0,4)) +^\(ab*\)*\1$;ababbabb;((0,8)) +^\(ab*\)*\1$;ababbab;() + +# BOL and EOL +^abc;abcdef;((0,3)) +#^abc;abcabc;((0,3)) +^abcd$;abcdef;() +^abcd$;abcd;((0,4)) +def$;abcdef;((3,6)) +def$;abcdefg;() + +# Special characters when treated as normal +*abc;*abc;((0,4)) +^*abc;*abc;((0,4)) +\(*abc\);*abc;((0,4)) +\(*abc\)*;*abc*abc;((0,8)) +abc^;abc^;((0,4)) +abc^;abc^def;((0,4)) +abc$d;abc$d;((0,5)) From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 17:34:56 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6B7D106564A; Thu, 14 Jul 2011 17:34:56 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8CCB98FC0A; Thu, 14 Jul 2011 17:34:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EHYuhq038872; Thu, 14 Jul 2011 17:34:56 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EHYuU0038869; Thu, 14 Jul 2011 17:34:56 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107141734.p6EHYuU0038869@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 14 Jul 2011 17:34:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224022 - in user/gabor/tre-integration/tools/test/regex: . tests X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 17:34:56 -0000 Author: gabor Date: Thu Jul 14 17:34:56 2011 New Revision: 224022 URL: http://svn.freebsd.org/changeset/base/224022 Log: - Rename test file to have a more descriptive name Added: user/gabor/tre-integration/tools/test/regex/tests/bre.tests - copied unchanged from r224021, user/gabor/tre-integration/tools/test/regex/tests/basic.tests Deleted: user/gabor/tre-integration/tools/test/regex/tests/basic.tests Modified: user/gabor/tre-integration/tools/test/regex/Makefile Modified: user/gabor/tre-integration/tools/test/regex/Makefile ============================================================================== --- user/gabor/tre-integration/tools/test/regex/Makefile Thu Jul 14 17:33:08 2011 (r224021) +++ user/gabor/tre-integration/tools/test/regex/Makefile Thu Jul 14 17:34:56 2011 (r224022) @@ -2,7 +2,7 @@ SUBDIR= regmatch -TESTS=basic.tests +TESTS=bre.tests test: regmatch .for t in ${TESTS} Copied: user/gabor/tre-integration/tools/test/regex/tests/bre.tests (from r224021, user/gabor/tre-integration/tools/test/regex/tests/basic.tests) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/tools/test/regex/tests/bre.tests Thu Jul 14 17:34:56 2011 (r224022, copy of r224021, user/gabor/tre-integration/tools/test/regex/tests/basic.tests) @@ -0,0 +1,64 @@ +# $FreeBSD$ + +# Fixed string and simple expressions +foo;foobarfoobar;((0,3),(6,9)) +ba.;foobarfoobaz;((3,6),(9,12)) +ba[rz];foobarfoobaz;((3,6),(9,12)) +ba[rz];foobahfoobav;() +ba[^r];foobarfoobaz;((9,12)) + +# Collating ranges +[a-c]12;a12z12b12u12c12;((0,3),(6,9),(12,15)) +[-a-c]12;a12z12b12u12c12-12;((0,3),(6,9),(12,15),(15,18)) + +# Collating elements +[[=a=]];bbbbabbbb;((4,5)) + +# Character classes +[[:alnum:]];__a____4_;((2,3),(7,8)) +[[:alpha:]];012345a67890b;((6,7),(12,13)) +[[:blank:]];0123456789abcdefghijklmnopqrstuvwxyz;() +[[:cntrl:]];012346789;() +[[:digit:]];abcdefgh1ijklmn2opqrstuv3wxyz4;((8,9),(15,16),(24,25),(29,30)) +#[[:graph:]];" 5 ";((5,6)) +[[:lower:]];ABCDEFg0123456hIJKL;((6,7),(14,15)) +#[[:print:]]; +[[:punct:]];01234,6789.abcd:efgh_;((5,6),(10,11),(15,16),(20,21)) +#[[:space:]]; +[[:upper:]];abcdEfghIjkLmnoPqrstU;((4,5),(8,9),(11,12),(15,16),(20,21)) +[[:xdigit:]];mmmm5mmmfmmmCmmmm3mmmd;((4,5),(8,9),(12,13),(17,18),(21,22)) + +# Matching multiple character +#a*;aaaabbbaa;((0,4),(7,9)) +a*b;aaaabbbaa;((0,5),(5,6),(6,7)) +a\{3\};aaabbaabaaaa;((0,3),(8,11)) +a\{1,3\};abbaaabaaaab;((0,1),(3,6),(7,10),(10,11)) +a\{2,\};abbaabbaaab;((3,5),(7,10)) + +# Backreferences +\(a\)\1;aazz;((0,2)) +\(a\)\1;aabbaazz;((0,2),(4,6)) +\(a\)*\1;aazz;((0,2)) +\(a\)*\1;aaaaazz;((0,5)) +\(a\(b\)*\)*\2;abababbbbzz;((0,9)) +\(a\(b\)*\)*\2;abababzz;((0,6)) +\(a\(b\)*\)*\2;ababazz;((0,4)) +^\(ab*\)*\1$;ababbabb;((0,8)) +^\(ab*\)*\1$;ababbab;() + +# BOL and EOL +^abc;abcdef;((0,3)) +#^abc;abcabc;((0,3)) +^abcd$;abcdef;() +^abcd$;abcd;((0,4)) +def$;abcdef;((3,6)) +def$;abcdefg;() + +# Special characters when treated as normal +*abc;*abc;((0,4)) +^*abc;*abc;((0,4)) +\(*abc\);*abc;((0,4)) +\(*abc\)*;*abc*abc;((0,8)) +abc^;abc^;((0,4)) +abc^;abc^def;((0,4)) +abc$d;abc$d;((0,5)) From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 17:50:16 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69E1310656B4; Thu, 14 Jul 2011 17:50:16 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A9788FC1C; Thu, 14 Jul 2011 17:50:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EHoGIV039462; Thu, 14 Jul 2011 17:50:16 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EHoG0K039460; Thu, 14 Jul 2011 17:50:16 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107141750.p6EHoG0K039460@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 14 Jul 2011 17:50:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224026 - user/gabor/tre-integration/tools/test/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 17:50:16 -0000 Author: gabor Date: Thu Jul 14 17:50:16 2011 New Revision: 224026 URL: http://svn.freebsd.org/changeset/base/224026 Log: - Run all tests with LC_ALL=C Modified: user/gabor/tre-integration/tools/test/regex/Makefile Modified: user/gabor/tre-integration/tools/test/regex/Makefile ============================================================================== --- user/gabor/tre-integration/tools/test/regex/Makefile Thu Jul 14 17:43:23 2011 (r224025) +++ user/gabor/tre-integration/tools/test/regex/Makefile Thu Jul 14 17:50:16 2011 (r224026) @@ -11,7 +11,7 @@ test: regmatch str=`echo $${l} | cut -d \; -f 2`; \ pat=`echo $${l} | cut -d \; -f 1`; \ match=`echo $${l} | cut -d \; -f 3`; \ - result=`./regmatch/regmatch $${pat} $${str}`; \ + result=`env LC_ALL=C ./regmatch/regmatch $${pat} $${str}`; \ if [ "$${match}" != "$${result}" ]; then \ echo "Failed matching pattern $${pat} to string $${str}"; \ else \ From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 18:11:52 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49CDF106564A; Thu, 14 Jul 2011 18:11:52 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20F638FC13; Thu, 14 Jul 2011 18:11:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EIBq5W040174; Thu, 14 Jul 2011 18:11:52 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EIBqjs040172; Thu, 14 Jul 2011 18:11:52 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107141811.p6EIBqjs040172@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 14 Jul 2011 18:11:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224028 - user/gabor/tre-integration/tools/test/regex/tests X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 18:11:52 -0000 Author: gabor Date: Thu Jul 14 18:11:51 2011 New Revision: 224028 URL: http://svn.freebsd.org/changeset/base/224028 Log: - Add tests for some more special BRE cases Modified: user/gabor/tre-integration/tools/test/regex/tests/bre.tests Modified: user/gabor/tre-integration/tools/test/regex/tests/bre.tests ============================================================================== --- user/gabor/tre-integration/tools/test/regex/tests/bre.tests Thu Jul 14 18:06:13 2011 (r224027) +++ user/gabor/tre-integration/tools/test/regex/tests/bre.tests Thu Jul 14 18:11:51 2011 (r224028) @@ -3,6 +3,10 @@ # Fixed string and simple expressions foo;foobarfoobar;((0,3),(6,9)) ba.;foobarfoobaz;((3,6),(9,12)) +(foo);zz(foo)barfoo;((2,7)) +#foo{2};zzfoo{2}zz;((2,6)) +#foo{2,3};zzfoo{2,3}zz;((2,8)) +#foo{2,};zzfoo{2,}zz;((2,7)) ba[rz];foobarfoobaz;((3,6),(9,12)) ba[rz];foobahfoobav;() ba[^r];foobarfoobaz;((9,12)) @@ -11,8 +15,14 @@ ba[^r];foobarfoobaz;((9,12)) [a-c]12;a12z12b12u12c12;((0,3),(6,9),(12,15)) [-a-c]12;a12z12b12u12c12-12;((0,3),(6,9),(12,15),(15,18)) -# Collating elements +# Collating elements and equivalence classes +# NOTE: there is not much to check here with LC_ALL=C +[[.a.]];bbbbabbbb;((4,5)) [[=a=]];bbbbabbbb;((4,5)) +[][.-.]-0]bcd;.bcdzz;((0,4)) +[][.-.]-0]bcd;-bcdzz;((0,4)) +[][.-.]-0]bcd;0bcdzz;((0,4)) +[][.-.]-0]bcd;]bcdzz;((0,4)) # Character classes [[:alnum:]];__a____4_;((2,3),(7,8)) @@ -31,6 +41,7 @@ ba[^r];foobarfoobaz;((9,12)) # Matching multiple character #a*;aaaabbbaa;((0,4),(7,9)) a*b;aaaabbbaa;((0,5),(5,6),(6,7)) +#[ab]*;ababab;((0,5)) a\{3\};aaabbaabaaaa;((0,3),(8,11)) a\{1,3\};abbaaabaaaab;((0,1),(3,6),(7,10),(10,11)) a\{2,\};abbaabbaaab;((3,5),(7,10)) @@ -53,12 +64,48 @@ a\{2,\};abbaabbaaab;((3,5),(7,10)) ^abcd$;abcd;((0,4)) def$;abcdef;((3,6)) def$;abcdefg;() +\(^ab\);cdefab;() # Special characters when treated as normal -*abc;*abc;((0,4)) -^*abc;*abc;((0,4)) -\(*abc\);*abc;((0,4)) +*abc;*abczz;((0,4)) +^*abc;*abczz;((0,4)) +\(*abc\);*abczz;((0,4)) \(*abc\)*;*abc*abc;((0,8)) -abc^;abc^;((0,4)) -abc^;abc^def;((0,4)) +abc^;abc^zz;((0,4)) abc$d;abc$d;((0,5)) +[]a]bcd;]bcdzz;((0,4)) +[]a]bcd;abcdzz;((0,4)) +[^]a]bcd;]bcdzz;() +[^]a]bcd;bbcdzz;((0,4)) +[a.]bcd;.bcdzz;((0,4)) +[a.]bcd;abcdzz;((0,4)) +[^a.]bcd;.bcdzz;() +[^a.]bcd;bbcdzz;((0,4)) +[a[]bcd;[bcdzz;((0,4)) +[a[]bcd;abcdzz;((0,4)) +[^a[]bcd;[bcdzz;() +[^a[]bcd;bbcdzz;((0,4)) +[a*]bcd;*bcdzz;((0,4)) +[a*]bcd;abcdzz;((0,4)) +[^a*]bcd;*bcdzz;() +[^a*]bcd;bbcdzz;((0,4)) +[a\]bcd;\bcdzz;((0,4)) +[a\]bcd;abcdzz;((0,4)) +[^a\]bcd;\bcdzz;() +[^a\]bcd;bbcdzz;((0,4)) +[a^]bcd;abcdzz;((0,4)) +[a^]bcd;^bcdzz;((0,4)) +[^a^]bcd;^bcdzz;() +[^a^]bcd;bbcdzz;((0,4)) +[-a]bcd;abcdzz;((0,4)) +[-a]bcd;-bcdzz;((0,4)) +[^-a]bcd;-bcdzz;() +[^-a]bcd;bbcdzz;((0,4)) +[a-]bcd;abcdzz;((0,4)) +[a-]bcd;-bcdzz;((0,4)) +[^a-]bcd;-bcdzz;() +[^a-]bcd;bbcdzz;((0,4)) +\^abcd;^abcd;((0,5)) +\^abcd;z^abcd;((1,6)) +abcd\$;abcd$;((0,5)) +abcd\$;abcd$z;((0,5)) From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 18:35:59 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9DF24106566B; Thu, 14 Jul 2011 18:35:59 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8EB1C8FC0C; Thu, 14 Jul 2011 18:35:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EIZxw2040882; Thu, 14 Jul 2011 18:35:59 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EIZx7C040880; Thu, 14 Jul 2011 18:35:59 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107141835.p6EIZx7C040880@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 14 Jul 2011 18:35:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224029 - user/gabor/tre-integration/tools/test/regex/regmatch X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 18:35:59 -0000 Author: gabor Date: Thu Jul 14 18:35:59 2011 New Revision: 224029 URL: http://svn.freebsd.org/changeset/base/224029 Log: - Shift one character forward after matching "" to avoid infinite loop Modified: user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c Modified: user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c ============================================================================== --- user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c Thu Jul 14 18:11:51 2011 (r224028) +++ user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c Thu Jul 14 18:35:59 2011 (r224029) @@ -42,7 +42,7 @@ main(int argc, char *argv[]) (unsigned long)pmatch.rm_eo); if (pmatch.rm_eo == len) break; - pmatch.rm_so = pmatch.rm_eo; + pmatch.rm_so = (pmatch.rm_so == pmatch.rm_eo) ? pmatch.rm_eo + 1 : pmatch.rm_eo; pmatch.rm_eo = len; first = false; } From owner-svn-src-user@FreeBSD.ORG Thu Jul 14 18:37:11 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27109106566B; Thu, 14 Jul 2011 18:37:11 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F24EC8FC13; Thu, 14 Jul 2011 18:37:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6EIbANP040953; Thu, 14 Jul 2011 18:37:10 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6EIbA5o040951; Thu, 14 Jul 2011 18:37:10 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107141837.p6EIbA5o040951@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 14 Jul 2011 18:37:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224030 - user/gabor/tre-integration/tools/test/regex/regmatch X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2011 18:37:11 -0000 Author: gabor Date: Thu Jul 14 18:37:10 2011 New Revision: 224030 URL: http://svn.freebsd.org/changeset/base/224030 Log: - Add conventional license text Modified: user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c Modified: user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c ============================================================================== --- user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c Thu Jul 14 18:35:59 2011 (r224029) +++ user/gabor/tre-integration/tools/test/regex/regmatch/regmatch.c Thu Jul 14 18:37:10 2011 (r224030) @@ -1,3 +1,31 @@ +/* $FreeBSD$ */ + +/*- + * Copyright (C) 2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include #include From owner-svn-src-user@FreeBSD.ORG Fri Jul 15 04:31:50 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D70F31065670; Fri, 15 Jul 2011 04:31:50 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AE9C98FC08; Fri, 15 Jul 2011 04:31:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6F4VoJm060585; Fri, 15 Jul 2011 04:31:50 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6F4VoR6060582; Fri, 15 Jul 2011 04:31:50 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107150431.p6F4VoR6060582@svn.freebsd.org> From: Hiroki Sato Date: Fri, 15 Jul 2011 04:31:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224052 - in user/hrs/ipv6/usr.sbin: rtadvctl rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2011 04:31:50 -0000 Author: hrs Date: Fri Jul 15 04:31:50 2011 New Revision: 224052 URL: http://svn.freebsd.org/changeset/base/224052 Log: Add conditions to accept or send RAs on 8.X and prior to make MFC easier. Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Fri Jul 15 02:29:10 2011 (r224051) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Fri Jul 15 04:31:50 2011 (r224052) @@ -454,12 +454,22 @@ action_show(int argc, char **argv) ra_ifstatus = RA_IFSTATUS_INACTIVE; if ((ifi_s->ifi_flags & IFF_UP) && (ifi_s->ifi_state == IFI_STATE_CONFIGURED)) { +#if (__FreeBSD_version < 900000) + if (getinet6sysctl(IPV6CTL_FORWARDING) == 0) { + if (getinet6sysctl(IPV6CTL_ACCEPT_RTADV)) + ra_ifstatus = RA_IFSTATUS_RA_RECV; + else + ra_ifstatus = RA_IFSTATUS_INACTIVE; + } else + ra_ifstatus = RA_IFSTATUS_RA_SEND; +#else if (ifi_s->ifi_nd_flags & ND6_IFF_ACCEPT_RTADV) ra_ifstatus = RA_IFSTATUS_RA_RECV; else if (getinet6sysctl(IPV6CTL_FORWARDING)) ra_ifstatus = RA_IFSTATUS_RA_SEND; else ra_ifstatus = RA_IFSTATUS_INACTIVE; +#endif } c = 0; Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Fri Jul 15 02:29:10 2011 (r224051) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Fri Jul 15 04:31:50 2011 (r224052) @@ -975,7 +975,6 @@ static int check_accept_rtadv(int idx) { struct ifinfo *ifi; - int error; TAILQ_FOREACH(ifi, &ifilist, ifi_next) { if (ifi->ifi_ifindex == idx) @@ -987,15 +986,19 @@ check_accept_rtadv(int idx) __func__, idx); return (0); } - error =update_ifinfo_nd_flags(ifi); - if (error) { +#if (__FreeBSD_version < 900000) + return ((getinet6sysctl(IPV6CTL_FORWARDING) == 0) && + (getinet6sysctl(IPV6CTL_ACCEPT_RTADV) == 1)); +#else + if (update_ifinfo_nd_flags(ifi) != 0) { syslog(LOG_ERR, "<%s> nd6 flags failed (idx=%d)", __func__, idx); return (0); } - + return (ifi->ifi_nd_flags & ND6_IFF_ACCEPT_RTADV); +#endif } static void From owner-svn-src-user@FreeBSD.ORG Fri Jul 15 04:49:31 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13E14106564A; Fri, 15 Jul 2011 04:49:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0396A8FC1B; Fri, 15 Jul 2011 04:49:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6F4nUMt061115; Fri, 15 Jul 2011 04:49:30 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6F4nUWl061105; Fri, 15 Jul 2011 04:49:30 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107150449.p6F4nUWl061105@svn.freebsd.org> From: Hiroki Sato Date: Fri, 15 Jul 2011 04:49:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224053 - in user/hrs/ipv6/usr.sbin: rtadvctl rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2011 04:49:31 -0000 Author: hrs Date: Fri Jul 15 04:49:30 2011 New Revision: 224053 URL: http://svn.freebsd.org/changeset/base/224053 Log: - Use the exact-width integer type for a member that need an exact-width in the data structure. - s/u_int[0-9]*_t/uint$1_t/ Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c user/hrs/ipv6/usr.sbin/rtadvd/config.c user/hrs/ipv6/usr.sbin/rtadvd/control.c user/hrs/ipv6/usr.sbin/rtadvd/control_server.c user/hrs/ipv6/usr.sbin/rtadvd/if.c user/hrs/ipv6/usr.sbin/rtadvd/if.h user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h user/hrs/ipv6/usr.sbin/rtadvd/timer_subr.c user/hrs/ipv6/usr.sbin/rtadvd/timer_subr.h Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Fri Jul 15 04:49:30 2011 (r224053) @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -538,7 +539,7 @@ action_show(int argc, char **argv) printf("\tAdvIfPrefixes: %s\n", rai->rai_advifprefix ? "yes" : "no"); if (rai->rai_clockskew) - printf("\tClock skew: %ldsec\n", + printf("\tClock skew: %" PRIu16 "sec\n", rai->rai_clockskew); if (vflag < LOG_WARNING) @@ -586,7 +587,7 @@ action_show(int argc, char **argv) if (error) continue; - len = *((u_int16_t *)cp.cp_val); + len = *((uint16_t *)cp.cp_val); if (len > 0) { printf("\tRDNSS entries:\n"); @@ -601,7 +602,7 @@ action_show(int argc, char **argv) if (error) continue; - len = *((u_int16_t *)cp.cp_val); + len = *((uint16_t *)cp.cp_val); if (len > 0) { printf("\tDNSSL entries:\n"); @@ -619,11 +620,12 @@ action_show(int argc, char **argv) printf("\tRA initcounts/waits: %d/%d\n", rai->rai_initcounter, rai->rai_waiting); - printf("\tRA out/in/inconsistent: %llu/%llu/%llu\n", + printf("\tRA out/in/inconsistent: " + "%" PRIu64 "/%" PRIu64 "/%" PRIu64 "\n", ifi_s->ifi_raoutput, ifi_s->ifi_rainput, ifi_s->ifi_rainconsistent); - printf("\tRS in: %llu\n", + printf("\tRS in: %" PRIu64 "\n", ifi_s->ifi_rsinput); printf("\n"); @@ -727,17 +729,17 @@ action_show_rdnss(void *msg) { struct rdnss *rdn; struct rdnss_addr *rda; - u_int16_t *rdn_cnt; - u_int16_t *rda_cnt; + uint16_t *rdn_cnt; + uint16_t *rda_cnt; int i; int j; char *p; - u_int32_t ltime; + uint32_t ltime; char ntopbuf[INET6_ADDRSTRLEN]; char ssbuf[SSBUFLEN]; p = msg; - rdn_cnt = (u_int16_t *)p; + rdn_cnt = (uint16_t *)p; p += sizeof(*rdn_cnt); if (*rdn_cnt > 0) { @@ -746,7 +748,7 @@ action_show_rdnss(void *msg) ltime = rdn->rd_ltime; p += sizeof(*rdn); - rda_cnt = (u_int16_t *)p; + rda_cnt = (uint16_t *)p; p += sizeof(*rda_cnt); if (*rda_cnt > 0) for (j = 0; j < *rda_cnt; j++) { @@ -770,17 +772,17 @@ action_show_dnssl(void *msg) { struct dnssl *dns; struct dnssl_addr *dna; - u_int16_t *dns_cnt; - u_int16_t *dna_cnt; + uint16_t *dns_cnt; + uint16_t *dna_cnt; int i; int j; char *p; - u_int32_t ltime; + uint32_t ltime; char hbuf[NI_MAXHOST]; char ssbuf[SSBUFLEN]; p = msg; - dns_cnt = (u_int16_t *)p; + dns_cnt = (uint16_t *)p; p += sizeof(*dns_cnt); if (*dns_cnt > 0) { @@ -789,7 +791,7 @@ action_show_dnssl(void *msg) ltime = dns->dn_ltime; p += sizeof(*dns); - dna_cnt = (u_int16_t *)p; + dna_cnt = (uint16_t *)p; p += sizeof(*dna_cnt); if (*dna_cnt > 0) for (j = 0; j < *dna_cnt; j++) { Modified: user/hrs/ipv6/usr.sbin/rtadvd/config.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/config.c Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvd/config.c Fri Jul 15 04:49:30 2011 (r224053) @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -288,7 +289,7 @@ getconfig(int idx) struct rainfo *rai; struct rainfo *rai_old; struct ifinfo *ifi; - long val; + int32_t val; int64_t val64; char buf[BUFSIZ]; char *bp = buf; @@ -348,24 +349,24 @@ getconfig(int idx) MAYHAVE(val, "maxinterval", DEF_MAXRTRADVINTERVAL); if (val < MIN_MAXINTERVAL || val > MAX_MAXINTERVAL) { syslog(LOG_ERR, - "<%s> maxinterval (%ld) on %s is invalid " + "<%s> maxinterval (%" PRIu32 ") on %s is invalid " "(must be between %u and %u)", __func__, val, ifi->ifi_ifname, MIN_MAXINTERVAL, MAX_MAXINTERVAL); goto getconfig_free_rai; } - rai->rai_maxinterval = (u_int)val; + rai->rai_maxinterval = (uint16_t)val; MAYHAVE(val, "mininterval", rai->rai_maxinterval/3); - if ((u_int)val < MIN_MININTERVAL || - (u_int)val > (rai->rai_maxinterval * 3) / 4) { + if ((uint16_t)val < MIN_MININTERVAL || + (uint16_t)val > (rai->rai_maxinterval * 3) / 4) { syslog(LOG_ERR, - "<%s> mininterval (%ld) on %s is invalid " + "<%s> mininterval (%" PRIu32 ") on %s is invalid " "(must be between %d and %d)", __func__, val, ifi->ifi_ifname, MIN_MININTERVAL, (rai->rai_maxinterval * 3) / 4); goto getconfig_free_rai; } - rai->rai_mininterval = (u_int)val; + rai->rai_mininterval = (uint16_t)val; MAYHAVE(val, "chlim", DEF_ADVCURHOPLIMIT); rai->rai_hoplimit = val & 0xff; @@ -403,10 +404,10 @@ getconfig(int idx) } MAYHAVE(val, "rltime", rai->rai_maxinterval * 3); - if ((u_int)val && ((u_int)val < rai->rai_maxinterval || - (u_int)val > MAXROUTERLIFETIME)) { + if ((uint16_t)val && ((uint16_t)val < rai->rai_maxinterval || + (uint16_t)val > MAXROUTERLIFETIME)) { syslog(LOG_ERR, - "<%s> router lifetime (%ld) on %s is invalid " + "<%s> router lifetime (%" PRIu32 ") on %s is invalid " "(must be 0 or between %d and %d)", __func__, val, ifi->ifi_ifname, rai->rai_maxinterval, MAXROUTERLIFETIME); @@ -417,20 +418,20 @@ getconfig(int idx) MAYHAVE(val, "rtime", DEF_ADVREACHABLETIME); if (val < 0 || val > MAXREACHABLETIME) { syslog(LOG_ERR, - "<%s> reachable time (%ld) on %s is invalid " + "<%s> reachable time (%" PRIu32 ") on %s is invalid " "(must be no greater than %d)", __func__, val, ifi->ifi_ifname, MAXREACHABLETIME); goto getconfig_free_rai; } - rai->rai_reachabletime = (u_int32_t)val; + rai->rai_reachabletime = (uint32_t)val; MAYHAVE(val64, "retrans", DEF_ADVRETRANSTIMER); if (val64 < 0 || val64 > 0xffffffff) { - syslog(LOG_ERR, "<%s> retrans time (%lld) on %s out of range", - __func__, (long long)val64, ifi->ifi_ifname); + syslog(LOG_ERR, "<%s> retrans time (%" PRIu64 ") on %s out of range", + __func__, val64, ifi->ifi_ifname); goto getconfig_free_rai; } - rai->rai_retranstimer = (u_int32_t)val64; + rai->rai_retranstimer = (uint32_t)val64; if (agetnum("hapref") != -1 || agetnum("hatime") != -1) { syslog(LOG_ERR, @@ -484,7 +485,7 @@ getconfig(int idx) makeentry(entbuf, sizeof(entbuf), i, "prefixlen"); MAYHAVE(val, entbuf, 64); if (val < 0 || val > 128) { - syslog(LOG_ERR, "<%s> prefixlen (%ld) for %s " + syslog(LOG_ERR, "<%s> prefixlen (%" PRIu32 ") for %s " "on %s out of range", __func__, val, addr, ifi->ifi_ifname); goto getconfig_free_pfx; @@ -508,13 +509,13 @@ getconfig(int idx) makeentry(entbuf, sizeof(entbuf), i, "vltime"); MAYHAVE(val64, entbuf, DEF_ADVVALIDLIFETIME); if (val64 < 0 || val64 > 0xffffffff) { - syslog(LOG_ERR, "<%s> vltime (%lld) for " + syslog(LOG_ERR, "<%s> vltime (%" PRIu64 ") for " "%s/%d on %s is out of range", - __func__, (long long)val64, + __func__, val64, addr, pfx->pfx_prefixlen, ifi->ifi_ifname); goto getconfig_free_pfx; } - pfx->pfx_validlifetime = (u_int32_t)val64; + pfx->pfx_validlifetime = (uint32_t)val64; makeentry(entbuf, sizeof(entbuf), i, "vltimedecr"); if (agetflag(entbuf)) { @@ -528,13 +529,13 @@ getconfig(int idx) MAYHAVE(val64, entbuf, DEF_ADVPREFERREDLIFETIME); if (val64 < 0 || val64 > 0xffffffff) { syslog(LOG_ERR, - "<%s> pltime (%lld) for %s/%d on %s " + "<%s> pltime (%" PRIu64 ") for %s/%d on %s " "is out of range", - __func__, (long long)val64, + __func__, val64, addr, pfx->pfx_prefixlen, ifi->ifi_ifname); goto getconfig_free_pfx; } - pfx->pfx_preflifetime = (u_int32_t)val64; + pfx->pfx_preflifetime = (uint32_t)val64; makeentry(entbuf, sizeof(entbuf), i, "pltimedecr"); if (agetflag(entbuf)) { @@ -553,14 +554,14 @@ getconfig_free_pfx: if (rai->rai_advifprefix && rai->rai_pfxs == 0) get_prefix(rai); - MAYHAVE(val, "mtu", 0); - if (val < 0 || (u_int)val > 0xffffffff) { + MAYHAVE(val64, "mtu", 0); + if (val < 0 || val64 > 0xffffffff) { syslog(LOG_ERR, - "<%s> mtu (%ld) on %s out of range", - __func__, val, ifi->ifi_ifname); + "<%s> mtu (%" PRIu64 ") on %s out of range", + __func__, val64, ifi->ifi_ifname); goto getconfig_free_rai; } - rai->rai_linkmtu = (u_int32_t)val; + rai->rai_linkmtu = (uint32_t)val64; if (rai->rai_linkmtu == 0) { char *mtustr; @@ -571,9 +572,9 @@ getconfig_free_pfx: else if (rai->rai_linkmtu < IPV6_MMTU || rai->rai_linkmtu > ifi->ifi_phymtu) { syslog(LOG_ERR, - "<%s> advertised link mtu (%lu) on %s is invalid (must " + "<%s> advertised link mtu (%" PRIu32 ") on %s is invalid (must " "be between least MTU (%d) and physical link MTU (%d)", - __func__, (unsigned long)rai->rai_linkmtu, ifi->ifi_ifname, + __func__, rai->rai_linkmtu, ifi->ifi_ifname, IPV6_MMTU, ifi->ifi_phymtu); goto getconfig_free_rai; } @@ -668,7 +669,7 @@ getconfig_free_pfx: val = 64; } if (val < 0 || val > 128) { - syslog(LOG_ERR, "<%s> prefixlen (%ld) for %s on %s " + syslog(LOG_ERR, "<%s> prefixlen (%" PRIu32 ") for %s on %s " "out of range", __func__, val, addr, ifi->ifi_ifname); goto getconfig_free_rti; @@ -732,13 +733,13 @@ getconfig_free_pfx: } } if (val64 < 0 || val64 > 0xffffffff) { - syslog(LOG_ERR, "<%s> route lifetime (%lld) for " + syslog(LOG_ERR, "<%s> route lifetime (%" PRIu64 ") for " "%s/%d on %s out of range", __func__, - (long long)val64, addr, rti->rti_prefixlen, + val64, addr, rti->rti_prefixlen, ifi->ifi_ifname); goto getconfig_free_rti; } - rti->rti_ltime = (u_int32_t)val64; + rti->rti_ltime = (uint32_t)val64; /* link into chain */ TAILQ_INSERT_TAIL(&rai->rai_route, rti, rti_next); @@ -779,9 +780,9 @@ getconfig_free_rti: makeentry(entbuf, sizeof(entbuf), i, "rdnssltime"); MAYHAVE(val, entbuf, (rai->rai_maxinterval * 3 / 2)); - if ((u_int)val < rai->rai_maxinterval || - (u_int)val > rai->rai_maxinterval * 2) { - syslog(LOG_ERR, "%s (%ld) on %s is invalid " + if ((uint16_t)val < rai->rai_maxinterval || + (uint16_t)val > rai->rai_maxinterval * 2) { + syslog(LOG_ERR, "%s (%" PRIu16 ") on %s is invalid " "(must be between %d and %d)", entbuf, val, ifi->ifi_ifname, rai->rai_maxinterval, rai->rai_maxinterval * 2); @@ -828,9 +829,9 @@ getconfig_free_rdn: makeentry(entbuf, sizeof(entbuf), i, "dnsslltime"); MAYHAVE(val, entbuf, (rai->rai_maxinterval * 3 / 2)); - if ((u_int)val < rai->rai_maxinterval || - (u_int)val > rai->rai_maxinterval * 2) { - syslog(LOG_ERR, "%s (%ld) on %s is invalid " + if ((uint16_t)val < rai->rai_maxinterval || + (uint16_t)val > rai->rai_maxinterval * 2) { + syslog(LOG_ERR, "%s (%" PRIu16 ") on %s is invalid " "(must be between %d and %d)", entbuf, val, ifi->ifi_ifname, rai->rai_maxinterval, rai->rai_maxinterval * 2); @@ -891,8 +892,8 @@ get_prefix(struct rainfo *rai) struct prefix *pfx; struct in6_addr *a; struct ifinfo *ifi; - u_char *p, *ep, *m, *lim; - u_char ntopbuf[INET6_ADDRSTRLEN]; + char *p, *ep, *m, *lim; + char ntopbuf[INET6_ADDRSTRLEN]; if (getifaddrs(&ifap) < 0) { syslog(LOG_ERR, @@ -913,8 +914,8 @@ get_prefix(struct rainfo *rai) if (IN6_IS_ADDR_LINKLOCAL(a)) continue; /* get prefix length */ - m = (u_char *)&((struct sockaddr_in6 *)ifa->ifa_netmask)->sin6_addr; - lim = (u_char *)(ifa->ifa_netmask) + ifa->ifa_netmask->sa_len; + m = (char *)&((struct sockaddr_in6 *)ifa->ifa_netmask)->sin6_addr; + lim = (char *)(ifa->ifa_netmask) + ifa->ifa_netmask->sa_len; plen = prefixlen(m, lim); if (plen <= 0 || plen > 128) { syslog(LOG_ERR, "<%s> failed to get prefixlen " @@ -935,8 +936,8 @@ get_prefix(struct rainfo *rai) /* set prefix, sweep bits outside of prefixlen */ pfx->pfx_prefixlen = plen; memcpy(&pfx->pfx_prefix, a, sizeof(*a)); - p = (u_char *)&pfx->pfx_prefix; - ep = (u_char *)(&pfx->pfx_prefix + 1); + p = (char *)&pfx->pfx_prefix; + ep = (char *)(&pfx->pfx_prefix + 1); while (m < lim && p < ep) *p++ &= *m++; while (p < ep) @@ -990,7 +991,7 @@ add_prefix(struct rainfo *rai, struct in { struct prefix *pfx; struct ifinfo *ifi; - u_char ntopbuf[INET6_ADDRSTRLEN]; + char ntopbuf[INET6_ADDRSTRLEN]; ifi = rai->rai_ifinfo; ELM_MALLOC(pfx, return); @@ -1025,7 +1026,7 @@ delete_prefix(struct prefix *pfx) { struct rainfo *rai; struct ifinfo *ifi; - u_char ntopbuf[INET6_ADDRSTRLEN]; + char ntopbuf[INET6_ADDRSTRLEN]; rai = pfx->pfx_rainfo; ifi = rai->rai_ifinfo; @@ -1047,7 +1048,7 @@ invalidate_prefix(struct prefix *pfx) struct timeval timo; struct rainfo *rai; struct ifinfo *ifi; - u_char ntopbuf[INET6_ADDRSTRLEN]; + char ntopbuf[INET6_ADDRSTRLEN]; rai = pfx->pfx_rainfo; ifi = rai->rai_ifinfo; @@ -1089,7 +1090,7 @@ update_prefix(struct prefix *pfx) { struct rainfo *rai; struct ifinfo *ifi; - u_char ntopbuf[INET6_ADDRSTRLEN]; + char ntopbuf[INET6_ADDRSTRLEN]; rai = pfx->pfx_rainfo; ifi = rai->rai_ifinfo; @@ -1137,7 +1138,7 @@ init_prefix(struct in6_prefixreq *ipr) /* omit other field initialization */ } else if (ipr->ipr_origin < PR_ORIG_RR) { - u_char ntopbuf[INET6_ADDRSTRLEN]; + char ntopbuf[INET6_ADDRSTRLEN]; syslog(LOG_WARNING, "<%s> Added prefix(%s)'s origin %d is" "lower than PR_ORIG_RR(router renumbering)." @@ -1263,7 +1264,7 @@ make_packet(struct rainfo *rai) ra->nd_ra_type = ND_ROUTER_ADVERT; ra->nd_ra_code = 0; ra->nd_ra_cksum = 0; - ra->nd_ra_curhoplimit = (u_int8_t)(0xff & rai->rai_hoplimit); + ra->nd_ra_curhoplimit = (uint8_t)(0xff & rai->rai_hoplimit); ra->nd_ra_flags_reserved = 0; /* just in case */ /* * XXX: the router preference field, which is a 2-bit field, should be @@ -1294,7 +1295,7 @@ make_packet(struct rainfo *rai) } TAILQ_FOREACH(pfx, &rai->rai_prefix, pfx_next) { - u_int32_t vltime, pltime; + uint32_t vltime, pltime; struct timeval now; ndopt_pi = (struct nd_opt_prefix_info *)buf; @@ -1316,7 +1317,7 @@ make_packet(struct rainfo *rai) if (pfx->pfx_vltimeexpire == 0) vltime = pfx->pfx_validlifetime; else - vltime = (pfx->pfx_vltimeexpire > now.tv_sec) ? + vltime = ((time_t)pfx->pfx_vltimeexpire > now.tv_sec) ? pfx->pfx_vltimeexpire - now.tv_sec : 0; } if (pfx->pfx_timer) @@ -1325,7 +1326,7 @@ make_packet(struct rainfo *rai) if (pfx->pfx_pltimeexpire == 0) pltime = pfx->pfx_preflifetime; else - pltime = (pfx->pfx_pltimeexpire > now.tv_sec) ? + pltime = ((time_t)pfx->pfx_pltimeexpire > now.tv_sec) ? pfx->pfx_pltimeexpire - now.tv_sec : 0; } if (vltime < pltime) { @@ -1344,7 +1345,7 @@ make_packet(struct rainfo *rai) } TAILQ_FOREACH(rti, &rai->rai_route, rti_next) { - u_int8_t psize = (rti->rti_prefixlen + 0x3f) >> 6; + uint8_t psize = (rti->rti_prefixlen + 0x3f) >> 6; ndopt_rti = (struct nd_opt_route_info *)buf; ndopt_rti->nd_opt_rti_type = ND_OPT_ROUTE_INFO; Modified: user/hrs/ipv6/usr.sbin/rtadvd/control.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control.c Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvd/control.c Fri Jul 15 04:49:30 2011 (r224053) @@ -157,12 +157,12 @@ cmsg_send(int fd, char *buf) } syslog(LOG_DEBUG, - "<%s> ctrl msg send: type=%d, count=%d, total_len=%d", __func__, + "<%s> ctrl msg send: type=%d, count=%d, total_len=%zd", __func__, cm->cm_type, iovcnt, iov_len_total); len = writev(fd, iov, iovcnt); syslog(LOG_DEBUG, - "<%s> ctrl msg send: length=%d", __func__, len); + "<%s> ctrl msg send: length=%zd", __func__, len); if (len == -1) { syslog(LOG_DEBUG, @@ -173,9 +173,9 @@ cmsg_send(int fd, char *buf) } syslog(LOG_DEBUG, - "<%s> write length = %d (actual)", __func__, len); + "<%s> write length = %zd (actual)", __func__, len); syslog(LOG_DEBUG, - "<%s> write length = %d (expected)", __func__, iov_len_total); + "<%s> write length = %zd (expected)", __func__, iov_len_total); if (len != iov_len_total) { close(fd); @@ -317,7 +317,7 @@ cmsg_bin2pl(char *str, struct ctrl_msg_p lenp = (size_t *)p; len = *lenp++; p = (char *)lenp; - syslog(LOG_DEBUG, "<%s> len(ifname) = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len(ifname) = %zu", __func__, len); if (len > 0) { cp->cp_ifname = malloc(len + 1); if (cp->cp_ifname == NULL) { @@ -332,7 +332,7 @@ cmsg_bin2pl(char *str, struct ctrl_msg_p lenp = (size_t *)p; len = *lenp++; p = (char *)lenp; - syslog(LOG_DEBUG, "<%s> len(key) = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len(key) = %zu", __func__, len); if (len > 0) { cp->cp_key = malloc(len + 1); if (cp->cp_key == NULL) { @@ -347,7 +347,7 @@ cmsg_bin2pl(char *str, struct ctrl_msg_p lenp = (size_t *)p; len = *lenp++; p = (char *)lenp; - syslog(LOG_DEBUG, "<%s> len(val) = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len(val) = %zu", __func__, len); if (len > 0) { cp->cp_val = malloc(len + 1); if (cp->cp_val == NULL) { @@ -382,11 +382,11 @@ cmsg_pl2bin(char *str, struct ctrl_msg_p len += cp->cp_val_len; if (len > CM_MSG_MAXLEN - sizeof(*cm)) { - syslog(LOG_DEBUG, "<%s> msg too long (len=%d)", + syslog(LOG_DEBUG, "<%s> msg too long (len=%zu)", __func__, len); return (0); } - syslog(LOG_DEBUG, "<%s> msglen=%d", __func__, len); + syslog(LOG_DEBUG, "<%s> msglen=%zu", __func__, len); memset(str, 0, len); p = str; lenp = (size_t *)p; @@ -434,11 +434,11 @@ cmsg_str2bin(char *bin, void *str, size_ syslog(LOG_DEBUG, "<%s> enter", __func__); if (len > CM_MSG_MAXLEN - sizeof(*cm)) { - syslog(LOG_DEBUG, "<%s> msg too long (len=%d)", + syslog(LOG_DEBUG, "<%s> msg too long (len=%zu)", __func__, len); return (0); } - syslog(LOG_DEBUG, "<%s> msglen=%d", __func__, len); + syslog(LOG_DEBUG, "<%s> msglen=%zu", __func__, len); memcpy(bin, (char *)str, len); return (len); Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Fri Jul 15 04:49:30 2011 (r224053) @@ -131,7 +131,7 @@ cmsg_getprop_ifilist(struct ctrl_msg_pl len += strlen(ifi->ifi_ifname) + 1; } - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); p = malloc(len); if (p == NULL) @@ -175,7 +175,7 @@ cmsg_getprop_ifi(struct ctrl_msg_pl *cp) exit(1); len = cmsg_str2bin(p, ifi, sizeof(*ifi)); - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); if (len == 0) return (1); @@ -216,7 +216,7 @@ cmsg_getprop_rai(struct ctrl_msg_pl *cp) exit(1); len = cmsg_str2bin(p, rai, sizeof(*rai)); - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); if (len == 0) return (1); @@ -262,7 +262,7 @@ cmsg_getprop_rai_timer(struct ctrl_msg_p exit(1); len = cmsg_str2bin(p, rtimer, sizeof(*rtimer)); - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); if (len == 0) return (1); @@ -304,7 +304,7 @@ cmsg_getprop_rti(struct ctrl_msg_pl *cp) len += sizeof(*rti); } - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); p = malloc(len); if (p == NULL) @@ -353,7 +353,7 @@ cmsg_getprop_pfx(struct ctrl_msg_pl *cp) len += sizeof(*pfx); } - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); p = malloc(len); if (p == NULL) @@ -380,8 +380,8 @@ cmsg_getprop_rdnss(struct ctrl_msg_pl *c struct rdnss_addr *rda; char *p; size_t len; - u_int16_t *rdn_cnt; - u_int16_t *rda_cnt; + uint16_t *rdn_cnt; + uint16_t *rda_cnt; syslog(LOG_DEBUG, "<%s> enter", __func__); @@ -411,7 +411,7 @@ cmsg_getprop_rdnss(struct ctrl_msg_pl *c } } - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); p = malloc(len); if (p == NULL) @@ -419,14 +419,14 @@ cmsg_getprop_rdnss(struct ctrl_msg_pl *c memset(p, 0, len); cp->cp_val = p; - rdn_cnt = (u_int16_t *)p; + rdn_cnt = (uint16_t *)p; p += sizeof(*rdn_cnt); TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) { *rdn_cnt += 1; memcpy(p, rdn, sizeof(*rdn)); p += sizeof(*rdn); - rda_cnt = (u_int16_t *)p; + rda_cnt = (uint16_t *)p; p += sizeof(*rda_cnt); TAILQ_FOREACH(rda, &rdn->rd_list, ra_next) { *rda_cnt += 1; @@ -449,8 +449,8 @@ cmsg_getprop_dnssl(struct ctrl_msg_pl *c struct dnssl_addr *dna; char *p; size_t len; - u_int16_t *dns_cnt; - u_int16_t *dna_cnt; + uint16_t *dns_cnt; + uint16_t *dna_cnt; syslog(LOG_DEBUG, "<%s> enter", __func__); @@ -480,7 +480,7 @@ cmsg_getprop_dnssl(struct ctrl_msg_pl *c } } - syslog(LOG_DEBUG, "<%s> len = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> len = %zu", __func__, len); p = malloc(len); if (p == NULL) @@ -488,14 +488,14 @@ cmsg_getprop_dnssl(struct ctrl_msg_pl *c memset(p, 0, len); cp->cp_val = p; - dns_cnt = (u_int16_t *)cp->cp_val; + dns_cnt = (uint16_t *)cp->cp_val; p += sizeof(*dns_cnt); TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) { (*dns_cnt)++; memcpy(p, dns, sizeof(*dns)); p += sizeof(*dns); - dna_cnt = (u_int16_t *)p; + dna_cnt = (uint16_t *)p; p += sizeof(*dna_cnt); TAILQ_FOREACH(dna, &dns->dn_list, da_next) { (*dna_cnt)++; @@ -620,7 +620,7 @@ cmsg_handler_server(int fd) syslog(LOG_DEBUG, "<%s> cm->cm_type = %d", __func__, cm->cm_type); syslog(LOG_DEBUG, - "<%s> cm->cm_len = %d", __func__, cm->cm_len); + "<%s> cm->cm_len = %zu", __func__, cm->cm_len); switch (cm->cm_type) { case CM_TYPE_EOM: Modified: user/hrs/ipv6/usr.sbin/rtadvd/if.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/if.c Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvd/if.c Fri Jul 15 04:49:30 2011 (r224053) @@ -281,24 +281,24 @@ get_prefixlen(char *buf) { struct rt_msghdr *rtm = (struct rt_msghdr *)buf; struct sockaddr *sa, *rti_info[RTAX_MAX]; - u_char *p, *lim; + char *p, *lim; sa = (struct sockaddr *)(rtm + 1); get_rtaddrs(rtm->rtm_addrs, sa, rti_info); sa = rti_info[RTAX_NETMASK]; - p = (u_char *)(&SIN6(sa)->sin6_addr); - lim = (u_char *)sa + sa->sa_len; + p = (char *)(&SIN6(sa)->sin6_addr); + lim = (char *)sa + sa->sa_len; return prefixlen(p, lim); } int -prefixlen(u_char *p, u_char *lim) +prefixlen(char *p, char *lim) { int masklen; for (masklen = 0; p < lim; p++) { - switch (*p) { + switch ((int)*p) { case 0xff: masklen += 8; break; @@ -442,7 +442,7 @@ update_ifinfo(struct ifilist_head_t *ifi ifm = get_next_msghdr(ifm,(struct if_msghdr *)lim)) { int ifi_new; - syslog(LOG_DEBUG, "<%s> ifm = %p, lim = %p, diff = %d", + syslog(LOG_DEBUG, "<%s> ifm = %p, lim = %p, diff = %zu", __func__, ifm, lim, (char *)lim - (char *)ifm); if (ifm->ifm_version != RTM_VERSION) { Modified: user/hrs/ipv6/usr.sbin/rtadvd/if.h ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/if.h Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvd/if.h Fri Jul 15 04:49:30 2011 (r224053) @@ -48,7 +48,7 @@ char *get_next_msg(char *, char *, int, struct in6_addr *get_addr(char *); int get_rtm_ifindex(char *); int get_prefixlen(char *); -int prefixlen(u_char *, u_char *); +int prefixlen(char *, char *); struct ifinfo *update_ifinfo(struct ifilist_head_t *, int); int update_ifinfo_nd_flags(struct ifinfo *); Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Fri Jul 15 04:49:30 2011 (r224053) @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -83,9 +84,9 @@ #define RTADV_TYPE2BITMASK(type) (0x1 << type) struct msghdr rcvmhdr; -static u_char *rcvcmsgbuf; +static char *rcvcmsgbuf; static size_t rcvcmsgbuflen; -static u_char *sndcmsgbuf = NULL; +static char *sndcmsgbuf = NULL; static size_t sndcmsgbuflen; struct msghdr sndmhdr; struct iovec rcviov[2]; @@ -137,7 +138,7 @@ union nd_opt { #define NDOPT_FLAG_RDNSS (1 << 5) #define NDOPT_FLAG_DNSSL (1 << 6) -u_int32_t ndopt_flags[] = { +uint32_t ndopt_flags[] = { [ND_OPT_SOURCE_LINKADDR] = NDOPT_FLAG_SRCLINKADDR, [ND_OPT_TARGET_LINKADDR] = NDOPT_FLAG_TGTLINKADDR, [ND_OPT_PREFIX_INFORMATION] = NDOPT_FLAG_PREFIXINFO, @@ -158,7 +159,7 @@ static void ra_input(int, struct nd_rout static int prefix_check(struct nd_opt_prefix_info *, struct rainfo *, struct sockaddr_in6 *); static int nd6_options(struct nd_opt_hdr *, int, - union nd_opt *, u_int32_t); + union nd_opt *, uint32_t); static void free_ndopts(union nd_opt *); static void rtmsg_input(struct sockinfo *); static void set_short_delay(struct rainfo *); @@ -240,7 +241,7 @@ main(int argc, char *argv[]) #ifdef __FreeBSD__ srandomdev(); #else - srandom((u_long)time(NULL)); + srandom((unsigned long)time(NULL)); #endif #endif pfh = pidfile_open(pidfilename, 0600, &otherpid); @@ -395,7 +396,7 @@ rtmsg_input(struct sockinfo *s) int n, type, ifindex = 0, plen; size_t len; char msg[2048], *next, *lim; - u_char ifname[IFNAMSIZ]; + char ifname[IFNAMSIZ]; struct if_announcemsghdr *ifan; struct rt_msghdr *rtm; struct prefix *pfx; @@ -643,7 +644,7 @@ rtadvd_input(struct sockinfo *s) int ifindex = 0; struct cmsghdr *cm; struct in6_pktinfo *pi = NULL; - u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; + char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; struct in6_addr dst = in6addr_any; struct ifinfo *ifi; @@ -839,8 +840,8 @@ static void rs_input(int len, struct nd_router_solicit *rs, struct in6_pktinfo *pi, struct sockaddr_in6 *from) { - u_char ntopbuf[INET6_ADDRSTRLEN]; - u_char ifnamebuf[IFNAMSIZ]; + char ntopbuf[INET6_ADDRSTRLEN]; + char ifnamebuf[IFNAMSIZ]; union nd_opt ndopts; struct rainfo *rai; struct ifinfo *ifi; @@ -986,10 +987,7 @@ check_accept_rtadv(int idx) __func__, idx); return (0); } -#if (__FreeBSD_version < 900000) - return ((getinet6sysctl(IPV6CTL_FORWARDING) == 0) && - (getinet6sysctl(IPV6CTL_ACCEPT_RTADV) == 1)); -#else +#if (__FreeBSD_version > 900000) if (update_ifinfo_nd_flags(ifi) != 0) { syslog(LOG_ERR, "<%s> nd6 flags failed (idx=%d)", @@ -998,6 +996,9 @@ check_accept_rtadv(int idx) } return (ifi->ifi_nd_flags & ND6_IFF_ACCEPT_RTADV); +#else + return ((getinet6sysctl(IPV6CTL_FORWARDING) == 0) && + (getinet6sysctl(IPV6CTL_ACCEPT_RTADV) == 1)); #endif } @@ -1007,11 +1008,11 @@ ra_input(int len, struct nd_router_adver { struct rainfo *rai; struct ifinfo *ifi; - u_char ntopbuf[INET6_ADDRSTRLEN]; - u_char ifnamebuf[IFNAMSIZ]; + char ntopbuf[INET6_ADDRSTRLEN]; + char ifnamebuf[IFNAMSIZ]; union nd_opt ndopts; const char *on_off[] = {"OFF", "ON"}; - u_int32_t reachabletime, retranstimer, mtu; + uint32_t reachabletime, retranstimer, mtu; int inconsistent = 0; int error; @@ -1051,7 +1052,7 @@ ra_input(int len, struct nd_router_adver } rai = ifi->ifi_rainfo; ifi->ifi_rainput++; - syslog(LOG_DEBUG, "<%s> ifi->ifi_rainput = %llu\n", __func__, + syslog(LOG_DEBUG, "<%s> ifi->ifi_rainput = %" PRIu64 "\n", __func__, ifi->ifi_rainput); /* Cur Hop Limit value */ @@ -1152,11 +1153,11 @@ prefix_check(struct nd_opt_prefix_info * struct rainfo *rai, struct sockaddr_in6 *from) { struct ifinfo *ifi; - u_int32_t preferred_time, valid_time; + uint32_t preferred_time, valid_time; struct prefix *pfx; int inconsistent = 0; - u_char ntopbuf[INET6_ADDRSTRLEN]; - u_char prefixbuf[INET6_ADDRSTRLEN]; + char ntopbuf[INET6_ADDRSTRLEN]; + char prefixbuf[INET6_ADDRSTRLEN]; struct timeval now; #if 0 /* impossible */ @@ -1208,7 +1209,7 @@ prefix_check(struct nd_opt_prefix_info * syslog(LOG_INFO, "<%s> preferred lifetime for %s/%d" " (decr. in real time) inconsistent on %s:" - " %d from %s, %ld from us", + " %" PRIu32 " from %s, %" PRIu32 " from us", __func__, inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, sizeof(prefixbuf)), @@ -1241,7 +1242,7 @@ prefix_check(struct nd_opt_prefix_info * syslog(LOG_INFO, "<%s> valid lifetime for %s/%d" " (decr. in real time) inconsistent on %s:" - " %d from %s, %ld from us", + " %d from %s, %" PRIu32 " from us", __func__, inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, sizeof(prefixbuf)), @@ -1274,7 +1275,7 @@ find_prefix(struct rainfo *rai, struct i { struct prefix *pfx; int bytelen, bitlen; - u_char bitmask; + char bitmask; TAILQ_FOREACH(pfx, &rai->rai_prefix, pfx_next) { if (plen != pfx->pfx_prefixlen) @@ -1303,7 +1304,7 @@ prefix_match(struct in6_addr *p0, int pl struct in6_addr *p1, int plen1) { int bytelen, bitlen; - u_char bitmask; + char bitmask; if (plen0 < plen1) return (0); @@ -1326,7 +1327,7 @@ prefix_match(struct in6_addr *p0, int pl static int nd6_options(struct nd_opt_hdr *hdr, int limit, - union nd_opt *ndopts, u_int32_t optflags) + union nd_opt *ndopts, uint32_t optflags) { int optlen = 0; @@ -1456,7 +1457,7 @@ sock_open(struct sockinfo *s) struct icmp6_filter filt; int on; /* XXX: should be max MTU attached to the node */ - static u_char answer[1500]; + static char answer[1500]; syslog(LOG_DEBUG, "<%s> enter", __func__); @@ -1466,7 +1467,7 @@ sock_open(struct sockinfo *s) } rcvcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int)); - rcvcmsgbuf = (u_char *)malloc(rcvcmsgbuflen); + rcvcmsgbuf = (char *)malloc(rcvcmsgbuflen); if (rcvcmsgbuf == NULL) { syslog(LOG_ERR, "<%s> not enough core", __func__); exit(1); @@ -1474,7 +1475,7 @@ sock_open(struct sockinfo *s) sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int)); - sndcmsgbuf = (u_char *)malloc(sndcmsgbuflen); + sndcmsgbuf = (char *)malloc(sndcmsgbuflen); if (sndcmsgbuf == NULL) { syslog(LOG_ERR, "<%s> not enough core", __func__); exit(1); Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Fri Jul 15 04:31:50 2011 (r224052) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Fri Jul 15 04:49:30 2011 (r224053) @@ -113,12 +113,12 @@ struct prefix { */ struct rtadvd_timer *pfx_timer; - u_int32_t pfx_validlifetime; /* AdvValidLifetime */ - long pfx_vltimeexpire; /* Expiration of vltime */ - u_int32_t pfx_preflifetime; /* AdvPreferredLifetime */ - long pfx_pltimeexpire; /* Expiration of pltime */ - u_int pfx_onlinkflg; /* bool: AdvOnLinkFlag */ - u_int pfx_autoconfflg; /* bool: AdvAutonomousFlag */ + uint32_t pfx_validlifetime; /* AdvValidLifetime */ + uint32_t pfx_vltimeexpire; /* Expiration of vltime */ + uint32_t pfx_preflifetime; /* AdvPreferredLifetime */ + uint32_t pfx_pltimeexpire; /* Expiration of pltime */ + int pfx_onlinkflg; /* bool: AdvOnLinkFlag */ + int pfx_autoconfflg; /* bool: AdvAutonomousFlag */ int pfx_prefixlen; int pfx_origin; /* From kernel or config */ @@ -128,8 +128,8 @@ struct prefix { struct rtinfo { TAILQ_ENTRY(rtinfo) rti_next; - u_int32_t rti_ltime; /* route lifetime */ - u_int rti_rtpref; /* route preference */ + uint32_t rti_ltime; /* route lifetime */ + int rti_rtpref; /* route preference */ int rti_prefixlen; struct in6_addr rti_prefix; }; @@ -144,8 +144,7 @@ struct rdnss { TAILQ_ENTRY(rdnss) rd_next; TAILQ_HEAD(, rdnss_addr) rd_list; /* list of DNS servers */ - int rd_cnt; /* number of DNS servers */ - u_int32_t rd_ltime; /* number of seconds valid */ + uint32_t rd_ltime; /* number of seconds valid */ }; /* @@ -170,7 +169,7 @@ struct dnssl { TAILQ_ENTRY(dnssl) dn_next; TAILQ_HEAD(, dnssl_addr) dn_list; /* list of search domains */ - u_int32_t dn_ltime; /* number of seconds valid */ + uint32_t dn_ltime; /* number of seconds valid */ }; struct soliciter { @@ -195,26 +194,26 @@ struct rainfo { /* interface information */ struct ifinfo *rai_ifinfo; - int rai_advlinkopt; /* bool: whether include link-layer addr opt */ + int rai_advlinkopt; /* bool: whether include link-layer addr opt */ int rai_advifprefix; /* bool: gather IF prefixes? */ /* Router configuration variables */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri Jul 15 05:57:10 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2566C1065672; Fri, 15 Jul 2011 05:57:10 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F0B3C8FC12; Fri, 15 Jul 2011 05:57:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6F5v93H063064; Fri, 15 Jul 2011 05:57:09 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6F5v9dM063062; Fri, 15 Jul 2011 05:57:09 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107150557.p6F5v9dM063062@svn.freebsd.org> From: Hiroki Sato Date: Fri, 15 Jul 2011 05:57:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224054 - user/hrs/ipv6/usr.sbin/rtadvctl X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2011 05:57:10 -0000 Author: hrs Date: Fri Jul 15 05:57:09 2011 New Revision: 224054 URL: http://svn.freebsd.org/changeset/base/224054 Log: - Fix grammatical errors. - Add AUTHOURS section. Suggested by: Benjamin Kaduk Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Fri Jul 15 04:49:30 2011 (r224053) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Fri Jul 15 05:57:09 2011 (r224054) @@ -39,36 +39,37 @@ .Op Ar interface ... .Sh DESCRIPTION .Nm -is a utility that communicates +is a utility that communicates with .Xr rtadvd 8 -daemon and displays information on Router Advertisement messages being -sent on each interfaces. +daemon and displays information about Router Advertisement messages being +sent on each interface. .Pp This utility provides several options and subcommands. The options are as follows: .Bl -tag -width indent .\" .It Fl v -Increase verbose level. When specified once, the +Increase verbosity level. +When specified once, the .Nm -utility shows additional information on prefixes, RDNSS, and DNSSL +utility shows additional information about prefixes, RDNSS, and DNSSL options. -When twice, it shows information on inactive interfaces and -some statistics. +When given twice, it additionally shows information about +inactive interfaces and some statistics. .El .Pp The subcommands are as follows: .Bl -tag -width indent .\" .It reload -Specifies reloading the configuration file. +Specifies to reload the configuration file. .It shutdown -Makes +Makes the .Xr rtadvd 8 daemon shut down immediately. .It show Op interfaces... Displays information on Router Advertisement messages being sent -on each interfaces. +on each interface. .Sh SEE ALSO .Xr rtadv 8 , .Xr rtadvd.conf 5 @@ -77,6 +78,10 @@ The .Nm command first appeared in .Fx 9.0 . +.Sh AUTHORS +.Nm +was written by +.An "Hiroki Sato" Aq hrs@FreeBSD.org . .Sh BUGS The .Xr rtadvd 8 @@ -87,6 +92,6 @@ subcommand. This is because in the current implementation it cannot communicate with .Nm -during sending some additional RAs for graceful transition from one +while sending some additional RAs for graceful transition from one configuration to another. It will take at most nine seconds for each interface. From owner-svn-src-user@FreeBSD.ORG Fri Jul 15 06:54:22 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8C261065673; Fri, 15 Jul 2011 06:54:21 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CDD658FC19; Fri, 15 Jul 2011 06:54:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6F6sLOB064754; Fri, 15 Jul 2011 06:54:21 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6F6sLL7064747; Fri, 15 Jul 2011 06:54:21 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107150654.p6F6sLL7064747@svn.freebsd.org> From: Hiroki Sato Date: Fri, 15 Jul 2011 06:54:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224055 - in user/hrs/ipv6/usr.sbin: rtadvctl rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2011 06:54:22 -0000 Author: hrs Date: Fri Jul 15 06:54:21 2011 New Revision: 224055 URL: http://svn.freebsd.org/changeset/base/224055 Log: Implement enable and disable subcommands. Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c user/hrs/ipv6/usr.sbin/rtadvd/control_server.c user/hrs/ipv6/usr.sbin/rtadvd/control_server.h user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Fri Jul 15 05:57:09 2011 (r224054) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Fri Jul 15 06:54:21 2011 (r224055) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 14, 2011 +.Dd July 15, 2011 .Dt RTADVCTL 8 .Os .Sh NAME @@ -61,8 +61,22 @@ inactive interfaces and some statistics. The subcommands are as follows: .Bl -tag -width indent .\" -.It reload -Specifies to reload the configuration file. +.It reload Op interfaces... +Specifies to reload the configuration file. If one or more +.Ar interface +is specified, configuration entries for the interfaces will be reloaded +selectively. +.It enable interfaces... +Specifies to mark the interface as enable and to try to reload the +configuration entry. +This subcommand is useful for dynamically-added interfaces. +.Pp +The +.Xr rtadvd 8 +daemon marks an interface as enable if the interface exists and the +configuration file has a valid entry for that when it is invoked. +.It disable interfaces... +Specifies to mark the interface as disable. .It shutdown Makes the .Xr rtadvd 8 Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Fri Jul 15 05:57:09 2011 (r224054) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Fri Jul 15 06:54:21 2011 (r224055) @@ -107,9 +107,9 @@ static struct dispatch_table { { "show", action_show }, { "reload", action_reload }, { "shutdown", action_shutdown }, - { NULL, NULL }, { "enable", action_enable }, { "disable", action_disable }, + { NULL, NULL }, { "echo", action_echo }, { "version", action_version }, { NULL, NULL }, @@ -294,33 +294,69 @@ action_propset(char *argv) return (action_plgeneric(CM_TYPE_REQ_SET_PROP, argv, buf)); } -/* XXX */ static int -action_enable(int argc, char **argv) +action_disable(int argc, char **argv) { - argc = argc; - argv = argv; + char *action_argv; + char argv_disable[IFNAMSIZ + sizeof(":disable=")]; + int i; + int error; - return (0); + if (argc < 1) + return (1); + + error = 0; + for (i = 0; i < argc; i++) { + sprintf(argv_disable, "%s:disable=", argv[i]); + action_argv = argv_disable; + error += action_propset(action_argv); + } + + return(error); } -/* XXX */ static int -action_disable(int argc, char **argv) +action_enable(int argc, char **argv) { - argc = argc; - argv = argv; + char *action_argv; + char argv_enable[IFNAMSIZ + sizeof(":enable=")]; + int i; + int error; - return (0); + if (argc < 1) + return (1); + + error = 0; + for (i = 0; i < argc; i++) { + sprintf(argv_enable, "%s:enable=", argv[i]); + action_argv = argv_enable; + error += action_propset(action_argv); + } + + return(error); } static int -action_reload(int argc __unused, char **argv __unused) +action_reload(int argc, char **argv) { char *action_argv; + char argv_reload[IFNAMSIZ + sizeof(":reload=")]; + int i; + int error; - action_argv = strdup("reload"); - return(action_propset(action_argv)); + if (argc == 0) { + action_argv = strdup(":reload="); + return(action_propset(action_argv)); + } + + error = 0; + for (i = 0; i < argc; i++) { + sprintf(argv_reload, "%s:reload=", argv[i]); + action_argv = argv_reload; + error += action_propset(action_argv); + } + + return(error); } static int Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Fri Jul 15 05:57:09 2011 (r224054) +++ user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Fri Jul 15 06:54:21 2011 (r224055) @@ -55,15 +55,18 @@ #include "control_server.h" #include "timer.h" -static sig_atomic_t p_do_reload; -static sig_atomic_t p_do_die; - -void set_do_reload(int sig __unused) { p_do_reload = 1; } -void set_do_die(int sig __unused) { p_do_die = 1; } -void reset_do_reload(void) { p_do_reload = 0; } -void reset_do_die(void) { p_do_die = 0; } -int do_reload(void) { return (p_do_reload); } -int do_die(void) { return (p_do_die); } +static char *do_reload_ifname; +static int do_reload; +static int do_shutdown; + +void set_do_reload(int sig __unused) { do_reload = 1; } +void set_do_reload_ifname(char *ifname){ do_reload_ifname = ifname; } +void set_do_shutdown(int sig __unused) { do_shutdown = 1; } +void reset_do_reload(void) { do_reload = 0; do_reload_ifname = NULL; } +void reset_do_shutdown(void) { do_shutdown = 0; } +int is_do_reload(void) { return (do_reload); } +int is_do_shutdown(void) { return (do_shutdown); } +char *reload_ifname(void) { return (do_reload_ifname); } #define DEF_PL_HANDLER(key) { #key, cmsg_getprop_##key } @@ -78,6 +81,10 @@ static int cmsg_getprop_rdnss(struct ctr static int cmsg_getprop_dnssl(struct ctrl_msg_pl *); static int cmsg_getprop_rti(struct ctrl_msg_pl *); +static int cmsg_setprop_reload(struct ctrl_msg_pl *); +static int cmsg_setprop_enable(struct ctrl_msg_pl *); +static int cmsg_setprop_disable(struct ctrl_msg_pl *); + static struct dispatch_table { const char *dt_comm; int (*dt_act)(struct ctrl_msg_pl *cp); @@ -535,10 +542,14 @@ cmsg_setprop(struct ctrl_msg_pl *cp) if (cp == NULL || cp->cp_key == NULL) return (1); - if (strncmp(cp->cp_key, "reload", 8) == 0) - set_do_reload(0); - else if (strncmp(cp->cp_key, "shutdown", 8) == 0) - set_do_die(0); + if (strncmp(cp->cp_key, "reload", sizeof("reload")) == 0) + cmsg_setprop_reload(cp); + else if (strncmp(cp->cp_key, "shutdown", sizeof("shutdown")) == 0) + set_do_shutdown(0); + else if (strncmp(cp->cp_key, "enable", sizeof("enable")) == 0) + cmsg_setprop_enable(cp); + else if (strncmp(cp->cp_key, "disable", sizeof("disable")) == 0) + cmsg_setprop_disable(cp); else if (strncmp(cp->cp_key, "echo", 8) == 0) ; /* do nothing */ else @@ -547,6 +558,64 @@ cmsg_setprop(struct ctrl_msg_pl *cp) return (0); } +static int +cmsg_setprop_reload(struct ctrl_msg_pl *cp) +{ + + syslog(LOG_DEBUG, "<%s> enter", __func__); + + set_do_reload_ifname(cp->cp_ifname); + set_do_reload(1); + + return (0); +} + +static int +cmsg_setprop_enable(struct ctrl_msg_pl *cp) +{ + struct ifinfo *ifi; + + syslog(LOG_DEBUG, "<%s> enter", __func__); + + TAILQ_FOREACH(ifi, &ifilist, ifi_next) { + if (strcmp(cp->cp_ifname, ifi->ifi_ifname) == 0) + break; + } + if (ifi == NULL) { + syslog(LOG_ERR, "<%s> %s not found", __func__, + cp->cp_ifname); + return (1); + } + + ifi->ifi_persist = 1; + set_do_reload_ifname(ifi->ifi_ifname); + set_do_reload(0); + + return (0); +} + +static int +cmsg_setprop_disable(struct ctrl_msg_pl *cp) +{ + struct ifinfo *ifi; + + syslog(LOG_DEBUG, "<%s> enter", __func__); + + TAILQ_FOREACH(ifi, &ifilist, ifi_next) { + if (strcmp(cp->cp_ifname, ifi->ifi_ifname) == 0) + break; + } + if (ifi == NULL) { + syslog(LOG_ERR, "<%s> %s not found", __func__, + cp->cp_ifname); + return (1); + } + + ifi->ifi_persist = 0; + + return (0); +} + int cmsg_handler_server(int fd) { Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.h ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control_server.h Fri Jul 15 05:57:09 2011 (r224054) +++ user/hrs/ipv6/usr.sbin/rtadvd/control_server.h Fri Jul 15 06:54:21 2011 (r224055) @@ -33,8 +33,10 @@ int cmsg_setprop(struct ctrl_msg_pl *); int cmsg_handler_server(int); void set_do_reload(int); -void set_do_die(int); +void set_do_reload_ifname(char *); +void set_do_shutdown(int); void reset_do_reload(void); -void reset_do_die(void); -int do_reload(void); -int do_die(void); +void reset_do_shutdown(void); +int is_do_reload(void); +char *reload_ifname(void); +int is_do_shutdown(void); Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Fri Jul 15 05:57:09 2011 (r224054) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Fri Jul 15 06:54:21 2011 (r224055) @@ -148,7 +148,7 @@ uint32_t ndopt_flags[] = { [ND_OPT_DNSSL] = NDOPT_FLAG_DNSSL, }; -static void die(void); +static void rtadvd_shutdown(void); static void sock_open(struct sockinfo *); static void rtsock_open(struct sockinfo *); static void rtadvd_input(struct sockinfo *); @@ -282,8 +282,8 @@ main(int argc, char *argv[]) set[PFD_RTSOCK].fd = -1; set[PFD_CSOCK].fd = ctrlsock.si_fd; set[PFD_CSOCK].events = POLLIN; - signal(SIGTERM, set_do_die); - signal(SIGINT, set_do_die); + signal(SIGTERM, set_do_shutdown); + signal(SIGINT, set_do_shutdown); signal(SIGHUP, set_do_reload); error = csock_listen(&ctrlsock); @@ -296,14 +296,19 @@ main(int argc, char *argv[]) set_do_reload(0); while (1) { - if (do_die()) - die(); + if (is_do_shutdown()) + rtadvd_shutdown(); - if (do_reload()) { + if (is_do_reload()) { + loadconfig_ifname(reload_ifname()); + if (reload_ifname() == NULL) + syslog(LOG_INFO, + "configuration file reloaded."); + else + syslog(LOG_INFO, + "configuration file for %s reloaded.", + reload_ifname()); reset_do_reload(); - loadconfig_ifname(NULL); - syslog(LOG_INFO, - "configuration file reloaded."); } /* timeout handler update for active interfaces */ @@ -354,7 +359,7 @@ main(int argc, char *argv[]) } static void -die(void) +rtadvd_shutdown(void) { struct rainfo *rai; struct rdnss *rdn; Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Fri Jul 15 05:57:09 2011 (r224054) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h Fri Jul 15 06:54:21 2011 (r224055) @@ -270,4 +270,4 @@ struct ifinfo *if_indextoifinfo(int); struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int); void rtadvd_set_reload(int); -void rtadvd_set_die(int); +void rtadvd_set_shutdown(int); From owner-svn-src-user@FreeBSD.ORG Fri Jul 15 17:36:12 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1367E1065672; Fri, 15 Jul 2011 17:36:12 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 040638FC08; Fri, 15 Jul 2011 17:36:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6FHaBw1089239; Fri, 15 Jul 2011 17:36:11 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6FHaBJr089236; Fri, 15 Jul 2011 17:36:11 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107151736.p6FHaBJr089236@svn.freebsd.org> From: Hiroki Sato Date: Fri, 15 Jul 2011 17:36:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224064 - user/hrs/ipv6/usr.sbin/rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2011 17:36:12 -0000 Author: hrs Date: Fri Jul 15 17:36:11 2011 New Revision: 224064 URL: http://svn.freebsd.org/changeset/base/224064 Log: The prefixlen() function requires unsigned char arguments. Modified: user/hrs/ipv6/usr.sbin/rtadvd/if.c user/hrs/ipv6/usr.sbin/rtadvd/if.h Modified: user/hrs/ipv6/usr.sbin/rtadvd/if.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/if.c Fri Jul 15 17:27:26 2011 (r224063) +++ user/hrs/ipv6/usr.sbin/rtadvd/if.c Fri Jul 15 17:36:11 2011 (r224064) @@ -293,12 +293,12 @@ get_prefixlen(char *buf) } int -prefixlen(char *p, char *lim) +prefixlen(unsigned char *p, unsigned char *lim) { int masklen; for (masklen = 0; p < lim; p++) { - switch ((int)*p) { + switch (*p) { case 0xff: masklen += 8; break; Modified: user/hrs/ipv6/usr.sbin/rtadvd/if.h ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/if.h Fri Jul 15 17:27:26 2011 (r224063) +++ user/hrs/ipv6/usr.sbin/rtadvd/if.h Fri Jul 15 17:36:11 2011 (r224064) @@ -48,7 +48,7 @@ char *get_next_msg(char *, char *, int, struct in6_addr *get_addr(char *); int get_rtm_ifindex(char *); int get_prefixlen(char *); -int prefixlen(char *, char *); +int prefixlen(unsigned char *, unsigned char *); struct ifinfo *update_ifinfo(struct ifilist_head_t *, int); int update_ifinfo_nd_flags(struct ifinfo *); From owner-svn-src-user@FreeBSD.ORG Sat Jul 16 09:20:23 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 754AF1065672; Sat, 16 Jul 2011 09:20:23 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 65F3B8FC15; Sat, 16 Jul 2011 09:20:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6G9KN2C018889; Sat, 16 Jul 2011 09:20:23 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6G9KNGi018881; Sat, 16 Jul 2011 09:20:23 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107160920.p6G9KNGi018881@svn.freebsd.org> From: Hiroki Sato Date: Sat, 16 Jul 2011 09:20:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224087 - in user/hrs/ipv6/usr.sbin: rtadvctl rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jul 2011 09:20:23 -0000 Author: hrs Date: Sat Jul 16 09:20:22 2011 New Revision: 224087 URL: http://svn.freebsd.org/changeset/base/224087 Log: - Implement burst unsolicited RA sending by using the ra_timer framework when AdvSendAdvertisements and/or configuration entries are changed as described in RFC 4861 6.2.4. This fixes issues that make termination of the rtadvd daemon take very long time and rtadvctl(8) utility become unresponsive after reloading the configuration file. An interface now has three states, UNCONFIGURED, TRANSITIVE, or CONFIGURED, and the burst unsolicited sending happens only in TRANSITIVE. See rtadvd.h for the details. - Remove extra make_packet(). - rtadvctl(8) now displays the RA timers. Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c user/hrs/ipv6/usr.sbin/rtadvd/config.c user/hrs/ipv6/usr.sbin/rtadvd/config.h user/hrs/ipv6/usr.sbin/rtadvd/control_server.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h user/hrs/ipv6/usr.sbin/rtadvd/timer.c user/hrs/ipv6/usr.sbin/rtadvd/timer_subr.c Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Sat Jul 16 08:51:09 2011 (r224086) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Sat Jul 16 09:20:22 2011 (r224087) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 15, 2011 +.Dd July 16, 2011 .Dt RTADVCTL 8 .Os .Sh NAME @@ -80,12 +80,17 @@ Specifies to mark the interface as disab .It shutdown Makes the .Xr rtadvd 8 -daemon shut down immediately. +daemon shut down. +Note that the +.Xr rtadvd 8 +daemon will send several RAs with zero lifetime to invalidate the old +information on each interface. +It will take at most nine seconds. .It show Op interfaces... Displays information on Router Advertisement messages being sent on each interface. .Sh SEE ALSO -.Xr rtadv 8 , +.Xr rtadvd 8 , .Xr rtadvd.conf 5 .Sh HISTORY The @@ -96,16 +101,3 @@ command first appeared in .Nm was written by .An "Hiroki Sato" Aq hrs@FreeBSD.org . -.Sh BUGS -The -.Xr rtadvd 8 -daemon stops responding to -.Nm -for a while just after reloading the configuration file by the reload -subcommand. -This is because in the current implementation it cannot communicate -with -.Nm -while sending some additional RAs for graceful transition from one -configuration to another. -It will take at most nine seconds for each interface. Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Sat Jul 16 08:51:09 2011 (r224086) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.c Sat Jul 16 09:20:22 2011 (r224087) @@ -61,6 +61,7 @@ #include "rtadvd.h" #include "if.h" #include "timer_subr.h" +#include "timer.h" #include "control.h" #include "control_client.h" @@ -115,6 +116,9 @@ static struct dispatch_table { { NULL, NULL }, }; +static char errmsgbuf[1024]; +static char *errmsg = NULL; + static void mysyslog(int priority, const char * restrict fmt, ...) { @@ -176,13 +180,17 @@ main(int argc, char *argv[]) } } - if (action != NULL) { - error = (dtable[i].dt_act)(--argc, ++argv); - if (error) - fprintf(stderr, "%s failed.\n", dtable[i].dt_comm); - } else + if (action == NULL) usage(); + error = (dtable[i].dt_act)(--argc, ++argv); + if (error) { + fprintf(stderr, "%s failed", dtable[i].dt_comm); + if (errmsg != NULL) + fprintf(stderr, ": %s", errmsg); + fprintf(stderr, ".\n"); + } + return (error); } @@ -312,7 +320,7 @@ action_disable(int argc, char **argv) error += action_propset(action_argv); } - return(error); + return (error); } static int @@ -333,7 +341,7 @@ action_enable(int argc, char **argv) error += action_propset(action_argv); } - return(error); + return (error); } static int @@ -346,7 +354,7 @@ action_reload(int argc, char **argv) if (argc == 0) { action_argv = strdup(":reload="); - return(action_propset(action_argv)); + return (action_propset(action_argv)); } error = 0; @@ -356,7 +364,7 @@ action_reload(int argc, char **argv) error += action_propset(action_argv); } - return(error); + return (error); } static int @@ -365,7 +373,7 @@ action_echo(int argc __unused, char **ar char *action_argv; action_argv = strdup("echo"); - return(action_propset(action_argv)); + return (action_propset(action_argv)); } static int @@ -374,7 +382,7 @@ action_shutdown(int argc __unused, char char *action_argv; action_argv = strdup("shutdown"); - return(action_propset(action_argv)); + return (action_propset(action_argv)); } /* XXX */ @@ -403,6 +411,7 @@ action_show(int argc, char **argv) char argv_rai[IFNAMSIZ + sizeof(":rai=")]; char argv_rti[IFNAMSIZ + sizeof(":rti=")]; char argv_pfx[IFNAMSIZ + sizeof(":pfx=")]; + char argv_ifi_ra_timer[IFNAMSIZ + sizeof(":ifi_ra_timer=")]; char argv_rdnss[IFNAMSIZ + sizeof(":rdnss=")]; char argv_dnssl[IFNAMSIZ + sizeof(":dnssl=")]; char ssbuf[SSBUFLEN]; @@ -427,7 +436,7 @@ action_show(int argc, char **argv) while (p < endp) { ifi = malloc(sizeof(*ifi)); if (ifi == NULL) - exit(1); + return (1); memset(ifi, 0, sizeof(*ifi)); strcpy(ifi->ifi_ifname, p); @@ -439,19 +448,25 @@ action_show(int argc, char **argv) for (i = 0; i < argc; i++) { ifi = malloc(sizeof(*ifi)); if (ifi == NULL) - exit(1); + return (1); memset(ifi, 0, sizeof(*ifi)); strcpy(ifi->ifi_ifname, argv[i]); ifi->ifi_ifindex = if_nametoindex(ifi->ifi_ifname); - if (ifi->ifi_ifindex == 0) - exit(1); + if (ifi->ifi_ifindex == 0) { + sprintf(errmsgbuf, "invalid interface %s", + ifi->ifi_ifname); + errmsg = errmsgbuf; + return (1); + } + TAILQ_INSERT_TAIL(&ifl, ifi, ifi_next); } } TAILQ_FOREACH(ifi, &ifl, ifi_next) { struct ifinfo *ifi_s; + struct rtadvd_timer *rat; struct rainfo *rai; struct rtinfo *rti; struct prefix *pfx; @@ -470,28 +485,33 @@ action_show(int argc, char **argv) printf("%s: flags=<", ifi->ifi_ifname); - /* - * RA_RECV = UP + CONFIGURED + ACCEPT_RTADV - * RA_SEND = UP + CONFIGURED + IPV6FORWARDING - */ - c = 0; if (ifi_s->ifi_ifindex == 0) c += printf("NONEXISTENT"); else c += printf("%s", (ifi_s->ifi_flags & IFF_UP) ? "UP" : "DOWN"); - if (ifi_s->ifi_state == IFI_STATE_CONFIGURED) + switch (ifi_s->ifi_state) { + case IFI_STATE_CONFIGURED: c += printf("%s%s", (c) ? "," : "", "CONFIGURED"); - + break; + case IFI_STATE_TRANSITIVE: + c += printf("%s%s", (c) ? "," : "", "TRANSITIVE"); + break; + } if (ifi_s->ifi_persist) c += printf("%s%s", (c) ? "," : "", "PERSIST"); printf(">"); ra_ifstatus = RA_IFSTATUS_INACTIVE; if ((ifi_s->ifi_flags & IFF_UP) && - (ifi_s->ifi_state == IFI_STATE_CONFIGURED)) { + ((ifi_s->ifi_state == IFI_STATE_CONFIGURED) || + (ifi_s->ifi_state == IFI_STATE_TRANSITIVE))) { #if (__FreeBSD_version < 900000) + /* + * RA_RECV: !ip6.forwarding && ip6.accept_rtadv + * RA_SEND: ip6.forwarding + */ if (getinet6sysctl(IPV6CTL_FORWARDING) == 0) { if (getinet6sysctl(IPV6CTL_ACCEPT_RTADV)) ra_ifstatus = RA_IFSTATUS_RA_RECV; @@ -500,6 +520,10 @@ action_show(int argc, char **argv) } else ra_ifstatus = RA_IFSTATUS_RA_SEND; #else + /* + * RA_RECV: ND6_IFF_ACCEPT_RTADV + * RA_SEND: ip6.forwarding + */ if (ifi_s->ifi_nd_flags & ND6_IFF_ACCEPT_RTADV) ra_ifstatus = RA_IFSTATUS_RA_RECV; else if (getinet6sysctl(IPV6CTL_FORWARDING)) @@ -519,7 +543,11 @@ action_show(int argc, char **argv) printf("%s%s", (c) ? "," : "", "RA_SEND"); printf("> "); - if (ifi_s->ifi_state != IFI_STATE_CONFIGURED) { + switch (ifi_s->ifi_state) { + case IFI_STATE_CONFIGURED: + case IFI_STATE_TRANSITIVE: + break; + default: printf("\n"); continue; } @@ -574,6 +602,26 @@ action_show(int argc, char **argv) rai->rai_hoplimit); printf("\tAdvIfPrefixes: %s\n", rai->rai_advifprefix ? "yes" : "no"); + + /* RA timer */ + rat = NULL; + if (ifi_s->ifi_ra_timer != NULL) { + sprintf(argv_ifi_ra_timer, "%s:ifi_ra_timer=", + ifi->ifi_ifname); + action_argv = argv_ifi_ra_timer; + + error = action_propget(action_argv, &cp); + if (error) + return (error); + + rat = (struct rtadvd_timer *)cp.cp_val; + } + printf("\tNext RA send: %s", + (rat == NULL) ? "never\n" : + ctime((time_t *)&rat->rat_tm.tv_sec)); + printf("\tLast RA sent: %s", + (ifi_s->ifi_ra_lastsent.tv_sec == 0) ? "never\n" : + ctime((time_t *)&ifi_s->ifi_ra_lastsent.tv_sec)); if (rai->rai_clockskew) printf("\tClock skew: %" PRIu16 "sec\n", rai->rai_clockskew); @@ -650,18 +698,22 @@ action_show(int argc, char **argv) printf("\n"); - printf("\tLast RA sent: %s", - (rai->rai_lastsent.tv_sec == 0) ? "never\n" : - ctime((time_t *)&rai->rai_lastsent.tv_sec)); - printf("\tRA initcounts/waits: %d/%d\n", - rai->rai_initcounter, - rai->rai_waiting); - printf("\tRA out/in/inconsistent: " - "%" PRIu64 "/%" PRIu64 "/%" PRIu64 "\n", - ifi_s->ifi_raoutput, + printf("\tCounters\n" + "\t RA burst counts: %" PRIu16 " (interval: %s)\n" + "\t RS wait counts: %" PRIu16 "\n", + ifi_s->ifi_burstcount, + sec2str(ifi_s->ifi_burstinterval, ssbuf), + ifi_s->ifi_rs_waitcount); + + printf("\tOutputs\n" + "\t RA: %" PRIu64 "\n", ifi_s->ifi_raoutput); + + printf("\tInputs\n" + "\t RA: %" PRIu64 " (normal)\n" + "\t RA: %" PRIu64 " (inconsistent)\n" + "\t RS: %" PRIu64 "\n", ifi_s->ifi_rainput, - ifi_s->ifi_rainconsistent); - printf("\tRS in: %" PRIu64 "\n", + ifi_s->ifi_rainconsistent, ifi_s->ifi_rsinput); printf("\n"); Modified: user/hrs/ipv6/usr.sbin/rtadvd/config.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/config.c Sat Jul 16 08:51:09 2011 (r224086) +++ user/hrs/ipv6/usr.sbin/rtadvd/config.c Sat Jul 16 09:20:22 2011 (r224087) @@ -149,7 +149,6 @@ int loadconfig_ifname(char *ifname) { struct ifinfo *ifi; - int error; syslog(LOG_DEBUG, "<%s> enter", __func__); @@ -175,37 +174,21 @@ loadconfig_ifname(char *ifname) ifi->ifi_ifname); continue; } - if (getconfig(ifi->ifi_ifindex) == NULL) { + if (getconfig(ifi) == NULL) { syslog(LOG_ERR, "<%s> invalid configuration for %s. " "Ignored at this moment.", __func__, ifi->ifi_ifname); continue; } - ifi->ifi_state = IFI_STATE_CONFIGURED; - syslog(LOG_DEBUG, - "<%s> ifname=%s marked as configured.", - __func__, ifi->ifi_ifname); - - error = sock_mc_join(&sock, ifi->ifi_ifindex); - if (error) - exit(1); } return (0); } int -rmconfig(int idx) +rm_ifinfo_index(int idx) { - struct rainfo *rai; - struct prefix *pfx; - struct soliciter *sol; - struct rdnss *rdn; - struct rdnss_addr *rdna; - struct dnssl *dns; - struct rtinfo *rti; struct ifinfo *ifi; - int error; ifi = if_indextoifinfo(idx); if (ifi == NULL) { @@ -213,24 +196,39 @@ rmconfig(int idx) __func__, idx); return (-1); } - rai = ifi->ifi_rainfo; - if (ifi->ifi_state == IFI_STATE_CONFIGURED) { + return (rm_ifinfo(ifi)); +} + +int +rm_ifinfo(struct ifinfo *ifi) +{ + int error; + + syslog(LOG_DEBUG, "<%s> enter (%s).", __func__, ifi->ifi_ifname); + switch (ifi->ifi_state) { + case IFI_STATE_UNCONFIGURED: + return (0); + break; + default: ifi->ifi_state = IFI_STATE_UNCONFIGURED; syslog(LOG_DEBUG, - "<%s> ifname=%s marked as unconfigured.", + "<%s> ifname=%s marked as UNCONFIGURED.", __func__, ifi->ifi_ifname); - error = sock_mc_leave(&sock, ifi->ifi_ifindex); - if (error) - exit(1); + /* XXX: No MC leaving here becasue index is disappeared */ + + /* Inactivate timer */ + rtadvd_remove_timer(ifi->ifi_ra_timer); + ifi->ifi_ra_timer = NULL; + break; } /* clean up ifi */ if (!ifi->ifi_persist) { TAILQ_REMOVE(&ifilist, ifi, ifi_next); syslog(LOG_DEBUG, "<%s>: ifinfo (idx=%d) removed.", - __func__, idx); + __func__, ifi->ifi_ifindex); free(ifi); } else { /* recreate an empty entry */ @@ -238,16 +236,62 @@ rmconfig(int idx) syslog(LOG_DEBUG, "<%s>: ifname=%s is persistent.", __func__, ifi->ifi_ifname); } + /* clean up rai if any */ - if (rai == NULL) - return (0); + switch (ifi->ifi_state) { + case IFI_STATE_CONFIGURED: + if (ifi->ifi_rainfo != NULL) { + error = rm_rainfo(ifi->ifi_rainfo); + if (error) + return (error); + ifi->ifi_rainfo = NULL; + } + break; + case IFI_STATE_TRANSITIVE: + if (ifi->ifi_rainfo == ifi->ifi_rainfo_trans) { + if (ifi->ifi_rainfo != NULL) { + error = rm_rainfo(ifi->ifi_rainfo); + if (error) + return (error); + ifi->ifi_rainfo = NULL; + ifi->ifi_rainfo_trans = NULL; + } + } else { + if (ifi->ifi_rainfo != NULL) { + error = rm_rainfo(ifi->ifi_rainfo); + if (error) + return (error); + ifi->ifi_rainfo = NULL; + } + if (ifi->ifi_rainfo_trans != NULL) { + error = rm_rainfo(ifi->ifi_rainfo_trans); + if (error) + return (error); + ifi->ifi_rainfo_trans = NULL; + } + } + } - TAILQ_REMOVE(&railist, rai, rai_next); - syslog(LOG_DEBUG, "<%s>: rainfo (idx=%d) removed.", - __func__, idx); + syslog(LOG_DEBUG, "<%s> leave (%s).", __func__, ifi->ifi_ifname); + return (0); +} + +int +rm_rainfo(struct rainfo *rai) +{ + struct prefix *pfx; + struct soliciter *sol; + struct rdnss *rdn; + struct rdnss_addr *rdna; + struct dnssl *dns; + struct rtinfo *rti; - /* Free all of allocated memories for this entry. */ - rtadvd_remove_timer(rai->rai_timer); + syslog(LOG_DEBUG, "<%s>: enter", __func__); + + TAILQ_REMOVE(&railist, rai, rai_next); + if (rai->rai_ifinfo != NULL) + syslog(LOG_DEBUG, "<%s>: rainfo (idx=%d) removed.", + __func__, rai->rai_ifinfo->ifi_ifindex); if (rai->rai_ra_data != NULL) free(rai->rai_ra_data); @@ -277,34 +321,34 @@ rmconfig(int idx) free(rti); } free(rai); + syslog(LOG_DEBUG, "<%s>: leave", __func__); return (0); } struct ifinfo * -getconfig(int idx) +getconfig(struct ifinfo *ifi) { int stat, i; + int error; char tbuf[BUFSIZ]; struct rainfo *rai; struct rainfo *rai_old; - struct ifinfo *ifi; int32_t val; int64_t val64; char buf[BUFSIZ]; char *bp = buf; char *addr, *flagstr; - if (idx == 0) - return (NULL); - TAILQ_FOREACH(ifi, &ifilist, ifi_next) { - if (ifi->ifi_ifindex == idx) - break; - } if (ifi == NULL) /* if does not exist */ return (NULL); - rai_old = ifi->ifi_rainfo; + if (ifi->ifi_state == IFI_STATE_TRANSITIVE && + ifi->ifi_rainfo == NULL) { + syslog(LOG_INFO, "<%s> %s is shutting down. Skipped.", + __func__, ifi->ifi_ifname); + return (NULL); + } if ((stat = agetent(tbuf, ifi->ifi_ifname)) <= 0) { memset(tbuf, 0, sizeof(tbuf)); @@ -857,26 +901,102 @@ getconfig_free_dns: * Before the removal, RDNSS and DNSSL options with * zero-lifetime will be sent. */ - if (rai_old != NULL) { - const int retrans = MAX_FINAL_RTR_ADVERTISEMENTS; - struct rdnss *rdn; - struct dnssl *dns; + switch (ifi->ifi_state) { + case IFI_STATE_UNCONFIGURED: + /* UNCONFIGURED -> TRANSITIVE */ - rai_old->rai_lifetime = 0; - TAILQ_FOREACH(rdn, &rai_old->rai_rdnss, rd_next) - rdn->rd_ltime = 0; - TAILQ_FOREACH(dns, &rai_old->rai_dnssl, dn_next) - dns->dn_ltime = 0; - - make_packet(rai_old); - for (i = 0; i < retrans; i++) { - ra_output(rai_old); - sleep(MIN_DELAY_BETWEEN_RAS); + error = sock_mc_join(&sock, ifi->ifi_ifindex); + if (error) + exit(1); + + ifi->ifi_state = IFI_STATE_TRANSITIVE; + ifi->ifi_burstcount = MAX_INITIAL_RTR_ADVERTISEMENTS; + ifi->ifi_burstinterval = MAX_INITIAL_RTR_ADVERT_INTERVAL; + + /* The same two rai mean initial burst */ + ifi->ifi_rainfo = rai; + ifi->ifi_rainfo_trans = rai; + TAILQ_INSERT_TAIL(&railist, rai, rai_next); + + if (ifi->ifi_ra_timer == NULL) + ifi->ifi_ra_timer = rtadvd_add_timer(ra_timeout, + ra_timer_update, ifi, ifi); + ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm); + rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm, + ifi->ifi_ra_timer); + + syslog(LOG_DEBUG, + "<%s> ifname=%s marked as TRANSITIVE (initial burst).", + __func__, ifi->ifi_ifname); + break; + case IFI_STATE_CONFIGURED: + /* CONFIGURED -> TRANSITIVE */ + rai_old = ifi->ifi_rainfo; + if (rai_old == NULL) { + syslog(LOG_ERR, + "<%s> ifi_rainfo is NULL" + " in IFI_STATE_CONFIGURED.", __func__); + ifi = NULL; + break; + } else { + struct rdnss *rdn; + struct dnssl *dns; + + rai_old->rai_lifetime = 0; + TAILQ_FOREACH(rdn, &rai_old->rai_rdnss, rd_next) + rdn->rd_ltime = 0; + TAILQ_FOREACH(dns, &rai_old->rai_dnssl, dn_next) + dns->dn_ltime = 0; + + ifi->ifi_rainfo_trans = rai_old; + ifi->ifi_state = IFI_STATE_TRANSITIVE; + ifi->ifi_burstcount = MAX_FINAL_RTR_ADVERTISEMENTS; + ifi->ifi_burstinterval = MIN_DELAY_BETWEEN_RAS; + + ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm); + rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm, + ifi->ifi_ra_timer); + + syslog(LOG_DEBUG, + "<%s> ifname=%s marked as TRANSITIVE" + " (transitional burst)", + __func__, ifi->ifi_ifname); + } + ifi->ifi_rainfo = rai; + TAILQ_INSERT_TAIL(&railist, rai, rai_next); + break; + case IFI_STATE_TRANSITIVE: + if (ifi->ifi_rainfo != NULL) { + if (ifi->ifi_rainfo == ifi->ifi_rainfo_trans) { + /* Reinitialize initial burst */ + rm_rainfo(ifi->ifi_rainfo); + ifi->ifi_rainfo = rai; + ifi->ifi_rainfo_trans = rai; + ifi->ifi_burstcount = + MAX_INITIAL_RTR_ADVERTISEMENTS; + ifi->ifi_burstinterval = + MAX_INITIAL_RTR_ADVERT_INTERVAL; + } else { + /* Replace ifi_rainfo with the new one */ + rm_rainfo(ifi->ifi_rainfo); + ifi->ifi_rainfo = rai; + } + TAILQ_INSERT_TAIL(&railist, rai, rai_next); + + ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm); + rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm, + ifi->ifi_ra_timer); + } else { + /* XXX: NOTREACHED. Being shut down. */ + syslog(LOG_ERR, + "<%s> %s is shutting down. Skipped.", + __func__, ifi->ifi_ifname); + rm_rainfo(rai); + + return (NULL); } - rmconfig(idx); + break; } - ifi->ifi_rainfo = rai; - TAILQ_INSERT_TAIL(&railist, rai, rai_next); return (ifi); @@ -913,6 +1033,7 @@ get_prefix(struct rainfo *rai) a = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr; if (IN6_IS_ADDR_LINKLOCAL(a)) continue; + /* get prefix length */ m = (char *)&((struct sockaddr_in6 *)ifa->ifa_netmask)->sin6_addr; lim = (char *)(ifa->ifa_netmask) + ifa->ifa_netmask->sa_len; @@ -1011,9 +1132,7 @@ add_prefix(struct rainfo *rai, struct in inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf, sizeof(ntopbuf)), ipr->ipr_plen, ifi->ifi_ifname); - /* reconstruct the packet */ rai->rai_pfxs++; - make_packet(rai); } /* @@ -1038,8 +1157,8 @@ delete_prefix(struct prefix *pfx) if (pfx->pfx_timer) rtadvd_remove_timer(pfx->pfx_timer); free(pfx); + rai->rai_pfxs--; - make_packet(rai); } void Modified: user/hrs/ipv6/usr.sbin/rtadvd/config.h ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/config.h Sat Jul 16 08:51:09 2011 (r224086) +++ user/hrs/ipv6/usr.sbin/rtadvd/config.h Sat Jul 16 09:20:22 2011 (r224087) @@ -30,8 +30,10 @@ * SUCH DAMAGE. */ -extern struct ifinfo *getconfig(int); -extern int rmconfig(int); +extern struct ifinfo *getconfig(struct ifinfo *); +extern int rm_ifinfo(struct ifinfo *); +extern int rm_ifinfo_index(int); +extern int rm_rainfo(struct rainfo *); extern int loadconfig_ifname(char *); extern int loadconfig_index(int); extern void delete_prefix(struct prefix *); Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Sat Jul 16 08:51:09 2011 (r224086) +++ user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Sat Jul 16 09:20:22 2011 (r224087) @@ -74,8 +74,8 @@ static int cmsg_getprop_echo(struct ctrl static int cmsg_getprop_version(struct ctrl_msg_pl *); static int cmsg_getprop_ifilist(struct ctrl_msg_pl *); static int cmsg_getprop_ifi(struct ctrl_msg_pl *); +static int cmsg_getprop_ifi_ra_timer(struct ctrl_msg_pl *); static int cmsg_getprop_rai(struct ctrl_msg_pl *); -static int cmsg_getprop_rai_timer(struct ctrl_msg_pl *); static int cmsg_getprop_pfx(struct ctrl_msg_pl *); static int cmsg_getprop_rdnss(struct ctrl_msg_pl *); static int cmsg_getprop_dnssl(struct ctrl_msg_pl *); @@ -94,8 +94,8 @@ static struct dispatch_table { DEF_PL_HANDLER(version), DEF_PL_HANDLER(ifilist), DEF_PL_HANDLER(ifi), + DEF_PL_HANDLER(ifi_ra_timer), DEF_PL_HANDLER(rai), - DEF_PL_HANDLER(rai_timer), DEF_PL_HANDLER(rti), DEF_PL_HANDLER(pfx), DEF_PL_HANDLER(rdnss), @@ -235,7 +235,7 @@ cmsg_getprop_rai(struct ctrl_msg_pl *cp) } static int -cmsg_getprop_rai_timer(struct ctrl_msg_pl *cp) +cmsg_getprop_ifi_ra_timer(struct ctrl_msg_pl *cp) { struct ifinfo *ifi; struct rainfo *rai; @@ -259,8 +259,8 @@ cmsg_getprop_rai_timer(struct ctrl_msg_p cp->cp_ifname); return (1); } - if ((rtimer = rai->rai_timer) == NULL) { - syslog(LOG_ERR, "<%s> %s has no rai_timer", __func__, + if ((rtimer = ifi->ifi_ra_timer) == NULL) { + syslog(LOG_ERR, "<%s> %s has no ifi_ra_timer", __func__, cp->cp_ifname); return (1); } Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Sat Jul 16 08:51:09 2011 (r224086) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Sat Jul 16 09:20:22 2011 (r224087) @@ -96,6 +96,7 @@ static const char *pidfilename = _PATH_R const char *conffile = _PATH_RTADVDCONF; static struct pidfh *pfh; int dflag = 0, sflag = 0; +static int wait_shutdown; #define PFD_RAWSOCK 0 #define PFD_RTSOCK 1 @@ -162,7 +163,7 @@ static int nd6_options(struct nd_opt_hdr union nd_opt *, uint32_t); static void free_ndopts(union nd_opt *); static void rtmsg_input(struct sockinfo *); -static void set_short_delay(struct rainfo *); +static void set_short_delay(struct ifinfo *); static int check_accept_rtadv(int); int @@ -313,7 +314,7 @@ main(int argc, char *argv[]) /* timeout handler update for active interfaces */ rtadvd_update_timeout_handler(); - + /* timer expiration check and reset the timer */ timeout = rtadvd_check_timer(); @@ -347,7 +348,7 @@ main(int argc, char *argv[]) if (set[PFD_CSOCK].revents & POLLIN) { int fd; - + fd = csock_accept(&ctrlsock); if (fd == -1) syslog(LOG_ERR, "<%s> accept", __func__); @@ -361,38 +362,66 @@ main(int argc, char *argv[]) static void rtadvd_shutdown(void) { + struct ifinfo *ifi; struct rainfo *rai; struct rdnss *rdn; struct dnssl *dns; - int i; - const int retrans = MAX_FINAL_RTR_ADVERTISEMENTS; + + if (wait_shutdown) { + syslog(LOG_INFO, + "waiting expiration of the all RA timers\n"); + + TAILQ_FOREACH(ifi, &ifilist, ifi_next) { + if (ifi->ifi_ra_timer != NULL) + break; + } + if (ifi == NULL) { + syslog(LOG_INFO, "gracefully terminated.\n"); + exit(0); + } + + sleep(1); + return; + } syslog(LOG_DEBUG, "<%s> cease to be an advertising router\n", __func__); + wait_shutdown = 1; + TAILQ_FOREACH(rai, &railist, rai_next) { rai->rai_lifetime = 0; TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) rdn->rd_ltime = 0; TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) dns->dn_ltime = 0; - make_packet(rai); } - for (i = 0; i < retrans; i++) { - syslog(LOG_INFO, "<%s> final RA transmission #%d/%d\n", - __func__, i, retrans - i); - TAILQ_FOREACH(rai, &railist, rai_next) - if (rai->rai_ifinfo->ifi_state - == IFI_STATE_CONFIGURED) - ra_output(rai); - syslog(LOG_INFO, "<%s> waiting for %d sec.\n", - __func__, MIN_DELAY_BETWEEN_RAS); - sleep(MIN_DELAY_BETWEEN_RAS); + TAILQ_FOREACH(ifi, &ifilist, ifi_next) { + if (!ifi->ifi_persist) + continue; + if (ifi->ifi_state == IFI_STATE_UNCONFIGURED) + continue; + if (ifi->ifi_ra_timer == NULL) + continue; + + ifi->ifi_state = IFI_STATE_TRANSITIVE; + + /* Mark as the shut-down state. */ + ifi->ifi_rainfo_trans = ifi->ifi_rainfo; + ifi->ifi_rainfo = NULL; + + ifi->ifi_burstcount = MAX_FINAL_RTR_ADVERTISEMENTS; + ifi->ifi_burstinterval = MIN_DELAY_BETWEEN_RAS; + + ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm); + rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm, + ifi->ifi_ra_timer); } + syslog(LOG_INFO, + "<%s> final RA transmission started.\n", __func__); + pidfile_remove(pfh); csock_close(&ctrlsock); - - exit(0); } static void @@ -489,7 +518,16 @@ rtmsg_input(struct sockinfo *s) syslog(LOG_INFO, "<%s>: interface removed (idx=%d)", __func__, ifan->ifan_index); - rmconfig(ifan->ifan_index); + rm_ifinfo_index(ifan->ifan_index); + + /* Clear ifi_ifindex */ + TAILQ_FOREACH(ifi, &ifilist, ifi_next) { + if (ifi->ifi_ifindex + == ifan->ifan_index) { + ifi->ifi_ifindex = 0; + break; + } + } update_ifinfo(&ifilist, ifan->ifan_index); break; } @@ -526,7 +564,7 @@ rtmsg_input(struct sockinfo *s) case RTM_ADD: if (sflag) break; /* we aren't interested in prefixes */ - + addr = get_addr(msg); plen = get_prefixlen(msg); /* sanity check for plen */ @@ -608,29 +646,32 @@ rtmsg_input(struct sockinfo *s) syslog(LOG_INFO, "<%s> interface %s becomes down. stop timer.", __func__, ifi->ifi_ifname); - rtadvd_remove_timer(rai->rai_timer); - rai->rai_timer = NULL; + rtadvd_remove_timer(ifi->ifi_ra_timer); + ifi->ifi_ra_timer = NULL; } else if (!(oldifflags & IFF_UP) && /* DOWN to UP */ (ifi->ifi_flags & IFF_UP)) { syslog(LOG_INFO, "<%s> interface %s becomes up. restart timer.", __func__, ifi->ifi_ifname); - rai->rai_initcounter = 0; /* reset the counter */ - rai->rai_waiting = 0; /* XXX */ - rai->rai_timer = rtadvd_add_timer(ra_timeout, - ra_timer_update, rai, rai); - ra_timer_update(rai, &rai->rai_timer->rat_tm); - rtadvd_set_timer(&rai->rai_timer->rat_tm, - rai->rai_timer); + ifi->ifi_state = IFI_STATE_TRANSITIVE; + ifi->ifi_burstcount = + MAX_INITIAL_RTR_ADVERTISEMENTS; + ifi->ifi_burstinterval = + MAX_INITIAL_RTR_ADVERT_INTERVAL; + + ifi->ifi_ra_timer = rtadvd_add_timer(ra_timeout, + ra_timer_update, ifi, ifi); + ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm); + rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm, + ifi->ifi_ra_timer); } else if (prefixchange && (ifi->ifi_flags & IFF_UP)) { /* * An advertised prefix has been added or invalidated. * Will notice the change in a short delay. */ - rai->rai_initcounter = 0; - set_short_delay(rai); + set_short_delay(ifi); } } @@ -654,7 +695,7 @@ rtadvd_input(struct sockinfo *s) struct ifinfo *ifi; syslog(LOG_DEBUG, "<%s> enter", __func__); - + if (s == NULL) { syslog(LOG_ERR, "<%s> internal error", __func__); exit(1); @@ -922,10 +963,10 @@ rs_input(int len, struct nd_router_solic * If there is already a waiting RS packet, don't * update the timer. */ - if (rai->rai_waiting++) + if (ifi->ifi_rs_waitcount++) goto done; - set_short_delay(rai); + set_short_delay(ifi); done: free_ndopts(&ndopts); @@ -933,7 +974,7 @@ rs_input(int len, struct nd_router_solic } static void -set_short_delay(struct rainfo *rai) +set_short_delay(struct ifinfo *ifi) { long delay; /* must not be greater than 1000000 */ struct timeval interval, now, min_delay, tm_tmp, *rest; @@ -952,7 +993,7 @@ set_short_delay(struct rainfo *rai) #endif interval.tv_sec = 0; interval.tv_usec = delay; - rest = rtadvd_timer_rest(rai->rai_timer); + rest = rtadvd_timer_rest(ifi->ifi_ra_timer); if (TIMEVAL_LT(rest, &interval)) { syslog(LOG_DEBUG, "<%s> random delay is larger than " "the rest of the current timer", __func__); @@ -967,21 +1008,21 @@ set_short_delay(struct rainfo *rai) * previous advertisement was sent. */ gettimeofday(&now, NULL); - TIMEVAL_SUB(&now, &rai->rai_lastsent, &tm_tmp); + TIMEVAL_SUB(&now, &ifi->ifi_ra_lastsent, &tm_tmp); min_delay.tv_sec = MIN_DELAY_BETWEEN_RAS; min_delay.tv_usec = 0; if (TIMEVAL_LT(&tm_tmp, &min_delay)) { TIMEVAL_SUB(&min_delay, &tm_tmp, &min_delay); TIMEVAL_ADD(&min_delay, &interval, &interval); } - rtadvd_set_timer(&interval, rai->rai_timer); + rtadvd_set_timer(&interval, ifi->ifi_ra_timer); } static int check_accept_rtadv(int idx) { struct ifinfo *ifi; - + TAILQ_FOREACH(ifi, &ifilist, ifi_next) { if (ifi->ifi_ifindex == idx) break; @@ -992,7 +1033,18 @@ check_accept_rtadv(int idx) __func__, idx); return (0); } -#if (__FreeBSD_version > 900000) +#if (__FreeBSD_version < 900000) + /* + * RA_RECV: !ip6.forwarding && ip6.accept_rtadv + * RA_SEND: ip6.forwarding + */ + return ((getinet6sysctl(IPV6CTL_FORWARDING) == 0) && *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat Jul 16 15:10:43 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B78D1065673; Sat, 16 Jul 2011 15:10:43 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6BFEE8FC19; Sat, 16 Jul 2011 15:10:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6GFAhwf032797; Sat, 16 Jul 2011 15:10:43 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6GFAhrt032795; Sat, 16 Jul 2011 15:10:43 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107161510.p6GFAhrt032795@svn.freebsd.org> From: Hiroki Sato Date: Sat, 16 Jul 2011 15:10:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224101 - user/hrs/ipv6/usr.sbin/rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jul 2011 15:10:43 -0000 Author: hrs Date: Sat Jul 16 15:10:43 2011 New Revision: 224101 URL: http://svn.freebsd.org/changeset/base/224101 Log: Fix fd leak. Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Sat Jul 16 14:51:28 2011 (r224100) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Sat Jul 16 15:10:43 2011 (r224101) @@ -352,8 +352,10 @@ main(int argc, char *argv[]) fd = csock_accept(&ctrlsock); if (fd == -1) syslog(LOG_ERR, "<%s> accept", __func__); - else + else { cmsg_handler_server(fd); + close(fd); + } } } exit(0); /* NOTREACHED */