From owner-svn-src-user@FreeBSD.ORG Sun Oct 4 21:07:20 2009 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 5AFF1106568B; Sun, 4 Oct 2009 21:07:20 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49E818FC13; Sun, 4 Oct 2009 21:07:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n94L7JHn085348; Sun, 4 Oct 2009 21:07:19 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n94L7JOc085345; Sun, 4 Oct 2009 21:07:19 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910042107.n94L7JOc085345@svn.freebsd.org> From: Edwin Groothuis Date: Sun, 4 Oct 2009 21:07:19 +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: r197754 - in user/edwin/locale: . usr.bin/unicode2utf8 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, 04 Oct 2009 21:07:20 -0000 Author: edwin Date: Sun Oct 4 21:07:19 2009 New Revision: 197754 URL: http://svn.freebsd.org/changeset/base/197754 Log: Add man-page for the unicode2utf8 utility. Fix wording of the examples, the ru_RU word was Saturday, not Sunday. Added: user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.1 Modified: user/edwin/locale/README.locale Modified: user/edwin/locale/README.locale ============================================================================== --- user/edwin/locale/README.locale Sun Oct 4 19:44:41 2009 (r197753) +++ user/edwin/locale/README.locale Sun Oct 4 21:07:19 2009 (r197754) @@ -46,18 +46,19 @@ Gotchas Examples -------- -The word for the last day of the week in the en_US language - country -code would be in Unicode format: - - +The word for the second last day of the week in the en_US language +- country code would be in Unicode format: + + + Converted into UTF-8 this will be: - Sunday + Saturday Converted into ISO-8859 this will be: - Sunday + Saturday -The word for the last day of the week in the ru_RU language - -country code would be in Unicode format: +The word for the second last day of the week in the ru_RU language +- country code would be in Unicode format: Added: user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.1 Sun Oct 4 21:07:19 2009 (r197754) @@ -0,0 +1,91 @@ +.\" Copyright (c) 2009 Edwin Groothuis +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd October 4, 2009 +.Dt unicode2utf8 1 +.Os +.Sh NAME +.Nm unicode2utf8 +.Nd converts a file with Unicode name definitions into UTF-8 character +definitions. +.Sh SYNOPSIS +.Nm +.Fl -cldr Ar directory +.Fl -input Ar filename +.Fl -output Ar filename +.Sh DESCRIPTION +The +.Nm +utility is made to convert the Unicode encoded strings in the +contents of the specified input file with the corresponding UTF-8 +character definitions. +.Pp +Lines starting with a # are copied as-is. +.Pp +The Unicode encoded strings are specified between a '<' and a '>' +sign. +They are looked up against the keys in the conversion table specified +in the file +.Pa posix/UTF-8.cm +in the with +.Fl -cldr +defined directory and the matching value is written out. +.Pp +Other characters are copied as-is. +.Sh OPTIONS +.Bl -tag -width indent +.It Fl -cldr Ar directory +The directory where the file +.Pa posix/UTF-8.cm +resides. +By default this should point to +.Pa /usr/share/misc , +but for maintainers of the FreeBSD locale database this could point +to their own extracted copy of the CLDR database. +.It Fl -input Ar filename +The source file with the Unicode encoded strings. +.It Fl -output Ar filename +The destination file with the Unicode encoded strings replaced with +their UTF-8 equivalents. +.El +.Sh EXIT STATUS +The +.Nm +utility exits 0 on success, and >0 if an error occurs. +.Sh SEE ALSO +.Xr iconv 1 , +.Xr bsdiconv 1 +.Bl -tag -width indent +.It http://cldr.unicode.org/ +Website of the Common Locale Database Repository, +the maintainers of the file +.Pa /usr/share/misc/UTF-8.cm +.El +.Sh AUTHORS +The +.Nm +utility and this manual page were written by +.An Edwin Groothuis Aq edwin@FreeBSD.org . From owner-svn-src-user@FreeBSD.ORG Sun Oct 4 21:07:48 2009 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 75FE61065694; Sun, 4 Oct 2009 21:07:48 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 64C9C8FC15; Sun, 4 Oct 2009 21:07:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n94L7msj085393; Sun, 4 Oct 2009 21:07:48 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n94L7mPj085391; Sun, 4 Oct 2009 21:07:48 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910042107.n94L7mPj085391@svn.freebsd.org> From: Edwin Groothuis Date: Sun, 4 Oct 2009 21:07:48 +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: r197755 - user/edwin/locale/usr.bin/unicode2utf8 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, 04 Oct 2009 21:07:48 -0000 Author: edwin Date: Sun Oct 4 21:07:48 2009 New Revision: 197755 URL: http://svn.freebsd.org/changeset/base/197755 Log: Stylify. Modified: user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Modified: user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c ============================================================================== --- user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Sun Oct 4 21:07:19 2009 (r197754) +++ user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Sun Oct 4 21:07:48 2009 (r197755) @@ -1,10 +1,40 @@ +/*- + * Copyright (c) 2009 Edwin Groothuis + * 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 +__FBSDID("$FreeBSD$"); + #include + +#include +#include +#include #include #include #include -#include -#include -#include #include #define MAXBUF 512 @@ -23,16 +53,19 @@ struct utf8map *get_utf8map(char *dir); struct utf8map *find_utf8map(char *unidata); void translate(char *file_in, char *file_out); +int debug = 0; + int -main(int argc, char **argv) { +main(int argc, char *argv[]) +{ char *cldr = NULL, *file_in = NULL, *file_out = NULL; char ch; - /* options descriptor */ static struct option longopts[] = { { "cldr", required_argument, NULL, 1 }, - { "input", required_argument, NULL, 3 }, - { "output", required_argument, NULL, 4 }, + { "input", required_argument, NULL, 2 }, + { "output", required_argument, NULL, 3 }, + { "debug", no_argument, NULL, 4 }, { NULL, 0, NULL, 0 } }; @@ -41,12 +74,14 @@ main(int argc, char **argv) { case 1: cldr = optarg; break; - case 3: + case 2: file_in = optarg; break; - case 4: + case 3: file_out = optarg; break; + case 4: + debug++; break; default: usage(); @@ -55,16 +90,19 @@ main(int argc, char **argv) { argc -= optind; argv += optind; + if (cldr == NULL || file_in == NULL || file_out == NULL) + usage(); + get_utf8map(cldr); translate(file_in, file_out); } void -translate(char *file_in, char *file_out) { - FILE *fin, *fout; - char line[MAXBUF]; - char *p, *q1, *q2; +translate(char *file_in, char *file_out) +{ struct utf8map *map; + FILE *fin, *fout; + char *p, *q1, *q2, line[MAXBUF]; if ((fin = fopen(file_in, "r")) == NULL) errx(EX_DATAERR, "Cannot open %s for reading.", file_in); @@ -110,7 +148,8 @@ translate(char *file_in, char *file_out) } struct utf8map * -find_utf8map(char *uniname) { +find_utf8map(char *uniname) +{ struct utf8map *p; int hashindex = uniname[strlen(uniname) - 1]; @@ -118,7 +157,8 @@ find_utf8map(char *uniname) { while (p != NULL) { if (strcmp(p->uniname, uniname) == 0) return p; - // printf("'%s' - '%s'\n", p->uniname, uniname); + if (debug) + printf("'%s' - '%s'\n", p->uniname, uniname); p = p->next; } @@ -126,14 +166,12 @@ find_utf8map(char *uniname) { } struct utf8map * -get_utf8map(char *dir) { - FILE *fin; - char filename[MAXPATHLEN]; - char uniname[MAXBUF], utf8char[MAXBUF]; - char *p; - int len, i; +get_utf8map(char *dir) +{ struct utf8map *new; - int hashindex; + FILE *fin; + int len, i, hashindex; + char filename[MAXPATHLEN], uniname[MAXBUF], utf8char[MAXBUF], *p; sprintf(filename, "%s/posix/UTF-8.cm", dir); @@ -155,7 +193,7 @@ get_utf8map(char *dir) { && strcmp(utf8char, "CHARMAP") == 0) break; - /* Get rid of the _'s in the name */ + /* Get rid of the _'s in the name. */ while ((p = strchr(uniname, '_')) != NULL) *p = ' '; if ((p = strchr(uniname, '>')) == NULL) @@ -167,7 +205,7 @@ get_utf8map(char *dir) { errx(EX_DATAERR, "No leading '<' for %s", uniname); - /* Translate hex strings into ascii-strings */ + /* Translate hex strings into ascii-strings. */ len = strlen(utf8char); if (len % 4 != 0) errx(EX_DATAERR, "Wrong length: '%s'", @@ -176,7 +214,7 @@ get_utf8map(char *dir) { for (i = 0; i < len; i++) { /* * Not setting will produce wrong results for - * the unicode string NULL + * the unicode string NULL. */ errno = 0; @@ -190,7 +228,9 @@ get_utf8map(char *dir) { utf8char[len] = 0; } - // printf("-%s-%s-\n", uniname, utf8char); + if (debug) + printf("-%s-%s-\n", uniname, utf8char); + new = (struct utf8map *)malloc(sizeof(struct utf8map)); new->next = utf8map_head[hashindex]; new->uniname = strdup(uniname + 1); @@ -202,16 +242,16 @@ get_utf8map(char *dir) { if (feof(fin)) errx(EX_DATAERR, "Didn't find final CHARMAP magic cookie.\n"); - fclose(fin); return NULL; } void -usage(void) { +usage(void) +{ - printf("Usage: unicode2utf8 --cldr=. --input=. --output=.\n"); + printf("Usage: unicode2utf8 --cldr=dir --input=file --output=file\n"); exit(EX_USAGE); } From owner-svn-src-user@FreeBSD.ORG Sun Oct 4 21:14:45 2009 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 9A65E1065670; Sun, 4 Oct 2009 21:14:45 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 70CDE8FC17; Sun, 4 Oct 2009 21:14:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n94LEjpg085580; Sun, 4 Oct 2009 21:14:45 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n94LEjGm085578; Sun, 4 Oct 2009 21:14:45 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910042114.n94LEjGm085578@svn.freebsd.org> From: Edwin Groothuis Date: Sun, 4 Oct 2009 21:14:45 +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: r197756 - user/edwin/locale 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, 04 Oct 2009 21:14:45 -0000 Author: edwin Date: Sun Oct 4 21:14:44 2009 New Revision: 197756 URL: http://svn.freebsd.org/changeset/base/197756 Log: main system -> base operating system Modified: user/edwin/locale/README.locale Modified: user/edwin/locale/README.locale ============================================================================== --- user/edwin/locale/README.locale Sun Oct 4 21:07:48 2009 (r197755) +++ user/edwin/locale/README.locale Sun Oct 4 21:14:44 2009 (r197756) @@ -107,7 +107,7 @@ Pending: system. These files for now live in src/tools/tools/locale/ Pending third parties: -- bsdiconv in the main system. +- bsdiconv in the base operating system. SCM From owner-svn-src-user@FreeBSD.ORG Sun Oct 4 21:22:20 2009 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 78C1F106568D; Sun, 4 Oct 2009 21:22:20 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 05EBC8FC0C; Sun, 4 Oct 2009 21:22:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n94LMJoO085774; Sun, 4 Oct 2009 21:22:19 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n94LMJP4085772; Sun, 4 Oct 2009 21:22:19 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910042122.n94LMJP4085772@svn.freebsd.org> From: Edwin Groothuis Date: Sun, 4 Oct 2009 21:22:19 +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: r197757 - user/edwin/locale/usr.bin/unicode2utf8 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, 04 Oct 2009 21:22:20 -0000 Author: edwin Date: Sun Oct 4 21:22:19 2009 New Revision: 197757 URL: http://svn.freebsd.org/changeset/base/197757 Log: Add warning about the output file being automatically generated. Modified: user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Modified: user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c ============================================================================== --- user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Sun Oct 4 21:14:44 2009 (r197756) +++ user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Sun Oct 4 21:22:19 2009 (r197757) @@ -109,6 +109,14 @@ translate(char *file_in, char *file_out) if ((fout = fopen(file_out, "w")) == NULL) errx(EX_DATAERR, "Cannot open %s for writing.", file_out); + fprintf(fout, +"#\n" +"# Do not edit this file, it is created automatically by the unicode2utf8\n" +"# utility. All changes to this file will be lost.\n" +"# The source of this file was %s\n" +"#\n", + file_in); + while (!feof(fin)) { if (fgets(line, sizeof(line), fin) != NULL) { if (line[0] == '#') { From owner-svn-src-user@FreeBSD.ORG Wed Oct 7 21:00:01 2009 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 E66961065672; Wed, 7 Oct 2009 21:00:01 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B89A88FC08; Wed, 7 Oct 2009 21:00:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n97L01kR099256; Wed, 7 Oct 2009 21:00:01 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n97L007b099247; Wed, 7 Oct 2009 21:00:00 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910072100.n97L007b099247@svn.freebsd.org> From: Edwin Groothuis Date: Wed, 7 Oct 2009 21:00:00 +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: r197844 - user/edwin/locale/share 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, 07 Oct 2009 21:00:02 -0000 Author: edwin Date: Wed Oct 7 20:59:59 2009 New Revision: 197844 URL: http://svn.freebsd.org/changeset/base/197844 Log: Add an target for the maintainers to compare the MD5 checksums of the UTF-8 files and to compare them with the MD5 checksums of the files created by the CMS_xxx variables (should be different) and with the MD5 checksums of the files created by the CMSLINK_xx variables (should be the same). Modified: user/edwin/locale/share/Makefile.def.inc Modified: user/edwin/locale/share/Makefile.def.inc ============================================================================== --- user/edwin/locale/share/Makefile.def.inc Wed Oct 7 20:56:15 2009 (r197843) +++ user/edwin/locale/share/Makefile.def.inc Wed Oct 7 20:59:59 2009 (r197844) @@ -255,6 +255,13 @@ ICONV_${ccln}.${cms}= ${ICONV} . endif . endfor . endif +. if defined(CMSLINK_${ccln}) +. for cms in ${CMSLINK_${ccln}} +. if !defined(ICONV_${ccln}.${cms}) +ICONV_${ccln}.${cms}= ${ICONV} +. endif +. endfor +. endif .endfor .for cm in ${CMS} @@ -305,7 +312,6 @@ ${ccln}.UTF-8.src: ${ccln}.unicode --cldr=${CLDRDIR} \ --input=${.ALLSRC} \ --output=${.TARGET} - . endif ${ccln}.UTF-8.out: ${ccln}.UTF-8.src @@ -360,4 +366,62 @@ beforeinstall: shift; \ done +.if defined(FULL) +# +# Maintainer Bag of Tricks +# +# Perform the following checks: +# - Create all files defined with CCLN and (CMS_xx and CMSLINK_xx) +# - See if all MD5 checksums for CMS_{ccln} are different. +# - See if all MD5 checksums for CMSLINK_{ccln} are the same. +# +checkcms: +. for ccln in ${CCLN} + ../../usr.bin/unicode2utf8/unicode2utf8 \ + --cldr=${CLDRDIR} \ + --input=${ccln}.unicode \ + --output=${ccln}.UTF-8.src + grep -v '^#' < ${ccln}.UTF-8.src > ${ccln}.UTF-8.out +. for cms in ${CMS_${ccln}} ${CMSLINK_${ccln}} + cat ${ccln}.UTF-8.src \ + ${_TRANSLATIONBEFORE_${cms}} | \ + ${ICONV_${ccln}.${cms}} \ + -f UTF-8 \ + -t ${CMALIAS_${cms}} \ + ${_TRANSLATIONAFTER_${cms}} \ + > ${ccln}.${cms}.src \ + || rm ${ccln}.${cms}.src && exit 0 + grep -v '^#' < ${ccln}.${cms}.src > ${ccln}.${cms}.out +. endfor +. endfor + md5 -r *.out > /tmp/a + FULL=1 ${MAKE} checkcms1 + +. for ccln in ${CCLN} +. for cms in UTF-8 ${CMS_${ccln}} ${CMSLINK_${ccln}} +MD5SUM_${ccln}.${cms}!= grep ${ccln}.${cms}.out /tmp/a | awk '{ print $$1 }' +. endfor +. endfor + +# +# Perform the following checks: +# - See if all MD5 checksums for CMS_{ccln} are different. +# - See if all MD5 checksums for CMSLINK_{ccln} are the same. +# +checkcms1: +. for ccln in ${CCLN} +. for cms in ${CMS_${ccln}} + @if [ ${MD5SUM_${ccln}.${cms}} = ${MD5SUM_${ccln}.UTF-8} ]; then \ + echo Same: ${ccln}.UTF-8 - ${ccln}.${cms}; \ + fi +. endfor +. for cms in ${CMSLINK_${ccln}} + @if [ ${MD5SUM_${ccln}.${cms}} != ${MD5SUM_${ccln}.UTF-8} ]; then \ + echo Different: ${ccln}.UTF-8 - ${ccln}.${cms}; \ + fi +. endfor +. endfor + +.endif + .include From owner-svn-src-user@FreeBSD.ORG Wed Oct 7 21:04:54 2009 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 43F1A1065670; Wed, 7 Oct 2009 21:04:54 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 317458FC18; Wed, 7 Oct 2009 21:04:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n97L4s0G099520; Wed, 7 Oct 2009 21:04:54 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n97L4rpY099428; Wed, 7 Oct 2009 21:04:53 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910072104.n97L4rpY099428@svn.freebsd.org> From: Edwin Groothuis Date: Wed, 7 Oct 2009 21:04:53 +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: r197845 - in user/edwin/locale/share: monetdef msgdef numericdef timedef 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, 07 Oct 2009 21:04:54 -0000 Author: edwin Date: Wed Oct 7 21:04:52 2009 New Revision: 197845 URL: http://svn.freebsd.org/changeset/base/197845 Log: The unicode2utf8 tool generates a warning in the output file that it is created automatically and that changes to it will be lost later in life. Modified: user/edwin/locale/share/monetdef/af_ZA.UTF-8.src user/edwin/locale/share/monetdef/am_ET.UTF-8.src user/edwin/locale/share/monetdef/be_BY.CP1131.src user/edwin/locale/share/monetdef/be_BY.CP1251.src user/edwin/locale/share/monetdef/be_BY.ISO8859-5.src user/edwin/locale/share/monetdef/be_BY.UTF-8.src user/edwin/locale/share/monetdef/bg_BG.CP1251.src user/edwin/locale/share/monetdef/bg_BG.UTF-8.src user/edwin/locale/share/monetdef/ca_ES.UTF-8.src user/edwin/locale/share/monetdef/cs_CZ.ISO8859-2.src user/edwin/locale/share/monetdef/cs_CZ.UTF-8.src user/edwin/locale/share/monetdef/da_DK.UTF-8.src user/edwin/locale/share/monetdef/de_AT.UTF-8.src user/edwin/locale/share/monetdef/de_CH.UTF-8.src user/edwin/locale/share/monetdef/de_DE.UTF-8.src user/edwin/locale/share/monetdef/el_GR.UTF-8.src user/edwin/locale/share/monetdef/en_AU.UTF-8.src user/edwin/locale/share/monetdef/en_CA.UTF-8.src user/edwin/locale/share/monetdef/en_GB.ISO8859-1.src user/edwin/locale/share/monetdef/en_GB.UTF-8.src user/edwin/locale/share/monetdef/en_IE.UTF-8.src user/edwin/locale/share/monetdef/en_NZ.UTF-8.src user/edwin/locale/share/monetdef/en_US.UTF-8.src user/edwin/locale/share/monetdef/es_ES.UTF-8.src user/edwin/locale/share/monetdef/et_EE.UTF-8.src user/edwin/locale/share/monetdef/fi_FI.UTF-8.src user/edwin/locale/share/monetdef/fr_BE.UTF-8.src user/edwin/locale/share/monetdef/fr_CA.UTF-8.src user/edwin/locale/share/monetdef/fr_FR.UTF-8.src user/edwin/locale/share/monetdef/he_IL.UTF-8.src user/edwin/locale/share/monetdef/hi_IN.ISCII-DEV.src user/edwin/locale/share/monetdef/hi_IN.UTF-8.src user/edwin/locale/share/monetdef/hr_HR.UTF-8.src user/edwin/locale/share/monetdef/hu_HU.UTF-8.src user/edwin/locale/share/monetdef/hy_AM.ARMSCII-8.src user/edwin/locale/share/monetdef/hy_AM.UTF-8.src user/edwin/locale/share/monetdef/is_IS.UTF-8.src user/edwin/locale/share/monetdef/it_IT.UTF-8.src user/edwin/locale/share/monetdef/ja_JP.UTF-8.src user/edwin/locale/share/monetdef/ja_JP.eucJP.src user/edwin/locale/share/monetdef/kk_KZ.PT154.src user/edwin/locale/share/monetdef/kk_KZ.UTF-8.src user/edwin/locale/share/monetdef/ko_KR.UTF-8.src user/edwin/locale/share/monetdef/ko_KR.eucKR.src user/edwin/locale/share/monetdef/lt_LT.UTF-8.src user/edwin/locale/share/monetdef/lv_LV.ISO8859-13.src user/edwin/locale/share/monetdef/lv_LV.UTF-8.src user/edwin/locale/share/monetdef/mn_MN.UTF-8.src user/edwin/locale/share/monetdef/nl_BE.UTF-8.src user/edwin/locale/share/monetdef/nl_NL.UTF-8.src user/edwin/locale/share/monetdef/no_NO.UTF-8.src user/edwin/locale/share/monetdef/pl_PL.ISO8859-2.src user/edwin/locale/share/monetdef/pl_PL.UTF-8.src user/edwin/locale/share/monetdef/pt_BR.UTF-8.src user/edwin/locale/share/monetdef/pt_PT.ISO8859-1.src user/edwin/locale/share/monetdef/pt_PT.ISO8859-15.src user/edwin/locale/share/monetdef/pt_PT.UTF-8.src user/edwin/locale/share/monetdef/ro_RO.UTF-8.src user/edwin/locale/share/monetdef/ru_RU.CP1251.src user/edwin/locale/share/monetdef/ru_RU.CP866.src user/edwin/locale/share/monetdef/ru_RU.ISO8859-5.src user/edwin/locale/share/monetdef/ru_RU.KOI8-R.src user/edwin/locale/share/monetdef/ru_RU.UTF-8.src user/edwin/locale/share/monetdef/sk_SK.UTF-8.src user/edwin/locale/share/monetdef/sl_SI.UTF-8.src user/edwin/locale/share/monetdef/sr_Cyrl_RS.ISO8859-5.src user/edwin/locale/share/monetdef/sr_Cyrl_RS.UTF-8.src user/edwin/locale/share/monetdef/sr_Latn_RS.UTF-8.src user/edwin/locale/share/monetdef/sv_SE.UTF-8.src user/edwin/locale/share/monetdef/tr_TR.UTF-8.src user/edwin/locale/share/monetdef/uk_UA.CP1251.src user/edwin/locale/share/monetdef/uk_UA.ISO8859-5.src user/edwin/locale/share/monetdef/uk_UA.KOI8-U.src user/edwin/locale/share/monetdef/uk_UA.UTF-8.src user/edwin/locale/share/monetdef/zh_Hans_CN.GB18030.src user/edwin/locale/share/monetdef/zh_Hans_CN.GB2312.src user/edwin/locale/share/monetdef/zh_Hans_CN.UTF-8.src user/edwin/locale/share/monetdef/zh_Hans_CN.eucCN.src user/edwin/locale/share/monetdef/zh_Hant_HK.UTF-8.src user/edwin/locale/share/monetdef/zh_Hant_TW.UTF-8.src user/edwin/locale/share/msgdef/af_ZA.UTF-8.src user/edwin/locale/share/msgdef/am_ET.UTF-8.src user/edwin/locale/share/msgdef/be_BY.CP1131.src user/edwin/locale/share/msgdef/be_BY.CP1251.src user/edwin/locale/share/msgdef/be_BY.ISO8859-5.src user/edwin/locale/share/msgdef/be_BY.UTF-8.src user/edwin/locale/share/msgdef/bg_BG.CP1251.src user/edwin/locale/share/msgdef/bg_BG.UTF-8.src user/edwin/locale/share/msgdef/ca_ES.UTF-8.src user/edwin/locale/share/msgdef/cs_CZ.UTF-8.src user/edwin/locale/share/msgdef/da_DK.UTF-8.src user/edwin/locale/share/msgdef/de_DE.UTF-8.src user/edwin/locale/share/msgdef/el_GR.ISO8859-7.src user/edwin/locale/share/msgdef/el_GR.UTF-8.src user/edwin/locale/share/msgdef/en_CA.UTF-8.src user/edwin/locale/share/msgdef/en_GB.UTF-8.src user/edwin/locale/share/msgdef/en_US.UTF-8.src user/edwin/locale/share/msgdef/es_ES.UTF-8.src user/edwin/locale/share/msgdef/et_EE.UTF-8.src user/edwin/locale/share/msgdef/eu_ES.UTF-8.src user/edwin/locale/share/msgdef/fi_FI.UTF-8.src user/edwin/locale/share/msgdef/fr_BE.UTF-8.src user/edwin/locale/share/msgdef/fr_CH.UTF-8.src user/edwin/locale/share/msgdef/fr_FR.UTF-8.src user/edwin/locale/share/msgdef/he_IL.UTF-8.src user/edwin/locale/share/msgdef/hi_IN.ISCII-DEV.src user/edwin/locale/share/msgdef/hi_IN.UTF-8.src user/edwin/locale/share/msgdef/hr_HR.UTF-8.src user/edwin/locale/share/msgdef/hu_HU.UTF-8.src user/edwin/locale/share/msgdef/hy_AM.ARMSCII-8.src user/edwin/locale/share/msgdef/hy_AM.UTF-8.src user/edwin/locale/share/msgdef/is_IS.UTF-8.src user/edwin/locale/share/msgdef/it_IT.UTF-8.src user/edwin/locale/share/msgdef/ja_JP.SJIS.src user/edwin/locale/share/msgdef/ja_JP.UTF-8.src user/edwin/locale/share/msgdef/ja_JP.eucJP.src user/edwin/locale/share/msgdef/kk_KZ.PT154.src user/edwin/locale/share/msgdef/kk_KZ.UTF-8.src user/edwin/locale/share/msgdef/ko_KR.UTF-8.src user/edwin/locale/share/msgdef/ko_KR.eucKR.src user/edwin/locale/share/msgdef/lt_LT.UTF-8.src user/edwin/locale/share/msgdef/lv_LV.ISO8859-13.src user/edwin/locale/share/msgdef/lv_LV.UTF-8.src user/edwin/locale/share/msgdef/mn_MN.UTF-8.src user/edwin/locale/share/msgdef/nl_NL.UTF-8.src user/edwin/locale/share/msgdef/no_NO.UTF-8.src user/edwin/locale/share/msgdef/pl_PL.UTF-8.src user/edwin/locale/share/msgdef/pt_PT.UTF-8.src user/edwin/locale/share/msgdef/ro_RO.UTF-8.src user/edwin/locale/share/msgdef/ru_RU.CP1251.src user/edwin/locale/share/msgdef/ru_RU.CP866.src user/edwin/locale/share/msgdef/ru_RU.ISO8859-5.src user/edwin/locale/share/msgdef/ru_RU.KOI8-R.src user/edwin/locale/share/msgdef/ru_RU.UTF-8.src user/edwin/locale/share/msgdef/sl_SI.UTF-8.src user/edwin/locale/share/msgdef/sr_Cyrl_RS.ISO8859-5.src user/edwin/locale/share/msgdef/sr_Cyrl_RS.UTF-8.src user/edwin/locale/share/msgdef/sr_Latn_RS.ISO8859-2.src user/edwin/locale/share/msgdef/sr_Latn_RS.UTF-8.src user/edwin/locale/share/msgdef/sv_SE.UTF-8.src user/edwin/locale/share/msgdef/tr_TR.UTF-8.src user/edwin/locale/share/msgdef/uk_UA.CP1251.src user/edwin/locale/share/msgdef/uk_UA.ISO8859-5.src user/edwin/locale/share/msgdef/uk_UA.KOI8-U.src user/edwin/locale/share/msgdef/uk_UA.UTF-8.src user/edwin/locale/share/msgdef/zh_Hans_CN.GB18030.src user/edwin/locale/share/msgdef/zh_Hans_CN.GB2312.src user/edwin/locale/share/msgdef/zh_Hans_CN.UTF-8.src user/edwin/locale/share/msgdef/zh_Hans_CN.eucCN.src user/edwin/locale/share/msgdef/zh_Hant_TW.Big5.src user/edwin/locale/share/msgdef/zh_Hant_TW.UTF-8.src user/edwin/locale/share/numericdef/af_ZA.UTF-8.src user/edwin/locale/share/numericdef/am_ET.UTF-8.src user/edwin/locale/share/numericdef/be_BY.UTF-8.src user/edwin/locale/share/numericdef/bg_BG.UTF-8.src user/edwin/locale/share/numericdef/ca_ES.UTF-8.src user/edwin/locale/share/numericdef/cs_CZ.UTF-8.src user/edwin/locale/share/numericdef/da_DK.UTF-8.src user/edwin/locale/share/numericdef/de_CH.UTF-8.src user/edwin/locale/share/numericdef/de_DE.UTF-8.src user/edwin/locale/share/numericdef/el_GR.UTF-8.src user/edwin/locale/share/numericdef/en_US.UTF-8.src user/edwin/locale/share/numericdef/es_ES.UTF-8.src user/edwin/locale/share/numericdef/et_EE.UTF-8.src user/edwin/locale/share/numericdef/eu_ES.UTF-8.src user/edwin/locale/share/numericdef/fi_FI.UTF-8.src user/edwin/locale/share/numericdef/fr_BE.UTF-8.src user/edwin/locale/share/numericdef/fr_FR.UTF-8.src user/edwin/locale/share/numericdef/hi_IN.UTF-8.src user/edwin/locale/share/numericdef/hr_HR.UTF-8.src user/edwin/locale/share/numericdef/hu_HU.UTF-8.src user/edwin/locale/share/numericdef/hy_AM.UTF-8.src user/edwin/locale/share/numericdef/is_IS.UTF-8.src user/edwin/locale/share/numericdef/it_IT.UTF-8.src user/edwin/locale/share/numericdef/ja_JP.UTF-8.src user/edwin/locale/share/numericdef/kk_KZ.UTF-8.src user/edwin/locale/share/numericdef/ko_KR.UTF-8.src user/edwin/locale/share/numericdef/lt_LT.UTF-8.src user/edwin/locale/share/numericdef/mn_MN.UTF-8.src user/edwin/locale/share/numericdef/nl_NL.UTF-8.src user/edwin/locale/share/numericdef/no_NO.UTF-8.src user/edwin/locale/share/numericdef/pl_PL.UTF-8.src user/edwin/locale/share/numericdef/pt_BR.UTF-8.src user/edwin/locale/share/numericdef/pt_PT.UTF-8.src user/edwin/locale/share/numericdef/ro_RO.UTF-8.src user/edwin/locale/share/numericdef/ru_RU.UTF-8.src user/edwin/locale/share/numericdef/sk_SK.UTF-8.src user/edwin/locale/share/numericdef/sl_SI.UTF-8.src user/edwin/locale/share/numericdef/sr_Cyrl_RS.UTF-8.src user/edwin/locale/share/numericdef/sr_Latn_RS.UTF-8.src user/edwin/locale/share/numericdef/sv_SE.UTF-8.src user/edwin/locale/share/numericdef/tr_TR.UTF-8.src user/edwin/locale/share/numericdef/uk_UA.UTF-8.src user/edwin/locale/share/numericdef/zh_Hans_CN.UTF-8.src user/edwin/locale/share/timedef/Makefile user/edwin/locale/share/timedef/am_ET.UTF-8.src user/edwin/locale/share/timedef/be_BY.CP1131.src user/edwin/locale/share/timedef/be_BY.CP1251.src user/edwin/locale/share/timedef/be_BY.ISO8859-5.src user/edwin/locale/share/timedef/be_BY.UTF-8.src user/edwin/locale/share/timedef/bg_BG.CP1251.src user/edwin/locale/share/timedef/bg_BG.UTF-8.src user/edwin/locale/share/timedef/ca_ES.ISO8859-1.src user/edwin/locale/share/timedef/ca_ES.UTF-8.src user/edwin/locale/share/timedef/cs_CZ.ISO8859-2.src user/edwin/locale/share/timedef/cs_CZ.UTF-8.src user/edwin/locale/share/timedef/da_DK.ISO8859-1.src user/edwin/locale/share/timedef/da_DK.UTF-8.src user/edwin/locale/share/timedef/de_AT.ISO8859-1.src user/edwin/locale/share/timedef/de_AT.UTF-8.src user/edwin/locale/share/timedef/de_DE.ISO8859-1.src user/edwin/locale/share/timedef/de_DE.UTF-8.src user/edwin/locale/share/timedef/el_GR.ISO8859-7.src user/edwin/locale/share/timedef/el_GR.UTF-8.src user/edwin/locale/share/timedef/en_GB.ISO8859-1.src user/edwin/locale/share/timedef/en_GB.UTF-8.src user/edwin/locale/share/timedef/en_US.ISO8859-1.src user/edwin/locale/share/timedef/en_US.UTF-8.src user/edwin/locale/share/timedef/es_ES.ISO8859-1.src user/edwin/locale/share/timedef/es_ES.UTF-8.src user/edwin/locale/share/timedef/et_EE.ISO8859-15.src user/edwin/locale/share/timedef/et_EE.UTF-8.src user/edwin/locale/share/timedef/eu_ES.ISO8859-1.src user/edwin/locale/share/timedef/eu_ES.UTF-8.src user/edwin/locale/share/timedef/fi_FI.ISO8859-1.src user/edwin/locale/share/timedef/fi_FI.UTF-8.src user/edwin/locale/share/timedef/fr_FR.ISO8859-1.src user/edwin/locale/share/timedef/fr_FR.UTF-8.src user/edwin/locale/share/timedef/he_IL.UTF-8.src user/edwin/locale/share/timedef/hi_IN.ISCII-DEV.src user/edwin/locale/share/timedef/hi_IN.UTF-8.src user/edwin/locale/share/timedef/hr_HR.ISO8859-2.src user/edwin/locale/share/timedef/hr_HR.UTF-8.src user/edwin/locale/share/timedef/hu_HU.ISO8859-2.src user/edwin/locale/share/timedef/hu_HU.UTF-8.src user/edwin/locale/share/timedef/hy_AM.ARMSCII-8.src user/edwin/locale/share/timedef/hy_AM.UTF-8.src user/edwin/locale/share/timedef/is_IS.ISO8859-1.src user/edwin/locale/share/timedef/is_IS.UTF-8.src user/edwin/locale/share/timedef/it_IT.ISO8859-1.src user/edwin/locale/share/timedef/it_IT.UTF-8.src user/edwin/locale/share/timedef/ja_JP.SJIS.src user/edwin/locale/share/timedef/ja_JP.UTF-8.src user/edwin/locale/share/timedef/ja_JP.eucJP.src user/edwin/locale/share/timedef/kk_KZ.PT154.src user/edwin/locale/share/timedef/kk_KZ.UTF-8.src user/edwin/locale/share/timedef/ko_KR.UTF-8.src user/edwin/locale/share/timedef/ko_KR.eucKR.src user/edwin/locale/share/timedef/la_LN.ISO8859-1.src user/edwin/locale/share/timedef/la_LN.UTF-8.src user/edwin/locale/share/timedef/lt_LT.ISO8859-13.src user/edwin/locale/share/timedef/lt_LT.ISO8859-4.src user/edwin/locale/share/timedef/lt_LT.UTF-8.src user/edwin/locale/share/timedef/lv_LV.ISO8859-13.src user/edwin/locale/share/timedef/lv_LV.UTF-8.src user/edwin/locale/share/timedef/mn_MN.UTF-8.src user/edwin/locale/share/timedef/nb_NO.ISO8859-1.src user/edwin/locale/share/timedef/nb_NO.UTF-8.src user/edwin/locale/share/timedef/nl_NL.ISO8859-1.src user/edwin/locale/share/timedef/nl_NL.UTF-8.src user/edwin/locale/share/timedef/nn_NO.ISO8859-1.src user/edwin/locale/share/timedef/nn_NO.UTF-8.src user/edwin/locale/share/timedef/pl_PL.ISO8859-2.src user/edwin/locale/share/timedef/pl_PL.UTF-8.src user/edwin/locale/share/timedef/pt_BR.ISO8859-1.src user/edwin/locale/share/timedef/pt_BR.UTF-8.src user/edwin/locale/share/timedef/pt_PT.ISO8859-1.src user/edwin/locale/share/timedef/pt_PT.UTF-8.src user/edwin/locale/share/timedef/ro_RO.ISO8859-2.src user/edwin/locale/share/timedef/ro_RO.UTF-8.src user/edwin/locale/share/timedef/ru_RU.CP1251.src user/edwin/locale/share/timedef/ru_RU.CP866.src user/edwin/locale/share/timedef/ru_RU.ISO8859-5.src user/edwin/locale/share/timedef/ru_RU.KOI8-R.src user/edwin/locale/share/timedef/ru_RU.UTF-8.src user/edwin/locale/share/timedef/sk_SK.ISO8859-2.src user/edwin/locale/share/timedef/sk_SK.UTF-8.src user/edwin/locale/share/timedef/sl_SI.ISO8859-2.src user/edwin/locale/share/timedef/sl_SI.UTF-8.src user/edwin/locale/share/timedef/sr_Cyrl_RS.ISO8859-5.src user/edwin/locale/share/timedef/sr_Cyrl_RS.UTF-8.src user/edwin/locale/share/timedef/sr_Latn_RS.ISO8859-2.src user/edwin/locale/share/timedef/sr_Latn_RS.UTF-8.src user/edwin/locale/share/timedef/sv_SE.ISO8859-1.src user/edwin/locale/share/timedef/sv_SE.UTF-8.src user/edwin/locale/share/timedef/tr_TR.ISO8859-9.src user/edwin/locale/share/timedef/tr_TR.UTF-8.src user/edwin/locale/share/timedef/uk_UA.CP1251.src user/edwin/locale/share/timedef/uk_UA.ISO8859-5.src user/edwin/locale/share/timedef/uk_UA.KOI8-U.src user/edwin/locale/share/timedef/uk_UA.UTF-8.src user/edwin/locale/share/timedef/zh_Hans_CN.GB18030.src user/edwin/locale/share/timedef/zh_Hans_CN.GB2312.src user/edwin/locale/share/timedef/zh_Hans_CN.UTF-8.src user/edwin/locale/share/timedef/zh_Hans_CN.eucCN.src user/edwin/locale/share/timedef/zh_Hant_TW.Big5.src user/edwin/locale/share/timedef/zh_Hant_TW.UTF-8.src Modified: user/edwin/locale/share/monetdef/af_ZA.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/af_ZA.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/af_ZA.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was af_ZA.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/af_ZA.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/am_ET.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/am_ET.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/am_ET.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was am_ET.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/am_ET.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/be_BY.CP1131.src ============================================================================== --- user/edwin/locale/share/monetdef/be_BY.CP1131.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/be_BY.CP1131.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/be_BY.unicode 196846 2009-09-04 23:11:59Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/monetdef/be_BY.CP1251.src ============================================================================== --- user/edwin/locale/share/monetdef/be_BY.CP1251.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/be_BY.CP1251.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/be_BY.unicode 196846 2009-09-04 23:11:59Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/monetdef/be_BY.ISO8859-5.src ============================================================================== --- user/edwin/locale/share/monetdef/be_BY.ISO8859-5.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/be_BY.ISO8859-5.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/be_BY.unicode 196846 2009-09-04 23:11:59Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/monetdef/be_BY.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/be_BY.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/be_BY.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/be_BY.unicode 196846 2009-09-04 23:11:59Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/monetdef/bg_BG.CP1251.src ============================================================================== --- user/edwin/locale/share/monetdef/bg_BG.CP1251.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/bg_BG.CP1251.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was bg_BG.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/bg_BG.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/bg_BG.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/bg_BG.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/bg_BG.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was bg_BG.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/bg_BG.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ca_ES.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/ca_ES.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ca_ES.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ca_ES.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ca_ES.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/cs_CZ.ISO8859-2.src ============================================================================== --- user/edwin/locale/share/monetdef/cs_CZ.ISO8859-2.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/cs_CZ.ISO8859-2.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was cs_CZ.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/cs_CZ.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/cs_CZ.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/cs_CZ.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/cs_CZ.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was cs_CZ.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/cs_CZ.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/da_DK.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/da_DK.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/da_DK.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was da_DK.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/da_DK.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/de_AT.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/de_AT.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/de_AT.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was de_AT.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/de_AT.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/de_CH.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/de_CH.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/de_CH.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was de_CH.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/de_CH.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/de_DE.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/de_DE.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/de_DE.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was de_DE.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/de_DE.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/el_GR.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/el_GR.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/el_GR.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was el_GR.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/el_GR.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/en_AU.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/en_AU.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/en_AU.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was en_AU.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/en_AU.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/en_CA.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/en_CA.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/en_CA.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was en_CA.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/en_CA.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/en_GB.ISO8859-1.src ============================================================================== --- user/edwin/locale/share/monetdef/en_GB.ISO8859-1.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/en_GB.ISO8859-1.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was en_GB.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/en_GB.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/en_GB.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/en_GB.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/en_GB.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was en_GB.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/en_GB.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/en_IE.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/en_IE.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/en_IE.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was en_IE.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/en_IE.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/en_NZ.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/en_NZ.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/en_NZ.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was en_NZ.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/en_NZ.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/en_US.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/en_US.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/en_US.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was en_US.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/en_US.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/es_ES.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/es_ES.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/es_ES.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was es_ES.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/es_ES.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/et_EE.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/et_EE.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/et_EE.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was et_EE.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/et_EE.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/fi_FI.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/fi_FI.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/fi_FI.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was fi_FI.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/fi_FI.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/fr_BE.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/fr_BE.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/fr_BE.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was fr_BE.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/fr_BE.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/fr_CA.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/fr_CA.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/fr_CA.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was fr_CA.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/fr_CA.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/fr_FR.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/fr_FR.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/fr_FR.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was fr_FR.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/fr_FR.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/he_IL.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/he_IL.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/he_IL.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was he_IL.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/he_IL.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/hi_IN.ISCII-DEV.src ============================================================================== --- user/edwin/locale/share/monetdef/hi_IN.ISCII-DEV.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/hi_IN.ISCII-DEV.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was hi_IN.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/hi_IN.unicode 197187 2009-09-14 08:04:48Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/hi_IN.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/hi_IN.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/hi_IN.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was hi_IN.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/hi_IN.unicode 197187 2009-09-14 08:04:48Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/hr_HR.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/hr_HR.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/hr_HR.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was hr_HR.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/hr_HR.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/hu_HU.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/hu_HU.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/hu_HU.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was hu_HU.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/hu_HU.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/hy_AM.ARMSCII-8.src ============================================================================== --- user/edwin/locale/share/monetdef/hy_AM.ARMSCII-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/hy_AM.ARMSCII-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file« it is created automatically by the unicode2utf8 +# utility© All changes to this file will be lost© +# The source of this file was hy_AM©unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/hy_AM©unicode 196846 2009¬09¬04 23:11:59Z edwin $ # # LC_MONETARY source for ARMSCII¬8 locale for FreeBSD Modified: user/edwin/locale/share/monetdef/hy_AM.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/hy_AM.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/hy_AM.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was hy_AM.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/hy_AM.unicode 196846 2009-09-04 23:11:59Z edwin $ # # LC_MONETARY source for ARMSCII-8 locale for FreeBSD Modified: user/edwin/locale/share/monetdef/is_IS.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/is_IS.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/is_IS.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was is_IS.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/is_IS.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/it_IT.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/it_IT.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/it_IT.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was it_IT.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/it_IT.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ja_JP.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/ja_JP.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ja_JP.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ja_JP.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ja_JP.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ja_JP.eucJP.src ============================================================================== --- user/edwin/locale/share/monetdef/ja_JP.eucJP.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ja_JP.eucJP.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ja_JP.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ja_JP.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/kk_KZ.PT154.src ============================================================================== --- user/edwin/locale/share/monetdef/kk_KZ.PT154.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/kk_KZ.PT154.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was kk_KZ.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/kk_KZ.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/kk_KZ.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/kk_KZ.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/kk_KZ.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was kk_KZ.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/kk_KZ.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ko_KR.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/ko_KR.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ko_KR.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ko_KR.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ko_KR.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ko_KR.eucKR.src ============================================================================== --- user/edwin/locale/share/monetdef/ko_KR.eucKR.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ko_KR.eucKR.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ko_KR.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ko_KR.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/lt_LT.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/lt_LT.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/lt_LT.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was lt_LT.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/lt_LT.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/lv_LV.ISO8859-13.src ============================================================================== --- user/edwin/locale/share/monetdef/lv_LV.ISO8859-13.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/lv_LV.ISO8859-13.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was lv_LV.unicode +# # $FreeBSD$ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/lv_LV.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/lv_LV.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/lv_LV.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was lv_LV.unicode +# # $FreeBSD$ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/mn_MN.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/mn_MN.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/mn_MN.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was mn_MN.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/mn_MN.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/nl_BE.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/nl_BE.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/nl_BE.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was nl_BE.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/nl_BE.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/nl_NL.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/nl_NL.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/nl_NL.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was nl_NL.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/nl_NL.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/no_NO.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/no_NO.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/no_NO.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was no_NO.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/no_NO.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/pl_PL.ISO8859-2.src ============================================================================== --- user/edwin/locale/share/monetdef/pl_PL.ISO8859-2.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/pl_PL.ISO8859-2.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was pl_PL.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/pl_PL.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/pl_PL.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/pl_PL.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/pl_PL.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was pl_PL.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/pl_PL.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/pt_BR.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/pt_BR.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/pt_BR.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was pt_BR.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/pt_BR.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/pt_PT.ISO8859-1.src ============================================================================== --- user/edwin/locale/share/monetdef/pt_PT.ISO8859-1.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/pt_PT.ISO8859-1.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was pt_PT.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/pt_PT.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/pt_PT.ISO8859-15.src ============================================================================== --- user/edwin/locale/share/monetdef/pt_PT.ISO8859-15.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/pt_PT.ISO8859-15.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was pt_PT.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/pt_PT.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/pt_PT.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/pt_PT.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/pt_PT.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was pt_PT.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/pt_PT.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ro_RO.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/ro_RO.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ro_RO.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ro_RO.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ro_RO.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ru_RU.CP1251.src ============================================================================== --- user/edwin/locale/share/monetdef/ru_RU.CP1251.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ru_RU.CP1251.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ru_RU.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ru_RU.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ru_RU.CP866.src ============================================================================== --- user/edwin/locale/share/monetdef/ru_RU.CP866.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ru_RU.CP866.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ru_RU.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ru_RU.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ru_RU.ISO8859-5.src ============================================================================== --- user/edwin/locale/share/monetdef/ru_RU.ISO8859-5.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ru_RU.ISO8859-5.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ru_RU.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ru_RU.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ru_RU.KOI8-R.src ============================================================================== --- user/edwin/locale/share/monetdef/ru_RU.KOI8-R.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ru_RU.KOI8-R.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ru_RU.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ru_RU.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/ru_RU.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/ru_RU.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/ru_RU.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ru_RU.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/ru_RU.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/sk_SK.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/sk_SK.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/sk_SK.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was sk_SK.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/sk_SK.unicode 196846 2009-09-04 23:11:59Z edwin $ # # Slovak monetary definition by Juraj Bednar Modified: user/edwin/locale/share/monetdef/sl_SI.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/sl_SI.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/sl_SI.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was sl_SI.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/sl_SI.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/sr_Cyrl_RS.ISO8859-5.src ============================================================================== --- user/edwin/locale/share/monetdef/sr_Cyrl_RS.ISO8859-5.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/sr_Cyrl_RS.ISO8859-5.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was sr_Cyrl_RS.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/sr_Cyrl_RS.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/sr_Cyrl_RS.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/sr_Cyrl_RS.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/sr_Cyrl_RS.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was sr_Cyrl_RS.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/sr_Cyrl_RS.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/sr_Latn_RS.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/sr_Latn_RS.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/sr_Latn_RS.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was sr_Latn_RS.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/sr_Latn_RS.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/sv_SE.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/sv_SE.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/sv_SE.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was sv_SE.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/sv_SE.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/tr_TR.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/tr_TR.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/tr_TR.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was tr_TR.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/tr_TR.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/uk_UA.CP1251.src ============================================================================== --- user/edwin/locale/share/monetdef/uk_UA.CP1251.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/uk_UA.CP1251.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was uk_UA.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/uk_UA.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/uk_UA.ISO8859-5.src ============================================================================== --- user/edwin/locale/share/monetdef/uk_UA.ISO8859-5.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/uk_UA.ISO8859-5.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was uk_UA.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/uk_UA.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/uk_UA.KOI8-U.src ============================================================================== --- user/edwin/locale/share/monetdef/uk_UA.KOI8-U.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/uk_UA.KOI8-U.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was uk_UA.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/uk_UA.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/uk_UA.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/uk_UA.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/uk_UA.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was uk_UA.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/uk_UA.unicode 196846 2009-09-04 23:11:59Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/zh_Hans_CN.GB18030.src ============================================================================== --- user/edwin/locale/share/monetdef/zh_Hans_CN.GB18030.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/zh_Hans_CN.GB18030.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was zh_Hans_CN.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/zh_Hans_CN.unicode 197161 2009-09-13 11:52:15Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/zh_Hans_CN.GB2312.src ============================================================================== --- user/edwin/locale/share/monetdef/zh_Hans_CN.GB2312.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/zh_Hans_CN.GB2312.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was zh_Hans_CN.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/zh_Hans_CN.unicode 197161 2009-09-13 11:52:15Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/zh_Hans_CN.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/zh_Hans_CN.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/zh_Hans_CN.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was zh_Hans_CN.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/zh_Hans_CN.unicode 197161 2009-09-13 11:52:15Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/zh_Hans_CN.eucCN.src ============================================================================== --- user/edwin/locale/share/monetdef/zh_Hans_CN.eucCN.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/zh_Hans_CN.eucCN.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was zh_Hans_CN.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/zh_Hans_CN.unicode 197161 2009-09-13 11:52:15Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/zh_Hant_HK.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/zh_Hant_HK.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/zh_Hant_HK.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was zh_Hant_HK.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/zh_Hant_HK.unicode 197161 2009-09-13 11:52:15Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/monetdef/zh_Hant_TW.UTF-8.src ============================================================================== --- user/edwin/locale/share/monetdef/zh_Hant_TW.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/monetdef/zh_Hant_TW.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was zh_Hant_TW.unicode +# # $FreeBSD: user/edwin/locale/share/monetdef/zh_Hant_TW.unicode 197161 2009-09-13 11:52:15Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/msgdef/af_ZA.UTF-8.src ============================================================================== --- user/edwin/locale/share/msgdef/af_ZA.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/af_ZA.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was af_ZA.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/af_ZA.unicode 196401 2009-08-20 13:59:52Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/msgdef/am_ET.UTF-8.src ============================================================================== --- user/edwin/locale/share/msgdef/am_ET.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/am_ET.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was am_ET.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/am_ET.unicode 196401 2009-08-20 13:59:52Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/msgdef/be_BY.CP1131.src ============================================================================== --- user/edwin/locale/share/msgdef/be_BY.CP1131.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/be_BY.CP1131.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/be_BY.unicode 196401 2009-08-20 13:59:52Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/msgdef/be_BY.CP1251.src ============================================================================== --- user/edwin/locale/share/msgdef/be_BY.CP1251.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/be_BY.CP1251.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/be_BY.unicode 196401 2009-08-20 13:59:52Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/msgdef/be_BY.ISO8859-5.src ============================================================================== --- user/edwin/locale/share/msgdef/be_BY.ISO8859-5.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/be_BY.ISO8859-5.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/be_BY.unicode 196401 2009-08-20 13:59:52Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/msgdef/be_BY.UTF-8.src ============================================================================== --- user/edwin/locale/share/msgdef/be_BY.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/be_BY.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was be_BY.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/be_BY.unicode 196401 2009-08-20 13:59:52Z edwin $ # WARNING: spaces may be essential at the end of lines # WARNING: empty lines are essential too Modified: user/edwin/locale/share/msgdef/bg_BG.CP1251.src ============================================================================== --- user/edwin/locale/share/msgdef/bg_BG.CP1251.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/bg_BG.CP1251.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was bg_BG.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/bg_BG.unicode 196401 2009-08-20 13:59:52Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/msgdef/bg_BG.UTF-8.src ============================================================================== --- user/edwin/locale/share/msgdef/bg_BG.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/bg_BG.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was bg_BG.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/bg_BG.unicode 196401 2009-08-20 13:59:52Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/msgdef/ca_ES.UTF-8.src ============================================================================== --- user/edwin/locale/share/msgdef/ca_ES.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/ca_ES.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was ca_ES.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/ca_ES.unicode 196401 2009-08-20 13:59:52Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/msgdef/cs_CZ.UTF-8.src ============================================================================== --- user/edwin/locale/share/msgdef/cs_CZ.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/cs_CZ.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was cs_CZ.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/cs_CZ.unicode 196401 2009-08-20 13:59:52Z edwin $ # # WARNING: spaces may be essential at the end of lines Modified: user/edwin/locale/share/msgdef/da_DK.UTF-8.src ============================================================================== --- user/edwin/locale/share/msgdef/da_DK.UTF-8.src Wed Oct 7 20:59:59 2009 (r197844) +++ user/edwin/locale/share/msgdef/da_DK.UTF-8.src Wed Oct 7 21:04:52 2009 (r197845) @@ -1,3 +1,8 @@ +# +# Do not edit this file, it is created automatically by the unicode2utf8 +# utility. All changes to this file will be lost. +# The source of this file was da_DK.unicode +# # $FreeBSD: user/edwin/locale/share/msgdef/da_DK.unicode 196401 2009-08-20 13:59:52Z edwin $ # *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 00:22:43 2009 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 C901C10656D2; Thu, 8 Oct 2009 00:22:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2A3108FC2B; Thu, 8 Oct 2009 00:22:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n980MhC2003915; Thu, 8 Oct 2009 00:22:43 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n980Mh8H003913; Thu, 8 Oct 2009 00:22:43 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200910080022.n980Mh8H003913@svn.freebsd.org> From: Kip Macy Date: Thu, 8 Oct 2009 00:22: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: r197851 - user/kmacy/releng_8_fcs/sys/kern 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, 08 Oct 2009 00:22:44 -0000 Author: kmacy Date: Thu Oct 8 00:22:42 2009 New Revision: 197851 URL: http://svn.freebsd.org/changeset/base/197851 Log: replace KTR flags Modified: user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c Modified: user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c ============================================================================== --- user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c Wed Oct 7 23:17:15 2009 (r197850) +++ user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c Thu Oct 8 00:22:42 2009 (r197851) @@ -3450,7 +3450,7 @@ soissending(struct socket *so, struct th bcopy(uap, &ref->sr_uap, sizeof(*uap)); ref->sr_uap.sbytes = NULL; ref->sr_sock_fp->f_sfbytes = 0; - CTR4(KTR_SPARE1, "sock %p off %ld sbytes %ld total_sbytes %ld", + CTR4(KTR_SPARE2, "sock %p off %ld sbytes %ld total_sbytes %ld", so, ref->sr_uap.offset, sbytes, ref->sr_fp->f_sfbytes); ref->sr_uap.offset += sbytes; if (uap->nbytes) @@ -3541,7 +3541,7 @@ sendfile_task_func(void *context, int pe error = kern_sendfile(curthread, &sr->sr_uap, hdr_uio, trl_uio, sr->sr_compat, fp, so, sr->sr_ucred); - CTR4(KTR_SPARE1, "sock %p off %ld sbytes %ld total_sbytes %ld", + CTR4(KTR_SPARE2, "sock %p off %ld sbytes %ld total_sbytes %ld", so, sr->sr_uap.offset, sbytes, fp->f_sfbytes); atomic_add_long(&fp->f_sfbytes, sbytes); sr->sr_uap.offset += sbytes; @@ -3549,14 +3549,14 @@ sendfile_task_func(void *context, int pe sr->sr_uap.nbytes -= sbytes; if (error == EAGAIN && (sr->sr_uap.offset + sbytes == sr->sr_vnp_size)) { - CTR0(KTR_SPARE1, "EAGAIN on full send"); + CTR0(KTR_SPARE2, "EAGAIN on full send"); error = 0; } SOCKBUF_LOCK(sb); } #ifdef KTR else - CTR2(KTR_SPARE1, "sock %p off %ld - not writeable in task_func", + CTR2(KTR_SPARE2, "sock %p off %ld - not writeable in task_func", so, sr->sr_uap.offset); #endif if (error == EAGAIN && srsendingwakeup(sr) != ENOTCONN) { @@ -3565,7 +3565,7 @@ sendfile_task_func(void *context, int pe } #ifdef KTR if (error && error != EAGAIN && error != EPIPE) - CTR1(KTR_SPARE1, "error %d", error); + CTR1(KTR_SPARE2, "error %d", error); #endif sb->sb_flags &= ~SB_SENDING; @@ -3595,12 +3595,12 @@ srsendingwakeup(struct socketref *sr) fp = sr->sr_sock_fp; CTR2(KTR_SPARE2, "processing s %d sock_fp %p", sr->sr_uap.s, fp); if (fp->f_type != DTYPE_SOCKET) { - CTR1(KTR_SPARE1, "not socket - type %d", fp->f_type); + CTR1(KTR_SPARE2, "not socket - type %d", fp->f_type); goto error; } so = fp->f_data; if ((so->so_state & SS_ISCONNECTED) == 0) { - CTR1(KTR_SPARE1, "not connected %p", so); + CTR1(KTR_SPARE2, "not connected %p", so); goto error; } @@ -3609,13 +3609,13 @@ srsendingwakeup(struct socketref *sr) SOCKBUF_LOCK_ASSERT(sb); sb->sb_flags &= ~SB_SENDING; if (sb->sb_state & SBS_CANTSENDMORE) { - CTR1(KTR_SPARE1, "SBS_CANTSENDMORE %p", so); + CTR1(KTR_SPARE2, "SBS_CANTSENDMORE %p", so); } else if (sowriteable(so)) { CTR2(KTR_SPARE2, "enqueue socket to task %p sr %p", so, sr); sb->sb_flags |= SB_SENDING; taskqueue_enqueue(sendfile_tq, &sr->sr_task); } else { - CTR2(KTR_SPARE1, "sock %p off %ld - not writeable in srsendingwakeup", + CTR2(KTR_SPARE2, "sock %p off %ld - not writeable in srsendingwakeup", so, sr->sr_uap.offset); sb->sb_flags |= SB_SENDING; mtx_lock(&sendfile_bg_lock); From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 18:28:25 2009 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 88E241065672; Thu, 8 Oct 2009 18:28:25 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F24B8FC12; Thu, 8 Oct 2009 18:28:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98ISPtq029692; Thu, 8 Oct 2009 18:28:25 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98ISPQh029691; Thu, 8 Oct 2009 18:28:25 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910081828.n98ISPQh029691@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 18:28:25 +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: r197864 - user/eri 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, 08 Oct 2009 18:28:25 -0000 Author: eri Date: Thu Oct 8 18:28:24 2009 New Revision: 197864 URL: http://svn.freebsd.org/changeset/base/197864 Log: Create my user directory Added: user/eri/ From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 18:44:17 2009 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 71787106566B; Thu, 8 Oct 2009 18:44:17 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F52E8FC0C; Thu, 8 Oct 2009 18:44:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98IiGsZ030128; Thu, 8 Oct 2009 18:44:16 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98IiGBG030122; Thu, 8 Oct 2009 18:44:16 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910081844.n98IiGBG030122@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 18:44: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: r197865 - in user/eri: net netinet 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, 08 Oct 2009 18:44:17 -0000 Author: eri Date: Thu Oct 8 18:44:15 2009 New Revision: 197865 URL: http://svn.freebsd.org/changeset/base/197865 Log: Import pf .4.5.002 branch to work on make it usable on FreeBSD. Added: user/eri/net/ user/eri/net/if_pflog.c (contents, props changed) user/eri/net/if_pflog.h (contents, props changed) user/eri/net/if_pflow.c (contents, props changed) user/eri/net/if_pflow.h (contents, props changed) user/eri/net/if_pfsync.c (contents, props changed) user/eri/net/if_pfsync.h (contents, props changed) user/eri/net/pf.c (contents, props changed) user/eri/net/pf_if.c (contents, props changed) user/eri/net/pf_ioctl.c (contents, props changed) user/eri/net/pf_lb.c (contents, props changed) user/eri/net/pf_norm.c (contents, props changed) user/eri/net/pf_osfp.c (contents, props changed) user/eri/net/pf_ruleset.c (contents, props changed) user/eri/net/pf_table.c (contents, props changed) user/eri/net/pfvar.h (contents, props changed) user/eri/netinet/ user/eri/netinet/in4_cksum.c (contents, props changed) Added: user/eri/net/if_pflog.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/eri/net/if_pflog.c Thu Oct 8 18:44:15 2009 (r197865) @@ -0,0 +1,269 @@ +/* $OpenBSD: if_pflog.c,v 1.26 2007/10/18 21:58:18 mpf Exp $ */ +/* + * The authors of this code are John Ioannidis (ji@tla.org), + * Angelos D. Keromytis (kermit@csd.uch.gr) and + * Niels Provos (provos@physnet.uni-hamburg.de). + * + * This code was written by John Ioannidis for BSD/OS in Athens, Greece, + * in November 1995. + * + * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, + * by Angelos D. Keromytis. + * + * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis + * and Niels Provos. + * + * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis + * and Niels Provos. + * Copyright (c) 2001, Angelos D. Keromytis, Niels Provos. + * + * Permission to use, copy, and modify this software with or without fee + * is hereby granted, provided that this entire notice is included in + * all copies of any software which is or includes a copy or + * modification of this software. + * You may use this code under the GNU public license if you so wish. Please + * contribute changes back to the authors under this freer than GPL license + * so that we may further the use of strong encryption without limitations to + * all. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE + * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR + * PURPOSE. + */ + +#include "bpfilter.h" +#include "pflog.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef INET +#include +#include +#include +#include +#endif + +#ifdef INET6 +#ifndef INET +#include +#endif +#include +#endif /* INET6 */ + +#include +#include + +#define PFLOGMTU (32768 + MHLEN + MLEN) + +#ifdef PFLOGDEBUG +#define DPRINTF(x) do { if (pflogdebug) printf x ; } while (0) +#else +#define DPRINTF(x) +#endif + +void pflogattach(int); +int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); +int pflogioctl(struct ifnet *, u_long, caddr_t); +void pflogstart(struct ifnet *); +int pflog_clone_create(struct if_clone *, int); +int pflog_clone_destroy(struct ifnet *); + +LIST_HEAD(, pflog_softc) pflogif_list; +struct if_clone pflog_cloner = + IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy); + +struct ifnet *pflogifs[PFLOGIFS_MAX]; /* for fast access */ + +void +pflogattach(int npflog) +{ + int i; + LIST_INIT(&pflogif_list); + for (i = 0; i < PFLOGIFS_MAX; i++) + pflogifs[i] = NULL; + if_clone_attach(&pflog_cloner); +} + +int +pflog_clone_create(struct if_clone *ifc, int unit) +{ + struct ifnet *ifp; + struct pflog_softc *pflogif; + int s; + + if (unit >= PFLOGIFS_MAX) + return (EINVAL); + + if ((pflogif = malloc(sizeof(*pflogif), + M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) + return (ENOMEM); + + pflogif->sc_unit = unit; + ifp = &pflogif->sc_if; + snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", unit); + ifp->if_softc = pflogif; + ifp->if_mtu = PFLOGMTU; + ifp->if_ioctl = pflogioctl; + ifp->if_output = pflogoutput; + ifp->if_start = pflogstart; + ifp->if_type = IFT_PFLOG; + ifp->if_snd.ifq_maxlen = ifqmaxlen; + ifp->if_hdrlen = PFLOG_HDRLEN; + if_attach(ifp); + if_alloc_sadl(ifp); + +#if NBPFILTER > 0 + bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); +#endif + + s = splnet(); + LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list); + pflogifs[unit] = ifp; + splx(s); + + return (0); +} + +int +pflog_clone_destroy(struct ifnet *ifp) +{ + struct pflog_softc *pflogif = ifp->if_softc; + int s; + + s = splnet(); + pflogifs[pflogif->sc_unit] = NULL; + LIST_REMOVE(pflogif, sc_list); + splx(s); + +#if NBPFILTER > 0 + bpfdetach(ifp); +#endif + if_detach(ifp); + free(pflogif, M_DEVBUF); + return (0); +} + +/* + * Start output on the pflog interface. + */ +void +pflogstart(struct ifnet *ifp) +{ + struct mbuf *m; + int s; + + for (;;) { + s = splnet(); + IF_DROP(&ifp->if_snd); + IF_DEQUEUE(&ifp->if_snd, m); + splx(s); + + if (m == NULL) + return; + else + m_freem(m); + } +} + +int +pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, + struct rtentry *rt) +{ + m_freem(m); + return (0); +} + +/* ARGSUSED */ +int +pflogioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + switch (cmd) { + case SIOCSIFFLAGS: + if (ifp->if_flags & IFF_UP) + ifp->if_flags |= IFF_RUNNING; + else + ifp->if_flags &= ~IFF_RUNNING; + break; + default: + return (ENOTTY); + } + + return (0); +} + +int +pflog_packet(struct pfi_kif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, + u_int8_t reason, struct pf_rule *rm, struct pf_rule *am, + struct pf_ruleset *ruleset, struct pf_pdesc *pd) +{ +#if NBPFILTER > 0 + struct ifnet *ifn; + struct pfloghdr hdr; + + if (kif == NULL || m == NULL || rm == NULL || pd == NULL) + return (-1); + + if ((ifn = pflogifs[rm->logif]) == NULL || !ifn->if_bpf) + return (0); + + bzero(&hdr, sizeof(hdr)); + hdr.length = PFLOG_REAL_HDRLEN; + hdr.af = af; + hdr.action = rm->action; + hdr.reason = reason; + memcpy(hdr.ifname, kif->pfik_name, sizeof(hdr.ifname)); + + if (am == NULL) { + hdr.rulenr = htonl(rm->nr); + hdr.subrulenr = -1; + } else { + hdr.rulenr = htonl(am->nr); + hdr.subrulenr = htonl(rm->nr); + if (ruleset != NULL && ruleset->anchor != NULL) + strlcpy(hdr.ruleset, ruleset->anchor->name, + sizeof(hdr.ruleset)); + } + if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done) + pd->lookup.done = pf_socket_lookup(dir, pd); + if (pd->lookup.done > 0) { + hdr.uid = pd->lookup.uid; + hdr.pid = pd->lookup.pid; + } else { + hdr.uid = UID_MAX; + hdr.pid = NO_PID; + } + hdr.rule_uid = rm->cuid; + hdr.rule_pid = rm->cpid; + hdr.dir = dir; + +#ifdef INET + if (af == AF_INET && dir == PF_OUT) { + struct ip *ip; + + ip = mtod(m, struct ip *); + ip->ip_sum = 0; + ip->ip_sum = in_cksum(m, ip->ip_hl << 2); + } +#endif /* INET */ + + ifn->if_opackets++; + ifn->if_obytes += m->m_pkthdr.len; + bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, + BPF_DIRECTION_OUT); +#endif + + return (0); +} Added: user/eri/net/if_pflog.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/eri/net/if_pflog.h Thu Oct 8 18:44:15 2009 (r197865) @@ -0,0 +1,80 @@ +/* $OpenBSD: if_pflog.h,v 1.13 2006/10/23 12:46:09 henning Exp $ */ +/* + * Copyright 2001 Niels Provos + * 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 ``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 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. + */ + +#ifndef _NET_IF_PFLOG_H_ +#define _NET_IF_PFLOG_H_ + +#define PFLOGIFS_MAX 16 + +struct pflog_softc { + struct ifnet sc_if; /* the interface */ + int sc_unit; + LIST_ENTRY(pflog_softc) sc_list; +}; + +#define PFLOG_RULESET_NAME_SIZE 16 + +struct pfloghdr { + u_int8_t length; + sa_family_t af; + u_int8_t action; + u_int8_t reason; + char ifname[IFNAMSIZ]; + char ruleset[PFLOG_RULESET_NAME_SIZE]; + u_int32_t rulenr; + u_int32_t subrulenr; + uid_t uid; + pid_t pid; + uid_t rule_uid; + pid_t rule_pid; + u_int8_t dir; + u_int8_t pad[3]; +}; + +#define PFLOG_HDRLEN sizeof(struct pfloghdr) +/* minus pad, also used as a signature */ +#define PFLOG_REAL_HDRLEN offsetof(struct pfloghdr, pad) + +/* XXX remove later when old format logs are no longer needed */ +struct old_pfloghdr { + u_int32_t af; + char ifname[IFNAMSIZ]; + short rnr; + u_short reason; + u_short action; + u_short dir; +}; +#define OLD_PFLOG_HDRLEN sizeof(struct old_pfloghdr) + +#ifdef _KERNEL + +#if NPFLOG > 0 +#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) pflog_packet(i,a,b,c,d,e,f,g,h) +#else +#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) ((void)0) +#endif /* NPFLOG > 0 */ +#endif /* _KERNEL */ +#endif /* _NET_IF_PFLOG_H_ */ Added: user/eri/net/if_pflow.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/eri/net/if_pflow.c Thu Oct 8 18:44:15 2009 (r197865) @@ -0,0 +1,621 @@ +/* $OpenBSD: if_pflow.c,v 1.9 2009/01/03 21:47:32 gollo Exp $ */ + +/* + * Copyright (c) 2008 Henning Brauer + * Copyright (c) 2008 Joerg Goltermann + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef INET +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* INET */ + +#include +#include + +#include "bpfilter.h" +#include "pflow.h" + +#define PFLOW_MINMTU \ + (sizeof(struct pflow_header) + sizeof(struct pflow_flow)) + +#ifdef PFLOWDEBUG +#define DPRINTF(x) do { printf x ; } while (0) +#else +#define DPRINTF(x) +#endif + +SLIST_HEAD(, pflow_softc) pflowif_list; +struct pflowstats pflowstats; + +void pflowattach(int); +int pflow_clone_create(struct if_clone *, int); +int pflow_clone_destroy(struct ifnet *); +void pflow_setmtu(struct pflow_softc *, int); +int pflowoutput(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); +int pflowioctl(struct ifnet *, u_long, caddr_t); +void pflowstart(struct ifnet *); + +struct mbuf *pflow_get_mbuf(struct pflow_softc *); +int pflow_sendout(struct pflow_softc *); +int pflow_sendout_mbuf(struct pflow_softc *, struct mbuf *); +void pflow_timeout(void *); +void copy_flow_data(struct pflow_flow *, struct pflow_flow *, + struct pf_state *, int, int); +int pflow_pack_flow(struct pf_state *, struct pflow_softc *); +int pflow_get_dynport(void); +int export_pflow_if(struct pf_state*, struct pflow_softc *); +int copy_flow_to_m(struct pflow_flow *flow, struct pflow_softc *sc); + +struct if_clone pflow_cloner = + IF_CLONE_INITIALIZER("pflow", pflow_clone_create, + pflow_clone_destroy); + +/* from in_pcb.c */ +extern int ipport_hifirstauto; +extern int ipport_hilastauto; + +/* from kern/kern_clock.c; incremented each clock tick. */ +extern int ticks; + +void +pflowattach(int npflow) +{ + SLIST_INIT(&pflowif_list); + if_clone_attach(&pflow_cloner); +} + +int +pflow_clone_create(struct if_clone *ifc, int unit) +{ + struct ifnet *ifp; + struct pflow_softc *pflowif; + + if ((pflowif = malloc(sizeof(*pflowif), + M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) + return (ENOMEM); + + pflowif->sc_sender_ip.s_addr = INADDR_ANY; + pflowif->sc_sender_port = pflow_get_dynport(); + + pflowif->sc_imo.imo_membership = malloc( + (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS, + M_WAITOK|M_ZERO); + pflowif->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; + pflowif->sc_receiver_ip.s_addr = 0; + pflowif->sc_receiver_port = 0; + pflowif->sc_sender_ip.s_addr = INADDR_ANY; + pflowif->sc_sender_port = pflow_get_dynport(); + ifp = &pflowif->sc_if; + snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflow%d", unit); + ifp->if_softc = pflowif; + ifp->if_ioctl = pflowioctl; + ifp->if_output = pflowoutput; + ifp->if_start = pflowstart; + ifp->if_type = IFT_PFLOW; + ifp->if_snd.ifq_maxlen = ifqmaxlen; + ifp->if_hdrlen = PFLOW_HDRLEN; + ifp->if_flags = IFF_UP; + ifp->if_flags &= ~IFF_RUNNING; /* not running, need receiver */ + pflow_setmtu(pflowif, ETHERMTU); + timeout_set(&pflowif->sc_tmo, pflow_timeout, pflowif); + if_attach(ifp); + if_alloc_sadl(ifp); + +#if NBPFILTER > 0 + bpfattach(&pflowif->sc_if.if_bpf, ifp, DLT_RAW, 0); +#endif + + /* Insert into list of pflows */ + SLIST_INSERT_HEAD(&pflowif_list, pflowif, sc_next); + return (0); +} + +int +pflow_clone_destroy(struct ifnet *ifp) +{ + struct pflow_softc *sc = ifp->if_softc; + int s; + + s = splnet(); + pflow_sendout(sc); +#if NBPFILTER > 0 + bpfdetach(ifp); +#endif + if_detach(ifp); + SLIST_REMOVE(&pflowif_list, sc, pflow_softc, sc_next); + free(sc->sc_imo.imo_membership, M_IPMOPTS); + free(sc, M_DEVBUF); + splx(s); + return (0); +} + +/* + * Start output on the pflow interface. + */ +void +pflowstart(struct ifnet *ifp) +{ + struct mbuf *m; + int s; + + for (;;) { + s = splnet(); + IF_DROP(&ifp->if_snd); + IF_DEQUEUE(&ifp->if_snd, m); + splx(s); + + if (m == NULL) + return; + m_freem(m); + } +} + +int +pflowoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, + struct rtentry *rt) +{ + m_freem(m); + return (0); +} + +/* ARGSUSED */ +int +pflowioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + struct proc *p = curproc; + struct pflow_softc *sc = ifp->if_softc; + struct ifreq *ifr = (struct ifreq *)data; + struct pflowreq pflowr; + int s, error; + + switch (cmd) { + case SIOCSIFADDR: + case SIOCAIFADDR: + case SIOCSIFDSTADDR: + case SIOCSIFFLAGS: + if ((ifp->if_flags & IFF_UP) && + sc->sc_receiver_ip.s_addr != 0 && + sc->sc_receiver_port != 0) { + ifp->if_flags |= IFF_RUNNING; + sc->sc_gcounter=pflowstats.pflow_flows; + } else + ifp->if_flags &= ~IFF_RUNNING; + break; + case SIOCSIFMTU: + if (ifr->ifr_mtu < PFLOW_MINMTU) + return (EINVAL); + if (ifr->ifr_mtu > MCLBYTES) + ifr->ifr_mtu = MCLBYTES; + s = splnet(); + if (ifr->ifr_mtu < ifp->if_mtu) + pflow_sendout(sc); + pflow_setmtu(sc, ifr->ifr_mtu); + splx(s); + break; + + case SIOCGETPFLOW: + bzero(&pflowr, sizeof(pflowr)); + + pflowr.sender_ip = sc->sc_sender_ip; + pflowr.receiver_ip = sc->sc_receiver_ip; + pflowr.receiver_port = sc->sc_receiver_port; + + if ((error = copyout(&pflowr, ifr->ifr_data, + sizeof(pflowr)))) + return (error); + break; + + case SIOCSETPFLOW: + if ((error = suser(p, p->p_acflag)) != 0) + return (error); + if ((error = copyin(ifr->ifr_data, &pflowr, + sizeof(pflowr)))) + return (error); + + s = splnet(); + pflow_sendout(sc); + splx(s); + + if (pflowr.addrmask & PFLOW_MASK_DSTIP) + sc->sc_receiver_ip = pflowr.receiver_ip; + if (pflowr.addrmask & PFLOW_MASK_DSTPRT) + sc->sc_receiver_port = pflowr.receiver_port; + if (pflowr.addrmask & PFLOW_MASK_SRCIP) + sc->sc_sender_ip.s_addr = pflowr.sender_ip.s_addr; + + if ((ifp->if_flags & IFF_UP) && + sc->sc_receiver_ip.s_addr != 0 && + sc->sc_receiver_port != 0) { + ifp->if_flags |= IFF_RUNNING; + sc->sc_gcounter=pflowstats.pflow_flows; + } else + ifp->if_flags &= ~IFF_RUNNING; + + break; + + default: + return (ENOTTY); + } + return (0); +} + +void +pflow_setmtu(struct pflow_softc *sc, int mtu_req) +{ + int mtu; + + if (sc->sc_pflow_ifp && sc->sc_pflow_ifp->if_mtu < mtu_req) + mtu = sc->sc_pflow_ifp->if_mtu; + else + mtu = mtu_req; + + sc->sc_maxcount = (mtu - sizeof(struct pflow_header) - + sizeof (struct udpiphdr)) / sizeof(struct pflow_flow); + if (sc->sc_maxcount > PFLOW_MAXFLOWS) + sc->sc_maxcount = PFLOW_MAXFLOWS; + sc->sc_if.if_mtu = sizeof(struct pflow_header) + + sizeof (struct udpiphdr) + + sc->sc_maxcount * sizeof(struct pflow_flow); +} + +struct mbuf * +pflow_get_mbuf(struct pflow_softc *sc) +{ + struct pflow_header h; + struct mbuf *m; + + MGETHDR(m, M_DONTWAIT, MT_DATA); + if (m == NULL) { + pflowstats.pflow_onomem++; + return (NULL); + } + + MCLGET(m, M_DONTWAIT); + if ((m->m_flags & M_EXT) == 0) { + m_free(m); + pflowstats.pflow_onomem++; + return (NULL); + } + + m->m_len = m->m_pkthdr.len = 0; + m->m_pkthdr.rcvif = NULL; + + /* populate pflow_header */ + h.reserved1 = 0; + h.reserved2 = 0; + h.count = 0; + h.version = htons(PFLOW_VERSION); + h.flow_sequence = htonl(sc->sc_gcounter); + h.engine_type = PFLOW_ENGINE_TYPE; + h.engine_id = PFLOW_ENGINE_ID; + m_copyback(m, 0, PFLOW_HDRLEN, &h); + + sc->sc_count = 0; + timeout_add_sec(&sc->sc_tmo, PFLOW_TIMEOUT); + return (m); +} + +void +copy_flow_data(struct pflow_flow *flow1, struct pflow_flow *flow2, + struct pf_state *st, int src, int dst) +{ + struct pf_state_key *sk = st->key[PF_SK_WIRE]; + + flow1->src_ip = flow2->dest_ip = sk->addr[src].v4.s_addr; + flow1->src_port = flow2->dest_port = sk->port[src]; + flow1->dest_ip = flow2->src_ip = sk->addr[dst].v4.s_addr; + flow1->dest_port = flow2->src_port = sk->port[dst]; + + flow1->dest_as = flow2->src_as = + flow1->src_as = flow2->dest_as = 0; + flow1->if_index_out = flow2->if_index_in = + flow1->if_index_in = flow2->if_index_out = 0; + flow1->dest_mask = flow2->src_mask = + flow1->src_mask = flow2->dest_mask = 0; + + flow1->flow_packets = htonl(st->packets[0]); + flow2->flow_packets = htonl(st->packets[1]); + flow1->flow_octets = htonl(st->bytes[0]); + flow2->flow_octets = htonl(st->bytes[1]); + + flow1->flow_start = flow2->flow_start = htonl(st->creation * 1000); + flow1->flow_finish = flow2->flow_finish = htonl(time_second * 1000); + flow1->tcp_flags = flow2->tcp_flags = 0; + flow1->protocol = flow2->protocol = sk->proto; + flow1->tos = flow2->tos = st->rule.ptr->tos; +} + +int +export_pflow(struct pf_state *st) +{ + struct pflow_softc *sc = NULL; + struct pf_state_key *sk = st->key[PF_SK_WIRE]; + + if (sk->af != AF_INET) + return (0); + + SLIST_FOREACH(sc, &pflowif_list, sc_next) { + export_pflow_if(st, sc); + } + + return (0); +} + +int +export_pflow_if(struct pf_state *st, struct pflow_softc *sc) +{ + struct pf_state pfs_copy; + struct ifnet *ifp = &sc->sc_if; + u_int64_t bytes[2]; + int ret = 0; + + if (!(ifp->if_flags & IFF_RUNNING)) + return (0); + + if ((st->bytes[0] < (u_int64_t)PFLOW_MAXBYTES) + && (st->bytes[1] < (u_int64_t)PFLOW_MAXBYTES)) + return (pflow_pack_flow(st, sc)); + + /* flow > PFLOW_MAXBYTES need special handling */ + bcopy(st, &pfs_copy, sizeof(pfs_copy)); + bytes[0] = pfs_copy.bytes[0]; + bytes[1] = pfs_copy.bytes[1]; + + while (bytes[0] > PFLOW_MAXBYTES) { + pfs_copy.bytes[0] = PFLOW_MAXBYTES; + pfs_copy.bytes[1] = 0; + + if ((ret = pflow_pack_flow(&pfs_copy, sc)) != 0) + return (ret); + if ((bytes[0] - PFLOW_MAXBYTES) > 0) + bytes[0] -= PFLOW_MAXBYTES; + } + + while (bytes[1] > (u_int64_t)PFLOW_MAXBYTES) { + pfs_copy.bytes[1] = PFLOW_MAXBYTES; + pfs_copy.bytes[0] = 0; + + if ((ret = pflow_pack_flow(&pfs_copy, sc)) != 0) + return (ret); + if ((bytes[1] - PFLOW_MAXBYTES) > 0) + bytes[1] -= PFLOW_MAXBYTES; + } + + pfs_copy.bytes[0] = bytes[0]; + pfs_copy.bytes[1] = bytes[1]; + + return (pflow_pack_flow(&pfs_copy, sc)); +} + +int +copy_flow_to_m(struct pflow_flow *flow, struct pflow_softc *sc) +{ + int s, ret = 0; + + s = splnet(); + if (sc->sc_mbuf == NULL) { + if ((sc->sc_mbuf = pflow_get_mbuf(sc)) == NULL) { + splx(s); + return (ENOBUFS); + } + } + m_copyback(sc->sc_mbuf, PFLOW_HDRLEN + + (sc->sc_count * sizeof (struct pflow_flow)), + sizeof (struct pflow_flow), flow); + + if (pflowstats.pflow_flows == sc->sc_gcounter) + pflowstats.pflow_flows++; + sc->sc_gcounter++; + sc->sc_count++; + + if (sc->sc_count >= sc->sc_maxcount) + ret = pflow_sendout(sc); + + splx(s); + return(ret); +} + +int +pflow_pack_flow(struct pf_state *st, struct pflow_softc *sc) +{ + struct pflow_flow flow1; + struct pflow_flow flow2; + int ret = 0; + + bzero(&flow1, sizeof(flow1)); + bzero(&flow2, sizeof(flow2)); + + if (st->direction == PF_OUT) + copy_flow_data(&flow1, &flow2, st, 1, 0); + else + copy_flow_data(&flow1, &flow2, st, 0, 1); + + if (st->bytes[0] != 0) /* first flow from state */ + ret = copy_flow_to_m(&flow1, sc); + + if (st->bytes[1] != 0) /* second flow from state */ + ret = copy_flow_to_m(&flow2, sc); + + return (ret); +} + +void +pflow_timeout(void *v) +{ + struct pflow_softc *sc = v; + int s; + + s = splnet(); + pflow_sendout(sc); + splx(s); +} + +/* This must be called in splnet() */ +int +pflow_sendout(struct pflow_softc *sc) +{ + struct mbuf *m = sc->sc_mbuf; + struct pflow_header *h; + struct ifnet *ifp = &sc->sc_if; + + timeout_del(&sc->sc_tmo); + + if (m == NULL) + return (0); + + sc->sc_mbuf = NULL; + if (!(ifp->if_flags & IFF_RUNNING)) { + m_freem(m); + return (0); + } + + pflowstats.pflow_packets++; + h = mtod(m, struct pflow_header *); + h->count = htons(sc->sc_count); + + /* populate pflow_header */ + h->uptime_ms = htonl(time_uptime * 1000); + h->time_sec = htonl(time_second); + h->time_nanosec = htonl(ticks); + + return (pflow_sendout_mbuf(sc, m)); +} + +int +pflow_sendout_mbuf(struct pflow_softc *sc, struct mbuf *m) +{ + struct udpiphdr *ui; + u_int16_t len = m->m_pkthdr.len; + struct ifnet *ifp = &sc->sc_if; + struct ip *ip; + int err; + + /* UDP Header*/ + M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT); + if (m == NULL) { + pflowstats.pflow_onomem++; + return (ENOBUFS); + } + + ui = mtod(m, struct udpiphdr *); + ui->ui_pr = IPPROTO_UDP; + ui->ui_src = sc->sc_sender_ip; + ui->ui_sport = sc->sc_sender_port; + ui->ui_dst = sc->sc_receiver_ip; + ui->ui_dport = sc->sc_receiver_port; + ui->ui_ulen = htons(sizeof (struct udphdr) + len); + + ip = (struct ip *)ui; + ip->ip_v = IPVERSION; + ip->ip_hl = sizeof(struct ip) >> 2; + ip->ip_id = htons(ip_randomid()); + ip->ip_off = htons(IP_DF); + ip->ip_tos = IPTOS_LOWDELAY; + ip->ip_ttl = IPDEFTTL; + ip->ip_len = htons(sizeof (struct udpiphdr) + len); + + /* + * Compute the pseudo-header checksum; defer further checksumming + * until ip_output() or hardware (if it exists). + */ + m->m_pkthdr.csum_flags |= M_UDPV4_CSUM_OUT; + ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr, + ui->ui_dst.s_addr, htons(len + sizeof(struct udphdr) + + IPPROTO_UDP)); + +#if NBPFILTER > 0 + if (ifp->if_bpf) { + ip->ip_sum = in_cksum(m, ip->ip_hl << 2); + bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); + } +#endif + + sc->sc_if.if_opackets++; + sc->sc_if.if_obytes += m->m_pkthdr.len; + + if ((err = ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL))) { + pflowstats.pflow_oerrors++; + sc->sc_if.if_oerrors++; + } + return (err); +} + +int +pflow_get_dynport(void) +{ + u_int16_t tmp, low, high, cut; + + low = ipport_hifirstauto; /* sysctl */ + high = ipport_hilastauto; + + cut = arc4random_uniform(1 + high - low) + low; + + for (tmp = cut; tmp <= high; ++(tmp)) { + if (!in_baddynamic(tmp, IPPROTO_UDP)) + return (htons(tmp)); + } + + for (tmp = cut - 1; tmp >= low; --(tmp)) { + if (!in_baddynamic(tmp, IPPROTO_UDP)) + return (htons(tmp)); + } + + return (htons(ipport_hilastauto)); /* XXX */ +} + +int +pflow_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + if (namelen != 1) + return (ENOTDIR); + + switch (name[0]) { + case NET_PFLOW_STATS: + if (newp != NULL) + return (EPERM); + return (sysctl_struct(oldp, oldlenp, newp, newlen, + &pflowstats, sizeof(pflowstats))); + default: + return (EOPNOTSUPP); + } + return (0); +} Added: user/eri/net/if_pflow.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/eri/net/if_pflow.h Thu Oct 8 18:44:15 2009 (r197865) @@ -0,0 +1,120 @@ +/* $OpenBSD: if_pflow.h,v 1.4 2009/01/03 21:47:32 gollo Exp $ */ + +/* + * Copyright (c) 2008 Henning Brauer + * Copyright (c) 2008 Joerg Goltermann + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 18:55:12 2009 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 A146310656A4; Thu, 8 Oct 2009 18:55:12 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 900178FC08; Thu, 8 Oct 2009 18:55:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98ItCD5030361; Thu, 8 Oct 2009 18:55:12 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98ItC5i030359; Thu, 8 Oct 2009 18:55:12 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910081855.n98ItC5i030359@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 18:55:12 +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: r197866 - user/eri/net 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, 08 Oct 2009 18:55:12 -0000 Author: eri Date: Thu Oct 8 18:55:12 2009 New Revision: 197866 URL: http://svn.freebsd.org/changeset/base/197866 Log: Integrate all the changes needed to make pf(4) compile. Mark areas still needing work around ifdef notyet, though they are features as pfsync/pfflow/pflog. Modified: user/eri/net/if_pflog.c user/eri/net/if_pflog.h user/eri/net/pf.c user/eri/net/pf_if.c user/eri/net/pf_ioctl.c user/eri/net/pf_lb.c user/eri/net/pf_norm.c user/eri/net/pf_osfp.c user/eri/net/pf_ruleset.c user/eri/net/pf_table.c user/eri/net/pfvar.h Modified: user/eri/net/if_pflog.c ============================================================================== --- user/eri/net/if_pflog.c Thu Oct 8 18:44:15 2009 (r197865) +++ user/eri/net/if_pflog.c Thu Oct 8 18:55:12 2009 (r197866) @@ -2,7 +2,7 @@ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and - * Niels Provos (provos@physnet.uni-hamburg.de). + * Niels Provos (provos@physnet.uni hamburg.de). * * This code was written by John Ioannidis for BSD/OS in Athens, Greece, * in November 1995. @@ -33,17 +33,51 @@ * PURPOSE. */ + #ifdef __FreeBSD__ + #include "opt_inet.h" + #include "opt_inet6.h" + #include "opt_bpf.h" + #include "opt_pf.h" + + #include + __FBSDID("$FreeBSD$"); + + #ifdef DEV_BPF + #define NBPFILTER DEV_BPF + #else + #define NBPFILTER 0 + #endif + + #ifdef DEV_PFLOG + #define NPFLOG DEV_PFLOG + #else + #define NPFLOG 0 + #endif + + #else /* ! __FreeBSD__ */ #include "bpfilter.h" #include "pflog.h" +#endif #include #include #include #include #include + #ifdef __FreeBSD__ + #include + #include + #include + #include + #include + #else #include +#endif #include + #ifdef __FreeBSD__ + #include + #endif #include #include #include @@ -65,6 +99,12 @@ #include #include + #ifdef INET + #ifdef __FreeBSD__ + #include + #endif + #endif + #define PFLOGMTU (32768 + MHLEN + MLEN) #ifdef PFLOGDEBUG @@ -78,12 +118,21 @@ int pflogoutput(struct ifnet *, struct m struct rtentry *); int pflogioctl(struct ifnet *, u_long, caddr_t); void pflogstart(struct ifnet *); + #ifdef __FreeBSD__ + static int pflog_clone_create(struct if_clone *, int, caddr_t); + static void pflog_clone_destroy(struct ifnet *); + #else int pflog_clone_create(struct if_clone *, int); int pflog_clone_destroy(struct ifnet *); +#endif LIST_HEAD(, pflog_softc) pflogif_list; + #ifdef __FreeBSD__ + IFC_SIMPLE_DECLARE(pflog, 1); + #else struct if_clone pflog_cloner = IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy); +#endif struct ifnet *pflogifs[PFLOGIFS_MAX]; /* for fast access */ @@ -97,8 +146,13 @@ pflogattach(int npflog) if_clone_attach(&pflog_cloner); } + #ifdef __FreeBSD__ + static int + pflog_clone_create(struct if_clone *ifc, int unit, caddr_t param) + #else int pflog_clone_create(struct if_clone *ifc, int unit) +#endif { struct ifnet *ifp; struct pflog_softc *pflogif; @@ -111,49 +165,85 @@ pflog_clone_create(struct if_clone *ifc, M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) return (ENOMEM); - pflogif->sc_unit = unit; - ifp = &pflogif->sc_if; - snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", unit); - ifp->if_softc = pflogif; - ifp->if_mtu = PFLOGMTU; - ifp->if_ioctl = pflogioctl; - ifp->if_output = pflogoutput; - ifp->if_start = pflogstart; - ifp->if_type = IFT_PFLOG; - ifp->if_snd.ifq_maxlen = ifqmaxlen; - ifp->if_hdrlen = PFLOG_HDRLEN; + pflogif >sc_unit = unit; + #ifdef __FreeBSD__ + ifp = pflogif >sc_ifp = if_alloc(IFT_PFLOG); + if (ifp == NULL) { + free(pflogif, M_DEVBUF); + return (ENOSPC); + } + if_initname(ifp, ifc >ifc_name, unit); + #else + ifp = &pflogif >sc_if; + snprintf(ifp >if_xname, sizeof ifp >if_xname, "pflog%d", unit); +#endif + ifp >if_softc = pflogif; + ifp >if_mtu = PFLOGMTU; + ifp >if_ioctl = pflogioctl; + ifp >if_output = pflogoutput; + ifp >if_start = pflogstart; +#ifndef __FreeBSD__ + ifp >if_type = IFT_PFLOG; +#endif + ifp >if_snd.ifq_maxlen = ifqmaxlen; + ifp >if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); +#ifndef __FreeBSD__ if_alloc_sadl(ifp); +#endif #if NBPFILTER > 0 - bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); + bpfattach(&pflogif >sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); #endif s = splnet(); + #ifdef __FreeBSD__ + /* XXX: Why pf(4) lock?! Better add a pflog lock?! */ + PF_LOCK(); + #endif LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list); pflogifs[unit] = ifp; + #ifdef __FreeBSD__ + PF_UNLOCK(); + #endif splx(s); return (0); } + #ifdef __FreeBSD__ + static void + pflog_clone_destroy(struct ifnet *ifp) + #else int pflog_clone_destroy(struct ifnet *ifp) +#endif { - struct pflog_softc *pflogif = ifp->if_softc; + struct pflog_softc *pflogif = ifp >if_softc; int s; s = splnet(); - pflogifs[pflogif->sc_unit] = NULL; + #ifdef __FreeBSD__ + PF_LOCK(); + #endif + pflogifs[pflogif >sc_unit] = NULL; LIST_REMOVE(pflogif, sc_list); + #ifdef __FreeBSD__ + PF_UNLOCK(); + #endif splx(s); #if NBPFILTER > 0 bpfdetach(ifp); #endif if_detach(ifp); + #ifdef __FreeBSD__ + if_free(ifp); + #endif free(pflogif, M_DEVBUF); +#ifndef __FreeBSD__ return (0); +#endif } /* @@ -163,13 +253,22 @@ void pflogstart(struct ifnet *ifp) { struct mbuf *m; + #ifndef __FreeBSD__ int s; +#endif for (;;) { + #ifdef __FreeBSD__ + IF_LOCK(&ifp >if_snd); + _IF_DROP(&ifp >if_snd); + _IF_DEQUEUE(&ifp >if_snd, m); + IF_UNLOCK(&ifp >if_snd); + #else s = splnet(); - IF_DROP(&ifp->if_snd); - IF_DEQUEUE(&ifp->if_snd, m); + IF_DROP(&ifp >if_snd); + IF_DEQUEUE(&ifp >if_snd, m); splx(s); +#endif if (m == NULL) return; @@ -192,10 +291,17 @@ pflogioctl(struct ifnet *ifp, u_long cmd { switch (cmd) { case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) - ifp->if_flags |= IFF_RUNNING; + #ifdef __FreeBSD__ + if (ifp >if_flags & IFF_UP) + ifp >if_drv_flags |= IFF_DRV_RUNNING; + else + ifp >if_drv_flags &= ~IFF_DRV_RUNNING; + #else + if (ifp >if_flags & IFF_UP) + ifp >if_flags |= IFF_RUNNING; else - ifp->if_flags &= ~IFF_RUNNING; + ifp >if_flags &= ~IFF_RUNNING; +#endif break; default: return (ENOTTY); @@ -214,39 +320,47 @@ pflog_packet(struct pfi_kif *kif, struct struct pfloghdr hdr; if (kif == NULL || m == NULL || rm == NULL || pd == NULL) - return (-1); + return ( 1); - if ((ifn = pflogifs[rm->logif]) == NULL || !ifn->if_bpf) + if ((ifn = pflogifs[rm >logif]) == NULL || !ifn >if_bpf) return (0); bzero(&hdr, sizeof(hdr)); hdr.length = PFLOG_REAL_HDRLEN; hdr.af = af; - hdr.action = rm->action; + hdr.action = rm >action; hdr.reason = reason; - memcpy(hdr.ifname, kif->pfik_name, sizeof(hdr.ifname)); + memcpy(hdr.ifname, kif >pfik_name, sizeof(hdr.ifname)); if (am == NULL) { - hdr.rulenr = htonl(rm->nr); - hdr.subrulenr = -1; + hdr.rulenr = htonl(rm >nr); + hdr.subrulenr = 1; } else { - hdr.rulenr = htonl(am->nr); - hdr.subrulenr = htonl(rm->nr); - if (ruleset != NULL && ruleset->anchor != NULL) - strlcpy(hdr.ruleset, ruleset->anchor->name, + hdr.rulenr = htonl(am >nr); + hdr.subrulenr = htonl(rm >nr); + if (ruleset != NULL && ruleset >anchor != NULL) + strlcpy(hdr.ruleset, ruleset >anchor >name, sizeof(hdr.ruleset)); } - if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done) - pd->lookup.done = pf_socket_lookup(dir, pd); - if (pd->lookup.done > 0) { - hdr.uid = pd->lookup.uid; - hdr.pid = pd->lookup.pid; + if (rm >log & PF_LOG_SOCKET_LOOKUP && !pd >lookup.done) + #ifdef __FreeBSD__ + /* + * XXX: This should not happen as we force an early lookup + * via debug.pfugidhack + */ + ; /* empty */ + #else + pd >lookup.done = pf_socket_lookup(dir, pd); +#endif + if (pd >lookup.done > 0) { + hdr.uid = pd >lookup.uid; + hdr.pid = pd >lookup.pid; } else { hdr.uid = UID_MAX; hdr.pid = NO_PID; } - hdr.rule_uid = rm->cuid; - hdr.rule_pid = rm->cpid; + hdr.rule_uid = rm >cuid; + hdr.rule_pid = rm >cpid; hdr.dir = dir; #ifdef INET @@ -254,16 +368,56 @@ pflog_packet(struct pfi_kif *kif, struct struct ip *ip; ip = mtod(m, struct ip *); - ip->ip_sum = 0; - ip->ip_sum = in_cksum(m, ip->ip_hl << 2); + ip >ip_sum = 0; + ip >ip_sum = in_cksum(m, ip >ip_hl << 2); } #endif /* INET */ - ifn->if_opackets++; - ifn->if_obytes += m->m_pkthdr.len; - bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, + ifn >if_opackets++; + ifn >if_obytes += m >m_pkthdr.len; + #ifdef __FreeBSD__ + BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m); + #else + bpf_mtap_hdr(ifn >if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, BPF_DIRECTION_OUT); #endif +#endif return (0); } + + #ifdef __FreeBSD__ + static int + pflog_modevent(module_t mod, int type, void *data) + { + int error = 0; + + switch (type) { + case MOD_LOAD: + pflogattach(1); + PF_LOCK(); + pflog_packet_ptr = pflog_packet; + PF_UNLOCK(); + break; + case MOD_UNLOAD: + PF_LOCK(); + pflog_packet_ptr = NULL; + PF_UNLOCK(); + if_clone_detach(&pflog_cloner); + break; + default: + error = EINVAL; + break; + } + + return error; + } + + static moduledata_t pflog_mod = { "pflog", pflog_modevent, 0 }; + + #define PFLOG_MODVER 1 + + DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); + MODULE_VERSION(pflog, PFLOG_MODVER); + MODULE_DEPEND(pflog, pf, PF_MODVER, PF_MODVER, PF_MODVER); + #endif /* __FreeBSD__ */ Modified: user/eri/net/if_pflog.h ============================================================================== --- user/eri/net/if_pflog.h Thu Oct 8 18:44:15 2009 (r197865) +++ user/eri/net/if_pflog.h Thu Oct 8 18:55:12 2009 (r197866) @@ -30,7 +30,11 @@ #define PFLOGIFS_MAX 16 struct pflog_softc { +#ifdef __FreeBSD__ + struct ifnet *sc_ifp; /* the interface pointer */ +#else struct ifnet sc_if; /* the interface */ +#endif int sc_unit; LIST_ENTRY(pflog_softc) sc_list; }; @@ -70,11 +74,26 @@ struct old_pfloghdr { #define OLD_PFLOG_HDRLEN sizeof(struct old_pfloghdr) #ifdef _KERNEL - +#ifdef __FreeBSD__ + struct pf_rule; + struct pf_ruleset; + struct pfi_kif; + struct pf_pdesc; + + typedef int pflog_packet_t(struct pfi_kif *, struct mbuf *, sa_family_t, + u_int8_t, u_int8_t, struct pf_rule *, struct pf_rule *, + struct pf_ruleset *, struct pf_pdesc *); + extern pflog_packet_t *pflog_packet_ptr; +#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) do { \ + if (pflog_packet_ptr != NULL) \ + pflog_packet_ptr(i,a,b,c,d,e,f,g,h); \ + } while (0) +#else /* ! __FreeBSD__ */ #if NPFLOG > 0 #define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) pflog_packet(i,a,b,c,d,e,f,g,h) #else #define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) ((void)0) #endif /* NPFLOG > 0 */ +#endif #endif /* _KERNEL */ #endif /* _NET_IF_PFLOG_H_ */ Modified: user/eri/net/pf.c ============================================================================== --- user/eri/net/pf.c Thu Oct 8 18:44:15 2009 (r197865) +++ user/eri/net/pf.c Thu Oct 8 18:55:12 2009 (r197866) @@ -35,10 +35,46 @@ * */ + #ifdef __FreeBSD__ + #include "opt_inet.h" + #include "opt_inet6.h" + + #include +__FBSDID("$FreeBSD$"); + #endif + + #ifdef __FreeBSD__ + #include "opt_bpf.h" + #include "opt_pf.h" + + #ifdef DEV_BPF + #define NBPFILTER DEV_BPF + #else + #define NBPFILTER 0 + #endif + + #ifdef DEV_PFLOG + #define NPFLOG DEV_PFLOG + #else + #define NPFLOG 0 + #endif + + #ifdef DEV_PFSYNC + #define NPFSYNC DEV_PFSYNC + #else + #define NPFSYNC 0 + #endif + + /* XXX */ + #define NPFLOW 0 + #else #include "bpfilter.h" #include "pflog.h" #include "pfsync.h" +#endif +#ifdef notyet #include "pflow.h" +#endif #include #include @@ -48,17 +84,40 @@ #include #include #include + #ifdef __FreeBSD__ + #include + #include + #include + #define betoh64 be64toh + #else #include +#endif #include + #ifdef __FreeBSD__ + #include + #include + #include + #else #include +#endif +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include #include #include +#ifdef __FreeBSD__ +#ifdef RADIX_MPATH #include +#endif +#else +#include +#endif #include #include @@ -76,10 +135,14 @@ #include #include +#ifndef __FreeBSD__ #include +#endif #include #include +#ifdef notyet #include +#endif #if NPFSYNC > 0 #include @@ -90,8 +153,21 @@ #include #include #include + #ifdef __FreeBSD__ + #include + #include + #endif #endif /* INET6 */ +#ifdef __FreeBSD__ + #include + #include + #include + #include + + extern int ip_optcopy(struct ip *, struct ip *); + extern int debug_pfugidhack; + #endif #define DPFPRINTF(n, x) if (pf_status.debug >= (n)) printf x @@ -125,9 +201,15 @@ struct pf_anchor_stackframe { struct pf_anchor *child; } pf_anchor_stack[64]; + #ifdef __FreeBSD__ + uma_zone_t pf_src_tree_pl, pf_rule_pl, pf_pooladdr_pl; + uma_zone_t pf_state_pl, pf_state_key_pl, pf_state_item_pl; +uma_zone_t pf_altq_pl; + #else struct pool pf_src_tree_pl, pf_rule_pl, pf_pooladdr_pl; struct pool pf_state_pl, pf_state_key_pl, pf_state_item_pl; struct pool pf_altq_pl; +#endif void pf_init_threshold(struct pf_threshold *, u_int32_t, u_int32_t); @@ -147,7 +229,12 @@ void pf_change_icmp(struct pf_addr *, struct pf_addr *, struct pf_addr *, u_int16_t, u_int16_t *, u_int16_t *, u_int16_t *, u_int16_t *, u_int8_t, sa_family_t); +#ifdef __FreeBSD__ + void pf_send_tcp(struct mbuf *, + const struct pf_rule *, sa_family_t, +#else void pf_send_tcp(const struct pf_rule *, sa_family_t, +#endif const struct pf_addr *, const struct pf_addr *, u_int16_t, u_int16_t, u_int32_t, u_int32_t, u_int8_t, u_int16_t, u_int16_t, u_int8_t, int, @@ -160,7 +247,12 @@ u_int32_t pf_tcp_iss(struct pf_pdesc * int pf_test_rule(struct pf_rule **, struct pf_state **, int, struct pfi_kif *, struct mbuf *, int, void *, struct pf_pdesc *, struct pf_rule **, +#ifdef __FreeBSD__ + struct pf_ruleset **, struct ifqueue *, + struct inpcb *); +#else struct pf_ruleset **, struct ifqueue *); +#endif static __inline int pf_create_state(struct pf_rule *, struct pf_rule *, struct pf_rule *, struct pf_pdesc *, struct pf_src_node *, struct pf_state_key *, @@ -197,7 +289,9 @@ void pf_route(struct mbuf **, struct void pf_route6(struct mbuf **, struct pf_rule *, int, struct ifnet *, struct pf_state *, struct pf_pdesc *); +#ifndef __FreeBSD__ int pf_socket_lookup(int, struct pf_pdesc *); +#endif u_int8_t pf_get_wscale(struct mbuf *, int, u_int16_t, sa_family_t); u_int16_t pf_get_mss(struct mbuf *, int, u_int16_t, @@ -215,11 +309,24 @@ int pf_addr_wrap_neq(struct pf_addr_w struct pf_addr_wrap *); int pf_compare_state_keys(struct pf_state_key *, struct pf_state_key *, struct pfi_kif *, u_int); +#ifdef __FreeBSD__ +struct pf_state *pf_find_state(struct pfi_kif *, + struct pf_state_key_cmp *, u_int, struct mbuf *, + struct pf_mtag *); +#else struct pf_state *pf_find_state(struct pfi_kif *, struct pf_state_key_cmp *, u_int, struct mbuf *); +#endif int pf_src_connlimit(struct pf_state **); int pf_check_congestion(struct ifqueue *); +#ifdef __FreeBSD__ + int in4_cksum(struct mbuf *m, u_int8_t nxt, int off, int len); + + extern int pf_end_threads; + + struct pf_pool_limit pf_pool_limits[PF_LIMIT_MAX]; + #else extern struct pool pfr_ktable_pl; extern struct pool pfr_kentry_pl; @@ -230,10 +337,27 @@ struct pf_pool_limit pf_pool_limits[PF_L { &pfr_ktable_pl, PFR_KTABLE_HIWAT }, { &pfr_kentry_pl, PFR_KENTRY_HIWAT } }; +#endif +#ifdef __FreeBSD__ +#define STATE_LOOKUP(i, k, d, s, m, pt) \ + do { \ + s = pf_find_state(i, k, d, m, pt); \ + if (s == NULL || (s)->timeout == PFTM_PURGE) \ + return (PF_DROP); \ + if (d == PF_OUT && \ + (((s)->rule.ptr->rt == PF_ROUTETO && \ + (s)->rule.ptr->direction == PF_OUT) || \ + ((s)->rule.ptr->rt == PF_REPLYTO && \ + (s)->rule.ptr->direction == PF_IN)) && \ + (s)->rt_kif != NULL && \ + (s)->rt_kif != i) \ + return (PF_PASS); \ + } while (0) +#else #define STATE_LOOKUP(i, k, d, s, m) \ do { \ - s = pf_find_state(i, k, d, m); \ + s = pf_find_state(i, k, d, m); \ if (s == NULL || (s)->timeout == PFTM_PURGE) \ return (PF_DROP); \ if (d == PF_OUT && \ @@ -245,6 +369,7 @@ struct pf_pool_limit pf_pool_limits[PF_L (s)->rt_kif != i) \ return (PF_PASS); \ } while (0) +#endif #define BOUND_IFACE(r, k) \ ((r)->rule_flag & PFRULE_IFBOUND) ? (k) : pfi_all @@ -636,7 +761,11 @@ pf_state_key_attach(struct pf_state_key struct pf_state_key *cur; struct pf_state *olds = NULL; +#ifdef __FreeBSD__ + KASSERT(s->key[idx] == NULL, ("%s: key is null!", __FUNCTION__)); +#else KASSERT(s->key[idx] == NULL); /* XXX handle this? */ +#endif if ((cur = RB_INSERT(pf_state_tree, &pf_statetbl, sk)) != NULL) { /* key exists. check for same kif, if none, add to key */ @@ -728,8 +857,12 @@ pf_state_key_detach(struct pf_state *s, RB_REMOVE(pf_state_tree, &pf_statetbl, s->key[idx]); if (s->key[idx]->reverse) s->key[idx]->reverse->reverse = NULL; +#ifdef __FreeBSD__ + /* XXX: implement this */ +#else if (s->key[idx]->inp) s->key[idx]->inp->inp_pf_sk = NULL; +#endif pool_put(&pf_state_key_pl, s->key[idx]); } s->key[idx] = NULL; @@ -754,7 +887,12 @@ pf_state_key_setup(struct pf_pdesc *pd, struct pf_addr *saddr, struct pf_addr *daddr, u_int16_t sport, u_int16_t dport) { +#ifdef __FreeBSD__ + KASSERT((*skp == NULL && *nkp == NULL), + ("%s: skp == NULL && nkp == NULL", __FUNCTION__)); +#else KASSERT((*skp == NULL && *nkp == NULL)); +#endif if ((*skp = pf_alloc_state_key(PR_NOWAIT | PR_ZERO)) == NULL) return (ENOMEM); @@ -795,7 +933,9 @@ int pf_state_insert(struct pfi_kif *kif, struct pf_state_key *skw, struct pf_state_key *sks, struct pf_state *s) { +#ifndef __FreeBSD__ splassert(IPL_SOFTNET); +#endif s->kif = kif; @@ -878,14 +1018,36 @@ pf_compare_state_keys(struct pf_state_ke } struct pf_state * +#ifdef __FreeBSD__ +pf_find_state(struct pfi_kif *kif, struct pf_state_key_cmp *key, u_int dir, + struct mbuf *m, struct pf_mtag *pftag) +#else pf_find_state(struct pfi_kif *kif, struct pf_state_key_cmp *key, u_int dir, struct mbuf *m) +#endif { struct pf_state_key *sk; struct pf_state_item *si; pf_status.fcounters[FCNT_STATE_SEARCH]++; +#ifdef __FreeBSD__ + if (dir == PF_OUT && pftag->statekey && + ((struct pf_state_key *)pftag->statekey)->reverse) + sk = ((struct pf_state_key *)pftag->statekey)->reverse; + else { + if ((sk = RB_FIND(pf_state_tree, &pf_statetbl, + (struct pf_state_key *)key)) == NULL) + return (NULL); + if (dir == PF_OUT && pftag->statekey && + pf_compare_state_keys(pftag->statekey, sk, + kif, dir) == 0) { + ((struct pf_state_key *) + pftag->statekey)->reverse = sk; + sk->reverse = pftag->statekey; + } + } +#else if (dir == PF_OUT && m->m_pkthdr.pf.statekey && ((struct pf_state_key *)m->m_pkthdr.pf.statekey)->reverse) sk = ((struct pf_state_key *)m->m_pkthdr.pf.statekey)->reverse; @@ -901,9 +1063,14 @@ pf_find_state(struct pfi_kif *kif, struc sk->reverse = m->m_pkthdr.pf.statekey; } } +#endif if (dir == PF_OUT) +#ifdef __FreeBSD__ + pftag->statekey = NULL; +#else m->m_pkthdr.pf.statekey = NULL; +#endif /* list is sorted, if-bound states before floating ones */ TAILQ_FOREACH(si, &sk->states, entry) @@ -949,15 +1116,53 @@ void pf_purge_thread(void *v) { int nloops = 0, s; + #ifdef __FreeBSD__ + int locked; + #endif for (;;) { tsleep(pf_purge_thread, PWAIT, "pftm", 1 * hz); + #ifdef __FreeBSD__ + sx_slock(&pf_consistency_lock); + PF_LOCK(); + locked = 0; + + if (pf_end_threads) { + PF_UNLOCK(); + sx_sunlock(&pf_consistency_lock); + sx_xlock(&pf_consistency_lock); + PF_LOCK(); + pf_purge_expired_states(pf_status.states, 1); + pf_purge_expired_fragments(); + pf_purge_expired_src_nodes(1); + pf_end_threads++; + + sx_xunlock(&pf_consistency_lock); + PF_UNLOCK(); + wakeup(pf_purge_thread); + kproc_exit(0); + } + #endif s = splsoftnet(); /* process a fraction of the state table every second */ + #ifdef __FreeBSD__ + if(!pf_purge_expired_states(1 + (pf_status.states + / pf_default_rule.timeout[PFTM_INTERVAL]), 0)) { + PF_UNLOCK(); + sx_sunlock(&pf_consistency_lock); + sx_xlock(&pf_consistency_lock); + PF_LOCK(); + locked = 1; + + pf_purge_expired_states(1 + (pf_status.states + / pf_default_rule.timeout[PFTM_INTERVAL]), 1); + } + #else pf_purge_expired_states(1 + (pf_status.states / pf_default_rule.timeout[PFTM_INTERVAL])); +#endif /* purge other expired types every PFTM_INTERVAL seconds */ if (++nloops >= pf_default_rule.timeout[PFTM_INTERVAL]) { @@ -967,6 +1172,13 @@ pf_purge_thread(void *v) } splx(s); + #ifdef __FreeBSD__ + PF_UNLOCK(); + if (locked) + sx_xunlock(&pf_consistency_lock); + else + sx_sunlock(&pf_consistency_lock); + #endif } } @@ -983,8 +1195,15 @@ pf_state_expires(const struct pf_state * return (time_second); if (state->timeout == PFTM_UNTIL_PACKET) return (0); + #ifdef __FreeBSD__ + KASSERT(state->timeout != PFTM_UNLINKED, + ("pf_state_expires: timeout == PFTM_UNLINKED")); + KASSERT((state->timeout < PFTM_MAX), + ("pf_state_expires: timeout > PFTM_MAX")); + #else KASSERT(state->timeout != PFTM_UNLINKED); KASSERT(state->timeout < PFTM_MAX); +#endif timeout = state->rule.ptr->timeout[state->timeout]; if (!timeout) timeout = pf_default_rule.timeout[state->timeout]; @@ -1007,8 +1226,13 @@ pf_state_expires(const struct pf_state * return (state->expire + timeout); } + #ifdef __FreeBSD__ + int + pf_purge_expired_src_nodes(int waslocked) + #else void pf_purge_expired_src_nodes(int waslocked) +#endif { struct pf_src_node *cur, *next; int locked = waslocked; @@ -1018,7 +1242,12 @@ pf_purge_expired_src_nodes(int waslocked if (cur->states <= 0 && cur->expire <= time_second) { if (! locked) { + #ifdef __FreeBSD__ + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); + #else rw_enter_write(&pf_consistency_lock); +#endif next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur); locked = 1; @@ -1037,7 +1266,14 @@ pf_purge_expired_src_nodes(int waslocked } if (locked && !waslocked) +#ifdef __FreeBSD__ + { + sx_downgrade(&pf_consistency_lock); + } + return (1); +#else rw_exit_write(&pf_consistency_lock); +#endif } void @@ -1072,11 +1308,21 @@ pf_src_tree_remove_state(struct pf_state void pf_unlink_state(struct pf_state *cur) { + #ifdef __FreeBSD__ + if (cur->local_flags & PFSTATE_EXPIRING) + return; + cur->local_flags |= PFSTATE_EXPIRING; +#else splassert(IPL_SOFTNET); + #endif if (cur->src.state == PF_TCPS_PROXY_DST) { /* XXX wire key the right one? */ + #ifdef __FreeBSD__ + pf_send_tcp(NULL, cur->rule.ptr, cur->key[PF_SK_WIRE]->af, + #else pf_send_tcp(cur->rule.ptr, cur->key[PF_SK_WIRE]->af, +#endif &cur->key[PF_SK_WIRE]->addr[1], &cur->key[PF_SK_WIRE]->addr[0], cur->key[PF_SK_WIRE]->port[1], @@ -1102,13 +1348,20 @@ pf_unlink_state(struct pf_state *cur) void pf_free_state(struct pf_state *cur) { +#ifndef __FreeBSD__ splassert(IPL_SOFTNET); +#endif #if NPFSYNC > 0 if (pfsync_state_in_use(cur)) return; #endif + #ifdef __FreeBSD__ + KASSERT(cur->timeout == PFTM_UNLINKED, + ("pf_free_state: cur->timeout != PFTM_UNLINKED")); + #else KASSERT(cur->timeout == PFTM_UNLINKED); +#endif if (--cur->rule.ptr->states_cur <= 0 && cur->rule.ptr->src_nodes <= 0) pf_rm_rule(NULL, cur->rule.ptr); @@ -1129,12 +1382,21 @@ pf_free_state(struct pf_state *cur) pf_status.states--; } + #ifdef __FreeBSD__ + int + pf_purge_expired_states(u_int32_t maxcheck, int waslocked) + #else void pf_purge_expired_states(u_int32_t maxcheck) +#endif { static struct pf_state *cur = NULL; struct pf_state *next; + #ifdef __FreeBSD__ + int locked = waslocked; + #else int locked = 0; +#endif while (maxcheck--) { /* wrap to start of list when we hit the end */ @@ -1150,7 +1412,12 @@ pf_purge_expired_states(u_int32_t maxche if (cur->timeout == PFTM_UNLINKED) { /* free unlinked state */ if (! locked) { + #ifdef __FreeBSD__ + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); + #else rw_enter_write(&pf_consistency_lock); +#endif locked = 1; } pf_free_state(cur); @@ -1158,7 +1425,12 @@ pf_purge_expired_states(u_int32_t maxche /* unlink and free expired state */ pf_unlink_state(cur); if (! locked) { + #ifdef __FreeBSD__ + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); + #else rw_enter_write(&pf_consistency_lock); +#endif locked = 1; } pf_free_state(cur); @@ -1166,8 +1438,15 @@ pf_purge_expired_states(u_int32_t maxche cur = next; } + #ifdef __FreeBSD__ + if (!waslocked && locked) + sx_downgrade(&pf_consistency_lock); + + return (1); + #else if (locked) rw_exit_write(&pf_consistency_lock); +#endif } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 21:10:58 2009 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 C25A21065679; Thu, 8 Oct 2009 21:10:58 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 99E848FC1B; Thu, 8 Oct 2009 21:10:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98LAwHf033173; Thu, 8 Oct 2009 21:10:58 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98LAwv7033172; Thu, 8 Oct 2009 21:10:58 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082110.n98LAwv7033172@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 21:10:58 +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: r197870 - user/eri/pf45 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, 08 Oct 2009 21:10:58 -0000 Author: eri Date: Thu Oct 8 21:10:58 2009 New Revision: 197870 URL: http://svn.freebsd.org/changeset/base/197870 Log: Create a dir to better follow guidelines and facilitate contributers on this code. Added: user/eri/pf45/ From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 21:14:17 2009 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 8BC1C1065670; Thu, 8 Oct 2009 21:14:17 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2D65E8FC14; Thu, 8 Oct 2009 21:14:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98LEHni033313; Thu, 8 Oct 2009 21:14:17 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98LEH1Z033312; Thu, 8 Oct 2009 21:14:17 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082114.n98LEH1Z033312@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 21:14:17 +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: r197871 - user/eri/pf45/head 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, 08 Oct 2009 21:14:17 -0000 Author: eri Date: Thu Oct 8 21:14:16 2009 New Revision: 197871 URL: http://svn.freebsd.org/changeset/base/197871 Log: Populate workspace with code from head. Added: user/eri/pf45/head/ (props changed) - copied from r197870, head/ From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 22:31:20 2009 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 3826F1065672; Thu, 8 Oct 2009 22:31:20 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 261978FC08; Thu, 8 Oct 2009 22:31:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98MVKZC035445; Thu, 8 Oct 2009 22:31:20 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98MVKta035440; Thu, 8 Oct 2009 22:31:20 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082231.n98MVKta035440@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 22:31: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: r197883 - in user/eri/pf45/head/sys/contrib/pf: net netinet 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, 08 Oct 2009 22:31:20 -0000 Author: eri Date: Thu Oct 8 22:31:19 2009 New Revision: 197883 URL: http://svn.freebsd.org/changeset/base/197883 Log: Import manually the vendor-sys part of pf(4). Added: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c (contents, props changed) user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h (contents, props changed) user/eri/pf45/head/sys/contrib/pf/net/pf_lb.c (contents, props changed) Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.h user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_if.c user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pf_norm.c user/eri/pf45/head/sys/contrib/pf/net/pf_osfp.c user/eri/pf45/head/sys/contrib/pf/net/pf_ruleset.c user/eri/pf45/head/sys/contrib/pf/net/pf_table.c user/eri/pf45/head/sys/contrib/pf/net/pfvar.h user/eri/pf45/head/sys/contrib/pf/netinet/in4_cksum.c Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c Thu Oct 8 22:26:31 2009 (r197882) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c Thu Oct 8 22:31:19 2009 (r197883) @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflog.c,v 1.22 2006/12/15 09:31:20 otto Exp $ */ +/* $OpenBSD: if_pflog.c,v 1.26 2007/10/18 21:58:18 mpf Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -33,51 +33,17 @@ * PURPOSE. */ -#ifdef __FreeBSD__ -#include "opt_inet.h" -#include "opt_inet6.h" -#include "opt_bpf.h" -#include "opt_pf.h" - -#include -__FBSDID("$FreeBSD$"); - -#ifdef DEV_BPF -#define NBPFILTER DEV_BPF -#else -#define NBPFILTER 0 -#endif - -#ifdef DEV_PFLOG -#define NPFLOG DEV_PFLOG -#else -#define NPFLOG 0 -#endif - -#else /* ! __FreeBSD__ */ #include "bpfilter.h" #include "pflog.h" -#endif /* __FreeBSD__ */ #include #include #include #include #include -#ifdef __FreeBSD__ -#include -#include -#include -#include -#include -#else #include -#endif #include -#ifdef __FreeBSD__ -#include -#endif #include #include #include @@ -99,12 +65,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef INET -#ifdef __FreeBSD__ -#include -#endif -#endif - #define PFLOGMTU (32768 + MHLEN + MLEN) #ifdef PFLOGDEBUG @@ -115,31 +75,18 @@ __FBSDID("$FreeBSD$"); void pflogattach(int); int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct route *); + struct rtentry *); int pflogioctl(struct ifnet *, u_long, caddr_t); void pflogstart(struct ifnet *); -#ifdef __FreeBSD__ -static int pflog_clone_create(struct if_clone *, int, caddr_t); -static void pflog_clone_destroy(struct ifnet *); -#else int pflog_clone_create(struct if_clone *, int); int pflog_clone_destroy(struct ifnet *); -#endif LIST_HEAD(, pflog_softc) pflogif_list; -#ifdef __FreeBSD__ -IFC_SIMPLE_DECLARE(pflog, 1); -#else struct if_clone pflog_cloner = IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy); -#endif struct ifnet *pflogifs[PFLOGIFS_MAX]; /* for fast access */ -#ifndef __FreeBSD__ -extern int ifqmaxlen; -#endif - void pflogattach(int npflog) { @@ -147,19 +94,11 @@ pflogattach(int npflog) LIST_INIT(&pflogif_list); for (i = 0; i < PFLOGIFS_MAX; i++) pflogifs[i] = NULL; -#ifndef __FreeBSD__ - (void) pflog_clone_create(&pflog_cloner, 0); -#endif if_clone_attach(&pflog_cloner); } -#ifdef __FreeBSD__ -static int -pflog_clone_create(struct if_clone *ifc, int unit, caddr_t param) -#else int pflog_clone_create(struct if_clone *ifc, int unit) -#endif { struct ifnet *ifp; struct pflog_softc *pflogif; @@ -168,92 +107,53 @@ pflog_clone_create(struct if_clone *ifc, if (unit >= PFLOGIFS_MAX) return (EINVAL); - if ((pflogif = malloc(sizeof(*pflogif), M_DEVBUF, M_NOWAIT)) == NULL) + if ((pflogif = malloc(sizeof(*pflogif), + M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) return (ENOMEM); - bzero(pflogif, sizeof(*pflogif)); pflogif->sc_unit = unit; -#ifdef __FreeBSD__ - ifp = pflogif->sc_ifp = if_alloc(IFT_PFLOG); - if (ifp == NULL) { - free(pflogif, M_DEVBUF); - return (ENOSPC); - } - if_initname(ifp, ifc->ifc_name, unit); -#else ifp = &pflogif->sc_if; snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", unit); -#endif ifp->if_softc = pflogif; ifp->if_mtu = PFLOGMTU; ifp->if_ioctl = pflogioctl; ifp->if_output = pflogoutput; ifp->if_start = pflogstart; -#ifndef __FreeBSD__ ifp->if_type = IFT_PFLOG; -#endif ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); -#ifndef __FreeBSD__ if_alloc_sadl(ifp); -#endif #if NBPFILTER > 0 -#ifdef __FreeBSD__ - bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN); -#else bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); #endif -#endif s = splnet(); -#ifdef __FreeBSD__ - PF_LOCK(); -#endif LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list); pflogifs[unit] = ifp; -#ifdef __FreeBSD__ - PF_UNLOCK(); -#endif splx(s); return (0); } -#ifdef __FreeBSD__ -static void -pflog_clone_destroy(struct ifnet *ifp) -#else int pflog_clone_destroy(struct ifnet *ifp) -#endif { struct pflog_softc *pflogif = ifp->if_softc; int s; s = splnet(); -#ifdef __FreeBSD__ - PF_LOCK(); -#endif pflogifs[pflogif->sc_unit] = NULL; LIST_REMOVE(pflogif, sc_list); -#ifdef __FreeBSD__ - PF_UNLOCK(); -#endif splx(s); #if NBPFILTER > 0 bpfdetach(ifp); #endif if_detach(ifp); -#ifdef __FreeBSD__ - if_free(ifp); -#endif free(pflogif, M_DEVBUF); -#ifndef __FreeBSD__ return (0); -#endif } /* @@ -263,22 +163,13 @@ void pflogstart(struct ifnet *ifp) { struct mbuf *m; -#ifndef __FreeBSD__ int s; -#endif for (;;) { -#ifdef __FreeBSD__ - IF_LOCK(&ifp->if_snd); - _IF_DROP(&ifp->if_snd); - _IF_DEQUEUE(&ifp->if_snd, m); - IF_UNLOCK(&ifp->if_snd); -#else s = splnet(); IF_DROP(&ifp->if_snd); IF_DEQUEUE(&ifp->if_snd, m); splx(s); -#endif if (m == NULL) return; @@ -289,7 +180,7 @@ pflogstart(struct ifnet *ifp) int pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct route *ro) + struct rtentry *rt) { m_freem(m); return (0); @@ -300,24 +191,14 @@ int pflogioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { switch (cmd) { - case SIOCSIFADDR: - case SIOCAIFADDR: - case SIOCSIFDSTADDR: case SIOCSIFFLAGS: -#ifdef __FreeBSD__ - if (ifp->if_flags & IFF_UP) - ifp->if_drv_flags |= IFF_DRV_RUNNING; - else - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; -#else if (ifp->if_flags & IFF_UP) ifp->if_flags |= IFF_RUNNING; else ifp->if_flags &= ~IFF_RUNNING; -#endif break; default: - return (EINVAL); + return (ENOTTY); } return (0); @@ -356,15 +237,7 @@ pflog_packet(struct pfi_kif *kif, struct sizeof(hdr.ruleset)); } if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done) -#ifdef __FreeBSD__ - /* - * XXX: This should not happen as we force an early lookup - * via debug.pfugidhack - */ - ; /* empty */ -#else pd->lookup.done = pf_socket_lookup(dir, pd); -#endif if (pd->lookup.done > 0) { hdr.uid = pd->lookup.uid; hdr.pid = pd->lookup.pid; @@ -388,49 +261,9 @@ pflog_packet(struct pfi_kif *kif, struct ifn->if_opackets++; ifn->if_obytes += m->m_pkthdr.len; -#ifdef __FreeBSD__ - BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m); -#else bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, BPF_DIRECTION_OUT); #endif -#endif return (0); } - -#ifdef __FreeBSD__ -static int -pflog_modevent(module_t mod, int type, void *data) -{ - int error = 0; - - switch (type) { - case MOD_LOAD: - pflogattach(1); - PF_LOCK(); - pflog_packet_ptr = pflog_packet; - PF_UNLOCK(); - break; - case MOD_UNLOAD: - PF_LOCK(); - pflog_packet_ptr = NULL; - PF_UNLOCK(); - if_clone_detach(&pflog_cloner); - break; - default: - error = EINVAL; - break; - } - - return error; -} - -static moduledata_t pflog_mod = { "pflog", pflog_modevent, 0 }; - -#define PFLOG_MODVER 1 - -DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); -MODULE_VERSION(pflog, PFLOG_MODVER); -MODULE_DEPEND(pflog, pf, PF_MODVER, PF_MODVER, PF_MODVER); -#endif /* __FreeBSD__ */ Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h Thu Oct 8 22:26:31 2009 (r197882) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h Thu Oct 8 22:31:19 2009 (r197883) @@ -1,5 +1,4 @@ -/* $FreeBSD$ */ -/* $OpenBSD: if_pflog.h,v 1.14 2006/10/25 11:27:01 henning Exp $ */ +/* $OpenBSD: if_pflog.h,v 1.13 2006/10/23 12:46:09 henning Exp $ */ /* * Copyright 2001 Niels Provos * All rights reserved. @@ -30,17 +29,11 @@ #define PFLOGIFS_MAX 16 -#ifdef _KERNEL struct pflog_softc { -#ifdef __FreeBSD__ - struct ifnet *sc_ifp; /* the interface pointer */ -#else struct ifnet sc_if; /* the interface */ -#endif int sc_unit; LIST_ENTRY(pflog_softc) sc_list; }; -#endif /* _KERNEL */ #define PFLOG_RULESET_NAME_SIZE 16 @@ -78,26 +71,10 @@ struct old_pfloghdr { #ifdef _KERNEL -#ifdef __FreeBSD__ -struct pf_rule; -struct pf_ruleset; -struct pfi_kif; -struct pf_pdesc; - -typedef int pflog_packet_t(struct pfi_kif *, struct mbuf *, sa_family_t, - u_int8_t, u_int8_t, struct pf_rule *, struct pf_rule *, - struct pf_ruleset *, struct pf_pdesc *); -extern pflog_packet_t *pflog_packet_ptr; -#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) do { \ - if (pflog_packet_ptr != NULL) \ - pflog_packet_ptr(i,a,b,c,d,e,f,g,h); \ -} while (0) -#else /* ! __FreeBSD__ */ #if NPFLOG > 0 #define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) pflog_packet(i,a,b,c,d,e,f,g,h) #else #define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) ((void)0) #endif /* NPFLOG > 0 */ -#endif /* __FreeBSD__ */ #endif /* _KERNEL */ #endif /* _NET_IF_PFLOG_H_ */ Added: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c Thu Oct 8 22:31:19 2009 (r197883) @@ -0,0 +1,621 @@ +/* $OpenBSD: if_pflow.c,v 1.9 2009/01/03 21:47:32 gollo Exp $ */ + +/* + * Copyright (c) 2008 Henning Brauer + * Copyright (c) 2008 Joerg Goltermann + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef INET +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* INET */ + +#include +#include + +#include "bpfilter.h" +#include "pflow.h" + +#define PFLOW_MINMTU \ + (sizeof(struct pflow_header) + sizeof(struct pflow_flow)) + +#ifdef PFLOWDEBUG +#define DPRINTF(x) do { printf x ; } while (0) +#else +#define DPRINTF(x) +#endif + +SLIST_HEAD(, pflow_softc) pflowif_list; +struct pflowstats pflowstats; + +void pflowattach(int); +int pflow_clone_create(struct if_clone *, int); +int pflow_clone_destroy(struct ifnet *); +void pflow_setmtu(struct pflow_softc *, int); +int pflowoutput(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); +int pflowioctl(struct ifnet *, u_long, caddr_t); +void pflowstart(struct ifnet *); + +struct mbuf *pflow_get_mbuf(struct pflow_softc *); +int pflow_sendout(struct pflow_softc *); +int pflow_sendout_mbuf(struct pflow_softc *, struct mbuf *); +void pflow_timeout(void *); +void copy_flow_data(struct pflow_flow *, struct pflow_flow *, + struct pf_state *, int, int); +int pflow_pack_flow(struct pf_state *, struct pflow_softc *); +int pflow_get_dynport(void); +int export_pflow_if(struct pf_state*, struct pflow_softc *); +int copy_flow_to_m(struct pflow_flow *flow, struct pflow_softc *sc); + +struct if_clone pflow_cloner = + IF_CLONE_INITIALIZER("pflow", pflow_clone_create, + pflow_clone_destroy); + +/* from in_pcb.c */ +extern int ipport_hifirstauto; +extern int ipport_hilastauto; + +/* from kern/kern_clock.c; incremented each clock tick. */ +extern int ticks; + +void +pflowattach(int npflow) +{ + SLIST_INIT(&pflowif_list); + if_clone_attach(&pflow_cloner); +} + +int +pflow_clone_create(struct if_clone *ifc, int unit) +{ + struct ifnet *ifp; + struct pflow_softc *pflowif; + + if ((pflowif = malloc(sizeof(*pflowif), + M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) + return (ENOMEM); + + pflowif->sc_sender_ip.s_addr = INADDR_ANY; + pflowif->sc_sender_port = pflow_get_dynport(); + + pflowif->sc_imo.imo_membership = malloc( + (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS, + M_WAITOK|M_ZERO); + pflowif->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; + pflowif->sc_receiver_ip.s_addr = 0; + pflowif->sc_receiver_port = 0; + pflowif->sc_sender_ip.s_addr = INADDR_ANY; + pflowif->sc_sender_port = pflow_get_dynport(); + ifp = &pflowif->sc_if; + snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflow%d", unit); + ifp->if_softc = pflowif; + ifp->if_ioctl = pflowioctl; + ifp->if_output = pflowoutput; + ifp->if_start = pflowstart; + ifp->if_type = IFT_PFLOW; + ifp->if_snd.ifq_maxlen = ifqmaxlen; + ifp->if_hdrlen = PFLOW_HDRLEN; + ifp->if_flags = IFF_UP; + ifp->if_flags &= ~IFF_RUNNING; /* not running, need receiver */ + pflow_setmtu(pflowif, ETHERMTU); + timeout_set(&pflowif->sc_tmo, pflow_timeout, pflowif); + if_attach(ifp); + if_alloc_sadl(ifp); + +#if NBPFILTER > 0 + bpfattach(&pflowif->sc_if.if_bpf, ifp, DLT_RAW, 0); +#endif + + /* Insert into list of pflows */ + SLIST_INSERT_HEAD(&pflowif_list, pflowif, sc_next); + return (0); +} + +int +pflow_clone_destroy(struct ifnet *ifp) +{ + struct pflow_softc *sc = ifp->if_softc; + int s; + + s = splnet(); + pflow_sendout(sc); +#if NBPFILTER > 0 + bpfdetach(ifp); +#endif + if_detach(ifp); + SLIST_REMOVE(&pflowif_list, sc, pflow_softc, sc_next); + free(sc->sc_imo.imo_membership, M_IPMOPTS); + free(sc, M_DEVBUF); + splx(s); + return (0); +} + +/* + * Start output on the pflow interface. + */ +void +pflowstart(struct ifnet *ifp) +{ + struct mbuf *m; + int s; + + for (;;) { + s = splnet(); + IF_DROP(&ifp->if_snd); + IF_DEQUEUE(&ifp->if_snd, m); + splx(s); + + if (m == NULL) + return; + m_freem(m); + } +} + +int +pflowoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, + struct rtentry *rt) +{ + m_freem(m); + return (0); +} + +/* ARGSUSED */ +int +pflowioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + struct proc *p = curproc; + struct pflow_softc *sc = ifp->if_softc; + struct ifreq *ifr = (struct ifreq *)data; + struct pflowreq pflowr; + int s, error; + + switch (cmd) { + case SIOCSIFADDR: + case SIOCAIFADDR: + case SIOCSIFDSTADDR: + case SIOCSIFFLAGS: + if ((ifp->if_flags & IFF_UP) && + sc->sc_receiver_ip.s_addr != 0 && + sc->sc_receiver_port != 0) { + ifp->if_flags |= IFF_RUNNING; + sc->sc_gcounter=pflowstats.pflow_flows; + } else + ifp->if_flags &= ~IFF_RUNNING; + break; + case SIOCSIFMTU: + if (ifr->ifr_mtu < PFLOW_MINMTU) + return (EINVAL); + if (ifr->ifr_mtu > MCLBYTES) + ifr->ifr_mtu = MCLBYTES; + s = splnet(); + if (ifr->ifr_mtu < ifp->if_mtu) + pflow_sendout(sc); + pflow_setmtu(sc, ifr->ifr_mtu); + splx(s); + break; + + case SIOCGETPFLOW: + bzero(&pflowr, sizeof(pflowr)); + + pflowr.sender_ip = sc->sc_sender_ip; + pflowr.receiver_ip = sc->sc_receiver_ip; + pflowr.receiver_port = sc->sc_receiver_port; + + if ((error = copyout(&pflowr, ifr->ifr_data, + sizeof(pflowr)))) + return (error); + break; + + case SIOCSETPFLOW: + if ((error = suser(p, p->p_acflag)) != 0) + return (error); + if ((error = copyin(ifr->ifr_data, &pflowr, + sizeof(pflowr)))) + return (error); + + s = splnet(); + pflow_sendout(sc); + splx(s); + + if (pflowr.addrmask & PFLOW_MASK_DSTIP) + sc->sc_receiver_ip = pflowr.receiver_ip; + if (pflowr.addrmask & PFLOW_MASK_DSTPRT) + sc->sc_receiver_port = pflowr.receiver_port; + if (pflowr.addrmask & PFLOW_MASK_SRCIP) + sc->sc_sender_ip.s_addr = pflowr.sender_ip.s_addr; + + if ((ifp->if_flags & IFF_UP) && + sc->sc_receiver_ip.s_addr != 0 && + sc->sc_receiver_port != 0) { + ifp->if_flags |= IFF_RUNNING; + sc->sc_gcounter=pflowstats.pflow_flows; + } else + ifp->if_flags &= ~IFF_RUNNING; + + break; + + default: + return (ENOTTY); + } + return (0); +} + +void +pflow_setmtu(struct pflow_softc *sc, int mtu_req) +{ + int mtu; + + if (sc->sc_pflow_ifp && sc->sc_pflow_ifp->if_mtu < mtu_req) + mtu = sc->sc_pflow_ifp->if_mtu; + else + mtu = mtu_req; + + sc->sc_maxcount = (mtu - sizeof(struct pflow_header) - + sizeof (struct udpiphdr)) / sizeof(struct pflow_flow); + if (sc->sc_maxcount > PFLOW_MAXFLOWS) + sc->sc_maxcount = PFLOW_MAXFLOWS; + sc->sc_if.if_mtu = sizeof(struct pflow_header) + + sizeof (struct udpiphdr) + + sc->sc_maxcount * sizeof(struct pflow_flow); +} + +struct mbuf * +pflow_get_mbuf(struct pflow_softc *sc) +{ + struct pflow_header h; + struct mbuf *m; + + MGETHDR(m, M_DONTWAIT, MT_DATA); + if (m == NULL) { + pflowstats.pflow_onomem++; + return (NULL); + } + + MCLGET(m, M_DONTWAIT); + if ((m->m_flags & M_EXT) == 0) { + m_free(m); + pflowstats.pflow_onomem++; + return (NULL); + } + + m->m_len = m->m_pkthdr.len = 0; + m->m_pkthdr.rcvif = NULL; + + /* populate pflow_header */ + h.reserved1 = 0; + h.reserved2 = 0; + h.count = 0; + h.version = htons(PFLOW_VERSION); + h.flow_sequence = htonl(sc->sc_gcounter); + h.engine_type = PFLOW_ENGINE_TYPE; + h.engine_id = PFLOW_ENGINE_ID; + m_copyback(m, 0, PFLOW_HDRLEN, &h); + + sc->sc_count = 0; + timeout_add_sec(&sc->sc_tmo, PFLOW_TIMEOUT); + return (m); +} + +void +copy_flow_data(struct pflow_flow *flow1, struct pflow_flow *flow2, + struct pf_state *st, int src, int dst) +{ + struct pf_state_key *sk = st->key[PF_SK_WIRE]; + + flow1->src_ip = flow2->dest_ip = sk->addr[src].v4.s_addr; + flow1->src_port = flow2->dest_port = sk->port[src]; + flow1->dest_ip = flow2->src_ip = sk->addr[dst].v4.s_addr; + flow1->dest_port = flow2->src_port = sk->port[dst]; + + flow1->dest_as = flow2->src_as = + flow1->src_as = flow2->dest_as = 0; + flow1->if_index_out = flow2->if_index_in = + flow1->if_index_in = flow2->if_index_out = 0; + flow1->dest_mask = flow2->src_mask = + flow1->src_mask = flow2->dest_mask = 0; + + flow1->flow_packets = htonl(st->packets[0]); + flow2->flow_packets = htonl(st->packets[1]); + flow1->flow_octets = htonl(st->bytes[0]); + flow2->flow_octets = htonl(st->bytes[1]); + + flow1->flow_start = flow2->flow_start = htonl(st->creation * 1000); + flow1->flow_finish = flow2->flow_finish = htonl(time_second * 1000); + flow1->tcp_flags = flow2->tcp_flags = 0; + flow1->protocol = flow2->protocol = sk->proto; + flow1->tos = flow2->tos = st->rule.ptr->tos; +} + +int +export_pflow(struct pf_state *st) +{ + struct pflow_softc *sc = NULL; + struct pf_state_key *sk = st->key[PF_SK_WIRE]; + + if (sk->af != AF_INET) + return (0); + + SLIST_FOREACH(sc, &pflowif_list, sc_next) { + export_pflow_if(st, sc); + } + + return (0); +} + +int +export_pflow_if(struct pf_state *st, struct pflow_softc *sc) +{ + struct pf_state pfs_copy; + struct ifnet *ifp = &sc->sc_if; + u_int64_t bytes[2]; + int ret = 0; + + if (!(ifp->if_flags & IFF_RUNNING)) + return (0); + + if ((st->bytes[0] < (u_int64_t)PFLOW_MAXBYTES) + && (st->bytes[1] < (u_int64_t)PFLOW_MAXBYTES)) + return (pflow_pack_flow(st, sc)); + + /* flow > PFLOW_MAXBYTES need special handling */ + bcopy(st, &pfs_copy, sizeof(pfs_copy)); + bytes[0] = pfs_copy.bytes[0]; + bytes[1] = pfs_copy.bytes[1]; + + while (bytes[0] > PFLOW_MAXBYTES) { + pfs_copy.bytes[0] = PFLOW_MAXBYTES; + pfs_copy.bytes[1] = 0; + + if ((ret = pflow_pack_flow(&pfs_copy, sc)) != 0) + return (ret); + if ((bytes[0] - PFLOW_MAXBYTES) > 0) + bytes[0] -= PFLOW_MAXBYTES; + } + + while (bytes[1] > (u_int64_t)PFLOW_MAXBYTES) { + pfs_copy.bytes[1] = PFLOW_MAXBYTES; + pfs_copy.bytes[0] = 0; + + if ((ret = pflow_pack_flow(&pfs_copy, sc)) != 0) + return (ret); + if ((bytes[1] - PFLOW_MAXBYTES) > 0) + bytes[1] -= PFLOW_MAXBYTES; + } + + pfs_copy.bytes[0] = bytes[0]; + pfs_copy.bytes[1] = bytes[1]; + + return (pflow_pack_flow(&pfs_copy, sc)); +} + +int +copy_flow_to_m(struct pflow_flow *flow, struct pflow_softc *sc) +{ + int s, ret = 0; + + s = splnet(); + if (sc->sc_mbuf == NULL) { + if ((sc->sc_mbuf = pflow_get_mbuf(sc)) == NULL) { + splx(s); + return (ENOBUFS); + } + } + m_copyback(sc->sc_mbuf, PFLOW_HDRLEN + + (sc->sc_count * sizeof (struct pflow_flow)), + sizeof (struct pflow_flow), flow); + + if (pflowstats.pflow_flows == sc->sc_gcounter) + pflowstats.pflow_flows++; + sc->sc_gcounter++; + sc->sc_count++; + + if (sc->sc_count >= sc->sc_maxcount) + ret = pflow_sendout(sc); + + splx(s); + return(ret); +} + +int +pflow_pack_flow(struct pf_state *st, struct pflow_softc *sc) +{ + struct pflow_flow flow1; + struct pflow_flow flow2; + int ret = 0; + + bzero(&flow1, sizeof(flow1)); + bzero(&flow2, sizeof(flow2)); + + if (st->direction == PF_OUT) + copy_flow_data(&flow1, &flow2, st, 1, 0); + else + copy_flow_data(&flow1, &flow2, st, 0, 1); + + if (st->bytes[0] != 0) /* first flow from state */ + ret = copy_flow_to_m(&flow1, sc); + + if (st->bytes[1] != 0) /* second flow from state */ + ret = copy_flow_to_m(&flow2, sc); + + return (ret); +} + +void +pflow_timeout(void *v) +{ + struct pflow_softc *sc = v; + int s; + + s = splnet(); + pflow_sendout(sc); + splx(s); +} + +/* This must be called in splnet() */ +int +pflow_sendout(struct pflow_softc *sc) +{ + struct mbuf *m = sc->sc_mbuf; + struct pflow_header *h; + struct ifnet *ifp = &sc->sc_if; + + timeout_del(&sc->sc_tmo); + + if (m == NULL) + return (0); + + sc->sc_mbuf = NULL; + if (!(ifp->if_flags & IFF_RUNNING)) { + m_freem(m); + return (0); + } + + pflowstats.pflow_packets++; + h = mtod(m, struct pflow_header *); + h->count = htons(sc->sc_count); + + /* populate pflow_header */ + h->uptime_ms = htonl(time_uptime * 1000); + h->time_sec = htonl(time_second); + h->time_nanosec = htonl(ticks); + + return (pflow_sendout_mbuf(sc, m)); +} + +int +pflow_sendout_mbuf(struct pflow_softc *sc, struct mbuf *m) +{ + struct udpiphdr *ui; + u_int16_t len = m->m_pkthdr.len; + struct ifnet *ifp = &sc->sc_if; + struct ip *ip; + int err; + + /* UDP Header*/ + M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT); + if (m == NULL) { + pflowstats.pflow_onomem++; + return (ENOBUFS); + } + + ui = mtod(m, struct udpiphdr *); + ui->ui_pr = IPPROTO_UDP; + ui->ui_src = sc->sc_sender_ip; + ui->ui_sport = sc->sc_sender_port; + ui->ui_dst = sc->sc_receiver_ip; + ui->ui_dport = sc->sc_receiver_port; + ui->ui_ulen = htons(sizeof (struct udphdr) + len); + + ip = (struct ip *)ui; + ip->ip_v = IPVERSION; + ip->ip_hl = sizeof(struct ip) >> 2; + ip->ip_id = htons(ip_randomid()); + ip->ip_off = htons(IP_DF); + ip->ip_tos = IPTOS_LOWDELAY; + ip->ip_ttl = IPDEFTTL; + ip->ip_len = htons(sizeof (struct udpiphdr) + len); + + /* + * Compute the pseudo-header checksum; defer further checksumming + * until ip_output() or hardware (if it exists). + */ + m->m_pkthdr.csum_flags |= M_UDPV4_CSUM_OUT; + ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr, + ui->ui_dst.s_addr, htons(len + sizeof(struct udphdr) + + IPPROTO_UDP)); + +#if NBPFILTER > 0 + if (ifp->if_bpf) { + ip->ip_sum = in_cksum(m, ip->ip_hl << 2); + bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); + } +#endif + + sc->sc_if.if_opackets++; + sc->sc_if.if_obytes += m->m_pkthdr.len; + + if ((err = ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL))) { + pflowstats.pflow_oerrors++; + sc->sc_if.if_oerrors++; + } + return (err); +} + +int +pflow_get_dynport(void) +{ + u_int16_t tmp, low, high, cut; + + low = ipport_hifirstauto; /* sysctl */ + high = ipport_hilastauto; + + cut = arc4random_uniform(1 + high - low) + low; + + for (tmp = cut; tmp <= high; ++(tmp)) { + if (!in_baddynamic(tmp, IPPROTO_UDP)) + return (htons(tmp)); + } + + for (tmp = cut - 1; tmp >= low; --(tmp)) { + if (!in_baddynamic(tmp, IPPROTO_UDP)) + return (htons(tmp)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 22:33:19 2009 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 C8968106566B; Thu, 8 Oct 2009 22:33:19 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B5B778FC08; Thu, 8 Oct 2009 22:33:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98MXJVJ035542; Thu, 8 Oct 2009 22:33:19 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98MXJK6035533; Thu, 8 Oct 2009 22:33:19 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082233.n98MXJK6035533@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 22:33:19 +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: r197884 - in user/eri/pf45/head/contrib/pf: authpf ftp-proxy libevent man pfctl pflogd tftp-proxy 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, 08 Oct 2009 22:33:20 -0000 Author: eri Date: Thu Oct 8 22:33:19 2009 New Revision: 197884 URL: http://svn.freebsd.org/changeset/base/197884 Log: Import manually the vendor part of pf(4). Added: user/eri/pf45/head/contrib/pf/man/pflow.4 (contents, props changed) Modified: user/eri/pf45/head/contrib/pf/authpf/authpf.8 user/eri/pf45/head/contrib/pf/authpf/authpf.c user/eri/pf45/head/contrib/pf/authpf/pathnames.h user/eri/pf45/head/contrib/pf/ftp-proxy/filter.c user/eri/pf45/head/contrib/pf/ftp-proxy/filter.h user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.8 user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.c user/eri/pf45/head/contrib/pf/libevent/buffer.c user/eri/pf45/head/contrib/pf/libevent/evbuffer.c user/eri/pf45/head/contrib/pf/libevent/event-internal.h user/eri/pf45/head/contrib/pf/libevent/event.c user/eri/pf45/head/contrib/pf/libevent/event.h user/eri/pf45/head/contrib/pf/libevent/evsignal.h user/eri/pf45/head/contrib/pf/libevent/kqueue.c user/eri/pf45/head/contrib/pf/libevent/log.c user/eri/pf45/head/contrib/pf/libevent/log.h user/eri/pf45/head/contrib/pf/libevent/poll.c user/eri/pf45/head/contrib/pf/libevent/select.c user/eri/pf45/head/contrib/pf/libevent/signal.c user/eri/pf45/head/contrib/pf/man/pf.4 user/eri/pf45/head/contrib/pf/man/pf.conf.5 user/eri/pf45/head/contrib/pf/man/pf.os.5 user/eri/pf45/head/contrib/pf/man/pflog.4 user/eri/pf45/head/contrib/pf/man/pfsync.4 user/eri/pf45/head/contrib/pf/pfctl/parse.y user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c user/eri/pf45/head/contrib/pf/pfctl/pfctl.8 user/eri/pf45/head/contrib/pf/pfctl/pfctl.c user/eri/pf45/head/contrib/pf/pfctl/pfctl.h user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_optimize.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_osfp.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.h user/eri/pf45/head/contrib/pf/pfctl/pfctl_qstats.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_radix.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_table.c user/eri/pf45/head/contrib/pf/pflogd/pflogd.8 user/eri/pf45/head/contrib/pf/pflogd/pflogd.c user/eri/pf45/head/contrib/pf/pflogd/pflogd.h user/eri/pf45/head/contrib/pf/pflogd/privsep.c user/eri/pf45/head/contrib/pf/pflogd/privsep_fdpass.c user/eri/pf45/head/contrib/pf/tftp-proxy/filter.c user/eri/pf45/head/contrib/pf/tftp-proxy/filter.h user/eri/pf45/head/contrib/pf/tftp-proxy/tftp-proxy.8 user/eri/pf45/head/contrib/pf/tftp-proxy/tftp-proxy.c Modified: user/eri/pf45/head/contrib/pf/authpf/authpf.8 ============================================================================== --- user/eri/pf45/head/contrib/pf/authpf/authpf.8 Thu Oct 8 22:31:19 2009 (r197883) +++ user/eri/pf45/head/contrib/pf/authpf/authpf.8 Thu Oct 8 22:33:19 2009 (r197884) @@ -1,5 +1,4 @@ -.\" $FreeBSD$ -.\" $OpenBSD: authpf.8,v 1.43 2007/02/24 17:21:04 beck Exp $ +.\" $OpenBSD: authpf.8,v 1.46 2008/03/18 23:03:14 merdely Exp $ .\" .\" Copyright (c) 1998-2007 Bob Beck (beck@openbsd.org>. All rights reserved. .\" @@ -15,14 +14,16 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd March 28, 2006 +.Dd $Mdocdate: March 18 2008 $ .Dt AUTHPF 8 .Os .Sh NAME -.Nm authpf +.Nm authpf , +.Nm authpf-noip .Nd authenticating gateway user shell .Sh SYNOPSIS .Nm authpf +.Nm authpf-noip .Sh DESCRIPTION .Nm is a user shell for authenticating gateways. @@ -31,47 +32,63 @@ It is used to change rules when a user authenticates and starts a session with .Xr sshd 8 and to undo these changes when the user's session exits. -It is designed for changing filter and translation rules for an individual -source IP address as long as a user maintains an active -.Xr ssh 1 -session. Typical use would be for a gateway that authenticates users before allowing them Internet use, or a gateway that allows different users into different places. +Combined with properly set up filter rules and secure switches, .Nm -logs the successful start and end of a session to -.Xr syslogd 8 . -This, combined with properly set up filter rules and secure switches, can be used to ensure users are held accountable for their network traffic. -.Pp -.Nm -can add filter and translation rules using the syntax described in -.Xr pf.conf 5 . -.Nm -requires that the +It is meant to be used with users who can connect via +.Xr ssh 1 +only, and requires the .Xr pf 4 -system be enabled and a -.Xr fdescfs 5 -file system be mounted at -.Pa /dev/fd -before use. +subsystem to be enabled. +.Pp +.Nm authpf-noip +is a user shell +which allows multiple connections to take +place from the same IP address. +It is useful primarily in cases where connections are tunneled via +the gateway system, and can be directly associated with the user name. +It cannot ensure accountability when +classifying connections by IP address; +in this case the client's IP address +is not provided to the packet filter via the +.Ar client_ip +macro or the +.Ar authpf_users +table. +Additionally, states associated with the client IP address +are not purged when the session is ended. +.Pp +To use either .Nm -can also maintain the list of IP address of connected users -in the "authpf_users" -.Pa table . +or +.Nm authpf-noip , +the user's shell needs to be set to +.Pa /usr/sbin/authpf +or +.Pa /usr/sbin/authpf-noip . .Pp .Nm -is meant to be used with users who can connect via +uses the +.Xr pf.conf 5 +syntax to change filter and translation rules for an individual +user or client IP address as long as a user maintains an active .Xr ssh 1 -only. -On startup, +session, and logs the successful start and end of a session to +.Xr syslogd 8 . .Nm retrieves the client's connecting IP address via the .Ev SSH_CLIENT environment variable and, after performing additional access checks, reads a template file to determine what filter and translation rules -(if any) to add. -On session exit the same rules that were added at startup are removed. +(if any) to add, and +maintains the list of IP addresses of connected users in the +.Ar authpf_users +table. +On session exit the same rules and table entries that were added at startup +are removed, and all states associated with the client's IP address are purged. .Pp Each .Nm @@ -185,6 +202,9 @@ It is also possible to configure to only allow specific users access. This is done by listing their login names, one per line, in .Pa /etc/authpf/authpf.allow . +A group of users can also be indicated by prepending "%" to the group name, +and all members of a login class can be indicated by prepending "@" to the +login class name. If "*" is found on a line, then all usernames match. If .Nm @@ -297,7 +317,8 @@ They have a wireless network which they would like to protect from unauthorized use. To accomplish this, they create the file .Pa /etc/authpf/authpf.allow -which lists their login ids, one per line. +which lists their login ids, group prepended with "%", or login class +prepended with "@", one per line. At this point, even if eve could authenticate to .Xr sshd 8 , she would not be allowed to use the gateway. @@ -501,6 +522,31 @@ table persist anchor "authpf/*" from rdr-anchor "authpf/*" from .Ed +.Pp +.Sy Tunneled users +\- normally +.Nm +allows only one session per client IP address. +However in some cases, such as when connections are tunneled via +.Xr ssh 1 +or +.Xr ipsec 4 , +the connections can be authorized based on the userid of the user instead of +the client IP address. +In this case it is appropriate to use +.Nm authpf-noip +to allow multiple users behind a NAT gateway to connect. +In the +.Pa /etc/authpf/authpf.rules +example below, the remote user could tunnel a remote desktop session to their +workstation: +.Bd -literal +internal_if="bge0" +workstation_ip="10.2.3.4" + +pass out on $internal_if from (self) to $workstation_ip port 3389 \e + user $user_id +.Ed .Sh FILES .Bl -tag -width "/etc/authpf/authpf.conf" -compact .It Pa /etc/authpf/authpf.conf @@ -512,7 +558,6 @@ rdr-anchor "authpf/*" from -__FBSDID("$FreeBSD$"); - -#include +#include #include #include #include @@ -33,11 +30,9 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef __FreeBSD__ -#include -#endif #include #include +#include #include #include #include @@ -49,9 +44,10 @@ __FBSDID("$FreeBSD$"); static int read_config(FILE *); static void print_message(char *); -static int allowed_luser(char *); +static int allowed_luser(struct passwd *); static int check_luser(char *, char *); static int remove_stale_rulesets(void); +static int recursive_ruleset_purge(char *, char *); static int change_filter(int, const char *, const char *); static int change_table(int, const char *); static void authpf_kill_states(void); @@ -60,8 +56,10 @@ int dev; /* pf device */ char anchorname[PF_ANCHOR_NAME_SIZE] = "authpf"; char rulesetname[MAXPATHLEN - PF_ANCHOR_NAME_SIZE - 2]; char tablename[PF_TABLE_NAME_SIZE] = "authpf_users"; +int user_ip = 1; /* controls whether $user_ip is set */ FILE *pidfp; +int pidfd = -1; char luser[MAXLOGNAME]; /* username */ char ipsrc[256]; /* ip as a string */ char pidfile[MAXPATHLEN]; /* we save pid in this file. */ @@ -70,11 +68,8 @@ struct timeval Tstart, Tend; /* start an volatile sig_atomic_t want_death; static void need_death(int signo); -#ifdef __FreeBSD__ -static __dead2 void do_death(int); -#else static __dead void do_death(int); -#endif +extern char *__progname; /* program name */ /* * User shell for authenticating gateways. Sole purpose is to allow @@ -85,7 +80,7 @@ static __dead void do_death(int); int main(int argc, char *argv[]) { - int lockcnt = 0, n, pidfd; + int lockcnt = 0, n; FILE *config; struct in6_addr ina; struct passwd *pw; @@ -95,9 +90,12 @@ main(int argc, char *argv[]) char *shell; login_cap_t *lc; + if (strcmp(__progname, "-authpf-noip") == 0) + user_ip = 0; + config = fopen(PATH_CONFFILE, "r"); if (config == NULL) { - syslog(LOG_ERR, "can not open %s (%m)", PATH_CONFFILE); + syslog(LOG_ERR, "cannot open %s (%m)", PATH_CONFFILE); exit(1); } @@ -142,14 +140,15 @@ main(int argc, char *argv[]) } if ((lc = login_getclass(pw->pw_class)) != NULL) - shell = (char *)login_getcapstr(lc, "shell", pw->pw_shell, + shell = login_getcapstr(lc, "shell", pw->pw_shell, pw->pw_shell); else shell = pw->pw_shell; login_close(lc); - if (strcmp(shell, PATH_AUTHPF_SHELL)) { + if (strcmp(shell, PATH_AUTHPF_SHELL) && + strcmp(shell, PATH_AUTHPF_SHELL_NOIP)) { syslog(LOG_ERR, "wrong shell for user %s, uid %u", pw->pw_name, pw->pw_uid); if (shell != pw->pw_shell) @@ -181,13 +180,22 @@ main(int argc, char *argv[]) } - /* Make our entry in /var/authpf as /var/authpf/ipaddr */ - n = snprintf(pidfile, sizeof(pidfile), "%s/%s", PATH_PIDFILE, ipsrc); + /* Make our entry in /var/authpf as ipaddr or username */ + n = snprintf(pidfile, sizeof(pidfile), "%s/%s", + PATH_PIDFILE, user_ip ? ipsrc : luser); if (n < 0 || (u_int)n >= sizeof(pidfile)) { syslog(LOG_ERR, "path to pidfile too long"); goto die; } + signal(SIGTERM, need_death); + signal(SIGINT, need_death); + signal(SIGALRM, need_death); + signal(SIGPIPE, need_death); + signal(SIGHUP, need_death); + signal(SIGQUIT, need_death); + signal(SIGTSTP, need_death); + /* * If someone else is already using this ip, then this person * wants to switch users - so kill the old process and exit @@ -241,15 +249,17 @@ main(int argc, char *argv[]) } /* - * we try to kill the previous process and acquire the lock + * We try to kill the previous process and acquire the lock * for 10 seconds, trying once a second. if we can't after - * 10 attempts we log an error and give up + * 10 attempts we log an error and give up. */ - if (++lockcnt > 10) { - syslog(LOG_ERR, "cannot kill previous authpf (pid %d)", - otherpid); + if (want_death || ++lockcnt > 10) { + if (!want_death) + syslog(LOG_ERR, "cannot kill previous authpf (pid %d)", + otherpid); fclose(pidfp); pidfp = NULL; + pidfd = -1; goto dogdeath; } sleep(1); @@ -260,6 +270,7 @@ main(int argc, char *argv[]) */ fclose(pidfp); pidfp = NULL; + pidfd = -1; } while (1); /* whack the group list */ @@ -277,7 +288,7 @@ main(int argc, char *argv[]) } openlog("authpf", LOG_PID | LOG_NDELAY, LOG_DAEMON); - if (!check_luser(PATH_BAN_DIR, luser) || !allowed_luser(luser)) { + if (!check_luser(PATH_BAN_DIR, luser) || !allowed_luser(pw)) { syslog(LOG_INFO, "user %s prohibited", luser); do_death(0); } @@ -302,19 +313,12 @@ main(int argc, char *argv[]) printf("Unable to modify filters\r\n"); do_death(0); } - if (change_table(1, ipsrc) == -1) { + if (user_ip && change_table(1, ipsrc) == -1) { printf("Unable to modify table\r\n"); change_filter(0, luser, ipsrc); do_death(0); } - signal(SIGTERM, need_death); - signal(SIGINT, need_death); - signal(SIGALRM, need_death); - signal(SIGPIPE, need_death); - signal(SIGHUP, need_death); - signal(SIGQUIT, need_death); - signal(SIGTSTP, need_death); while (1) { printf("\r\nHello %s. ", luser); printf("You are authenticated from host \"%s\"\r\n", ipsrc); @@ -337,8 +341,6 @@ dogdeath: sleep(180); /* them lusers read reaaaaal slow */ die: do_death(0); - - /* NOTREACHED */ } /* @@ -361,6 +363,8 @@ read_config(FILE *f) } i++; len = strlen(buf); + if (len == 0) + continue; if (buf[len - 1] != '\n' && !feof(f)) { syslog(LOG_ERR, "line %d too long in %s", i, PATH_CONFFILE); @@ -436,6 +440,7 @@ print_message(char *filename) * allowed_luser checks to see if user "luser" is allowed to * use this gateway by virtue of being listed in an allowed * users file, namely /etc/authpf/authpf.allow . + * Users may be listed by , %, or @. * * If /etc/authpf/authpf.allow does not exist, then we assume that * all users who are allowed in by sshd(8) are permitted to @@ -444,7 +449,7 @@ print_message(char *filename) * the session terminates in the same manner as being banned. */ static int -allowed_luser(char *luser) +allowed_luser(struct passwd *pw) { char *buf, *lbuf; int matched; @@ -476,8 +481,14 @@ allowed_luser(char *luser) * "public" gateway, such as it is, so let * everyone use it. */ + int gl_init = 0, ngroups = NGROUPS + 1; + gid_t groups[NGROUPS + 1]; + lbuf = NULL; + matched = 0; + while ((buf = fgetln(f, &len))) { + if (buf[len - 1] == '\n') buf[len - 1] = '\0'; else { @@ -488,7 +499,40 @@ allowed_luser(char *luser) buf = lbuf; } - matched = strcmp(luser, buf) == 0 || strcmp("*", buf) == 0; + if (buf[0] == '@') { + /* check login class */ + if (strcmp(pw->pw_class, buf + 1) == 0) + matched++; + } else if (buf[0] == '%') { + /* check group membership */ + int cnt; + struct group *group; + + if ((group = getgrnam(buf + 1)) == NULL) { + syslog(LOG_ERR, + "invalid group '%s' in %s (%s)", + buf + 1, PATH_ALLOWFILE, + strerror(errno)); + return (0); + } + + if (!gl_init) { + (void) getgrouplist(pw->pw_name, + pw->pw_gid, groups, &ngroups); + gl_init++; + } + + for ( cnt = 0; cnt < ngroups; cnt++) { + if (group->gr_gid == groups[cnt]) { + matched++; + break; + } + } + } else { + /* check username and wildcard */ + matched = strcmp(pw->pw_name, buf) == 0 || + strcmp("*", buf) == 0; + } if (lbuf != NULL) { free(lbuf); @@ -496,10 +540,10 @@ allowed_luser(char *luser) } if (matched) - return (1); /* matched an allowed username */ + return (1); /* matched an allowed user/group */ } syslog(LOG_INFO, "denied access to %s: not listed in %s", - luser, PATH_ALLOWFILE); + pw->pw_name, PATH_ALLOWFILE); /* reuse buf */ buf = "\n\nSorry, you are not allowed to use this facility!\n"; @@ -581,7 +625,7 @@ static int remove_stale_rulesets(void) { struct pfioc_ruleset prs; - u_int32_t nr, mnr; + u_int32_t nr; memset(&prs, 0, sizeof(prs)); strlcpy(prs.path, anchorname, sizeof(prs.path)); @@ -592,13 +636,12 @@ remove_stale_rulesets(void) return (1); } - mnr = prs.nr; - nr = 0; - while (nr < mnr) { + nr = prs.nr; + while (nr) { char *s, *t; pid_t pid; - prs.nr = nr; + prs.nr = nr - 1; if (ioctl(dev, DIOCGETRULESET, &prs)) return (1); errno = 0; @@ -610,119 +653,159 @@ remove_stale_rulesets(void) if (!prs.name[0] || errno || (*s && (t == prs.name || *s != ')'))) return (1); - if (kill(pid, 0) && errno != EPERM) { - int i; - struct pfioc_trans_e t_e[PF_RULESET_MAX+1]; - struct pfioc_trans t; - - bzero(&t, sizeof(t)); - bzero(t_e, sizeof(t_e)); - t.size = PF_RULESET_MAX+1; - t.esize = sizeof(t_e[0]); - t.array = t_e; - for (i = 0; i < PF_RULESET_MAX+1; ++i) { - t_e[i].rs_num = i; - snprintf(t_e[i].anchor, sizeof(t_e[i].anchor), - "%s/%s", anchorname, prs.name); - } - t_e[PF_RULESET_MAX].rs_num = PF_RULESET_TABLE; - if ((ioctl(dev, DIOCXBEGIN, &t) || - ioctl(dev, DIOCXCOMMIT, &t)) && - errno != EINVAL) + if ((kill(pid, 0) && errno != EPERM) || pid == getpid()) { + if (recursive_ruleset_purge(anchorname, prs.name)) return (1); - mnr--; - } else - nr++; + } + nr--; } return (0); } +static int +recursive_ruleset_purge(char *an, char *rs) +{ + struct pfioc_trans_e *t_e = NULL; + struct pfioc_trans *t = NULL; + struct pfioc_ruleset *prs = NULL; + int i; + + + /* purge rules */ + errno = 0; + if ((t = calloc(1, sizeof(struct pfioc_trans))) == NULL) + goto no_mem; + if ((t_e = calloc(PF_RULESET_MAX+1, + sizeof(struct pfioc_trans_e))) == NULL) + goto no_mem; + t->size = PF_RULESET_MAX+1; + t->esize = sizeof(struct pfioc_trans_e); + t->array = t_e; + for (i = 0; i < PF_RULESET_MAX+1; ++i) { + t_e[i].rs_num = i; + snprintf(t_e[i].anchor, sizeof(t_e[i].anchor), "%s/%s", an, rs); + } + t_e[PF_RULESET_MAX].rs_num = PF_RULESET_TABLE; + if ((ioctl(dev, DIOCXBEGIN, t) || + ioctl(dev, DIOCXCOMMIT, t)) && + errno != EINVAL) + goto cleanup; + + /* purge any children */ + if ((prs = calloc(1, sizeof(struct pfioc_ruleset))) == NULL) + goto no_mem; + snprintf(prs->path, sizeof(prs->path), "%s/%s", an, rs); + if (ioctl(dev, DIOCGETRULESETS, prs)) { + if (errno != EINVAL) + goto cleanup; + errno = 0; + } else { + int nr = prs->nr; + + while (nr) { + prs->nr = 0; + if (ioctl(dev, DIOCGETRULESET, prs)) + goto cleanup; + + if (recursive_ruleset_purge(prs->path, prs->name)) + goto cleanup; + nr--; + } + } + +no_mem: + if (errno == ENOMEM) + syslog(LOG_ERR, "calloc failed"); + +cleanup: + free(t); + free(t_e); + free(prs); + return (errno); +} + /* * Add/remove filter entries for user "luser" from ip "ipsrc" */ static int change_filter(int add, const char *luser, const char *ipsrc) { - char *pargv[13] = { - "pfctl", "-p", "/dev/pf", "-q", "-a", "anchor/ruleset", - "-D", "user_ip=X", "-D", "user_id=X", "-f", - "file", NULL - }; char *fdpath = NULL, *userstr = NULL, *ipstr = NULL; char *rsn = NULL, *fn = NULL; pid_t pid; gid_t gid; int s; - if (luser == NULL || !luser[0] || ipsrc == NULL || !ipsrc[0]) { - syslog(LOG_ERR, "invalid luser/ipsrc"); - goto error; - } - - if (asprintf(&rsn, "%s/%s", anchorname, rulesetname) == -1) - goto no_mem; - if (asprintf(&fdpath, "/dev/fd/%d", dev) == -1) - goto no_mem; - if (asprintf(&ipstr, "user_ip=%s", ipsrc) == -1) - goto no_mem; - if (asprintf(&userstr, "user_id=%s", luser) == -1) - goto no_mem; - if (add) { struct stat sb; + char *pargv[13] = { + "pfctl", "-p", "/dev/pf", "-q", "-a", "anchor/ruleset", + "-D", "user_id=X", "-D", "user_ip=X", "-f", "file", NULL + }; + + if (luser == NULL || !luser[0] || ipsrc == NULL || !ipsrc[0]) { + syslog(LOG_ERR, "invalid luser/ipsrc"); + goto error; + } - if (asprintf(&fn, "%s/%s/authpf.rules", PATH_USER_DIR, luser) - == -1) + if (asprintf(&rsn, "%s/%s", anchorname, rulesetname) == -1) + goto no_mem; + if (asprintf(&fdpath, "/dev/fd/%d", dev) == -1) + goto no_mem; + if (asprintf(&ipstr, "user_ip=%s", ipsrc) == -1) + goto no_mem; + if (asprintf(&userstr, "user_id=%s", luser) == -1) + goto no_mem; + if (asprintf(&fn, "%s/%s/authpf.rules", + PATH_USER_DIR, luser) == -1) goto no_mem; if (stat(fn, &sb) == -1) { free(fn); if ((fn = strdup(PATH_PFRULES)) == NULL) goto no_mem; } - } - pargv[2] = fdpath; - pargv[5] = rsn; - pargv[7] = userstr; - pargv[9] = ipstr; - if (!add) - pargv[11] = "/dev/null"; - else - pargv[11] = fn; + pargv[2] = fdpath; + pargv[5] = rsn; + pargv[7] = userstr; + if (user_ip) { + pargv[9] = ipstr; + pargv[11] = fn; + } else { + pargv[8] = "-f"; + pargv[9] = fn; + pargv[10] = NULL; + } - switch (pid = fork()) { - case -1: - syslog(LOG_ERR, "fork failed"); - goto error; - case 0: - /* revoke group privs before exec */ - gid = getgid(); - if (setregid(gid, gid) == -1) { - err(1, "setregid"); - } - execvp(PATH_PFCTL, pargv); - warn("exec of %s failed", PATH_PFCTL); - _exit(1); - } - - /* parent */ - waitpid(pid, &s, 0); - if (s != 0) { - syslog(LOG_ERR, "pfctl exited abnormally"); - goto error; - } + switch (pid = fork()) { + case -1: + syslog(LOG_ERR, "fork failed"); + goto error; + case 0: + /* revoke group privs before exec */ + gid = getgid(); + if (setregid(gid, gid) == -1) { + err(1, "setregid"); + } + execvp(PATH_PFCTL, pargv); + warn("exec of %s failed", PATH_PFCTL); + _exit(1); + } + + /* parent */ + waitpid(pid, &s, 0); + if (s != 0) { + syslog(LOG_ERR, "pfctl exited abnormally"); + goto error; + } - if (add) { gettimeofday(&Tstart, NULL); syslog(LOG_INFO, "allowing %s, user %s", ipsrc, luser); } else { + remove_stale_rulesets(); + gettimeofday(&Tend, NULL); -#ifdef __FreeBSD__ - syslog(LOG_INFO, "removed %s, user %s - duration %jd seconds", - ipsrc, luser, (intmax_t)(Tend.tv_sec - Tstart.tv_sec)); -#else syslog(LOG_INFO, "removed %s, user %s - duration %ld seconds", ipsrc, luser, Tend.tv_sec - Tstart.tv_sec); -#endif } return (0); no_mem: @@ -829,22 +912,19 @@ need_death(int signo) /* * function that removes our stuff when we go away. */ -#ifdef __FreeBSD__ -static __dead2 void -#else static __dead void -#endif do_death(int active) { int ret = 0; if (active) { change_filter(0, luser, ipsrc); - change_table(0, ipsrc); - authpf_kill_states(); - remove_stale_rulesets(); + if (user_ip) { + change_table(0, ipsrc); + authpf_kill_states(); + } } - if (pidfile[0] && (pidfp != NULL)) + if (pidfile[0] && pidfd != -1) if (unlink(pidfile) == -1) syslog(LOG_ERR, "cannot unlink %s (%m)", pidfile); exit(ret); Modified: user/eri/pf45/head/contrib/pf/authpf/pathnames.h ============================================================================== --- user/eri/pf45/head/contrib/pf/authpf/pathnames.h Thu Oct 8 22:31:19 2009 (r197883) +++ user/eri/pf45/head/contrib/pf/authpf/pathnames.h Thu Oct 8 22:33:19 2009 (r197884) @@ -35,4 +35,5 @@ #define PATH_DEVFILE "/dev/pf" #define PATH_PIDFILE "/var/authpf" #define PATH_AUTHPF_SHELL "/usr/sbin/authpf" +#define PATH_AUTHPF_SHELL_NOIP "/usr/sbin/authpf-noip" #define PATH_PFCTL "/sbin/pfctl" Modified: user/eri/pf45/head/contrib/pf/ftp-proxy/filter.c ============================================================================== --- user/eri/pf45/head/contrib/pf/ftp-proxy/filter.c Thu Oct 8 22:31:19 2009 (r197883) +++ user/eri/pf45/head/contrib/pf/ftp-proxy/filter.c Thu Oct 8 22:33:19 2009 (r197884) @@ -1,4 +1,4 @@ -/* $OpenBSD: filter.c,v 1.5 2006/12/01 07:31:21 camield Exp $ */ +/* $OpenBSD: filter.c,v 1.7 2008/02/26 18:52:53 henning Exp $ */ /* * Copyright (c) 2004, 2005 Camiel Dobbelaar, @@ -53,7 +53,7 @@ static struct pfioc_rule pfr; static struct pfioc_trans pft; static struct pfioc_trans_e pfte[TRANS_SIZE]; static int dev, rule_log; -static char *qname; +static char *qname, *tagname; int add_filter(u_int32_t id, u_int8_t dir, struct sockaddr *src, @@ -159,11 +159,12 @@ do_rollback(void) } void -init_filter(char *opt_qname, int opt_verbose) +init_filter(char *opt_qname, char *opt_tagname, int opt_verbose) { struct pf_status status; qname = opt_qname; + tagname = opt_tagname; if (opt_verbose == 1) rule_log = PF_LOG; @@ -172,7 +173,7 @@ init_filter(char *opt_qname, int opt_ver dev = open("/dev/pf", O_RDWR); if (dev == -1) - err(1, "/dev/pf"); + err(1, "open /dev/pf"); if (ioctl(dev, DIOCGETSTATUS, &status) == -1) err(1, "DIOCGETSTATUS"); if (!status.running) @@ -280,9 +281,9 @@ prepare_rule(u_int32_t id, int rs_num, s switch (rs_num) { case PF_RULESET_FILTER: /* - * pass quick [log] inet[6] proto tcp \ + * pass [quick] [log] inet[6] proto tcp \ * from $src to $dst port = $d_port flags S/SA keep state - * (max 1) [queue qname] + * (max 1) [queue qname] [tag tagname] */ pfr.rule.action = PF_PASS; pfr.rule.quick = 1; @@ -293,6 +294,11 @@ prepare_rule(u_int32_t id, int rs_num, s pfr.rule.max_states = 1; if (qname != NULL) strlcpy(pfr.rule.qname, qname, sizeof pfr.rule.qname); + if (tagname != NULL) { + pfr.rule.quick = 0; + strlcpy(pfr.rule.tagname, tagname, + sizeof pfr.rule.tagname); + } break; case PF_RULESET_NAT: /* Modified: user/eri/pf45/head/contrib/pf/ftp-proxy/filter.h ============================================================================== --- user/eri/pf45/head/contrib/pf/ftp-proxy/filter.h Thu Oct 8 22:31:19 2009 (r197883) +++ user/eri/pf45/head/contrib/pf/ftp-proxy/filter.h Thu Oct 8 22:33:19 2009 (r197884) @@ -26,6 +26,6 @@ int add_rdr(u_int32_t, struct sockaddr * struct sockaddr *, u_int16_t); int do_commit(void); int do_rollback(void); -void init_filter(char *, int); +void init_filter(char *, char *, int); int prepare_commit(u_int32_t); int server_lookup(struct sockaddr *, struct sockaddr *, struct sockaddr *); Modified: user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.8 ============================================================================== --- user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.8 Thu Oct 8 22:31:19 2009 (r197883) +++ user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.8 Thu Oct 8 22:33:19 2009 (r197884) @@ -1,4 +1,4 @@ -.\" $OpenBSD: ftp-proxy.8,v 1.7 2006/12/30 13:01:54 camield Exp $ +.\" $OpenBSD: ftp-proxy.8,v 1.10 2007/08/01 15:45:41 jmc Exp $ .\" .\" Copyright (c) 2004, 2005 Camiel Dobbelaar, .\" @@ -14,16 +14,15 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.\" $FreeBSD$ -.\" -.Dd November 28, 2004 +.Dd $Mdocdate$ .Dt FTP-PROXY 8 .Os .Sh NAME .Nm ftp-proxy .Nd Internet File Transfer Protocol proxy daemon .Sh SYNOPSIS -.Nm ftp-proxy +.Nm +.Bk -words .Op Fl 6Adrv .Op Fl a Ar address .Op Fl b Ar address @@ -33,7 +32,9 @@ .Op Fl p Ar port .Op Fl q Ar queue .Op Fl R Ar address +.Op Fl T Ar tag .Op Fl t Ar timeout +.Ek .Sh DESCRIPTION .Nm is a proxy for the Internet File Transfer Protocol. @@ -58,7 +59,7 @@ facility for this. Assuming the FTP control connection is from $client to $server, the proxy connected to the server using the $proxy source address, and $port is negotiated, then -.Nm ftp-proxy +.Nm adds the following rules to the various anchors. (These example rules use inet, but the proxy also supports inet6.) .Pp @@ -130,6 +131,20 @@ connections to another proxy. .It Fl r Rewrite sourceport to 20 in active mode to suit ancient clients that insist on this RFC property. +.It Fl T Ar tag +The filter rules will add tag +.Ar tag +to data connections, and not match quick. +This way alternative rules that use the +.Ar tagged +keyword can be implemented following the +.Nm +anchor. +These rules can use special +.Xr pf 4 +features like route-to, reply-to, label, rtable, overload, etc. that +.Nm +does not implement itself. .It Fl t Ar timeout Number of seconds that the control connection can be idle, before the proxy will disconnect. @@ -172,7 +187,7 @@ does not allow the ruleset to be modifie .Xr securelevel 7 higher than 1. At that level -.Nm ftp-proxy +.Nm cannot add rules to the anchors and FTP data connections may get blocked. .Pp Negotiated data connection ports below 1024 are not allowed. @@ -181,5 +196,5 @@ The negotiated IP address for active mod reasons. This makes third party file transfers impossible. .Pp -.Nm ftp-proxy +.Nm chroots to "/var/empty" and changes to user "proxy" to drop privileges. Modified: user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.c ============================================================================== --- user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.c Thu Oct 8 22:31:19 2009 (r197883) +++ user/eri/pf45/head/contrib/pf/ftp-proxy/ftp-proxy.c Thu Oct 8 22:33:19 2009 (r197884) @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp-proxy.c,v 1.13 2006/12/30 13:24:00 camield Exp $ */ +/* $OpenBSD: ftp-proxy.c,v 1.18 2008/04/22 02:22:22 joel Exp $ */ /* * Copyright (c) 2004, 2005 Camiel Dobbelaar, @@ -16,9 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -__FBSDID("$FreeBSD$"); - #include #include #include @@ -94,7 +91,7 @@ int client_parse_cmd(struct session *s); void client_read(struct bufferevent *, void *); int drop_privs(void); void end_session(struct session *); -int exit_daemon(void); +void exit_daemon(void); int getline(char *, size_t *); void handle_connection(const int, short, void *); void handle_signal(int, short, void *); @@ -105,6 +102,7 @@ u_int16_t pick_proxy_port(void); void proxy_reply(int, struct sockaddr *, u_int16_t); void server_error(struct bufferevent *, short, void *); int server_parse(struct session *s); +int allow_data_connection(struct session *s); void server_read(struct bufferevent *, void *); const char *sock_ntop(struct sockaddr *); void usage(void); @@ -116,7 +114,7 @@ char ntop_buf[NTOP_BUFS][INET6_ADDRSTRLE struct sockaddr_storage fixed_server_ss, fixed_proxy_ss; char *fixed_server, *fixed_server_port, *fixed_proxy, *listen_ip, *listen_port, - *qname; + *qname, *tagname; int anonymous_only, daemonize, id_count, ipv6_mode, loglevel, max_sessions, rfc_mode, session_count, timeout, verbose; extern char *__progname; @@ -152,8 +150,19 @@ client_parse(struct session *s) return (1); if (linebuf[0] == 'P' || linebuf[0] == 'p' || - linebuf[0] == 'E' || linebuf[0] == 'e') - return (client_parse_cmd(s)); + linebuf[0] == 'E' || linebuf[0] == 'e') { + if (!client_parse_cmd(s)) + return (0); + + /* + * Allow active mode connections immediately, instead of + * waiting for a positive reply from the server. Some + * rare servers/proxies try to probe or setup the data + * connection before an actual transfer request. + */ + if (s->cmd == CMD_PORT || s->cmd == CMD_EPRT) + return (allow_data_connection(s)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 22:38:47 2009 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 0D682106568B; Thu, 8 Oct 2009 22:38:47 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EF4C08FC16; Thu, 8 Oct 2009 22:38:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98Mcknd035690; Thu, 8 Oct 2009 22:38:46 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98MckT1035685; Thu, 8 Oct 2009 22:38:46 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082238.n98MckT1035685@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 22:38: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: r197885 - in user/eri/pf45/head/sys: contrib/pf/net modules/pf 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, 08 Oct 2009 22:38:47 -0000 Author: eri Date: Thu Oct 8 22:38:46 2009 New Revision: 197885 URL: http://svn.freebsd.org/changeset/base/197885 Log: Integrate all the changes needed to make kernel/module pf(4) compile. Mark areas still needing work around ifdef notyet, though they are features as pfsync/pfflow/pflog. Deleted: user/eri/pf45/head/sys/contrib/pf/net/pf_subr.c Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_if.c user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pf_lb.c user/eri/pf45/head/sys/contrib/pf/net/pf_norm.c user/eri/pf45/head/sys/contrib/pf/net/pf_osfp.c user/eri/pf45/head/sys/contrib/pf/net/pf_ruleset.c user/eri/pf45/head/sys/contrib/pf/net/pf_table.c user/eri/pf45/head/sys/contrib/pf/net/pfvar.h user/eri/pf45/head/sys/modules/pf/Makefile Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c Thu Oct 8 22:33:19 2009 (r197884) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c Thu Oct 8 22:38:46 2009 (r197885) @@ -2,7 +2,7 @@ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and - * Niels Provos (provos@physnet.uni-hamburg.de). + * Niels Provos (provos@physnet.uni hamburg.de). * * This code was written by John Ioannidis for BSD/OS in Athens, Greece, * in November 1995. @@ -33,17 +33,51 @@ * PURPOSE. */ + #ifdef __FreeBSD__ + #include "opt_inet.h" + #include "opt_inet6.h" + #include "opt_bpf.h" + #include "opt_pf.h" + + #include + __FBSDID("$FreeBSD$"); + + #ifdef DEV_BPF + #define NBPFILTER DEV_BPF + #else + #define NBPFILTER 0 + #endif + + #ifdef DEV_PFLOG + #define NPFLOG DEV_PFLOG + #else + #define NPFLOG 0 + #endif + + #else /* ! __FreeBSD__ */ #include "bpfilter.h" #include "pflog.h" +#endif #include #include #include #include #include + #ifdef __FreeBSD__ + #include + #include + #include + #include + #include + #else #include +#endif #include + #ifdef __FreeBSD__ + #include + #endif #include #include #include @@ -65,6 +99,12 @@ #include #include + #ifdef INET + #ifdef __FreeBSD__ + #include + #endif + #endif + #define PFLOGMTU (32768 + MHLEN + MLEN) #ifdef PFLOGDEBUG @@ -78,12 +118,21 @@ int pflogoutput(struct ifnet *, struct m struct rtentry *); int pflogioctl(struct ifnet *, u_long, caddr_t); void pflogstart(struct ifnet *); + #ifdef __FreeBSD__ + static int pflog_clone_create(struct if_clone *, int, caddr_t); + static void pflog_clone_destroy(struct ifnet *); + #else int pflog_clone_create(struct if_clone *, int); int pflog_clone_destroy(struct ifnet *); +#endif LIST_HEAD(, pflog_softc) pflogif_list; + #ifdef __FreeBSD__ + IFC_SIMPLE_DECLARE(pflog, 1); + #else struct if_clone pflog_cloner = IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy); +#endif struct ifnet *pflogifs[PFLOGIFS_MAX]; /* for fast access */ @@ -97,8 +146,13 @@ pflogattach(int npflog) if_clone_attach(&pflog_cloner); } + #ifdef __FreeBSD__ + static int + pflog_clone_create(struct if_clone *ifc, int unit, caddr_t param) + #else int pflog_clone_create(struct if_clone *ifc, int unit) +#endif { struct ifnet *ifp; struct pflog_softc *pflogif; @@ -111,49 +165,85 @@ pflog_clone_create(struct if_clone *ifc, M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) return (ENOMEM); - pflogif->sc_unit = unit; - ifp = &pflogif->sc_if; - snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", unit); - ifp->if_softc = pflogif; - ifp->if_mtu = PFLOGMTU; - ifp->if_ioctl = pflogioctl; - ifp->if_output = pflogoutput; - ifp->if_start = pflogstart; - ifp->if_type = IFT_PFLOG; - ifp->if_snd.ifq_maxlen = ifqmaxlen; - ifp->if_hdrlen = PFLOG_HDRLEN; + pflogif >sc_unit = unit; + #ifdef __FreeBSD__ + ifp = pflogif >sc_ifp = if_alloc(IFT_PFLOG); + if (ifp == NULL) { + free(pflogif, M_DEVBUF); + return (ENOSPC); + } + if_initname(ifp, ifc >ifc_name, unit); + #else + ifp = &pflogif >sc_if; + snprintf(ifp >if_xname, sizeof ifp >if_xname, "pflog%d", unit); +#endif + ifp >if_softc = pflogif; + ifp >if_mtu = PFLOGMTU; + ifp >if_ioctl = pflogioctl; + ifp >if_output = pflogoutput; + ifp >if_start = pflogstart; +#ifndef __FreeBSD__ + ifp >if_type = IFT_PFLOG; +#endif + ifp >if_snd.ifq_maxlen = ifqmaxlen; + ifp >if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); +#ifndef __FreeBSD__ if_alloc_sadl(ifp); +#endif #if NBPFILTER > 0 - bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); + bpfattach(&pflogif >sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); #endif s = splnet(); + #ifdef __FreeBSD__ + /* XXX: Why pf(4) lock?! Better add a pflog lock?! */ + PF_LOCK(); + #endif LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list); pflogifs[unit] = ifp; + #ifdef __FreeBSD__ + PF_UNLOCK(); + #endif splx(s); return (0); } + #ifdef __FreeBSD__ + static void + pflog_clone_destroy(struct ifnet *ifp) + #else int pflog_clone_destroy(struct ifnet *ifp) +#endif { - struct pflog_softc *pflogif = ifp->if_softc; + struct pflog_softc *pflogif = ifp >if_softc; int s; s = splnet(); - pflogifs[pflogif->sc_unit] = NULL; + #ifdef __FreeBSD__ + PF_LOCK(); + #endif + pflogifs[pflogif >sc_unit] = NULL; LIST_REMOVE(pflogif, sc_list); + #ifdef __FreeBSD__ + PF_UNLOCK(); + #endif splx(s); #if NBPFILTER > 0 bpfdetach(ifp); #endif if_detach(ifp); + #ifdef __FreeBSD__ + if_free(ifp); + #endif free(pflogif, M_DEVBUF); +#ifndef __FreeBSD__ return (0); +#endif } /* @@ -163,13 +253,22 @@ void pflogstart(struct ifnet *ifp) { struct mbuf *m; + #ifndef __FreeBSD__ int s; +#endif for (;;) { + #ifdef __FreeBSD__ + IF_LOCK(&ifp >if_snd); + _IF_DROP(&ifp >if_snd); + _IF_DEQUEUE(&ifp >if_snd, m); + IF_UNLOCK(&ifp >if_snd); + #else s = splnet(); - IF_DROP(&ifp->if_snd); - IF_DEQUEUE(&ifp->if_snd, m); + IF_DROP(&ifp >if_snd); + IF_DEQUEUE(&ifp >if_snd, m); splx(s); +#endif if (m == NULL) return; @@ -192,10 +291,17 @@ pflogioctl(struct ifnet *ifp, u_long cmd { switch (cmd) { case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) - ifp->if_flags |= IFF_RUNNING; + #ifdef __FreeBSD__ + if (ifp >if_flags & IFF_UP) + ifp >if_drv_flags |= IFF_DRV_RUNNING; + else + ifp >if_drv_flags &= ~IFF_DRV_RUNNING; + #else + if (ifp >if_flags & IFF_UP) + ifp >if_flags |= IFF_RUNNING; else - ifp->if_flags &= ~IFF_RUNNING; + ifp >if_flags &= ~IFF_RUNNING; +#endif break; default: return (ENOTTY); @@ -214,39 +320,47 @@ pflog_packet(struct pfi_kif *kif, struct struct pfloghdr hdr; if (kif == NULL || m == NULL || rm == NULL || pd == NULL) - return (-1); + return ( 1); - if ((ifn = pflogifs[rm->logif]) == NULL || !ifn->if_bpf) + if ((ifn = pflogifs[rm >logif]) == NULL || !ifn >if_bpf) return (0); bzero(&hdr, sizeof(hdr)); hdr.length = PFLOG_REAL_HDRLEN; hdr.af = af; - hdr.action = rm->action; + hdr.action = rm >action; hdr.reason = reason; - memcpy(hdr.ifname, kif->pfik_name, sizeof(hdr.ifname)); + memcpy(hdr.ifname, kif >pfik_name, sizeof(hdr.ifname)); if (am == NULL) { - hdr.rulenr = htonl(rm->nr); - hdr.subrulenr = -1; + hdr.rulenr = htonl(rm >nr); + hdr.subrulenr = 1; } else { - hdr.rulenr = htonl(am->nr); - hdr.subrulenr = htonl(rm->nr); - if (ruleset != NULL && ruleset->anchor != NULL) - strlcpy(hdr.ruleset, ruleset->anchor->name, + hdr.rulenr = htonl(am >nr); + hdr.subrulenr = htonl(rm >nr); + if (ruleset != NULL && ruleset >anchor != NULL) + strlcpy(hdr.ruleset, ruleset >anchor >name, sizeof(hdr.ruleset)); } - if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done) - pd->lookup.done = pf_socket_lookup(dir, pd); - if (pd->lookup.done > 0) { - hdr.uid = pd->lookup.uid; - hdr.pid = pd->lookup.pid; + if (rm >log & PF_LOG_SOCKET_LOOKUP && !pd >lookup.done) + #ifdef __FreeBSD__ + /* + * XXX: This should not happen as we force an early lookup + * via debug.pfugidhack + */ + ; /* empty */ + #else + pd >lookup.done = pf_socket_lookup(dir, pd); +#endif + if (pd >lookup.done > 0) { + hdr.uid = pd >lookup.uid; + hdr.pid = pd >lookup.pid; } else { hdr.uid = UID_MAX; hdr.pid = NO_PID; } - hdr.rule_uid = rm->cuid; - hdr.rule_pid = rm->cpid; + hdr.rule_uid = rm >cuid; + hdr.rule_pid = rm >cpid; hdr.dir = dir; #ifdef INET @@ -254,16 +368,56 @@ pflog_packet(struct pfi_kif *kif, struct struct ip *ip; ip = mtod(m, struct ip *); - ip->ip_sum = 0; - ip->ip_sum = in_cksum(m, ip->ip_hl << 2); + ip >ip_sum = 0; + ip >ip_sum = in_cksum(m, ip >ip_hl << 2); } #endif /* INET */ - ifn->if_opackets++; - ifn->if_obytes += m->m_pkthdr.len; - bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, + ifn >if_opackets++; + ifn >if_obytes += m >m_pkthdr.len; + #ifdef __FreeBSD__ + BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m); + #else + bpf_mtap_hdr(ifn >if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, BPF_DIRECTION_OUT); #endif +#endif return (0); } + + #ifdef __FreeBSD__ + static int + pflog_modevent(module_t mod, int type, void *data) + { + int error = 0; + + switch (type) { + case MOD_LOAD: + pflogattach(1); + PF_LOCK(); + pflog_packet_ptr = pflog_packet; + PF_UNLOCK(); + break; + case MOD_UNLOAD: + PF_LOCK(); + pflog_packet_ptr = NULL; + PF_UNLOCK(); + if_clone_detach(&pflog_cloner); + break; + default: + error = EINVAL; + break; + } + + return error; + } + + static moduledata_t pflog_mod = { "pflog", pflog_modevent, 0 }; + + #define PFLOG_MODVER 1 + + DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); + MODULE_VERSION(pflog, PFLOG_MODVER); + MODULE_DEPEND(pflog, pf, PF_MODVER, PF_MODVER, PF_MODVER); + #endif /* __FreeBSD__ */ Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h Thu Oct 8 22:33:19 2009 (r197884) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflog.h Thu Oct 8 22:38:46 2009 (r197885) @@ -30,7 +30,11 @@ #define PFLOGIFS_MAX 16 struct pflog_softc { +#ifdef __FreeBSD__ + struct ifnet *sc_ifp; /* the interface pointer */ +#else struct ifnet sc_if; /* the interface */ +#endif int sc_unit; LIST_ENTRY(pflog_softc) sc_list; }; @@ -70,11 +74,26 @@ struct old_pfloghdr { #define OLD_PFLOG_HDRLEN sizeof(struct old_pfloghdr) #ifdef _KERNEL - +#ifdef __FreeBSD__ + struct pf_rule; + struct pf_ruleset; + struct pfi_kif; + struct pf_pdesc; + + typedef int pflog_packet_t(struct pfi_kif *, struct mbuf *, sa_family_t, + u_int8_t, u_int8_t, struct pf_rule *, struct pf_rule *, + struct pf_ruleset *, struct pf_pdesc *); + extern pflog_packet_t *pflog_packet_ptr; +#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) do { \ + if (pflog_packet_ptr != NULL) \ + pflog_packet_ptr(i,a,b,c,d,e,f,g,h); \ + } while (0) +#else /* ! __FreeBSD__ */ #if NPFLOG > 0 #define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) pflog_packet(i,a,b,c,d,e,f,g,h) #else #define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) ((void)0) #endif /* NPFLOG > 0 */ +#endif #endif /* _KERNEL */ #endif /* _NET_IF_PFLOG_H_ */ Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Thu Oct 8 22:33:19 2009 (r197884) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Thu Oct 8 22:38:46 2009 (r197885) @@ -35,10 +35,46 @@ * */ + #ifdef __FreeBSD__ + #include "opt_inet.h" + #include "opt_inet6.h" + + #include +__FBSDID("$FreeBSD$"); + #endif + + #ifdef __FreeBSD__ + #include "opt_bpf.h" + #include "opt_pf.h" + + #ifdef DEV_BPF + #define NBPFILTER DEV_BPF + #else + #define NBPFILTER 0 + #endif + + #ifdef DEV_PFLOG + #define NPFLOG DEV_PFLOG + #else + #define NPFLOG 0 + #endif + + #ifdef DEV_PFSYNC + #define NPFSYNC DEV_PFSYNC + #else + #define NPFSYNC 0 + #endif + + /* XXX */ + #define NPFLOW 0 + #else #include "bpfilter.h" #include "pflog.h" #include "pfsync.h" +#endif +#ifdef notyet #include "pflow.h" +#endif #include #include @@ -48,17 +84,40 @@ #include #include #include + #ifdef __FreeBSD__ + #include + #include + #include + #define betoh64 be64toh + #else #include +#endif #include + #ifdef __FreeBSD__ + #include + #include + #include + #else #include +#endif +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include #include #include +#ifdef __FreeBSD__ +#ifdef RADIX_MPATH #include +#endif +#else +#include +#endif #include #include @@ -76,10 +135,14 @@ #include #include +#ifndef __FreeBSD__ #include +#endif #include #include +#ifdef notyet #include +#endif #if NPFSYNC > 0 #include @@ -90,8 +153,21 @@ #include #include #include + #ifdef __FreeBSD__ + #include + #include + #endif #endif /* INET6 */ +#ifdef __FreeBSD__ + #include + #include + #include + #include + + extern int ip_optcopy(struct ip *, struct ip *); + extern int debug_pfugidhack; + #endif #define DPFPRINTF(n, x) if (pf_status.debug >= (n)) printf x @@ -125,9 +201,15 @@ struct pf_anchor_stackframe { struct pf_anchor *child; } pf_anchor_stack[64]; + #ifdef __FreeBSD__ + uma_zone_t pf_src_tree_pl, pf_rule_pl, pf_pooladdr_pl; + uma_zone_t pf_state_pl, pf_state_key_pl, pf_state_item_pl; +uma_zone_t pf_altq_pl; + #else struct pool pf_src_tree_pl, pf_rule_pl, pf_pooladdr_pl; struct pool pf_state_pl, pf_state_key_pl, pf_state_item_pl; struct pool pf_altq_pl; +#endif void pf_init_threshold(struct pf_threshold *, u_int32_t, u_int32_t); @@ -147,7 +229,12 @@ void pf_change_icmp(struct pf_addr *, struct pf_addr *, struct pf_addr *, u_int16_t, u_int16_t *, u_int16_t *, u_int16_t *, u_int16_t *, u_int8_t, sa_family_t); +#ifdef __FreeBSD__ + void pf_send_tcp(struct mbuf *, + const struct pf_rule *, sa_family_t, +#else void pf_send_tcp(const struct pf_rule *, sa_family_t, +#endif const struct pf_addr *, const struct pf_addr *, u_int16_t, u_int16_t, u_int32_t, u_int32_t, u_int8_t, u_int16_t, u_int16_t, u_int8_t, int, @@ -160,7 +247,12 @@ u_int32_t pf_tcp_iss(struct pf_pdesc * int pf_test_rule(struct pf_rule **, struct pf_state **, int, struct pfi_kif *, struct mbuf *, int, void *, struct pf_pdesc *, struct pf_rule **, +#ifdef __FreeBSD__ + struct pf_ruleset **, struct ifqueue *, + struct inpcb *); +#else struct pf_ruleset **, struct ifqueue *); +#endif static __inline int pf_create_state(struct pf_rule *, struct pf_rule *, struct pf_rule *, struct pf_pdesc *, struct pf_src_node *, struct pf_state_key *, @@ -197,7 +289,9 @@ void pf_route(struct mbuf **, struct void pf_route6(struct mbuf **, struct pf_rule *, int, struct ifnet *, struct pf_state *, struct pf_pdesc *); +#ifndef __FreeBSD__ int pf_socket_lookup(int, struct pf_pdesc *); +#endif u_int8_t pf_get_wscale(struct mbuf *, int, u_int16_t, sa_family_t); u_int16_t pf_get_mss(struct mbuf *, int, u_int16_t, @@ -215,11 +309,24 @@ int pf_addr_wrap_neq(struct pf_addr_w struct pf_addr_wrap *); int pf_compare_state_keys(struct pf_state_key *, struct pf_state_key *, struct pfi_kif *, u_int); +#ifdef __FreeBSD__ +struct pf_state *pf_find_state(struct pfi_kif *, + struct pf_state_key_cmp *, u_int, struct mbuf *, + struct pf_mtag *); +#else struct pf_state *pf_find_state(struct pfi_kif *, struct pf_state_key_cmp *, u_int, struct mbuf *); +#endif int pf_src_connlimit(struct pf_state **); int pf_check_congestion(struct ifqueue *); +#ifdef __FreeBSD__ + int in4_cksum(struct mbuf *m, u_int8_t nxt, int off, int len); + + extern int pf_end_threads; + + struct pf_pool_limit pf_pool_limits[PF_LIMIT_MAX]; + #else extern struct pool pfr_ktable_pl; extern struct pool pfr_kentry_pl; @@ -230,10 +337,27 @@ struct pf_pool_limit pf_pool_limits[PF_L { &pfr_ktable_pl, PFR_KTABLE_HIWAT }, { &pfr_kentry_pl, PFR_KENTRY_HIWAT } }; +#endif +#ifdef __FreeBSD__ +#define STATE_LOOKUP(i, k, d, s, m, pt) \ + do { \ + s = pf_find_state(i, k, d, m, pt); \ + if (s == NULL || (s)->timeout == PFTM_PURGE) \ + return (PF_DROP); \ + if (d == PF_OUT && \ + (((s)->rule.ptr->rt == PF_ROUTETO && \ + (s)->rule.ptr->direction == PF_OUT) || \ + ((s)->rule.ptr->rt == PF_REPLYTO && \ + (s)->rule.ptr->direction == PF_IN)) && \ + (s)->rt_kif != NULL && \ + (s)->rt_kif != i) \ + return (PF_PASS); \ + } while (0) +#else #define STATE_LOOKUP(i, k, d, s, m) \ do { \ - s = pf_find_state(i, k, d, m); \ + s = pf_find_state(i, k, d, m); \ if (s == NULL || (s)->timeout == PFTM_PURGE) \ return (PF_DROP); \ if (d == PF_OUT && \ @@ -245,6 +369,7 @@ struct pf_pool_limit pf_pool_limits[PF_L (s)->rt_kif != i) \ return (PF_PASS); \ } while (0) +#endif #define BOUND_IFACE(r, k) \ ((r)->rule_flag & PFRULE_IFBOUND) ? (k) : pfi_all @@ -636,7 +761,11 @@ pf_state_key_attach(struct pf_state_key struct pf_state_key *cur; struct pf_state *olds = NULL; +#ifdef __FreeBSD__ + KASSERT(s->key[idx] == NULL, ("%s: key is null!", __FUNCTION__)); +#else KASSERT(s->key[idx] == NULL); /* XXX handle this? */ +#endif if ((cur = RB_INSERT(pf_state_tree, &pf_statetbl, sk)) != NULL) { /* key exists. check for same kif, if none, add to key */ @@ -728,8 +857,12 @@ pf_state_key_detach(struct pf_state *s, RB_REMOVE(pf_state_tree, &pf_statetbl, s->key[idx]); if (s->key[idx]->reverse) s->key[idx]->reverse->reverse = NULL; +#ifdef __FreeBSD__ + /* XXX: implement this */ +#else if (s->key[idx]->inp) s->key[idx]->inp->inp_pf_sk = NULL; +#endif pool_put(&pf_state_key_pl, s->key[idx]); } s->key[idx] = NULL; @@ -754,7 +887,12 @@ pf_state_key_setup(struct pf_pdesc *pd, struct pf_addr *saddr, struct pf_addr *daddr, u_int16_t sport, u_int16_t dport) { +#ifdef __FreeBSD__ + KASSERT((*skp == NULL && *nkp == NULL), + ("%s: skp == NULL && nkp == NULL", __FUNCTION__)); +#else KASSERT((*skp == NULL && *nkp == NULL)); +#endif if ((*skp = pf_alloc_state_key(PR_NOWAIT | PR_ZERO)) == NULL) return (ENOMEM); @@ -795,7 +933,9 @@ int pf_state_insert(struct pfi_kif *kif, struct pf_state_key *skw, struct pf_state_key *sks, struct pf_state *s) { +#ifndef __FreeBSD__ splassert(IPL_SOFTNET); +#endif s->kif = kif; @@ -878,14 +1018,36 @@ pf_compare_state_keys(struct pf_state_ke } struct pf_state * +#ifdef __FreeBSD__ +pf_find_state(struct pfi_kif *kif, struct pf_state_key_cmp *key, u_int dir, + struct mbuf *m, struct pf_mtag *pftag) +#else pf_find_state(struct pfi_kif *kif, struct pf_state_key_cmp *key, u_int dir, struct mbuf *m) +#endif { struct pf_state_key *sk; struct pf_state_item *si; pf_status.fcounters[FCNT_STATE_SEARCH]++; +#ifdef __FreeBSD__ + if (dir == PF_OUT && pftag->statekey && + ((struct pf_state_key *)pftag->statekey)->reverse) + sk = ((struct pf_state_key *)pftag->statekey)->reverse; + else { + if ((sk = RB_FIND(pf_state_tree, &pf_statetbl, + (struct pf_state_key *)key)) == NULL) + return (NULL); + if (dir == PF_OUT && pftag->statekey && + pf_compare_state_keys(pftag->statekey, sk, + kif, dir) == 0) { + ((struct pf_state_key *) + pftag->statekey)->reverse = sk; + sk->reverse = pftag->statekey; + } + } +#else if (dir == PF_OUT && m->m_pkthdr.pf.statekey && ((struct pf_state_key *)m->m_pkthdr.pf.statekey)->reverse) sk = ((struct pf_state_key *)m->m_pkthdr.pf.statekey)->reverse; @@ -901,9 +1063,14 @@ pf_find_state(struct pfi_kif *kif, struc sk->reverse = m->m_pkthdr.pf.statekey; } } +#endif if (dir == PF_OUT) +#ifdef __FreeBSD__ + pftag->statekey = NULL; +#else m->m_pkthdr.pf.statekey = NULL; +#endif /* list is sorted, if-bound states before floating ones */ TAILQ_FOREACH(si, &sk->states, entry) @@ -949,15 +1116,53 @@ void pf_purge_thread(void *v) { int nloops = 0, s; + #ifdef __FreeBSD__ + int locked; + #endif for (;;) { tsleep(pf_purge_thread, PWAIT, "pftm", 1 * hz); + #ifdef __FreeBSD__ + sx_slock(&pf_consistency_lock); + PF_LOCK(); + locked = 0; + + if (pf_end_threads) { + PF_UNLOCK(); + sx_sunlock(&pf_consistency_lock); + sx_xlock(&pf_consistency_lock); + PF_LOCK(); + pf_purge_expired_states(pf_status.states, 1); + pf_purge_expired_fragments(); + pf_purge_expired_src_nodes(1); + pf_end_threads++; + + sx_xunlock(&pf_consistency_lock); + PF_UNLOCK(); + wakeup(pf_purge_thread); + kproc_exit(0); + } + #endif s = splsoftnet(); /* process a fraction of the state table every second */ + #ifdef __FreeBSD__ + if(!pf_purge_expired_states(1 + (pf_status.states + / pf_default_rule.timeout[PFTM_INTERVAL]), 0)) { + PF_UNLOCK(); + sx_sunlock(&pf_consistency_lock); + sx_xlock(&pf_consistency_lock); + PF_LOCK(); + locked = 1; + + pf_purge_expired_states(1 + (pf_status.states + / pf_default_rule.timeout[PFTM_INTERVAL]), 1); + } + #else pf_purge_expired_states(1 + (pf_status.states / pf_default_rule.timeout[PFTM_INTERVAL])); +#endif /* purge other expired types every PFTM_INTERVAL seconds */ if (++nloops >= pf_default_rule.timeout[PFTM_INTERVAL]) { @@ -967,6 +1172,13 @@ pf_purge_thread(void *v) } splx(s); + #ifdef __FreeBSD__ + PF_UNLOCK(); + if (locked) + sx_xunlock(&pf_consistency_lock); + else + sx_sunlock(&pf_consistency_lock); + #endif } } @@ -983,8 +1195,15 @@ pf_state_expires(const struct pf_state * return (time_second); if (state->timeout == PFTM_UNTIL_PACKET) return (0); + #ifdef __FreeBSD__ + KASSERT(state->timeout != PFTM_UNLINKED, + ("pf_state_expires: timeout == PFTM_UNLINKED")); + KASSERT((state->timeout < PFTM_MAX), + ("pf_state_expires: timeout > PFTM_MAX")); + #else KASSERT(state->timeout != PFTM_UNLINKED); KASSERT(state->timeout < PFTM_MAX); +#endif timeout = state->rule.ptr->timeout[state->timeout]; if (!timeout) timeout = pf_default_rule.timeout[state->timeout]; @@ -1007,8 +1226,13 @@ pf_state_expires(const struct pf_state * return (state->expire + timeout); } + #ifdef __FreeBSD__ + int + pf_purge_expired_src_nodes(int waslocked) + #else void pf_purge_expired_src_nodes(int waslocked) +#endif { struct pf_src_node *cur, *next; int locked = waslocked; @@ -1018,7 +1242,12 @@ pf_purge_expired_src_nodes(int waslocked if (cur->states <= 0 && cur->expire <= time_second) { if (! locked) { + #ifdef __FreeBSD__ + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); + #else rw_enter_write(&pf_consistency_lock); +#endif next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur); locked = 1; @@ -1037,7 +1266,14 @@ pf_purge_expired_src_nodes(int waslocked } if (locked && !waslocked) +#ifdef __FreeBSD__ + { + sx_downgrade(&pf_consistency_lock); + } + return (1); +#else rw_exit_write(&pf_consistency_lock); +#endif } void @@ -1072,11 +1308,21 @@ pf_src_tree_remove_state(struct pf_state void pf_unlink_state(struct pf_state *cur) { + #ifdef __FreeBSD__ + if (cur->local_flags & PFSTATE_EXPIRING) + return; + cur->local_flags |= PFSTATE_EXPIRING; +#else splassert(IPL_SOFTNET); + #endif if (cur->src.state == PF_TCPS_PROXY_DST) { /* XXX wire key the right one? */ + #ifdef __FreeBSD__ + pf_send_tcp(NULL, cur->rule.ptr, cur->key[PF_SK_WIRE]->af, + #else pf_send_tcp(cur->rule.ptr, cur->key[PF_SK_WIRE]->af, +#endif &cur->key[PF_SK_WIRE]->addr[1], &cur->key[PF_SK_WIRE]->addr[0], cur->key[PF_SK_WIRE]->port[1], @@ -1102,13 +1348,20 @@ pf_unlink_state(struct pf_state *cur) void pf_free_state(struct pf_state *cur) { +#ifndef __FreeBSD__ splassert(IPL_SOFTNET); +#endif #if NPFSYNC > 0 if (pfsync_state_in_use(cur)) return; #endif + #ifdef __FreeBSD__ + KASSERT(cur->timeout == PFTM_UNLINKED, + ("pf_free_state: cur->timeout != PFTM_UNLINKED")); + #else KASSERT(cur->timeout == PFTM_UNLINKED); +#endif if (--cur->rule.ptr->states_cur <= 0 && cur->rule.ptr->src_nodes <= 0) pf_rm_rule(NULL, cur->rule.ptr); @@ -1129,12 +1382,21 @@ pf_free_state(struct pf_state *cur) pf_status.states--; } + #ifdef __FreeBSD__ + int + pf_purge_expired_states(u_int32_t maxcheck, int waslocked) + #else void pf_purge_expired_states(u_int32_t maxcheck) +#endif { static struct pf_state *cur = NULL; struct pf_state *next; + #ifdef __FreeBSD__ + int locked = waslocked; + #else int locked = 0; +#endif while (maxcheck--) { /* wrap to start of list when we hit the end */ @@ -1150,7 +1412,12 @@ pf_purge_expired_states(u_int32_t maxche if (cur->timeout == PFTM_UNLINKED) { /* free unlinked state */ if (! locked) { + #ifdef __FreeBSD__ + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); + #else rw_enter_write(&pf_consistency_lock); +#endif locked = 1; } pf_free_state(cur); @@ -1158,7 +1425,12 @@ pf_purge_expired_states(u_int32_t maxche /* unlink and free expired state */ pf_unlink_state(cur); if (! locked) { + #ifdef __FreeBSD__ + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); + #else rw_enter_write(&pf_consistency_lock); +#endif locked = 1; } pf_free_state(cur); @@ -1166,8 +1438,15 @@ pf_purge_expired_states(u_int32_t maxche cur = next; } + #ifdef __FreeBSD__ + if (!waslocked && locked) + sx_downgrade(&pf_consistency_lock); + + return (1); + #else if (locked) rw_exit_write(&pf_consistency_lock); +#endif } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 22:42:08 2009 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 CC181106568F; Thu, 8 Oct 2009 22:42:08 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA6538FC18; Thu, 8 Oct 2009 22:42:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98Mg75s035962; Thu, 8 Oct 2009 22:42:07 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98Mg7Uo035952; Thu, 8 Oct 2009 22:42:07 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082242.n98Mg7Uo035952@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 22:42:07 +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: r197886 - user/eri/pf45/head/contrib/pf/pfctl 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, 08 Oct 2009 22:42:09 -0000 Author: eri Date: Thu Oct 8 22:42:07 2009 New Revision: 197886 URL: http://svn.freebsd.org/changeset/base/197886 Log: Make pfctl compile as well. This allows pf(4) 4.5 to be tested. Modified: user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c user/eri/pf45/head/contrib/pf/pfctl/pfctl.c user/eri/pf45/head/contrib/pf/pfctl/pfctl.h user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_optimize.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.h user/eri/pf45/head/contrib/pf/pfctl/pfctl_qstats.c user/eri/pf45/head/contrib/pf/pfctl/pfctl_radix.c Modified: user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c Thu Oct 8 22:42:07 2009 (r197886) @@ -30,6 +30,9 @@ * */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl.c Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl.c Thu Oct 8 22:42:07 2009 (r197886) @@ -31,6 +31,9 @@ * */ + #include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -56,6 +59,10 @@ #include "pfctl_parser.h" #include "pfctl.h" + #ifdef __FreeBSD__ + #define HTONL(x) (x) = htonl((__uint32_t)(x)) + #endif + void usage(void); int pfctl_enable(int, int); int pfctl_disable(int, int); @@ -244,6 +251,10 @@ pfctl_enable(int dev, int opts) if (ioctl(dev, DIOCSTART)) { if (errno == EEXIST) errx(1, "pf already enabled"); + #ifdef __FreeBSD__ + else if (errno == ESRCH) + errx(1, "pfil registeration failed"); + #endif else err(1, "DIOCSTART"); } @@ -2182,7 +2193,11 @@ main(int argc, char *argv[]) /* turn off options */ opts &= ~ (PF_OPT_DISABLE | PF_OPT_ENABLE); clearopt = showopt = debugopt = NULL; + #if defined(__FreeBSD__) && !defined(ENABLE_ALTQ) + altqsupport = 0; + #else altqsupport = 1; +#endif } if (opts & PF_OPT_DISABLE) Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl.h ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl.h Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl.h Thu Oct 8 22:42:07 2009 (r197886) @@ -85,6 +85,11 @@ void warn_namespace_collision(const cha int pfctl_show_ifaces(const char *, int); FILE *pfctl_fopen(const char *, const char *); +#ifdef __FreeBSD__ +extern int altqsupport; +extern int dummynetsupport; +#endif + #ifndef DEFAULT_PRIORITY #define DEFAULT_PRIORITY 1 #endif Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c Thu Oct 8 22:42:07 2009 (r197886) @@ -18,6 +18,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -74,7 +77,11 @@ static int gsc_add_seg(struct gen_sc * double); static double sc_x2y(struct service_curve *, double); +#ifdef __FreeBSD__ +u_int32_t getifspeed(int, char *); +#else u_int32_t getifspeed(char *); +#endif u_long getifmtu(char *); int eval_queue_opts(struct pf_altq *, struct node_queue_opt *, u_int32_t); @@ -146,6 +153,11 @@ print_altq(const struct pf_altq *a, unsi return; } +#ifdef __FreeBSD__ + if (a->local_flags & PFALTQ_FLAG_IF_REMOVED) + printf("INACTIVE "); +#endif + printf("altq on %s ", a->ifname); switch (a->scheduler) { @@ -181,6 +193,10 @@ print_queue(const struct pf_altq *a, uns { unsigned int i; +#ifdef __FreeBSD__ + if (a->local_flags & PFALTQ_FLAG_IF_REMOVED) + printf("INACTIVE "); +#endif printf("queue "); for (i = 0; i < level; ++i) printf(" "); @@ -223,7 +239,11 @@ eval_pfaltq(struct pfctl *pf, struct pf_ if (bw->bw_absolute > 0) pa->ifbandwidth = bw->bw_absolute; else +#ifdef __FreeBSD__ + if ((rate = getifspeed(pf->dev, pa->ifname)) == 0) { +#else if ((rate = getifspeed(pa->ifname)) == 0) { +#endif fprintf(stderr, "interface %s does not know its bandwidth, " "please specify an absolute bandwidth\n", pa->ifname); @@ -1075,6 +1095,26 @@ rate2str(double rate) return (buf); } +-#ifdef __FreeBSD__ +-/* +- * XXX +- * FreeBSD does not have SIOCGIFDATA. +- * To emulate this, DIOCGIFSPEED ioctl added to pf. +- */ +u_int32_t +getifspeed(int pfdev, char *ifname) +{ + struct pf_ifspeed io; + + bzero(&io, sizeof io); + if (strlcpy(io.ifname, ifname, IFNAMSIZ) >= + sizeof(io.ifname)) + errx(1, "getifspeed: strlcpy"); + if (ioctl(pfdev, DIOCGIFSPEED, &io) == -1) + err(1, "DIOCGIFSPEED"); + return ((u_int32_t)io.baudrate); +} +#else u_int32_t getifspeed(char *ifname) { @@ -1095,6 +1135,7 @@ getifspeed(char *ifname) err(1, "close"); return ((u_int32_t)ifrdat.ifi_baudrate); } +#endif u_long getifmtu(char *ifname) @@ -1109,7 +1150,11 @@ getifmtu(char *ifname) sizeof(ifr.ifr_name)) errx(1, "getifmtu: strlcpy"); if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) == -1) +#ifdef __FreeBSD__ + ifr.ifr_mtu = 1500; +#else err(1, "SIOCGIFMTU"); +#endif if (close(s)) err(1, "close"); if (ifr.ifr_mtu > 0) Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_optimize.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl_optimize.c Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_optimize.c Thu Oct 8 22:42:07 2009 (r197886) @@ -16,6 +16,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -859,7 +862,11 @@ block_feedback(struct pfctl *pf, struct break; } } +#ifdef __FreeBSD__ + if (por2 == NULL) +#else if (por2 == TAILQ_END(&block->sb_rules)) +#endif TAILQ_INSERT_TAIL(&block->sb_rules, por1, por_entry); } Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c Thu Oct 8 22:42:07 2009 (r197886) @@ -31,6 +31,9 @@ * */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -594,7 +597,11 @@ print_status(struct pf_status *s, int op printf("Limit Counters\n"); for (i = 0; i < LCNT_MAX; i++) { printf(" %-25s %14lld ", pf_lcounters[i], +#ifdef __FreeBSD__ + (unsigned long long)s->lcounters[i]); +#else s->lcounters[i]); +#endif if (runtime > 0) printf("%14.1f/s\n", (double)s->lcounters[i] / (double)runtime); @@ -639,8 +646,13 @@ print_src_node(struct pf_src_node *sn, i sn->expire, min, sec); } printf(", %llu pkts, %llu bytes", +#ifdef __FreeBSD__ + (unsigned long long)(sn->packets[0] + sn->packets[1]), + (unsigned long long)(sn->bytes[0] + sn->bytes[1])); +#else sn->packets[0] + sn->packets[1], sn->bytes[0] + sn->bytes[1]); +#endif switch (sn->ruletype) { case PF_NAT: if (sn->rule.nr != -1) Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.h ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.h Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.h Thu Oct 8 22:42:07 2009 (r197886) @@ -157,6 +157,30 @@ struct node_queue_opt { } data; }; +#ifdef __FreeBSD__ +/* + * XXX + * Absolutely this is not correct location to define this. + * Should we use an another sperate header file? + */ +#define SIMPLEQ_HEAD STAILQ_HEAD +#define SIMPLEQ_HEAD_INITIALIZER STAILQ_HEAD_INITIALIZER +#define SIMPLEQ_ENTRY STAILQ_ENTRY +#define SIMPLEQ_FIRST STAILQ_FIRST +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY STAILQ_EMPTY +#define SIMPLEQ_NEXT STAILQ_NEXT +/*#define SIMPLEQ_FOREACH STAILQ_FOREACH*/ +#define SIMPLEQ_FOREACH(var, head, field) \ + for((var) = SIMPLEQ_FIRST(head); \ + (var) != SIMPLEQ_END(head); \ + (var) = SIMPLEQ_NEXT(var, field)) +#define SIMPLEQ_INIT STAILQ_INIT +#define SIMPLEQ_INSERT_HEAD STAILQ_INSERT_HEAD +#define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL +#define SIMPLEQ_INSERT_AFTER STAILQ_INSERT_AFTER +#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD +#endif SIMPLEQ_HEAD(node_tinithead, node_tinit); struct node_tinit { /* table initializer */ SIMPLEQ_ENTRY(node_tinit) entries; Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_qstats.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl_qstats.c Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_qstats.c Thu Oct 8 22:42:07 2009 (r197886) @@ -16,6 +16,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -86,6 +89,10 @@ pfctl_show_altq(int dev, const char *ifa struct pf_altq_node *root = NULL, *node; int nodes, dotitle = (opts & PF_OPT_SHOWALL); +#ifdef __FreeBSD__ + if (!altqsupport) + return (-1); +#endif if ((nodes = pfctl_update_qstats(dev, &root)) < 0) return (-1); @@ -111,6 +118,10 @@ pfctl_show_altq(int dev, const char *ifa for (node = root; node != NULL; node = node->next) { if (iface != NULL && strcmp(node->altq.ifname, iface)) continue; +#ifdef __FreeBSD__ + if (node->altq.local_flags & PFALTQ_FLAG_IF_REMOVED) + continue; +#endif pfctl_print_altq_node(dev, node, 0, opts); } } @@ -150,7 +161,12 @@ pfctl_update_qstats(int dev, struct pf_a warn("DIOCGETALTQ"); return (-1); } +#ifdef __FreeBSD__ + if (pa.altq.qid > 0 && + !(pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED)) { +#else if (pa.altq.qid > 0) { +#endif pq.nr = nr; pq.ticket = pa.ticket; pq.buf = &qstats.data; @@ -168,6 +184,19 @@ pfctl_update_qstats(int dev, struct pf_a pfctl_insert_altq_node(root, pa.altq, qstats); } } +#ifdef __FreeBSD__ + else if (pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED) { + memset(&qstats.data, 0, sizeof(qstats.data)); + if ((node = pfctl_find_altq_node(*root, pa.altq.qname, + pa.altq.ifname)) != NULL) { + memcpy(&node->qstats.data, &qstats.data, + sizeof(qstats.data)); + update_avg(node); + } else { + pfctl_insert_altq_node(root, pa.altq, qstats); + } + } +#endif } return (mnr); } @@ -274,6 +303,10 @@ pfctl_print_altq_nodestat(int dev, const if (a->altq.qid == 0) return; +#ifdef __FreeBSD__ + if (a->altq.local_flags & PFALTQ_FLAG_IF_REMOVED) + return; +#endif switch (a->altq.scheduler) { case ALTQT_CBQ: print_cbqstats(a->qstats); Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_radix.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl_radix.c Thu Oct 8 22:38:46 2009 (r197885) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_radix.c Thu Oct 8 22:42:07 2009 (r197886) @@ -30,6 +30,9 @@ * */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 22:45:19 2009 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 02C87106568F; Thu, 8 Oct 2009 22:45:19 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E69958FC15; Thu, 8 Oct 2009 22:45:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98MjImc036077; Thu, 8 Oct 2009 22:45:18 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98MjICu036075; Thu, 8 Oct 2009 22:45:18 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082245.n98MjICu036075@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 22:45:18 +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: r197887 - user/eri/pf45/head/sys/conf 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, 08 Oct 2009 22:45:19 -0000 Author: eri Date: Thu Oct 8 22:45:18 2009 New Revision: 197887 URL: http://svn.freebsd.org/changeset/base/197887 Log: pf_subr.c is gone glory to pf_lb.c Modified: user/eri/pf45/head/sys/conf/files Modified: user/eri/pf45/head/sys/conf/files ============================================================================== --- user/eri/pf45/head/sys/conf/files Thu Oct 8 22:42:07 2009 (r197886) +++ user/eri/pf45/head/sys/conf/files Thu Oct 8 22:45:18 2009 (r197887) @@ -357,7 +357,7 @@ contrib/pf/net/pf_osfp.c optional pf ine compile-with "${NORMAL_C} -I$S/contrib/pf" contrib/pf/net/pf_ruleset.c optional pf inet \ compile-with "${NORMAL_C} -I$S/contrib/pf" -contrib/pf/net/pf_subr.c optional pf inet \ +contrib/pf/net/pf_lb.c optional pf inet \ compile-with "${NORMAL_C} -I$S/contrib/pf" contrib/pf/net/pf_table.c optional pf inet \ compile-with "${NORMAL_C} -I$S/contrib/pf" From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 22:53:45 2009 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 6AB531065695; Thu, 8 Oct 2009 22:53:45 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E34EB8FC15; Thu, 8 Oct 2009 22:53:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98MriF7036246; Thu, 8 Oct 2009 22:53:44 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98Mri9W036244; Thu, 8 Oct 2009 22:53:44 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082253.n98Mri9W036244@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 22:53: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: r197888 - user/eri/pf45/head/sys/contrib/pf/net 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, 08 Oct 2009 22:53:45 -0000 Author: eri Date: Thu Oct 8 22:53:44 2009 New Revision: 197888 URL: http://svn.freebsd.org/changeset/base/197888 Log: Correct pf tag declaration. Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_mtag.h Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_mtag.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_mtag.h Thu Oct 8 22:45:18 2009 (r197887) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_mtag.h Thu Oct 8 22:53:44 2009 (r197888) @@ -37,15 +37,16 @@ #define PF_TAG_GENERATED 0x01 #define PF_TAG_FRAGCACHE 0x02 #define PF_TAG_TRANSLATE_LOCALHOST 0x04 +#define PF_TAG_DIVERTED 0x08 struct pf_mtag { void *hdr; /* saved hdr pos in mbuf, for ECN */ - u_int rtableid; /* alternate routing table id */ + void *statekey; /* pf stackside statekey */ u_int32_t qid; /* queue id */ + u_int rtableid; /* alternate routing table id */ u_int16_t tag; /* tag id */ u_int8_t flags; u_int8_t routed; - sa_family_t af; /* for ECN */ }; static __inline struct pf_mtag *pf_find_mtag(struct mbuf *); From owner-svn-src-user@FreeBSD.ORG Thu Oct 8 23:01:13 2009 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 4B13F106566B; Thu, 8 Oct 2009 23:01:13 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 397328FC0A; Thu, 8 Oct 2009 23:01:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98N1DJ0036440; Thu, 8 Oct 2009 23:01:13 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98N1Da0036439; Thu, 8 Oct 2009 23:01:13 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910082301.n98N1Da0036439@svn.freebsd.org> From: Ermal Luçi Date: Thu, 8 Oct 2009 23:01:13 +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: r197889 - in user/eri/pf45/head/sys/contrib/pf: net netinet 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, 08 Oct 2009 23:01:13 -0000 Author: eri Date: Thu Oct 8 23:01:12 2009 New Revision: 197889 URL: http://svn.freebsd.org/changeset/base/197889 Log: Remove accidentally slipped in code. Add back in4_cksum.c from previous verison of pf(4). Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/netinet/in4_cksum.c Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Thu Oct 8 22:53:44 2009 (r197888) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Thu Oct 8 23:01:12 2009 (r197889) @@ -3710,10 +3710,8 @@ fail: pfh_inet = pfil_head_get(PFIL_TYPE_AF, AF_INET); if (pfh_inet == NULL) return (ESRCH); /* XXX */ - pfil_add_named_hook(pf_check_in, NULL, "pf", PFIL_IN | PFIL_WAITOK, - pfh_inet); - pfil_add_named_hook(pf_check_out, NULL, "pf", PFIL_OUT | PFIL_WAITOK, - pfh_inet); + pfil_add_hook(pf_check_in, NULL, PFIL_IN | PFIL_WAITOK, pfh_inet); + pfil_add_hook(pf_check_out, NULL, PFIL_OUT | PFIL_WAITOK, pfh_inet); #ifdef INET6 pfh_inet6 = pfil_head_get(PFIL_TYPE_AF, AF_INET6); if (pfh_inet6 == NULL) { @@ -3723,10 +3721,8 @@ fail: pfh_inet); return (ESRCH); /* XXX */ } - pfil_add_named_hook(pf_check6_in, NULL, "pf", PFIL_IN | PFIL_WAITOK, - pfh_inet6); - pfil_add_named_hook(pf_check6_out, NULL, "pf", PFIL_OUT | PFIL_WAITOK, - pfh_inet6); + pfil_add_hook(pf_check6_in, NULL, PFIL_IN | PFIL_WAITOK, pfh_inet6); + pfil_add_hook(pf_check6_out, NULL, PFIL_OUT | PFIL_WAITOK, pfh_inet6); #endif pf_pfil_hooked = 1; Modified: user/eri/pf45/head/sys/contrib/pf/netinet/in4_cksum.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/netinet/in4_cksum.c Thu Oct 8 22:53:44 2009 (r197888) +++ user/eri/pf45/head/sys/contrib/pf/netinet/in4_cksum.c Thu Oct 8 23:01:12 2009 (r197889) @@ -1,4 +1,5 @@ -/* $OpenBSD: in4_cksum.c,v 1.6 2002/07/29 09:26:15 itojun Exp $ */ +/* $FreeBSD$ */ +/* $OpenBSD: in4_cksum.c,v 1.7 2003/06/02 23:28:13 millert Exp $ */ /* $KAME: in4_cksum.c,v 1.10 2001/11/30 10:06:15 itojun Exp $ */ /* $NetBSD: in_cksum.c,v 1.13 1996/10/13 02:03:03 christos Exp $ */ @@ -63,52 +64,37 @@ */ #include -#include #include -#include -#include +#include + #include #include #include #include -/* - * Checksum routine for Internet Protocol family headers (Portable Version). - * This is only for IPv4 pseudo header checksum. - * No need to clear non-pseudo-header fields in IPv4 header. - * len is for actual payload size, and does not include IPv4 header and - * skipped header chain (off + len should be equal to the whole packet). - * - * This routine is very heavily used in the network - * code and should be modified for each CPU to be as fast as possible. - */ +#include #define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) #define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);} +int in4_cksum(struct mbuf *, u_int8_t, int, int); + int -in4_cksum(m, nxt, off, len) - struct mbuf *m; - u_int8_t nxt; - int off, len; +in4_cksum(struct mbuf *m, u_int8_t nxt, int off, int len) { - u_int16_t *w; - int sum = 0; - int mlen = 0; - int byte_swapped = 0; union { struct ipovly ipov; u_int16_t w[10]; } u; union { - u_int8_t c[2]; - u_int16_t s; - } s_util; - union { u_int16_t s[2]; u_int32_t l; } l_util; + u_int16_t *w; + int psum; + int sum = 0; + if (nxt != 0) { /* pseudo header */ if (off < sizeof(struct ipovly)) @@ -126,94 +112,9 @@ in4_cksum(m, nxt, off, len) sum += w[5]; sum += w[6]; sum += w[7]; sum += w[8]; sum += w[9]; } - /* skip unnecessary part */ - while (m && off > 0) { - if (m->m_len > off) - break; - off -= m->m_len; - m = m->m_next; - } - - for (;m && len; m = m->m_next) { - if (m->m_len == 0) - continue; - w = (u_int16_t *)(mtod(m, caddr_t) + off); - if (mlen == -1) { - /* - * The first byte of this mbuf is the continuation - * of a word spanning between this mbuf and the - * last mbuf. - * - * s_util.c[0] is already saved when scanning previous - * mbuf. - */ - s_util.c[1] = *(u_int8_t *)w; - sum += s_util.s; - w = (u_int16_t *)((u_int8_t *)w + 1); - mlen = m->m_len - off - 1; - len--; - } else - mlen = m->m_len - off; - off = 0; - if (len < mlen) - mlen = len; - len -= mlen; - /* - * Force to even boundary. - */ - if ((1 & (long) w) && (mlen > 0)) { - REDUCE; - sum <<= 8; - s_util.c[0] = *(u_int8_t *)w; - w = (u_int16_t *)((int8_t *)w + 1); - mlen--; - byte_swapped = 1; - } - /* - * Unroll the loop to make overhead from - * branches &c small. - */ - while ((mlen -= 32) >= 0) { - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; - sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; - sum += w[8]; sum += w[9]; sum += w[10]; sum += w[11]; - sum += w[12]; sum += w[13]; sum += w[14]; sum += w[15]; - w += 16; - } - mlen += 32; - while ((mlen -= 8) >= 0) { - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; - w += 4; - } - mlen += 8; - if (mlen == 0 && byte_swapped == 0) - continue; - REDUCE; - while ((mlen -= 2) >= 0) { - sum += *w++; - } - if (byte_swapped) { - REDUCE; - sum <<= 8; - byte_swapped = 0; - if (mlen == -1) { - s_util.c[1] = *(u_int8_t *)w; - sum += s_util.s; - mlen = 0; - } else - mlen = -1; - } else if (mlen == -1) - s_util.c[0] = *(u_int8_t *)w; - } - if (len) - printf("cksum4: out of data\n"); - if (mlen == -1) { - /* The last mbuf has odd # of bytes. Follow the - standard (the odd byte may be shifted left by 8 bits - or not as determined by endian-ness of the machine) */ - s_util.c[1] = 0; - sum += s_util.s; - } + psum = in_cksum_skip(m, len + off, off); + psum = ~psum & 0xffff; + sum += psum; REDUCE; return (~sum & 0xffff); } From owner-svn-src-user@FreeBSD.ORG Fri Oct 9 06:53:36 2009 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 BB66D1065692; Fri, 9 Oct 2009 06:53:36 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A985D8FC0C; Fri, 9 Oct 2009 06:53:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n996rar1045310; Fri, 9 Oct 2009 06:53:36 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n996raxD045304; Fri, 9 Oct 2009 06:53:36 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910090653.n996raxD045304@svn.freebsd.org> From: Edwin Groothuis Date: Fri, 9 Oct 2009 06:53:36 +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: r197893 - in user/edwin/locale/share: . colldef monetdef msgdef timedef 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, 09 Oct 2009 06:53:36 -0000 Author: edwin Date: Fri Oct 9 06:53:36 2009 New Revision: 197893 URL: http://svn.freebsd.org/changeset/base/197893 Log: Change the definition of CMSLINK_xx_XX.cm: It can only point to charactermaps, not the cc_CC.charactermaps. Modified: user/edwin/locale/share/Makefile.def.inc user/edwin/locale/share/colldef/Makefile user/edwin/locale/share/monetdef/Makefile user/edwin/locale/share/msgdef/Makefile user/edwin/locale/share/timedef/Makefile Modified: user/edwin/locale/share/Makefile.def.inc ============================================================================== --- user/edwin/locale/share/Makefile.def.inc Fri Oct 9 03:03:26 2009 (r197892) +++ user/edwin/locale/share/Makefile.def.inc Fri Oct 9 06:53:36 2009 (r197893) @@ -174,8 +174,8 @@ SYMLINKS+= ../${ccln}.UTF-8/${LCTYPE} ${ .for ccln in ${CCLN} . for cm in ${CMS} . ifdef CMSLINK_${ccln}.${cm} -. for cclncm in ${CMSLINK_${ccln}.${cm}} -SYMLINKS+= ../${ccln}.${cm}/${LCTYPE} ${LOCALEDIR}/${cclncm} +. for cmi in ${CMSLINK_${ccln}.${cm}} +SYMLINKS+= ../${ccln}.${cm}/${LCTYPE} ${LOCALEDIR}/${ccln}.${cmi} . endfor . endif . endfor @@ -214,8 +214,8 @@ SYMLINKS+= ../${ccln}.UTF-8/${LCTYPE} ${ . for cclni in ${CCLNLINK_${ccln}} . for cm in ${CMS} . ifdef CMSLINK_${ccln}.${cm} -. for cclncmi in ${CMSLINK_${ccln}.${cm}} -SYMLINKS+= ../${ccln}.${cm}/${LCTYPE} ${LOCALEDIR}/${cclncmi:S/${ccln}/${cclni}/} +. for cmi in ${CMSLINK_${ccln}.${cm}} +SYMLINKS+= ../${ccln}.${cm}/${LCTYPE} ${LOCALEDIR}/${cclni}.${cmi} . endfor . endif . endfor @@ -329,7 +329,7 @@ ${ccln}.${cms}.src: ${ccln}.UTF-8.src -t ${CMALIAS_${cms}} \ ${_TRANSLATIONAFTER_${cms}} \ > ${.TARGET} \ - || rm ${.TARGET} && exit 0 + || (rm ${.TARGET} && exit 1) . endif ${ccln}.${cms}.out: ${ccln}.${cms}.src @@ -366,62 +366,4 @@ beforeinstall: shift; \ done -.if defined(FULL) -# -# Maintainer Bag of Tricks -# -# Perform the following checks: -# - Create all files defined with CCLN and (CMS_xx and CMSLINK_xx) -# - See if all MD5 checksums for CMS_{ccln} are different. -# - See if all MD5 checksums for CMSLINK_{ccln} are the same. -# -checkcms: -. for ccln in ${CCLN} - ../../usr.bin/unicode2utf8/unicode2utf8 \ - --cldr=${CLDRDIR} \ - --input=${ccln}.unicode \ - --output=${ccln}.UTF-8.src - grep -v '^#' < ${ccln}.UTF-8.src > ${ccln}.UTF-8.out -. for cms in ${CMS_${ccln}} ${CMSLINK_${ccln}} - cat ${ccln}.UTF-8.src \ - ${_TRANSLATIONBEFORE_${cms}} | \ - ${ICONV_${ccln}.${cms}} \ - -f UTF-8 \ - -t ${CMALIAS_${cms}} \ - ${_TRANSLATIONAFTER_${cms}} \ - > ${ccln}.${cms}.src \ - || rm ${ccln}.${cms}.src && exit 0 - grep -v '^#' < ${ccln}.${cms}.src > ${ccln}.${cms}.out -. endfor -. endfor - md5 -r *.out > /tmp/a - FULL=1 ${MAKE} checkcms1 - -. for ccln in ${CCLN} -. for cms in UTF-8 ${CMS_${ccln}} ${CMSLINK_${ccln}} -MD5SUM_${ccln}.${cms}!= grep ${ccln}.${cms}.out /tmp/a | awk '{ print $$1 }' -. endfor -. endfor - -# -# Perform the following checks: -# - See if all MD5 checksums for CMS_{ccln} are different. -# - See if all MD5 checksums for CMSLINK_{ccln} are the same. -# -checkcms1: -. for ccln in ${CCLN} -. for cms in ${CMS_${ccln}} - @if [ ${MD5SUM_${ccln}.${cms}} = ${MD5SUM_${ccln}.UTF-8} ]; then \ - echo Same: ${ccln}.UTF-8 - ${ccln}.${cms}; \ - fi -. endfor -. for cms in ${CMSLINK_${ccln}} - @if [ ${MD5SUM_${ccln}.${cms}} != ${MD5SUM_${ccln}.UTF-8} ]; then \ - echo Different: ${ccln}.UTF-8 - ${ccln}.${cms}; \ - fi -. endfor -. endfor - -.endif - .include Modified: user/edwin/locale/share/colldef/Makefile ============================================================================== --- user/edwin/locale/share/colldef/Makefile Fri Oct 9 03:03:26 2009 (r197892) +++ user/edwin/locale/share/colldef/Makefile Fri Oct 9 06:53:36 2009 (r197893) @@ -32,24 +32,24 @@ CMS_uk_UA= CP1251 ISO8859-5 KOI8-U # For these locales, link the following charactermaps to the UTF-8 map. # (unless the origin charactermap is defined) -CMSLINK_ca_ES.ISO8859-1= ca_AD.ISO8859-1 ca_FR.ISO8859-1 ca_IT.ISO8859-1 -CMSLINK_ca_ES.ISO8859-15= ca_AD.ISO8859-15 ca_FR.ISO8859-15 ca_IT.ISO8859-15 -CMSLINK_cs_CZ.ISO8859-2= sk_SK.ISO8859-2 -CMSLINK_de_DE.ISO8859-1= de_AT.ISO8859-1 de_CH.ISO8859-1 -CMSLINK_de_DE.ISO8859-15= de_AT.ISO8859-15 de_CH.ISO8859-15 -CMSLINK_is_IS.ISO8859-1= zh_Hant_TW.Big5 -CMSLINK_no_NO.ISO8859-1= nb_NO.ISO8859-1 nn_NO.ISO8859-1 -CMSLINK_no_NO.ISO8859-15= nb_NO.ISO8859-15 nn_NO.ISO8859-15 -CMSLINK_pt_PT.ISO8859-1= pt_BR.ISO8859-1 -CMSLINK_la_LN.ISO8859-1= af_ZA.ISO8859-1 da_DK.ISO8859-1 en_AU.ISO8859-1 en_CA.ISO8859-1 en_GB.ISO8859-1 en_NZ.ISO8859-1 en_US.ISO8859-1 eu_ES.ISO8859-1 fi_FI.ISO8859-1 fr_BE.ISO8859-1 fr_CA.ISO8859-1 fr_CH.ISO8859-1 fr_FR.ISO8859-1 it_CH.ISO8859-1 it_IT.ISO8859-1 nl_BE.ISO8859-1 nl_NL.ISO8859-1 pt_BR.ISO8859-1 pt_PT.ISO8859-1 -CMSLINK_la_LN.ISO8859-2= hu_HU.ISO8859-2 ro_RO.ISO8859-2 sr_YU.ISO8859-2 -CMSLINK_la_LN.ISO8859-13= lt_LT.ISO8859-13 lv_LV.ISO8859-13 -CMSLINK_la_LN.ISO8859-15= af_ZA.ISO8859-15 da_DK.ISO8859-15 en_AU.ISO8859-15 en_CA.ISO8859-15 en_GB.ISO8859-15 en_NZ.ISO8859-15 en_US.ISO8859-15 eu_ES.ISO8859-15 fi_FI.ISO8859-15 fr_BE.ISO8859-15 fr_CA.ISO8859-15 fr_CH.ISO8859-15 fr_FR.ISO8859-15 it_CH.ISO8859-15 it_IT.ISO8859-15 nl_BE.ISO8859-15 nl_NL.ISO8859-15 pt_PT.ISO8859-15 -CMSLINK_la_LN.US-ASCII= af_ZA.UTF-8 am_ET.UTF-8 be_BY.UTF-8 bg_BG.UTF-8 ca_AD.UTF-8 ca_ES.UTF-8 ca_FR.UTF-8 ca_IT.UTF-8 cs_CZ.UTF-8 da_DK.UTF-8 de_AT.UTF-8 de_CH.UTF-8 de_DE.UTF-8 el_GR.UTF-8 en_AU.US-ASCII en_AU.UTF-8 en_CA.US-ASCII en_CA.UTF-8 en_GB.US-ASCII en_GB.UTF-8 en_IE.UTF-8 en_NZ.US-ASCII en_NZ.UTF-8 en_US.US-ASCII en_US.UTF-8 es_ES.UTF-8 et_EE.UTF-8 eu_ES.UTF-8 fi_FI.UTF-8 fr_BE.UTF-8 fr_CA.UTF-8 fr_CH.UTF-8 fr_FR.UTF-8 he_IL.UTF-8 hr_HR.UTF-8 hu_HU.UTF-8 hy_AM.UTF-8 is_IS.UTF-8 it_CH.UTF-8 it_IT.UTF-8 ja_JP.SJIS ja_JP.UTF-8 ja_JP.eucJP kk_KZ.UTF-8 ko_KR.CP949 ko_KR.UTF-8 ko_KR.eucKR lt_LT.UTF-8 lv_LV.UTF-8 mn_MN.UTF-8 nb_NO.UTF-8 nl_BE.UTF-8 nl_NL.UTF-8 nn_NO.UTF-8 no_NO.UTF-8 pl_PL.UTF-8 pt_BR.UTF-8 pt_PT.UTF-8 ro_RO.UTF-8 ru_RU.UTF-8 sk_SK.UTF-8 sl_SI.UTF-8 sr_YU.UTF-8 sv_SE.UTF-8 tr_TR.UTF-8 uk_UA.UTF-8 zh_Hans_CN.GB18030 zh_Hans_CN.GB2312 zh_Hans_CN.GBK zh_Hans_CN.UTF-8 zh_Hans_CN.eucCN zh_Hant_HK.Big5HKSCS zh_Hant_HK.UTF-8 zh_Hant_TW.UTF-8 +# None! # For these locales, also create symlinks to the main locale. #CCLNLINK_ccln= ccnln -# None! +CCLNLINK_ca_ES.ISO8859-1= ca_AD.ISO8859-1 ca_FR.ISO8859-1 ca_IT.ISO8859-1 +CCLNLINK_ca_ES.ISO8859-15= ca_AD.ISO8859-15 ca_FR.ISO8859-15 ca_IT.ISO8859-15 +CCLNLINK_cs_CZ.ISO8859-2= sk_SK.ISO8859-2 +CCLNLINK_de_DE.ISO8859-1= de_AT.ISO8859-1 de_CH.ISO8859-1 +CCLNLINK_de_DE.ISO8859-15= de_AT.ISO8859-15 de_CH.ISO8859-15 +CCLNLINK_is_IS.ISO8859-1= zh_Hant_TW.Big5 +CCLNLINK_no_NO.ISO8859-1= nb_NO.ISO8859-1 nn_NO.ISO8859-1 +CCLNLINK_no_NO.ISO8859-15= nb_NO.ISO8859-15 nn_NO.ISO8859-15 +CCLNLINK_pt_PT.ISO8859-1= pt_BR.ISO8859-1 +CCLNLINK_la_LN.ISO8859-1= af_ZA.ISO8859-1 da_DK.ISO8859-1 en_AU.ISO8859-1 en_CA.ISO8859-1 en_GB.ISO8859-1 en_NZ.ISO8859-1 en_US.ISO8859-1 eu_ES.ISO8859-1 fi_FI.ISO8859-1 fr_BE.ISO8859-1 fr_CA.ISO8859-1 fr_CH.ISO8859-1 fr_FR.ISO8859-1 it_CH.ISO8859-1 it_IT.ISO8859-1 nl_BE.ISO8859-1 nl_NL.ISO8859-1 pt_BR.ISO8859-1 pt_PT.ISO8859-1 +CCLNLINK_la_LN.ISO8859-2= hu_HU.ISO8859-2 ro_RO.ISO8859-2 sr_YU.ISO8859-2 +CCLNLINK_la_LN.ISO8859-13= lt_LT.ISO8859-13 lv_LV.ISO8859-13 +CCLNLINK_la_LN.ISO8859-15= af_ZA.ISO8859-15 da_DK.ISO8859-15 en_AU.ISO8859-15 en_CA.ISO8859-15 en_GB.ISO8859-15 en_NZ.ISO8859-15 en_US.ISO8859-15 eu_ES.ISO8859-15 fi_FI.ISO8859-15 fr_BE.ISO8859-15 fr_CA.ISO8859-15 fr_CH.ISO8859-15 fr_FR.ISO8859-15 it_CH.ISO8859-15 it_IT.ISO8859-15 nl_BE.ISO8859-15 nl_NL.ISO8859-15 pt_PT.ISO8859-15 +CCLNLINK_la_LN.US-ASCII= af_ZA.UTF-8 am_ET.UTF-8 be_BY.UTF-8 bg_BG.UTF-8 ca_AD.UTF-8 ca_ES.UTF-8 ca_FR.UTF-8 ca_IT.UTF-8 cs_CZ.UTF-8 da_DK.UTF-8 de_AT.UTF-8 de_CH.UTF-8 de_DE.UTF-8 el_GR.UTF-8 en_AU.US-ASCII en_AU.UTF-8 en_CA.US-ASCII en_CA.UTF-8 en_GB.US-ASCII en_GB.UTF-8 en_IE.UTF-8 en_NZ.US-ASCII en_NZ.UTF-8 en_US.US-ASCII en_US.UTF-8 es_ES.UTF-8 et_EE.UTF-8 eu_ES.UTF-8 fi_FI.UTF-8 fr_BE.UTF-8 fr_CA.UTF-8 fr_CH.UTF-8 fr_FR.UTF-8 he_IL.UTF-8 hr_HR.UTF-8 hu_HU.UTF-8 hy_AM.UTF-8 is_IS.UTF-8 it_CH.UTF-8 it_IT.UTF-8 ja_JP.SJIS ja_JP.UTF-8 ja_JP.eucJP kk_KZ.UTF-8 ko_KR.CP949 ko_KR.UTF-8 ko_KR.eucKR lt_LT.UTF-8 lv_LV.UTF-8 mn_MN.UTF-8 nb_NO.UTF-8 nl_BE.UTF-8 nl_NL.UTF-8 nn_NO.UTF-8 no_NO.UTF-8 pl_PL.UTF-8 pt_BR.UTF-8 pt_PT.UTF-8 ro_RO.UTF-8 ru_RU.UTF-8 sk_SK.UTF-8 sl_SI.UTF-8 sr_YU.UTF-8 sv_SE.UTF-8 tr_TR.UTF-8 uk_UA.UTF-8 zh_Hans_CN.GB18030 zh_Hans_CN.GB2312 zh_Hans_CN.GBK zh_Hans_CN.UTF-8 zh_Hans_CN.eucCN zh_Hant_HK.Big5HKSCS zh_Hant_HK.UTF-8 zh_Hant_TW.UTF-8 # For these locales, create symlinks to the main locale for historical reasons. # The ones for zh_XX are linked to la_LN because there are no Modified: user/edwin/locale/share/monetdef/Makefile ============================================================================== --- user/edwin/locale/share/monetdef/Makefile Fri Oct 9 03:03:26 2009 (r197892) +++ user/edwin/locale/share/monetdef/Makefile Fri Oct 9 06:53:36 2009 (r197893) @@ -40,7 +40,7 @@ CMSLINK_de_DE= ISO8859-1 ISO8859-15 CMSLINK_el_GR= ISO8859-7 CMSLINK_en_AU= ISO8859-1 ISO8859-15 US-ASCII CMSLINK_en_CA= ISO8859-1 ISO8859-15 US-ASCII -CMSLINK_en_GB.ISO8859-1= en_GB.ISO8859-15 en_GB.US-ASCII +CMSLINK_en_GB.ISO8859-1= ISO8859-15 US-ASCII CMSLINK_en_NZ= ISO8859-1 ISO8859-15 US-ASCII CMSLINK_en_US= ISO8859-1 ISO8859-15 US-ASCII CMSLINK_es_ES= ISO8859-1 ISO8859-15 @@ -53,8 +53,8 @@ CMSLINK_hr_HR= ISO8859-2 CMSLINK_hu_HU= ISO8859-2 CMSLINK_is_IS= ISO8859-1 ISO8859-15 CMSLINK_it_IT= ISO8859-1 ISO8859-15 -CMSLINK_ja_JP.eucJP= ja_JP.SJIS -CMSLINK_ko_KR.eucKR= ko_KR.CP949 +CMSLINK_ja_JP.eucJP= SJIS +CMSLINK_ko_KR.eucKR= CP949 CMSLINK_lt_LT= ISO8859-4 ISO8859-13 CMSLINK_nl_BE= ISO8859-1 ISO8859-15 CMSLINK_nl_NL= ISO8859-1 ISO8859-15 @@ -66,7 +66,7 @@ CMSLINK_sl_SI= ISO8859-2 CMSLINK_sr_Latn_RS= ISO8859-2 CMSLINK_sv_SE= ISO8859-1 ISO8859-15 CMSLINK_tr_TR= ISO8859-9 -CMSLINK_zh_Hans_CN.GB2312= zh_Hans_CN.GBK +CMSLINK_zh_Hans_CN.GB2312= GBK CMSLINK_zh_Hant_HK= Big5HKSCS CMSLINK_zh_Hant_TW= Big5 Modified: user/edwin/locale/share/msgdef/Makefile ============================================================================== --- user/edwin/locale/share/msgdef/Makefile Fri Oct 9 03:03:26 2009 (r197892) +++ user/edwin/locale/share/msgdef/Makefile Fri Oct 9 06:53:36 2009 (r197893) @@ -47,7 +47,7 @@ CMSLINK_hr_HR= ISO8859-2 CMSLINK_hu_HU= ISO8859-2 CMSLINK_is_IS= ISO8859-1 ISO8859-15 CMSLINK_it_IT= ISO8859-1 ISO8859-15 -CMSLINK_ko_KR.eucKR= ko_KR.CP949 +CMSLINK_ko_KR.eucKR= CP949 CMSLINK_lt_LT= ISO8859-4 ISO8859-13 CMSLINK_nl_NL= ISO8859-1 ISO8859-15 CMSLINK_no_NO= ISO8859-1 ISO8859-15 @@ -57,8 +57,7 @@ CMSLINK_ro_RO= ISO8859-2 CMSLINK_sl_SI= ISO8859-2 CMSLINK_sv_SE= ISO8859-1 ISO8859-15 CMSLINK_tr_TR= ISO8859-9 -CMSLINK_zh_Hans_CN.GB2312= zh_Hans_CN.GBK -CMSLINK_zh_Hant_TW.Big5= zh_Hant_HK.Big5HKSCS +CMSLINK_zh_Hans_CN.GB2312= GBK # For these locales, also create symlinks to the main locale. CCLNLINK_ca_ES= ca_AD ca_FR ca_IT @@ -72,6 +71,7 @@ CCLNLINK_no_NO= nb_NO nn_NO CCLNLINK_pt_PT= pt_BR CCLNLINK_zh_Hant_TW= zh_Hant_HK CCLNLINK_en_GB.UTF-8= en_IE.UTF-8 +CCLNLINK_zh_Hant_TW.Big5= zh_Hant_HK.Big5HKSCS # TRANSLATIONAFTER_ARMSCII-8= 5DA9:5D2E # ]. fixing Modified: user/edwin/locale/share/timedef/Makefile ============================================================================== --- user/edwin/locale/share/timedef/Makefile Fri Oct 9 03:03:26 2009 (r197892) +++ user/edwin/locale/share/timedef/Makefile Fri Oct 9 06:53:36 2009 (r197893) @@ -53,26 +53,26 @@ CMS_zh_Hant_TW= Big5 # For these locales, link the following charactermaps to the UTF-8 map. # (unless the origin charactermap is defined) -CMSLINK_ca_ES.ISO8859-1= ca_ES.ISO8859-15 -CMSLINK_da_DK.ISO8859-1= da_DK.ISO8859-15 -CMSLINK_de_AT.ISO8859-1= de_AT.ISO8859-15 -CMSLINK_de_DE.ISO8859-1= de_DE.ISO8859-15 +CMSLINK_ca_ES.ISO8859-1= ISO8859-15 +CMSLINK_da_DK.ISO8859-1= ISO8859-15 +CMSLINK_de_AT.ISO8859-1= ISO8859-15 +CMSLINK_de_DE.ISO8859-1= ISO8859-15 CMSLINK_en_GB= ISO8859-1 ISO8859-15 US-ASCII CMSLINK_en_US= ISO8859-1 ISO8859-15 US-ASCII -CMSLINK_es_ES.ISO8859-1= es_ES.ISO8859-15 +CMSLINK_es_ES.ISO8859-1= ISO8859-15 CMSLINK_eu_ES= ISO8859-1 ISO8859-15 -CMSLINK_fi_FI.ISO8859-1= fi_FI.ISO8859-15 -CMSLINK_fr_FR.ISO8859-1= fr_FR.ISO8859-15 -CMSLINK_is_IS.ISO8859-1= is_IS.ISO8859-15 -CMSLINK_it_IT.ISO8859-1= it_IT.ISO8859-15 -CMSLINK_ko_KR.eucKR= ko_KR.CP949 -CMSLINK_la_LN.ISO8859-1= la_LN.ISO8859-2 la_LN.ISO8859-4 la_LN.ISO8859-15 la_LN.US-ASCII -CMSLINK_nb_NO.ISO8859-1= nb_NO.ISO8859-15 +CMSLINK_fi_FI.ISO8859-1= ISO8859-15 +CMSLINK_fr_FR.ISO8859-1= ISO8859-15 +CMSLINK_is_IS.ISO8859-1= ISO8859-15 +CMSLINK_it_IT.ISO8859-1= ISO8859-15 +CMSLINK_ko_KR.eucKR= CP949 +CMSLINK_la_LN.ISO8859-1= ISO8859-2 ISO8859-4 ISO8859-15 US-ASCII +CMSLINK_nb_NO.ISO8859-1= ISO8859-15 CMSLINK_nl_NL= ISO8859-1 ISO8859-15 -CMSLINK_nn_NO.ISO8859-1= nn_NO.ISO8859-15 -CMSLINK_pt_PT.ISO8859-1= pt_PT.ISO8859-15 -CMSLINK_sv_SE.ISO8859-1= sv_SE.ISO8859-15 -CMSLINK_zh_Hans_CN.GB2312= zh_Hans_CN.GBK +CMSLINK_nn_NO.ISO8859-1= ISO8859-15 +CMSLINK_pt_PT.ISO8859-1= ISO8859-15 +CMSLINK_sv_SE.ISO8859-1= ISO8859-15 +CMSLINK_zh_Hans_CN.GB2312= GBK # For these locales, also create symlinks to the main locale. CCLNLINK_en_US.UTF-8= af_ZA.UTF-8 From owner-svn-src-user@FreeBSD.ORG Fri Oct 9 19:01:27 2009 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 135701065692; Fri, 9 Oct 2009 19:01:27 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0203F8FC15; Fri, 9 Oct 2009 19:01:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n99J1QZw061319; Fri, 9 Oct 2009 19:01:26 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n99J1QEb061316; Fri, 9 Oct 2009 19:01:26 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910091901.n99J1QEb061316@svn.freebsd.org> From: Ermal Luçi Date: Fri, 9 Oct 2009 19:01: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: r197912 - in user/eri/pf45/head/sys: contrib/pf/net netinet/ipfw 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, 09 Oct 2009 19:01:27 -0000 Author: eri Date: Fri Oct 9 19:01:26 2009 New Revision: 197912 URL: http://svn.freebsd.org/changeset/base/197912 Log: * pflog(4) now compiles * Unbreak ipfw(4) build since the changing of pf(4) tag structure * Fix typos on some KASSERTs NOTE: GENERIC kernel now compiles. Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/netinet/ipfw/ip_fw2.c Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c Fri Oct 9 16:01:57 2009 (r197911) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflog.c Fri Oct 9 19:01:26 2009 (r197912) @@ -115,7 +115,11 @@ void pflogattach(int); int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *, +#ifdef __FreeBSD__ + struct route *); +#else struct rtentry *); +#endif int pflogioctl(struct ifnet *, u_long, caddr_t); void pflogstart(struct ifnet *); #ifdef __FreeBSD__ @@ -165,35 +169,39 @@ pflog_clone_create(struct if_clone *ifc, M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) return (ENOMEM); - pflogif >sc_unit = unit; + pflogif->sc_unit = unit; #ifdef __FreeBSD__ - ifp = pflogif >sc_ifp = if_alloc(IFT_PFLOG); + ifp = pflogif->sc_ifp = if_alloc(IFT_PFLOG); if (ifp == NULL) { free(pflogif, M_DEVBUF); return (ENOSPC); } - if_initname(ifp, ifc >ifc_name, unit); + if_initname(ifp, ifc->ifc_name, unit); #else - ifp = &pflogif >sc_if; - snprintf(ifp >if_xname, sizeof ifp >if_xname, "pflog%d", unit); + ifp = &pflogif->sc_if; + snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", unit); #endif - ifp >if_softc = pflogif; - ifp >if_mtu = PFLOGMTU; - ifp >if_ioctl = pflogioctl; - ifp >if_output = pflogoutput; - ifp >if_start = pflogstart; + ifp->if_softc = pflogif; + ifp->if_mtu = PFLOGMTU; + ifp->if_ioctl = pflogioctl; + ifp->if_output = pflogoutput; + ifp->if_start = pflogstart; #ifndef __FreeBSD__ - ifp >if_type = IFT_PFLOG; + ifp->if_type = IFT_PFLOG; #endif - ifp >if_snd.ifq_maxlen = ifqmaxlen; - ifp >if_hdrlen = PFLOG_HDRLEN; + ifp->if_snd.ifq_maxlen = ifqmaxlen; + ifp->if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); #ifndef __FreeBSD__ if_alloc_sadl(ifp); #endif #if NBPFILTER > 0 - bpfattach(&pflogif >sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); +#ifdef __FreeBSD__ + bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN); +#else + bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); +#endif #endif s = splnet(); @@ -219,14 +227,14 @@ int pflog_clone_destroy(struct ifnet *ifp) #endif { - struct pflog_softc *pflogif = ifp >if_softc; + struct pflog_softc *pflogif = ifp->if_softc; int s; s = splnet(); #ifdef __FreeBSD__ PF_LOCK(); #endif - pflogifs[pflogif >sc_unit] = NULL; + pflogifs[pflogif->sc_unit] = NULL; LIST_REMOVE(pflogif, sc_list); #ifdef __FreeBSD__ PF_UNLOCK(); @@ -259,14 +267,14 @@ pflogstart(struct ifnet *ifp) for (;;) { #ifdef __FreeBSD__ - IF_LOCK(&ifp >if_snd); - _IF_DROP(&ifp >if_snd); - _IF_DEQUEUE(&ifp >if_snd, m); - IF_UNLOCK(&ifp >if_snd); + IF_LOCK(&ifp->if_snd); + _IF_DROP(&ifp->if_snd); + _IF_DEQUEUE(&ifp->if_snd, m); + IF_UNLOCK(&ifp->if_snd); #else s = splnet(); - IF_DROP(&ifp >if_snd); - IF_DEQUEUE(&ifp >if_snd, m); + IF_DROP(&ifp->if_snd); + IF_DEQUEUE(&ifp->if_snd, m); splx(s); #endif @@ -279,7 +287,11 @@ pflogstart(struct ifnet *ifp) int pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +#ifdef __FreeBSD__ + struct route *rt) +#else struct rtentry *rt) +#endif { m_freem(m); return (0); @@ -292,15 +304,15 @@ pflogioctl(struct ifnet *ifp, u_long cmd switch (cmd) { case SIOCSIFFLAGS: #ifdef __FreeBSD__ - if (ifp >if_flags & IFF_UP) - ifp >if_drv_flags |= IFF_DRV_RUNNING; + if (ifp->if_flags & IFF_UP) + ifp->if_drv_flags |= IFF_DRV_RUNNING; else - ifp >if_drv_flags &= ~IFF_DRV_RUNNING; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; #else - if (ifp >if_flags & IFF_UP) - ifp >if_flags |= IFF_RUNNING; + if (ifp->if_flags & IFF_UP) + ifp->if_flags |= IFF_RUNNING; else - ifp >if_flags &= ~IFF_RUNNING; + ifp->if_flags &= ~IFF_RUNNING; #endif break; default: @@ -322,27 +334,27 @@ pflog_packet(struct pfi_kif *kif, struct if (kif == NULL || m == NULL || rm == NULL || pd == NULL) return ( 1); - if ((ifn = pflogifs[rm >logif]) == NULL || !ifn >if_bpf) + if ((ifn = pflogifs[rm->logif]) == NULL || !ifn->if_bpf) return (0); bzero(&hdr, sizeof(hdr)); hdr.length = PFLOG_REAL_HDRLEN; hdr.af = af; - hdr.action = rm >action; + hdr.action = rm->action; hdr.reason = reason; - memcpy(hdr.ifname, kif >pfik_name, sizeof(hdr.ifname)); + memcpy(hdr.ifname, kif->pfik_name, sizeof(hdr.ifname)); if (am == NULL) { - hdr.rulenr = htonl(rm >nr); + hdr.rulenr = htonl(rm->nr); hdr.subrulenr = 1; } else { - hdr.rulenr = htonl(am >nr); - hdr.subrulenr = htonl(rm >nr); - if (ruleset != NULL && ruleset >anchor != NULL) - strlcpy(hdr.ruleset, ruleset >anchor >name, + hdr.rulenr = htonl(am->nr); + hdr.subrulenr = htonl(rm->nr); + if (ruleset != NULL && ruleset->anchor != NULL) + strlcpy(hdr.ruleset, ruleset->anchor->name, sizeof(hdr.ruleset)); } - if (rm >log & PF_LOG_SOCKET_LOOKUP && !pd >lookup.done) + if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done) #ifdef __FreeBSD__ /* * XXX: This should not happen as we force an early lookup @@ -350,17 +362,17 @@ pflog_packet(struct pfi_kif *kif, struct */ ; /* empty */ #else - pd >lookup.done = pf_socket_lookup(dir, pd); + pd->lookup.done = pf_socket_lookup(dir, pd); #endif - if (pd >lookup.done > 0) { - hdr.uid = pd >lookup.uid; - hdr.pid = pd >lookup.pid; + if (pd->lookup.done > 0) { + hdr.uid = pd->lookup.uid; + hdr.pid = pd->lookup.pid; } else { hdr.uid = UID_MAX; hdr.pid = NO_PID; } - hdr.rule_uid = rm >cuid; - hdr.rule_pid = rm >cpid; + hdr.rule_uid = rm->cuid; + hdr.rule_pid = rm->cpid; hdr.dir = dir; #ifdef INET @@ -368,17 +380,17 @@ pflog_packet(struct pfi_kif *kif, struct struct ip *ip; ip = mtod(m, struct ip *); - ip >ip_sum = 0; - ip >ip_sum = in_cksum(m, ip >ip_hl << 2); + ip->ip_sum = 0; + ip->ip_sum = in_cksum(m, ip->ip_hl << 2); } #endif /* INET */ - ifn >if_opackets++; - ifn >if_obytes += m >m_pkthdr.len; + ifn->if_opackets++; + ifn->if_obytes += m->m_pkthdr.len; #ifdef __FreeBSD__ BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m); #else - bpf_mtap_hdr(ifn >if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, + bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, BPF_DIRECTION_OUT); #endif #endif Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Fri Oct 9 16:01:57 2009 (r197911) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Fri Oct 9 19:01:26 2009 (r197912) @@ -5160,10 +5160,10 @@ pf_test_state_other(struct pf_state **st struct pf_state_key *nk = (*state)->key[pd->didx]; #ifdef __FreeBSD__ - KASSERT(nk, ("%s: nk is null", __FUNCTION)); - KASSERT(pd, ("%s: pd is null", __FUNCTION)); - KASSERT(pd->src, ("%s: pd->src is null", __FUNCTION)); - KASSERT(pd->dst, ("%s: pd->dst is null", __FUNCTION)); + KASSERT(nk, ("%s: nk is null", __FUNCTION__)); + KASSERT(pd, ("%s: pd is null", __FUNCTION__)); + KASSERT(pd->src, ("%s: pd->src is null", __FUNCTION__)); + KASSERT(pd->dst, ("%s: pd->dst is null", __FUNCTION__)); #else KASSERT(nk); KASSERT(pd); Modified: user/eri/pf45/head/sys/netinet/ipfw/ip_fw2.c ============================================================================== --- user/eri/pf45/head/sys/netinet/ipfw/ip_fw2.c Fri Oct 9 16:01:57 2009 (r197911) +++ user/eri/pf45/head/sys/netinet/ipfw/ip_fw2.c Fri Oct 9 19:01:26 2009 (r197912) @@ -2930,10 +2930,6 @@ check_body: break; } at->qid = altq->qid; - if (is_ipv4) - at->af = AF_INET; - else - at->af = AF_LINK; at->hdr = ip; break; } From owner-svn-src-user@FreeBSD.ORG Fri Oct 9 19:23:13 2009 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 7E9E5106568F; Fri, 9 Oct 2009 19:23:13 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6E3758FC15; Fri, 9 Oct 2009 19:23:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n99JNDVe061720; Fri, 9 Oct 2009 19:23:13 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n99JNDmZ061714; Fri, 9 Oct 2009 19:23:13 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910091923.n99JNDmZ061714@svn.freebsd.org> From: Ermal Luçi Date: Fri, 9 Oct 2009 19:23:13 +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: r197913 - user/eri/pf45/head/contrib/pf/pfctl 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, 09 Oct 2009 19:23:13 -0000 Author: eri Date: Fri Oct 9 19:23:12 2009 New Revision: 197913 URL: http://svn.freebsd.org/changeset/base/197913 Log: Actually make pfctl compile. Modified: user/eri/pf45/head/contrib/pf/pfctl/parse.y user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c user/eri/pf45/head/contrib/pf/pfctl/pfctl.c user/eri/pf45/head/contrib/pf/pfctl/pfctl.h user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c Modified: user/eri/pf45/head/contrib/pf/pfctl/parse.y ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/parse.y Fri Oct 9 19:01:26 2009 (r197912) +++ user/eri/pf45/head/contrib/pf/pfctl/parse.y Fri Oct 9 19:23:12 2009 (r197913) @@ -1171,7 +1171,7 @@ scrub_opt : NODF { scrub_opts.randomid = 1; } | RTABLE NUMBER { - if ($2 < 0 || $2 > RT_TABLEID_MAX) { + if ($2 < 0 /* || $2 > RT_TABLEID_MAX */) { yyerror("invalid rtable id"); YYERROR; } @@ -1319,7 +1319,7 @@ antispoof_opt : label { antispoof_opts.label = $1; } | RTABLE NUMBER { - if ($2 < 0 || $2 > RT_TABLEID_MAX) { + if ($2 < 0 /* || $2 > RT_TABLEID_MAX */ ) { yyerror("invalid rtable id"); YYERROR; } @@ -2354,7 +2354,7 @@ filter_opt : USER uids { filter_opts.prob = 1; } | RTABLE NUMBER { - if ($2 < 0 || $2 > RT_TABLEID_MAX) { + if ($2 < 0 /* || $2 > RT_TABLEID_MAX */ ) { yyerror("invalid rtable id"); YYERROR; } @@ -4161,7 +4161,7 @@ tagged : /* empty */ { $$.neg = 0; $$. rtable : /* empty */ { $$ = -1; } | RTABLE NUMBER { - if ($2 < 0 || $2 > RT_TABLEID_MAX) { + if ($2 < 0 /* || $2 > RT_TABLEID_MAX */ ) { yyerror("invalid rtable id"); YYERROR; } Modified: user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c Fri Oct 9 19:01:26 2009 (r197912) +++ user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c Fri Oct 9 19:23:12 2009 (r197913) @@ -35,6 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __FreeBSD__ +#include +#define betoh64 be64toh +#endif #include #define TCPSTATES #include Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl.c Fri Oct 9 19:01:26 2009 (r197912) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl.c Fri Oct 9 19:23:12 2009 (r197913) @@ -39,6 +39,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __FreeBSD__ +#include +#endif + #include #include #include @@ -59,10 +63,6 @@ __FBSDID("$FreeBSD$"); #include "pfctl_parser.h" #include "pfctl.h" - #ifdef __FreeBSD__ - #define HTONL(x) (x) = htonl((__uint32_t)(x)) - #endif - void usage(void); int pfctl_enable(int, int); int pfctl_disable(int, int); @@ -1583,7 +1583,11 @@ pfctl_init_options(struct pfctl *pf) pf->limit[PF_LIMIT_TABLE_ENTRIES] = PFR_KENTRY_HIWAT; mib[0] = CTL_HW; +#ifdef __FreeBSD__ + mib[1] = HW_PHYSMEM; +#else mib[1] = HW_PHYSMEM64; +#endif size = sizeof(mem); if (sysctl(mib, 2, &mem, &size, NULL, 0) == -1) err(1, "sysctl"); Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl.h ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl.h Fri Oct 9 19:01:26 2009 (r197912) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl.h Fri Oct 9 19:23:12 2009 (r197913) @@ -88,6 +88,7 @@ FILE *pfctl_fopen(const char *, const ch #ifdef __FreeBSD__ extern int altqsupport; extern int dummynetsupport; + #define HTONL(x) (x) = htonl((__uint32_t)(x)) #endif #ifndef DEFAULT_PRIORITY Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c ============================================================================== --- user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c Fri Oct 9 19:01:26 2009 (r197912) +++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_altq.c Fri Oct 9 19:23:12 2009 (r197913) @@ -1095,12 +1095,12 @@ rate2str(double rate) return (buf); } --#ifdef __FreeBSD__ --/* -- * XXX -- * FreeBSD does not have SIOCGIFDATA. -- * To emulate this, DIOCGIFSPEED ioctl added to pf. -- */ +#ifdef __FreeBSD__ +/* + * XXX + * FreeBSD does not have SIOCGIFDATA. + * To emulate this, DIOCGIFSPEED ioctl added to pf. + */ u_int32_t getifspeed(int pfdev, char *ifname) { From owner-svn-src-user@FreeBSD.ORG Fri Oct 9 23:04:15 2009 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 B7DF3106566B; Fri, 9 Oct 2009 23:04:15 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A6F258FC12; Fri, 9 Oct 2009 23:04:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n99N4FAT065828; Fri, 9 Oct 2009 23:04:15 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n99N4FYs065824; Fri, 9 Oct 2009 23:04:15 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910092304.n99N4FYs065824@svn.freebsd.org> From: Ermal Luçi Date: Fri, 9 Oct 2009 23:04:15 +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: r197915 - in user/eri/pf45/head/sys: contrib/pf/net modules/pf 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, 09 Oct 2009 23:04:15 -0000 Author: eri Date: Fri Oct 9 23:04:15 2009 New Revision: 197915 URL: http://svn.freebsd.org/changeset/base/197915 Log: * Remove unused uma zone in pf 4.5 * Correct a typo in pf module makefile that has lurked in FreeBSD unbelivably long!!! Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pfvar.h user/eri/pf45/head/sys/modules/pf/Makefile Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Fri Oct 9 19:30:23 2009 (r197914) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Fri Oct 9 23:04:15 2009 (r197915) @@ -291,7 +291,6 @@ static struct cdevsw pf_cdevsw = { UMA_DESTROY(pf_cache_pl); UMA_DESTROY(pf_cent_pl); UMA_DESTROY(pfr_ktable_pl); - UMA_DESTROY(pfr_kentry_pl2); UMA_DESTROY(pfr_kentry_pl); UMA_DESTROY(pf_state_scrub_pl); UMA_DESTROY(pfi_addr_pl); @@ -311,7 +310,6 @@ int UMA_CREATE(pf_pooladdr_pl, struct pf_pooladdr, "pfpooladdrpl"); UMA_CREATE(pfr_ktable_pl, struct pfr_ktable, "pfrktable"); UMA_CREATE(pfr_kentry_pl, struct pfr_kentry, "pfrkentry"); - UMA_CREATE(pfr_kentry_pl2, struct pfr_kentry, "pfrkentry2"); UMA_CREATE(pf_frent_pl, struct pf_frent, "pffrent"); UMA_CREATE(pf_frag_pl, struct pf_fragment, "pffrag"); UMA_CREATE(pf_cache_pl, struct pf_fragment, "pffrcache"); Modified: user/eri/pf45/head/sys/contrib/pf/net/pfvar.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Fri Oct 9 19:30:23 2009 (r197914) +++ user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Fri Oct 9 23:04:15 2009 (r197915) @@ -1736,7 +1736,7 @@ extern void pf_altq_ifnet_event(struc extern uma_zone_t pf_src_tree_pl, pf_rule_pl; extern uma_zone_t pf_state_pl, pf_state_key_pl, pf_state_item_pl, pf_altq_pl, pf_pooladdr_pl; -extern uma_zone_t pfr_ktable_pl, pfr_kentry_pl, pfr_kentry_pl2; +extern uma_zone_t pfr_ktable_pl, pfr_kentry_pl; extern uma_zone_t pf_cache_pl, pf_cent_pl; extern uma_zone_t pf_state_scrub_pl; extern uma_zone_t pfi_addr_pl; Modified: user/eri/pf45/head/sys/modules/pf/Makefile ============================================================================== --- user/eri/pf45/head/sys/modules/pf/Makefile Fri Oct 9 19:30:23 2009 (r197914) +++ user/eri/pf45/head/sys/modules/pf/Makefile Fri Oct 9 23:04:15 2009 (r197915) @@ -28,7 +28,7 @@ opt_bpf.h: # pflog can be loaded as a module, have the additional checks turned on opt_pf.h: echo "#define DEV_PF 1" > ${.TARGET} - echo "#define DEF_PFLOG 1" >> ${.TARGET} + echo "#define DEV_PFLOG 1" >> ${.TARGET} .endif .include From owner-svn-src-user@FreeBSD.ORG Fri Oct 9 23:38:10 2009 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 99F3D106568B; Fri, 9 Oct 2009 23:38:09 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7E2028FC0C; Fri, 9 Oct 2009 23:38:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n99Nc9kl066458; Fri, 9 Oct 2009 23:38:09 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n99Nc9pA066455; Fri, 9 Oct 2009 23:38:09 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910092338.n99Nc9pA066455@svn.freebsd.org> From: Ermal Luçi Date: Fri, 9 Oct 2009 23:38: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: r197916 - user/eri/pf45/head/sys/contrib/pf/net 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, 09 Oct 2009 23:38:10 -0000 Author: eri Date: Fri Oct 9 23:38:08 2009 New Revision: 197916 URL: http://svn.freebsd.org/changeset/base/197916 Log: * Add to initialization/destroy some new pools used in pf(4) * Fix a panic related to trying to allocate memory with M_WAITOK whith the lock held in pf(4) osfp code. Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pf_osfp.c Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Fri Oct 9 23:04:15 2009 (r197915) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Fri Oct 9 23:38:08 2009 (r197916) @@ -272,7 +272,8 @@ static struct cdevsw pf_cdevsw = { init_zone_var(void) { pf_src_tree_pl = pf_rule_pl = NULL; - pf_state_pl = pf_altq_pl = pf_pooladdr_pl = NULL; + pf_state_pl = pf_state_key_pl = pf_state_item_pl = NULL; + pf_altq_pl = pf_pooladdr_pl = NULL; pf_frent_pl = pf_frag_pl = pf_cache_pl = pf_cent_pl = NULL; pf_state_scrub_pl = NULL; pfr_ktable_pl = pfr_kentry_pl = NULL; @@ -284,6 +285,8 @@ static struct cdevsw pf_cdevsw = { UMA_DESTROY(pf_src_tree_pl); UMA_DESTROY(pf_rule_pl); UMA_DESTROY(pf_state_pl); + UMA_DESTROY(pf_state_key_pl); + UMA_DESTROY(pf_state_item_pl); UMA_DESTROY(pf_altq_pl); UMA_DESTROY(pf_pooladdr_pl); UMA_DESTROY(pf_frent_pl); @@ -306,6 +309,8 @@ int UMA_CREATE(pf_src_tree_pl,struct pf_src_node, "pfsrctrpl"); UMA_CREATE(pf_rule_pl, struct pf_rule, "pfrulepl"); UMA_CREATE(pf_state_pl, struct pf_state, "pfstatepl"); + UMA_CREATE(pf_state_key_pl, struct pf_state, "pfstatekeypl"); + UMA_CREATE(pf_state_item_pl, struct pf_state, "pfstateitempl"); UMA_CREATE(pf_altq_pl, struct pf_altq, "pfaltqpl"); UMA_CREATE(pf_pooladdr_pl, struct pf_pooladdr, "pfpooladdrpl"); UMA_CREATE(pfr_ktable_pl, struct pfr_ktable, "pfrktable"); Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_osfp.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_osfp.c Fri Oct 9 23:04:15 2009 (r197915) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_osfp.c Fri Oct 9 23:38:08 2009 (r197916) @@ -410,7 +410,7 @@ pf_osfp_add(struct pf_osfp_ioctl *fpioc) } if ((entry = pool_get(&pf_osfp_entry_pl, #ifdef __FreeBSD__ - PR_WAITOK)) == NULL) + PR_NOWAIT)) == NULL) #else PR_WAITOK|PR_LIMITFAIL)) == NULL) #endif @@ -418,7 +418,7 @@ pf_osfp_add(struct pf_osfp_ioctl *fpioc) } else { if ((fp = pool_get(&pf_osfp_pl, #ifdef __FreeBSD__ - PR_WAITOK)) == NULL) + PR_NOWAIT)) == NULL) #else PR_WAITOK|PR_LIMITFAIL)) == NULL) #endif @@ -435,7 +435,7 @@ pf_osfp_add(struct pf_osfp_ioctl *fpioc) SLIST_INIT(&fp->fp_oses); if ((entry = pool_get(&pf_osfp_entry_pl, #ifdef __FreeBSD__ - PR_WAITOK)) == NULL) { + PR_NOWAIT)) == NULL) { #else PR_WAITOK|PR_LIMITFAIL)) == NULL) { #endif From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 16:08:05 2009 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 CD1E71065676; Sat, 10 Oct 2009 16:08:05 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BB1408FC0C; Sat, 10 Oct 2009 16:08:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9AG85Lh086487; Sat, 10 Oct 2009 16:08:05 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9AG85L2086484; Sat, 10 Oct 2009 16:08:05 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910101608.n9AG85L2086484@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 16:08:05 +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: r197935 - in user/eri/pf45/head/sys: contrib/pf/net i386/conf modules/pfsync 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, 10 Oct 2009 16:08:06 -0000 Author: eri Date: Sat Oct 10 16:08:05 2009 New Revision: 197935 URL: http://svn.freebsd.org/changeset/base/197935 Log: * Make pfsync(4) compile. OpenBSD TDB features are wrapped with notyet for now. * Add Makefile under modules directory to allow pfsync(4) to be built/loaded as module. * Remove dependency of pf(4) module from pfsync(4) internals. Added: user/eri/pf45/head/sys/modules/pfsync/ user/eri/pf45/head/sys/modules/pfsync/Makefile (contents, props changed) Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.h user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pfvar.h user/eri/pf45/head/sys/i386/conf/GENERIC Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 15:33:01 2009 (r197934) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 16:08:05 2009 (r197935) @@ -42,20 +42,71 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef __FreeBSD__ +#include "opt_inet.h" +#include "opt_inet6.h" +#include "opt_bpf.h" +#include "opt_pf.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef DEV_BPF +#define NBPFILTER DEV_BPF +#else +#define NBPFILTER 0 +#endif + +#ifdef DEV_PFSYNC +#define NPFSYNC DEV_PFSYNC +#else +#define NPFSYNC 0 +#endif + +#ifdef DEV_CARP +#define NCARP DEV_CARP +#else +#define NCARP 0 +#endif +#endif /* __FreeBSD__ */ + #include +#ifdef __FreeBSD__ +#include +#include +#include +#endif #include #include #include #include #include +#ifdef __FreeBSD__ +#include +#include +#include +#include +#include +#include +#include +#else #include #include +#endif #include #include +#ifndef __FreeBSD__ #include +#endif #include +#ifdef __FreeBSD__ +#include +#endif #include +#ifdef __FreeBSD__ +#include +#endif #include #include #include @@ -75,7 +126,9 @@ #include #endif /* INET6 */ +#ifndef __FreeBSD__ #include "carp.h" +#endif #if NCARP > 0 #include #endif @@ -83,8 +136,10 @@ #include #include +#ifndef __FreeBSD__ #include "bpfilter.h" #include "pfsync.h" +#endif #define PFSYNC_MINPKT ( \ sizeof(struct ip) + \ @@ -166,20 +221,34 @@ struct pfsync_deferral { TAILQ_ENTRY(pfsync_deferral) pd_entry; struct pf_state *pd_st; struct mbuf *pd_m; +#ifdef __FreeBSD__ + struct callout pd_tmo; +#else struct timeout pd_tmo; +#endif }; TAILQ_HEAD(pfsync_deferrals, pfsync_deferral); #define PFSYNC_PLSIZE MAX(sizeof(struct pfsync_upd_req_item), \ sizeof(struct pfsync_deferral)) +#ifdef notyet int pfsync_out_tdb(struct tdb *, struct mbuf *, int); +#endif struct pfsync_softc { +#ifdef __FreeBSD__ + struct ifnet *sc_ifp; +#else struct ifnet sc_if; +#endif struct ifnet *sc_sync_if; +#ifdef __FreeBSD__ + uma_zone_t sc_pool; +#else struct pool sc_pool; +#endif struct ip_moptions sc_imo; @@ -201,29 +270,77 @@ struct pfsync_softc { u_int32_t sc_ureq_sent; int sc_bulk_tries; +#ifdef __FreeBSD__ + struct callout sc_bulkfail_tmo; +#else struct timeout sc_bulkfail_tmo; +#endif u_int32_t sc_ureq_received; struct pf_state *sc_bulk_next; struct pf_state *sc_bulk_last; +#ifdef __FreeBSD__ + struct callout sc_bulk_tmo; +#else struct timeout sc_bulk_tmo; +#endif TAILQ_HEAD(, tdb) sc_tdb_q; +#ifdef __FreeBSD__ + struct callout sc_tmo; +#else struct timeout sc_tmo; +#endif +#ifdef __FreeBSD__ + eventhandler_tag sc_detachtag; +#endif + }; struct pfsync_softc *pfsyncif = NULL; struct pfsyncstats pfsyncstats; +#ifdef __FreeBSD__ +#ifdef notyet +SYSCTL_DECL(_net_inet_pfsync); +SYSCTL_STRUCT(_net_inet_pfsync, 0, stats, CTLFLAG_RW, + &pfsyncstats, pfsyncstats, + "PFSYNC statistics (struct pfsyncstats, net/if_pfsync.h)"); +#endif + +/* Macros to set/clear/test flags. */ +#ifdef _KERNEL +#define SET(t, f) ((t) |= (f)) +#define CLR(t, f) ((t) &= ~(f)) +#define ISSET(t, f) ((t) & (f)) +#endif + +static void pfsyncintr(void *); +struct pfsync_swi { + void * pfsync_swi_cookie; +}; +static struct pfsync_swi pfsync_swi; +#define schednetisr(p) swi_sched(pfsync_swi.pfsync_swi_cookie, 0) +#define NETISR_PFSYNC +#endif void pfsyncattach(int); +#ifdef __FreeBSD__ +int pfsync_clone_create(struct if_clone *, int, caddr_t); +void pfsync_clone_destroy(struct ifnet *); +#else int pfsync_clone_create(struct if_clone *, int); int pfsync_clone_destroy(struct ifnet *); +#endif int pfsync_alloc_scrub_memory(struct pfsync_state_peer *, struct pf_state_peer *); void pfsync_update_net_tdb(struct pfsync_tdb *); int pfsyncoutput(struct ifnet *, struct mbuf *, struct sockaddr *, +#ifdef __FreeBSD__ + struct route *); +#else struct rtentry *); +#endif int pfsyncioctl(struct ifnet *, u_long, caddr_t); void pfsyncstart(struct ifnet *); @@ -251,11 +368,23 @@ void pfsync_bulk_status(u_int8_t); void pfsync_bulk_update(void *); void pfsync_bulk_fail(void *); +#ifdef __FreeBSD__ +void pfsync_ifdetach(void *, struct ifnet *); + +/* XXX: ugly */ +#define betoh64 (unsigned long long)be64toh +#define timeout_del callout_stop +#endif + #define PFSYNC_MAX_BULKTRIES 12 int pfsync_sync_ok; +#ifdef __FreeBSD__ +IFC_SIMPLE_DECLARE(pfsync, 1); +#else struct if_clone pfsync_cloner = IF_CLONE_INITIALIZER("pfsync", pfsync_clone_create, pfsync_clone_destroy); +#endif void pfsyncattach(int npfsync) @@ -263,7 +392,11 @@ pfsyncattach(int npfsync) if_clone_attach(&pfsync_cloner); } int +#ifdef __FreeBSD__ +pfsync_clone_create(struct if_clone *ifc, int unit, caddr_t param) +#else pfsync_clone_create(struct if_clone *ifc, int unit) +#endif { struct pfsync_softc *sc; struct ifnet *ifp; @@ -274,14 +407,23 @@ pfsync_clone_create(struct if_clone *ifc pfsync_sync_ok = 1; - sc = malloc(sizeof(*pfsyncif), M_DEVBUF, M_NOWAIT | M_ZERO); + sc = malloc(sizeof(struct pfsync_softc), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc == NULL) return (ENOMEM); for (q = 0; q < PFSYNC_S_COUNT; q++) TAILQ_INIT(&sc->sc_qs[q]); +#ifdef __FreeBSD__ + sc->sc_pool = uma_zcreate("pfsync", PFSYNC_PLSIZE, + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); + if (sc->sc_pool == NULL) { + free(sc, M_DEVBUF); + return (ENOMEM); + } +#else pool_init(&sc->sc_pool, PFSYNC_PLSIZE, 0, 0, 0, "pfsync", NULL); +#endif TAILQ_INIT(&sc->sc_upd_req_list); TAILQ_INIT(&sc->sc_deferrals); sc->sc_deferred = 0; @@ -291,13 +433,42 @@ pfsync_clone_create(struct if_clone *ifc sc->sc_len = PFSYNC_MINPKT; sc->sc_maxupdates = 128; +#ifdef __FreeBSD__ + sc->sc_imo.imo_membership = (struct in_multi **)malloc( + (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_DEVBUF, + M_NOWAIT | M_ZERO); + sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; + sc->sc_imo.imo_multicast_vif = -1; +#else sc->sc_imo.imo_membership = (struct in_multi **)malloc( (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS, M_WAITOK | M_ZERO); sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; +#endif +#ifdef __FreeBSD__ + ifp = sc->sc_ifp = if_alloc(IFT_PFSYNC); + if (ifp == NULL) { + free(sc->sc_imo.imo_membership, M_DEVBUF); + uma_zdestroy(sc->sc_pool); + free(sc, M_DEVBUF); + return (ENOSPC); + } + if_initname(ifp, ifc->ifc_name, unit); + + sc->sc_detachtag = EVENTHANDLER_REGISTER(ifnet_departure_event, + pfsync_ifdetach, pfsyncif, EVENTHANDLER_PRI_ANY); + if (sc->sc_detachtag == NULL) { + if_free(ifp); + free(sc->sc_imo.imo_membership, M_DEVBUF); + uma_zdestroy(sc->sc_pool); + free(sc, M_DEVBUF); + return (ENOSPC); + } +#else ifp = &sc->sc_if; snprintf(ifp->if_xname, sizeof ifp->if_xname, "pfsync%d", unit); +#endif ifp->if_softc = sc; ifp->if_ioctl = pfsyncioctl; ifp->if_output = pfsyncoutput; @@ -306,38 +477,59 @@ pfsync_clone_create(struct if_clone *ifc ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_hdrlen = sizeof(struct pfsync_header); ifp->if_mtu = 1500; /* XXX */ +#ifdef __FreeBSD__ + callout_init(&sc->sc_tmo, CALLOUT_MPSAFE); + callout_init(&sc->sc_bulk_tmo, CALLOUT_MPSAFE); + callout_init(&sc->sc_bulkfail_tmo, CALLOUT_MPSAFE); +#else ifp->if_hardmtu = MCLBYTES; /* XXX */ timeout_set(&sc->sc_tmo, pfsync_timeout, sc); timeout_set(&sc->sc_bulk_tmo, pfsync_bulk_update, sc); timeout_set(&sc->sc_bulkfail_tmo, pfsync_bulk_fail, sc); +#endif if_attach(ifp); +#ifndef __FreeBSD__ if_alloc_sadl(ifp); +#endif #if NCARP > 0 if_addgroup(ifp, "carp"); #endif #if NBPFILTER > 0 +#ifdef __FreeBSD__ + bpfattach(ifp, DLT_PFSYNC, PFSYNC_HDRLEN); +#else bpfattach(&sc->sc_if.if_bpf, ifp, DLT_PFSYNC, PFSYNC_HDRLEN); #endif +#endif pfsyncif = sc; return (0); } +#ifdef __FreeBSD__ +void +#else int +#endif pfsync_clone_destroy(struct ifnet *ifp) { struct pfsync_softc *sc = ifp->if_softc; +#ifdef __FreeBSD__ + EVENTHANDLER_DEREGISTER(ifnet_departure_event, sc->sc_detachtag); +#endif timeout_del(&sc->sc_bulk_tmo); timeout_del(&sc->sc_tmo); #if NCARP > 0 +#ifdef notyet if (!pfsync_sync_ok) carp_group_demote_adj(&sc->sc_if, -1); #endif +#endif #if NBPFILTER > 0 bpfdetach(ifp); #endif @@ -348,24 +540,44 @@ pfsync_clone_destroy(struct ifnet *ifp) while (sc->sc_deferred > 0) pfsync_undefer(TAILQ_FIRST(&sc->sc_deferrals), 0); +#ifdef __FreeBSD__ + UMA_DESTROY(sc->sc_pool); +#else pool_destroy(&sc->sc_pool); +#endif +#ifdef __FreeBSD__ + if_free(ifp); + free(sc->sc_imo.imo_membership, M_DEVBUF); +#else free(sc->sc_imo.imo_membership, M_IPMOPTS); +#endif free(sc, M_DEVBUF); pfsyncif = NULL; +#ifndef __FreeBSD__ return (0); +#endif } struct mbuf * pfsync_if_dequeue(struct ifnet *ifp) { struct mbuf *m; +#ifndef __FreeBSD__ int s; +#endif +#ifdef __FreeBSD__ + IF_LOCK(&ifp->if_snd); + _IF_DROP(&ifp->if_snd); + _IF_DEQUEUE(&ifp->if_snd, m); + IF_UNLOCK(&ifp->if_snd); +#else s = splnet(); IF_DEQUEUE(&ifp->if_snd, m); splx(s); +#endif return (m); } @@ -379,7 +591,9 @@ pfsyncstart(struct ifnet *ifp) struct mbuf *m; while ((m = pfsync_if_dequeue(ifp)) != NULL) { +#ifndef __FreeBSD__ IF_DROP(&ifp->if_snd); +#endif m_freem(m); } } @@ -397,6 +611,7 @@ pfsync_alloc_scrub_memory(struct pfsync_ return (0); } +#ifndef __FreeBSD__ void pfsync_state_export(struct pfsync_state *sp, struct pf_state *st) { @@ -457,6 +672,7 @@ pfsync_state_export(struct pfsync_state pf_state_counter_hton(st->bytes[1], sp->bytes[1]); } +#endif int pfsync_state_import(struct pfsync_state *sp, u_int8_t flags) @@ -498,10 +714,17 @@ pfsync_state_import(struct pfsync_state if ((r->max_states && r->states_cur >= r->max_states)) goto cleanup; +#ifdef __FreeBSD__ + if (flags & PFSYNC_SI_IOCTL) + pool_flags = PR_WAITOK | PR_ZERO; + else + pool_flags = PR_ZERO; +#else if (flags & PFSYNC_SI_IOCTL) pool_flags = PR_WAITOK | PR_LIMITFAIL | PR_ZERO; else pool_flags = PR_LIMITFAIL | PR_ZERO; +#endif if ((st = pool_get(&pf_state_pl, pool_flags)) == NULL) goto cleanup; @@ -614,7 +837,11 @@ pfsync_state_import(struct pfsync_state } void +#ifdef __FreeBSD__ +pfsync_input(struct mbuf *m, __unused int off) +#else pfsync_input(struct mbuf *m, ...) +#endif { struct pfsync_softc *sc = pfsyncif; struct pfsync_pkt pkt; @@ -637,9 +864,13 @@ pfsync_input(struct mbuf *m, ...) goto done; } +#ifdef __FreeBSD__ + sc->sc_ifp->if_ipackets++; + sc->sc_ifp->if_ibytes += m->m_pkthdr.len; +#else sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += m->m_pkthdr.len; - +#endif /* verify that the IP TTL is 255. */ if (ip->ip_ttl != PFSYNC_DFLTTL) { pfsyncstats.pfsyncs_badttl++; @@ -726,6 +957,9 @@ pfsync_in_clr(struct pfsync_pkt *pkt, st clr = (struct pfsync_clr *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) { creatorid = clr[i].creatorid; @@ -757,6 +991,9 @@ pfsync_in_clr(struct pfsync_pkt *pkt, st } } } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); return (len); @@ -780,6 +1017,9 @@ pfsync_in_ins(struct pfsync_pkt *pkt, st sa = (struct pfsync_state *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) { sp = &sa[i]; @@ -802,6 +1042,9 @@ pfsync_in_ins(struct pfsync_pkt *pkt, st break; } } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); return (len); @@ -827,6 +1070,9 @@ pfsync_in_iack(struct pfsync_pkt *pkt, s iaa = (struct pfsync_ins_ack *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) { ia = &iaa[i]; @@ -840,6 +1086,9 @@ pfsync_in_iack(struct pfsync_pkt *pkt, s if (ISSET(st->state_flags, PFSTATE_ACK)) pfsync_deferred(st, 0); } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); /* * XXX this is not yet implemented, but we know the size of the @@ -905,6 +1154,9 @@ pfsync_in_upd(struct pfsync_pkt *pkt, st sa = (struct pfsync_state *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) { sp = &sa[i]; @@ -970,6 +1222,9 @@ pfsync_in_upd(struct pfsync_pkt *pkt, st st->timeout = sp->timeout; st->pfsync_time = time_second; } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); return (len); @@ -998,6 +1253,9 @@ pfsync_in_upd_c(struct pfsync_pkt *pkt, ua = (struct pfsync_upd_c *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) { up = &ua[i]; @@ -1062,6 +1320,9 @@ pfsync_in_upd_c(struct pfsync_pkt *pkt, st->timeout = up->timeout; st->pfsync_time = time_second; } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); return (len); @@ -1128,6 +1389,9 @@ pfsync_in_del(struct pfsync_pkt *pkt, st sa = (struct pfsync_state *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) { sp = &sa[i]; @@ -1142,6 +1406,9 @@ pfsync_in_del(struct pfsync_pkt *pkt, st SET(st->state_flags, PFSTATE_NOSYNC); pf_unlink_state(st); } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); return (len); @@ -1166,6 +1433,9 @@ pfsync_in_del_c(struct pfsync_pkt *pkt, sa = (struct pfsync_del_c *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) { sp = &sa[i]; @@ -1181,6 +1451,9 @@ pfsync_in_del_c(struct pfsync_pkt *pkt, SET(st->state_flags, PFSTATE_NOSYNC); pf_unlink_state(st); } +#ifdef __FreeBSD__ + PF_LOCK(); +#endif splx(s); return (len); @@ -1208,8 +1481,13 @@ pfsync_in_bus(struct pfsync_pkt *pkt, st switch (bus->status) { case PFSYNC_BUS_START: +#ifdef __FreeBSD__ + callout_reset(&sc->sc_bulkfail_tmo, 5 * hz, pfsync_bulk_fail, + pfsyncif); +#else timeout_add_sec(&sc->sc_bulkfail_tmo, 5); /* XXX magic */ -#if XXX +#endif +#ifdef XXX pf_pool_limits[PF_LIMIT_STATES].limit / (PFSYNC_BULKPACKETS * sc->sc_maxcount)); #endif @@ -1225,9 +1503,11 @@ pfsync_in_bus(struct pfsync_pkt *pkt, st sc->sc_bulk_tries = 0; timeout_del(&sc->sc_bulkfail_tmo); #if NCARP > 0 +#ifdef notyet if (!pfsync_sync_ok) carp_group_demote_adj(&sc->sc_if, -1); #endif +#endif pfsync_sync_ok = 1; if (pf_status.debug >= PF_DEBUG_MISC) printf("pfsync: received valid " @@ -1263,8 +1543,14 @@ pfsync_in_tdb(struct pfsync_pkt *pkt, st tp = (struct pfsync_tdb *)(mp->m_data + offp); s = splsoftnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif for (i = 0; i < count; i++) pfsync_update_net_tdb(&tp[i]); +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); #endif @@ -1337,7 +1623,11 @@ pfsync_in_error(struct pfsync_pkt *pkt, int pfsyncoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +#ifdef __FreeBSD__ + struct route *rt) +#else struct rtentry *rt) +#endif { m_freem(m); return (0); @@ -1347,7 +1637,9 @@ pfsyncoutput(struct ifnet *ifp, struct m int pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { +#ifndef __FreeBSD__ struct proc *p = curproc; +#endif struct pfsync_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct ip_moptions *imo = &sc->sc_imo; @@ -1363,10 +1655,17 @@ pfsyncioctl(struct ifnet *ifp, u_long cm case SIOCSIFDSTADDR: #endif case SIOCSIFFLAGS: +#ifdef __FreeBSD__ + if (ifp->if_flags & IFF_UP) + ifp->if_drv_flags |= IFF_DRV_RUNNING; + else + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; +#else if (ifp->if_flags & IFF_UP) ifp->if_flags |= IFF_RUNNING; else ifp->if_flags &= ~IFF_RUNNING; +#endif break; case SIOCSIFMTU: if (ifr->ifr_mtu <= PFSYNC_MINPKT) @@ -1375,7 +1674,13 @@ pfsyncioctl(struct ifnet *ifp, u_long cm ifr->ifr_mtu = MCLBYTES; if (ifr->ifr_mtu < ifp->if_mtu) { s = splnet(); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif pfsync_sendout(); +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); } ifp->if_mtu = ifr->ifr_mtu; @@ -1391,23 +1696,44 @@ pfsyncioctl(struct ifnet *ifp, u_long cm return (copyout(&pfsyncr, ifr->ifr_data, sizeof(pfsyncr))); case SIOCSETPFSYNC: +#ifdef __FreeBSD__ + if ((error = priv_check(curthread, PRIV_NETINET_PF)) != 0) +#else if ((error = suser(p, p->p_acflag)) != 0) +#endif return (error); if ((error = copyin(ifr->ifr_data, &pfsyncr, sizeof(pfsyncr)))) return (error); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif if (pfsyncr.pfsyncr_syncpeer.s_addr == 0) +#ifdef __FreeBSD__ + sc->sc_sync_peer.s_addr = htonl(INADDR_PFSYNC_GROUP); +#else sc->sc_sync_peer.s_addr = INADDR_PFSYNC_GROUP; +#endif else sc->sc_sync_peer.s_addr = pfsyncr.pfsyncr_syncpeer.s_addr; if (pfsyncr.pfsyncr_maxupdates > 255) +#ifdef __FreeBSD__ + { + PF_UNLOCK(); +#endif return (EINVAL); +#ifdef __FreeBSD__ + } +#endif sc->sc_maxupdates = pfsyncr.pfsyncr_maxupdates; if (pfsyncr.pfsyncr_syncdev[0] == 0) { sc->sc_sync_if = NULL; +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif if (imo->imo_num_memberships > 0) { in_delmulti(imo->imo_membership[ --imo->imo_num_memberships]); @@ -1416,11 +1742,21 @@ pfsyncioctl(struct ifnet *ifp, u_long cm break; } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif if ((sifp = ifunit(pfsyncr.pfsyncr_syncdev)) == NULL) return (EINVAL); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif s = splnet(); +#ifdef __FreeBSD__ + if (sifp->if_mtu < sc->sc_ifp->if_mtu || +#else if (sifp->if_mtu < sc->sc_if.if_mtu || +#endif (sc->sc_sync_if != NULL && sifp->if_mtu < sc->sc_sync_if->if_mtu) || sifp->if_mtu < MCLBYTES - sizeof(struct ip)) @@ -1428,28 +1764,51 @@ pfsyncioctl(struct ifnet *ifp, u_long cm sc->sc_sync_if = sifp; if (imo->imo_num_memberships > 0) { +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif in_delmulti(imo->imo_membership[--imo->imo_num_memberships]); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif imo->imo_multicast_ifp = NULL; } if (sc->sc_sync_if && +#ifdef __FreeBSD__ + sc->sc_sync_peer.s_addr == htonl(INADDR_PFSYNC_GROUP)) { +#else sc->sc_sync_peer.s_addr == INADDR_PFSYNC_GROUP) { +#endif struct in_addr addr; if (!(sc->sc_sync_if->if_flags & IFF_MULTICAST)) { sc->sc_sync_if = NULL; +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); return (EADDRNOTAVAIL); } +#ifdef __FreeBSD__ + addr.s_addr = htonl(INADDR_PFSYNC_GROUP); +#else addr.s_addr = INADDR_PFSYNC_GROUP; +#endif +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif if ((imo->imo_membership[0] = in_addmulti(&addr, sc->sc_sync_if)) == NULL) { sc->sc_sync_if = NULL; splx(s); return (ENOBUFS); } +#ifdef __FreeBSD__ + PF_LOCK(); +#endif imo->imo_num_memberships++; imo->imo_multicast_ifp = sc->sc_sync_if; imo->imo_multicast_ttl = PFSYNC_DFLTTL; @@ -1472,15 +1831,25 @@ pfsyncioctl(struct ifnet *ifp, u_long cm /* Request a full state table update. */ sc->sc_ureq_sent = time_uptime; #if NCARP > 0 +#ifdef notyet if (pfsync_sync_ok) carp_group_demote_adj(&sc->sc_if, 1); #endif +#endif pfsync_sync_ok = 0; if (pf_status.debug >= PF_DEBUG_MISC) printf("pfsync: requesting bulk update\n"); +#ifdef __FreeBSD__ + callout_reset(&sc->sc_bulkfail_tmo, 5 * hz, + pfsync_bulk_fail, pfsyncif); +#else timeout_add_sec(&sc->sc_bulkfail_tmo, 5); +#endif pfsync_request_update(0, 0); } +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif splx(s); break; @@ -1554,7 +1923,9 @@ pfsync_drop(struct pfsync_softc *sc) { struct pf_state *st; struct pfsync_upd_req_item *ur; +#ifdef notyet struct tdb *t; +#endif int q; for (q = 0; q < PFSYNC_S_COUNT; q++) { @@ -1563,8 +1934,14 @@ pfsync_drop(struct pfsync_softc *sc) TAILQ_FOREACH(st, &sc->sc_qs[q], sync_list) { #ifdef PFSYNC_DEBUG +#ifdef __FreeBSD__ + KASSERT(st->sync_state == q, + ("%s: st->sync_state == q", + __FUNCTION__)); +#else KASSERT(st->sync_state == q); #endif +#endif st->sync_state = PFSYNC_S_NONE; } TAILQ_INIT(&sc->sc_qs[q]); @@ -1577,12 +1954,14 @@ pfsync_drop(struct pfsync_softc *sc) sc->sc_plus = NULL; +#ifdef notyet if (!TAILQ_EMPTY(&sc->sc_tdb_q)) { TAILQ_FOREACH(t, &sc->sc_tdb_q, tdb_sync_entry) CLR(t->tdb_flags, TDBF_PFSYNC); TAILQ_INIT(&sc->sc_tdb_q); } +#endif sc->sc_len = PFSYNC_MINPKT; } @@ -1592,20 +1971,32 @@ pfsync_sendout(void) { struct pfsync_softc *sc = pfsyncif; #if NBPFILTER > 0 +#ifdef __FreeBSD__ + struct ifnet *ifp = sc->sc_ifp; +#else struct ifnet *ifp = &sc->sc_if; #endif struct mbuf *m; +#endif struct ip *ip; struct pfsync_header *ph; struct pfsync_subheader *subh; struct pf_state *st; struct pfsync_upd_req_item *ur; +#ifdef notyet struct tdb *t; - +#endif +#ifdef __FreeBSD__ + size_t pktlen; +#endif int offset; int q, count = 0; +#ifdef __FreeBSD__ + PF_ASSERT(MA_OWNED); +#else splassert(IPL_NET); +#endif if (sc == NULL || sc->sc_len == PFSYNC_MINPKT) return; @@ -1621,17 +2012,38 @@ pfsync_sendout(void) MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { +#ifdef __FreeBSD__ + sc->sc_ifp->if_oerrors++; +#else sc->sc_if.if_oerrors++; +#endif pfsyncstats.pfsyncs_onomem++; pfsync_drop(sc); return; } +#ifdef __FreeBSD__ + pktlen = max_linkhdr + sc->sc_len; + if (pktlen > MHLEN) { + /* Find the right pool to allocate from. */ + /* XXX: This is ugly. */ + m_cljget(m, M_DONTWAIT, pktlen <= MSIZE ? MSIZE : + pktlen <= MCLBYTES ? MCLBYTES : +#if MJUMPAGESIZE != MCLBYTES + pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE : +#endif + pktlen <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES); +#else if (max_linkhdr + sc->sc_len > MHLEN) { MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len); +#endif if (!ISSET(m->m_flags, M_EXT)) { m_free(m); +#ifdef __FreeBSD__ + sc->sc_ifp->if_oerrors++; +#else sc->sc_if.if_oerrors++; +#endif pfsyncstats.pfsyncs_onomem++; pfsync_drop(sc); return; @@ -1668,8 +2080,14 @@ pfsync_sendout(void) count = 0; TAILQ_FOREACH(st, &sc->sc_qs[q], sync_list) { #ifdef PFSYNC_DEBUG +#ifdef __FreeBSD__ + KASSERT(st->sync_state == q, + ("%s: st->sync_state == q", + __FUNCTION__)); +#else KASSERT(st->sync_state == q); #endif +#endif offset += pfsync_qs[q].write(st, m, offset); st->sync_state = PFSYNC_S_NONE; @@ -1712,6 +2130,7 @@ pfsync_sendout(void) sc->sc_plus = NULL; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 17:41:17 2009 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 170BE106566B; Sat, 10 Oct 2009 17:41:17 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 059E88FC12; Sat, 10 Oct 2009 17:41:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9AHfGpk088335; Sat, 10 Oct 2009 17:41:16 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9AHfGnt088331; Sat, 10 Oct 2009 17:41:16 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910101741.n9AHfGnt088331@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 17:41: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: r197936 - in user/eri/pf45/head/sys: contrib/pf/net i386/conf 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, 10 Oct 2009 17:41:17 -0000 Author: eri Date: Sat Oct 10 17:41:16 2009 New Revision: 197936 URL: http://svn.freebsd.org/changeset/base/197936 Log: * Make possible that pfsync(4) can be loaded as module. * Fix typos which unbreaks GENERIC builds. NOTE: As of now pf 4.5 is working on FreeBSD 8+. Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pfvar.h user/eri/pf45/head/sys/i386/conf/GENERIC Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 16:08:05 2009 (r197935) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 17:41:16 2009 (r197936) @@ -308,13 +308,6 @@ SYSCTL_STRUCT(_net_inet_pfsync, 0, stats "PFSYNC statistics (struct pfsyncstats, net/if_pfsync.h)"); #endif -/* Macros to set/clear/test flags. */ -#ifdef _KERNEL -#define SET(t, f) ((t) |= (f)) -#define CLR(t, f) ((t) &= ~(f)) -#define ISSET(t, f) ((t) & (f)) -#endif - static void pfsyncintr(void *); struct pfsync_swi { void * pfsync_swi_cookie; @@ -2604,7 +2597,7 @@ pfsync_q_ins(struct pf_state *st, int q) #ifdef __FreeBSD__ KASSERT(st->sync_state == PFSYNC_S_NONE, - ("%s: st->sync_state == PFSYNC_S_NONE" __FUNCITON__)); + ("%s: st->sync_state == PFSYNC_S_NONE", __FUNCTION__)); #else KASSERT(st->sync_state == PFSYNC_S_NONE); #endif @@ -2647,7 +2640,7 @@ pfsync_q_del(struct pf_state *st) #ifdef __FreeBSD__ KASSERT(st->sync_state != PFSYNC_S_NONE, - ("%s: st->sync_state != PFSYNC_S_NONE", __FUNCTION)); + ("%s: st->sync_state != PFSYNC_S_NONE", __FUNCTION__)); #else KASSERT(st->sync_state != PFSYNC_S_NONE); #endif @@ -3049,6 +3042,12 @@ pfsync_modevent(module_t mod, int type, panic("%s: swi_add %d", __func__, error); pfsync_state_import_ptr = pfsync_state_import; + pfsync_up_ptr = pfsync_up; + pfsync_insert_state_ptr = pfsync_insert_state; + pfsync_update_state_ptr = pfsync_update_state; + pfsync_delete_state_ptr = pfsync_delete_state; + pfsync_clear_states_ptr = pfsync_clear_states; + pfsync_defer_ptr = pfsync_defer; #endif break; case MOD_UNLOAD: @@ -3056,6 +3055,12 @@ pfsync_modevent(module_t mod, int type, swi_remove(pfsync_swi.pfsync_swi_cookie); pfsync_state_import_ptr = NULL; + pfsync_up_ptr = NULL; + pfsync_insert_state_ptr = NULL; + pfsync_update_state_ptr = NULL; + pfsync_delete_state_ptr = NULL; + pfsync_clear_states_ptr = NULL; + pfsync_defer_ptr = NULL; #endif if_clone_detach(&pfsync_cloner); break; Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 16:08:05 2009 (r197935) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 17:41:16 2009 (r197936) @@ -973,8 +973,13 @@ pf_state_insert(struct pfi_kif *kif, str pf_status.states++; pfi_kif_ref(kif, PFI_KIF_REF_STATE); #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_insert_state_ptr != NULL) + pfsync_insert_state_ptr(s); +#else pfsync_insert_state(s); #endif +#endif return (0); } @@ -1336,8 +1341,13 @@ pf_unlink_state(struct pf_state *cur) export_pflow(cur); #endif #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_delete_state_ptr != NULL) + pfsync_delete_state_ptr(cur); +#else pfsync_delete_state(cur); #endif +#endif cur->timeout = PFTM_UNLINKED; pf_src_tree_remove_state(cur); pf_detach_state(cur); @@ -3407,14 +3417,23 @@ pf_test_rule(struct pf_rule **rm, struct #if NPFSYNC > 0 if (*sm != NULL && !ISSET((*sm)->state_flags, PFSTATE_NOSYNC) && +#ifdef __FreeBSD__ + direction == PF_OUT && pfsync_up_ptr != NULL && pfsync_up_ptr()) { +#else direction == PF_OUT && pfsync_up()) { +#endif /* * We want the state created, but we dont * want to send this in case a partner * firewall has to know about it to allow * replies through it. */ +#ifdef __FreeBSD__ + if (pfsync_defer_ptr != NULL) + pfsync_defer(*sm, m); +#else if (pfsync_defer(*sm, m)) +#endif return (PF_DEFER); } #endif @@ -6293,7 +6312,12 @@ pf_test(int dir, struct ifnet *ifp, stru &reason); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; @@ -6328,7 +6352,12 @@ pf_test(int dir, struct ifnet *ifp, stru action = pf_test_state_udp(&s, dir, kif, m, off, h, &pd); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; @@ -6357,7 +6386,12 @@ pf_test(int dir, struct ifnet *ifp, stru &reason); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; @@ -6386,7 +6420,12 @@ pf_test(int dir, struct ifnet *ifp, stru action = pf_test_state_other(&s, dir, kif, m, &pd); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; @@ -6761,7 +6800,12 @@ pf_test6(int dir, struct ifnet *ifp, str &reason); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; @@ -6796,7 +6840,12 @@ pf_test6(int dir, struct ifnet *ifp, str action = pf_test_state_udp(&s, dir, kif, m, off, h, &pd); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; @@ -6832,7 +6881,12 @@ pf_test6(int dir, struct ifnet *ifp, str m, off, h, &pd, &reason); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; @@ -6852,7 +6906,12 @@ pf_test6(int dir, struct ifnet *ifp, str action = pf_test_state_other(&s, dir, kif, m, &pd); if (action == PF_PASS) { #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_update_state_ptr != NULL) + pfsync_update_state_ptr(s); +#else pfsync_update_state(s); +#endif #endif /* NPFSYNC */ r = s->rule.ptr; a = s->anchor.ptr; Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 16:08:05 2009 (r197935) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 17:41:16 2009 (r197936) @@ -250,7 +250,13 @@ static struct cdevsw pf_cdevsw = { int pf_end_threads = 0; struct mtx pf_task_mtx; #ifdef __FreeBSD__ - pfsync_state_import_t *pfsync_state_import_ptr = NULL; + pfsync_state_import_t *pfsync_state_import_ptr = NULL; + pfsync_up_t *pfsync_up_ptr = NULL; + pfsync_insert_state_t *pfsync_insert_state_ptr = NULL; + pfsync_update_state_t *pfsync_update_state_ptr = NULL; + pfsync_delete_state_t *pfsync_delete_state_ptr = NULL; + pfsync_clear_states_t *pfsync_clear_states_ptr = NULL; + pfsync_defer_t *pfsync_defer_ptr = NULL; #if NPFLOG >0 pflog_packet_t *pflog_packet_ptr = NULL; #endif @@ -1991,8 +1997,13 @@ pfioctl(dev_t dev, u_long cmd, caddr_t a } psk->psk_killed = killed; #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_clear_states_ptr != NULL) + pfsync_clear_states_ptr(pf_status.hostid, psk->psk_ifname); +#else pfsync_clear_states(pf_status.hostid, psk->psk_ifname); #endif +#endif break; } @@ -2072,7 +2083,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t a } #ifdef __FreeBSD__ if (pfsync_state_import_ptr != NULL) - pfsync_state_import_ptr(sp, PFSYNC_SI_IOCTL); + error = pfsync_state_import_ptr(sp, PFSYNC_SI_IOCTL); #else error = pfsync_state_import(sp, PFSYNC_SI_IOCTL); #endif @@ -3526,7 +3537,7 @@ pfsync_state_export(struct pfsync_state state->timeout = PFTM_PURGE; #if NPFSYNC /* don't send out individual delete messages */ - state->sync_flags = PFSTATE_NOSYNC; + state->state_flags = PFSTATE_NOSYNC; #endif pf_unlink_state(state); } Modified: user/eri/pf45/head/sys/contrib/pf/net/pfvar.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Sat Oct 10 16:08:05 2009 (r197935) +++ user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Sat Oct 10 17:41:16 2009 (r197936) @@ -828,7 +828,7 @@ struct pf_state { u_int8_t direction; #ifdef __FreeBSD__ u_int8_t pad[2]; - u_int8_t local_flags; + u_int8_t local_flags; #define PFSTATE_EXPIRING 0x01 #else u_int8_t pad[3]; @@ -930,9 +930,30 @@ struct pfsync_state { #ifdef __FreeBSD__ typedef int pfsync_state_import_t(struct pfsync_state *, u_int8_t); -extern pfsync_state_import_t *pfsync_state_import_ptr; +typedef int pfsync_up_t(void); +typedef void pfsync_insert_state_t(struct pf_state *); +typedef void pfsync_update_state_t(struct pf_state *); +typedef void pfsync_delete_state_t(struct pf_state *); +typedef void pfsync_clear_states_t(u_int32_t, const char *); +typedef int pfsync_defer_t(struct pf_state *, struct mbuf *); + +extern pfsync_state_import_t *pfsync_state_import_ptr; +extern pfsync_up_t *pfsync_up_ptr; +extern pfsync_insert_state_t *pfsync_insert_state_ptr; +extern pfsync_update_state_t *pfsync_update_state_ptr; +extern pfsync_delete_state_t *pfsync_delete_state_ptr; +extern pfsync_clear_states_t *pfsync_clear_states_ptr; +extern pfsync_defer_t *pfsync_defer_ptr; + void pfsync_state_export(struct pfsync_state *, struct pf_state *); + +/* Macros to set/clear/test flags. */ +#ifdef _KERNEL +#define SET(t, f) ((t) |= (f)) +#define CLR(t, f) ((t) &= ~(f)) +#define ISSET(t, f) ((t) & (f)) +#endif #endif #define PFSYNC_FLAG_SRCNODE 0x04 Modified: user/eri/pf45/head/sys/i386/conf/GENERIC ============================================================================== --- user/eri/pf45/head/sys/i386/conf/GENERIC Sat Oct 10 16:08:05 2009 (r197935) +++ user/eri/pf45/head/sys/i386/conf/GENERIC Sat Oct 10 17:41:16 2009 (r197936) @@ -97,8 +97,6 @@ device acpi device eisa device pci -device pfsync - # Floppy drives device fdc From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 17:56:19 2009 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 62B39106568F; Sat, 10 Oct 2009 17:56:19 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 38CA08FC17; Sat, 10 Oct 2009 17:56:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9AHuJw0088653; Sat, 10 Oct 2009 17:56:19 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9AHuJov088649; Sat, 10 Oct 2009 17:56:19 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910101756.n9AHuJov088649@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 17:56:19 +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: r197937 - in user/eri/pf45/head/sys: contrib/pf/net modules/pf 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, 10 Oct 2009 17:56:19 -0000 Author: eri Date: Sat Oct 10 17:56:18 2009 New Revision: 197937 URL: http://svn.freebsd.org/changeset/base/197937 Log: pfsync(4) can be loaded at runtime. Remove leftovers notyet defines for pfsync(4). Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/modules/pf/Makefile Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 17:41:16 2009 (r197936) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 17:56:18 2009 (r197937) @@ -3497,9 +3497,7 @@ pf_create_state(struct pf_rule *r, struc if (r->rule_flag & PFRULE_PFLOW) s->state_flags |= PFSTATE_PFLOW; s->log = r->log & PF_LOG_ALL; -#ifdef notyet s->sync_state = PFSYNC_S_NONE; -#endif if (nr != NULL) s->log |= nr->log & PF_LOG_ALL; switch (pd->proto) { Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 17:41:16 2009 (r197936) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 17:56:18 2009 (r197937) @@ -115,13 +115,9 @@ __FBSDID("$FreeBSD$"); #endif #include -#ifdef __FreeBSD__ -#include -#else #if NPFSYNC > 0 #include #endif /* NPFSYNC > 0 */ -#endif #if NPFLOG > 0 #include @@ -3537,7 +3533,7 @@ pfsync_state_export(struct pfsync_state state->timeout = PFTM_PURGE; #if NPFSYNC /* don't send out individual delete messages */ - state->state_flags = PFSTATE_NOSYNC; + state->sync_state = PFSTATE_NOSYNC; #endif pf_unlink_state(state); } Modified: user/eri/pf45/head/sys/modules/pf/Makefile ============================================================================== --- user/eri/pf45/head/sys/modules/pf/Makefile Sat Oct 10 17:41:16 2009 (r197936) +++ user/eri/pf45/head/sys/modules/pf/Makefile Sat Oct 10 17:56:18 2009 (r197937) @@ -26,9 +26,12 @@ opt_bpf.h: echo "#define DEV_BPF 1" > ${.TARGET} # pflog can be loaded as a module, have the additional checks turned on +# pfsync can be loaded as a module, have the additional checks turned on opt_pf.h: echo "#define DEV_PF 1" > ${.TARGET} echo "#define DEV_PFLOG 1" >> ${.TARGET} + echo "#define DEV_PFSYNC 1" >> ${.TARGET} + .endif .include From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 19:54:45 2009 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 E4F09106566B; Sat, 10 Oct 2009 19:54:45 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D2BFB8FC08; Sat, 10 Oct 2009 19:54:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9AJsjDa090809; Sat, 10 Oct 2009 19:54:45 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9AJsjmA090800; Sat, 10 Oct 2009 19:54:45 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910101954.n9AJsjmA090800@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 19:54:45 +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: r197939 - in user/eri/pf45/head/sys: contrib/pf/net modules/pflow net 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, 10 Oct 2009 19:54:46 -0000 Author: eri Date: Sat Oct 10 19:54:45 2009 New Revision: 197939 URL: http://svn.freebsd.org/changeset/base/197939 Log: * Make pflow(4) compile. TODO: Add locking to it. Added: user/eri/pf45/head/sys/modules/pflow/ user/eri/pf45/head/sys/modules/pflow/Makefile (contents, props changed) Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pfvar.h user/eri/pf45/head/sys/net/if_types.h Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c Sat Oct 10 18:24:54 2009 (r197938) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c Sat Oct 10 19:54:45 2009 (r197939) @@ -17,17 +17,50 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef __FreeBSD__ +#include "opt_inet.h" +#include "opt_inet6.h" +#include "opt_bpf.h" +#include "opt_pf.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef DEV_BPF +#define NBPFILTER DEV_BPF +#else +#define NBPFILTER 0 +#endif + +#endif /* __FreeBSD__ */ + #include +#ifdef __FreeBSD__ +#include +#endif #include #include #include #include +#ifdef __FreeBSD__ +#include +#include +#include +#include +#include +#else #include +#endif #include #include +#ifndef __FreeBSD__ #include +#endif #include +#ifdef __FreeBSD__ +#include +#endif #include #include #include @@ -49,9 +82,14 @@ #include #include +#ifndef __FreeBSD__ #include "bpfilter.h" #include "pflow.h" +#endif +#ifdef __FreeBSD__ +#include +#endif #define PFLOW_MINMTU \ (sizeof(struct pflow_header) + sizeof(struct pflow_flow)) @@ -65,11 +103,20 @@ SLIST_HEAD(, pflow_softc) pflowif_list; struct pflowstats pflowstats; void pflowattach(int); +#ifdef __FreeBSD__ +int pflow_clone_create(struct if_clone *, int, caddr_t); +void pflow_clone_destroy(struct ifnet *); +#else int pflow_clone_create(struct if_clone *, int); int pflow_clone_destroy(struct ifnet *); +#endif void pflow_setmtu(struct pflow_softc *, int); int pflowoutput(struct ifnet *, struct mbuf *, struct sockaddr *, +#ifdef __FreeBSD__ + struct route *); +#else struct rtentry *); +#endif int pflowioctl(struct ifnet *, u_long, caddr_t); void pflowstart(struct ifnet *); @@ -84,16 +131,22 @@ int pflow_get_dynport(void); int export_pflow_if(struct pf_state*, struct pflow_softc *); int copy_flow_to_m(struct pflow_flow *flow, struct pflow_softc *sc); +#ifdef __FreeBSD__ +IFC_SIMPLE_DECLARE(pflow, 1); +#else struct if_clone pflow_cloner = IF_CLONE_INITIALIZER("pflow", pflow_clone_create, pflow_clone_destroy); +#endif +#ifndef __FreeBSD__ /* from in_pcb.c */ extern int ipport_hifirstauto; extern int ipport_hilastauto; /* from kern/kern_clock.c; incremented each clock tick. */ extern int ticks; +#endif void pflowattach(int npflow) @@ -103,7 +156,11 @@ pflowattach(int npflow) } int +#ifdef __FreeBSD__ +pflow_clone_create(struct if_clone *ifc, int unit, caddr_t param) +#else pflow_clone_create(struct if_clone *ifc, int unit) +#endif { struct ifnet *ifp; struct pflow_softc *pflowif; @@ -115,16 +172,33 @@ pflow_clone_create(struct if_clone *ifc, pflowif->sc_sender_ip.s_addr = INADDR_ANY; pflowif->sc_sender_port = pflow_get_dynport(); +#ifdef __FreeBSD__ + pflowif->sc_imo.imo_membership = (struct in_multi **)malloc( + (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_DEVBUF, + M_NOWAIT | M_ZERO); + pflowif->sc_imo.imo_multicast_vif = -1; +#else pflowif->sc_imo.imo_membership = malloc( (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS, M_WAITOK|M_ZERO); +#endif pflowif->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; pflowif->sc_receiver_ip.s_addr = 0; pflowif->sc_receiver_port = 0; pflowif->sc_sender_ip.s_addr = INADDR_ANY; pflowif->sc_sender_port = pflow_get_dynport(); +#ifdef __FreeBSD__ + ifp = pflowif->sc_ifp = if_alloc(IFT_PFLOW); + if (ifp == NULL) { + free(pflowif->sc_imo.imo_membership, M_DEVBUF); + free(pflowif, M_DEVBUF); + return (ENOSPC); + } + if_initname(ifp, ifc->ifc_name, unit); +#else ifp = &pflowif->sc_if; snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflow%d", unit); +#endif ifp->if_softc = pflowif; ifp->if_ioctl = pflowioctl; ifp->if_output = pflowoutput; @@ -133,22 +207,39 @@ pflow_clone_create(struct if_clone *ifc, ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_hdrlen = PFLOW_HDRLEN; ifp->if_flags = IFF_UP; +#ifdef __FreeBSD__ + ifp->if_flags &= ~IFF_DRV_RUNNING; +#else ifp->if_flags &= ~IFF_RUNNING; /* not running, need receiver */ +#endif pflow_setmtu(pflowif, ETHERMTU); +#ifdef __FreeBSD__ + callout_init(&pflowif->sc_tmo, CALLOUT_MPSAFE); +#else timeout_set(&pflowif->sc_tmo, pflow_timeout, pflowif); +#endif if_attach(ifp); +#ifndef __FreeBSD__ if_alloc_sadl(ifp); +#endif #if NBPFILTER > 0 +#ifdef __FreeBSD__ + bpfattach(ifp, DLT_RAW, 0); +#else bpfattach(&pflowif->sc_if.if_bpf, ifp, DLT_RAW, 0); #endif - +#endif /* Insert into list of pflows */ SLIST_INSERT_HEAD(&pflowif_list, pflowif, sc_next); return (0); } +#ifdef __FreeBSD__ +void +#else int +#endif pflow_clone_destroy(struct ifnet *ifp) { struct pflow_softc *sc = ifp->if_softc; @@ -161,10 +252,16 @@ pflow_clone_destroy(struct ifnet *ifp) #endif if_detach(ifp); SLIST_REMOVE(&pflowif_list, sc, pflow_softc, sc_next); +#ifdef __FreeBSD__ + free(sc->sc_imo.imo_membership, M_DEVBUF); +#else free(sc->sc_imo.imo_membership, M_IPMOPTS); +#endif free(sc, M_DEVBUF); splx(s); +#ifndef __FreeBSD__ return (0); +#endif } /* @@ -178,8 +275,17 @@ pflowstart(struct ifnet *ifp) for (;;) { s = splnet(); +#ifdef __FreeBSD__ + IF_LOCK(&ifp->if_snd); + _IF_DROP(&ifp->if_snd); + _IF_DEQUEUE(&ifp->if_snd, m); +#else IF_DROP(&ifp->if_snd); IF_DEQUEUE(&ifp->if_snd, m); +#endif +#ifdef __FreeBSD__ + IF_UNLOCK(&ifp->if_snd); +#endif splx(s); if (m == NULL) @@ -190,7 +296,11 @@ pflowstart(struct ifnet *ifp) int pflowoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +#ifdef __FreeBSD__ + struct route *rt) +#else struct rtentry *rt) +#endif { m_freem(m); return (0); @@ -200,7 +310,9 @@ pflowoutput(struct ifnet *ifp, struct mb int pflowioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { +#ifndef __FreeBSD__ struct proc *p = curproc; +#endif struct pflow_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct pflowreq pflowr; @@ -214,10 +326,18 @@ pflowioctl(struct ifnet *ifp, u_long cmd if ((ifp->if_flags & IFF_UP) && sc->sc_receiver_ip.s_addr != 0 && sc->sc_receiver_port != 0) { +#ifdef __FreeBSD__ + ifp->if_drv_flags |= IFF_DRV_RUNNING; +#else ifp->if_flags |= IFF_RUNNING; +#endif sc->sc_gcounter=pflowstats.pflow_flows; } else +#ifdef __FreeBSD__ + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; +#else ifp->if_flags &= ~IFF_RUNNING; +#endif break; case SIOCSIFMTU: if (ifr->ifr_mtu < PFLOW_MINMTU) @@ -244,7 +364,11 @@ pflowioctl(struct ifnet *ifp, u_long cmd break; case SIOCSETPFLOW: +#ifdef __FreeBSD__ + if ((error = priv_check(curthread, PRIV_NETINET_PF)) != 0) +#else if ((error = suser(p, p->p_acflag)) != 0) +#endif return (error); if ((error = copyin(ifr->ifr_data, &pflowr, sizeof(pflowr)))) @@ -264,10 +388,18 @@ pflowioctl(struct ifnet *ifp, u_long cmd if ((ifp->if_flags & IFF_UP) && sc->sc_receiver_ip.s_addr != 0 && sc->sc_receiver_port != 0) { +#ifdef __FreeBSD__ + ifp->if_drv_flags |= IFF_DRV_RUNNING; +#else ifp->if_flags |= IFF_RUNNING; +#endif sc->sc_gcounter=pflowstats.pflow_flows; } else +#ifdef __FreeBSD__ + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; +#else ifp->if_flags &= ~IFF_RUNNING; +#endif break; @@ -291,7 +423,11 @@ pflow_setmtu(struct pflow_softc *sc, int sizeof (struct udpiphdr)) / sizeof(struct pflow_flow); if (sc->sc_maxcount > PFLOW_MAXFLOWS) sc->sc_maxcount = PFLOW_MAXFLOWS; +#ifdef __FreeBSD__ + sc->sc_ifp->if_mtu = sizeof(struct pflow_header) + +#else sc->sc_if.if_mtu = sizeof(struct pflow_header) + +#endif sizeof (struct udpiphdr) + sc->sc_maxcount * sizeof(struct pflow_flow); } @@ -326,10 +462,19 @@ pflow_get_mbuf(struct pflow_softc *sc) h.flow_sequence = htonl(sc->sc_gcounter); h.engine_type = PFLOW_ENGINE_TYPE; h.engine_id = PFLOW_ENGINE_ID; +#ifdef __FreeBSD__ + m_copyback(m, 0, PFLOW_HDRLEN, (caddr_t)&h); +#else m_copyback(m, 0, PFLOW_HDRLEN, &h); +#endif sc->sc_count = 0; +#ifdef __FreeBSD__ + callout_reset(&sc->sc_tmo, PFLOW_TIMEOUT * hz, + pflow_timeout, sc); +#else timeout_add_sec(&sc->sc_tmo, PFLOW_TIMEOUT); +#endif return (m); } @@ -383,11 +528,19 @@ int export_pflow_if(struct pf_state *st, struct pflow_softc *sc) { struct pf_state pfs_copy; +#ifdef __FreeBSD__ + struct ifnet *ifp = sc->sc_ifp; +#else struct ifnet *ifp = &sc->sc_if; +#endif u_int64_t bytes[2]; int ret = 0; +#ifdef __FreeBSD__ + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) +#else if (!(ifp->if_flags & IFF_RUNNING)) +#endif return (0); if ((st->bytes[0] < (u_int64_t)PFLOW_MAXBYTES) @@ -439,7 +592,11 @@ copy_flow_to_m(struct pflow_flow *flow, } m_copyback(sc->sc_mbuf, PFLOW_HDRLEN + (sc->sc_count * sizeof (struct pflow_flow)), +#ifdef __FreeBSD__ + sizeof (struct pflow_flow), (caddr_t)flow); +#else sizeof (struct pflow_flow), flow); +#endif if (pflowstats.pflow_flows == sc->sc_gcounter) pflowstats.pflow_flows++; @@ -494,15 +651,27 @@ pflow_sendout(struct pflow_softc *sc) { struct mbuf *m = sc->sc_mbuf; struct pflow_header *h; +#ifdef __FreeBSD__ + struct ifnet *ifp = sc->sc_ifp; +#else struct ifnet *ifp = &sc->sc_if; +#endif +#ifdef __FreeBSD__ + callout_stop(&sc->sc_tmo); +#else timeout_del(&sc->sc_tmo); +#endif if (m == NULL) return (0); sc->sc_mbuf = NULL; +#ifdef __FreeBSD__ + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { +#else if (!(ifp->if_flags & IFF_RUNNING)) { +#endif m_freem(m); return (0); } @@ -524,7 +693,11 @@ pflow_sendout_mbuf(struct pflow_softc *s { struct udpiphdr *ui; u_int16_t len = m->m_pkthdr.len; +#ifdef __FreeBSD__ + struct ifnet *ifp = sc->sc_ifp; +#else struct ifnet *ifp = &sc->sc_if; +#endif struct ip *ip; int err; @@ -556,24 +729,40 @@ pflow_sendout_mbuf(struct pflow_softc *s * Compute the pseudo-header checksum; defer further checksumming * until ip_output() or hardware (if it exists). */ +#ifndef __FreeBSD__ + /* XXX */ m->m_pkthdr.csum_flags |= M_UDPV4_CSUM_OUT; ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr, ui->ui_dst.s_addr, htons(len + sizeof(struct udphdr) + IPPROTO_UDP)); +#endif #if NBPFILTER > 0 if (ifp->if_bpf) { ip->ip_sum = in_cksum(m, ip->ip_hl << 2); +#ifdef __FreeBSD__ + BPF_MTAP(ifp, m); +#else bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); +#endif } #endif +#ifdef __FreeBSD__ + sc->sc_ifp->if_opackets++; + sc->sc_ifp->if_obytes += m->m_pkthdr.len; +#else sc->sc_if.if_opackets++; sc->sc_if.if_obytes += m->m_pkthdr.len; +#endif if ((err = ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL))) { pflowstats.pflow_oerrors++; +#ifdef __FreeBSD__ + sc->sc_ifp->if_oerrors++; +#else sc->sc_if.if_oerrors++; +#endif } return (err); } @@ -581,13 +770,29 @@ pflow_sendout_mbuf(struct pflow_softc *s int pflow_get_dynport(void) { +#ifdef __FreeBSD__ + u_int16_t low, high, cut; +#else u_int16_t tmp, low, high, cut; +#endif +#ifdef __FreeBSD__ + low = V_ipport_firstauto; /* sysctl */ + high = V_ipport_lastauto; +#else low = ipport_hifirstauto; /* sysctl */ high = ipport_hilastauto; +#endif +#ifdef __FreeBSD__ + cut = low + (arc4random() % (1 + high - low)); +#else cut = arc4random_uniform(1 + high - low) + low; +#endif +#ifdef __FreeBSD__ + return (cut); +#else for (tmp = cut; tmp <= high; ++(tmp)) { if (!in_baddynamic(tmp, IPPROTO_UDP)) return (htons(tmp)); @@ -599,8 +804,10 @@ pflow_get_dynport(void) } return (htons(ipport_hilastauto)); /* XXX */ +#endif } +#ifdef notyet int pflow_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) @@ -619,3 +826,40 @@ pflow_sysctl(int *name, u_int namelen, v } return (0); } +#endif + +#ifdef __FreeBSD__ +static int +pflow_modevent(module_t mod, int type, void *data) +{ + int error = 0; + + switch (type) { + case MOD_LOAD: + pflowattach(0); + export_pflow_ptr = export_pflow; + break; + case MOD_UNLOAD: + if_clone_detach(&pflow_cloner); + export_pflow_ptr = NULL; + break; + default: + error = EINVAL; + break; + } + + return error; +} + +static moduledata_t pflow_mod = { + "pflow", + pflow_modevent, + 0 +}; + +#define PFLOW_MODVER 1 + +DECLARE_MODULE(pflow, pflow_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); +MODULE_VERSION(pflow, PFLOW_MODVER); +MODULE_DEPEND(pflow, pf, PF_MODVER, PF_MODVER, PF_MODVER); +#endif /* __FreeBSD__ */ Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h Sat Oct 10 18:24:54 2009 (r197938) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h Sat Oct 10 19:54:45 2009 (r197939) @@ -57,14 +57,22 @@ struct pflow_flow { extern int pflow_ok; struct pflow_softc { +#ifdef __FreeBSD__ + struct ifnet *sc_ifp; +#else struct ifnet sc_if; +#endif struct ifnet *sc_pflow_ifp; unsigned int sc_count; unsigned int sc_maxcount; u_int64_t sc_gcounter; struct ip_moptions sc_imo; +#ifdef __FreeBSD__ + struct callout sc_tmo; +#else struct timeout sc_tmo; +#endif struct in_addr sc_sender_ip; u_int16_t sc_sender_port; struct in_addr sc_receiver_ip; @@ -74,7 +82,6 @@ struct pflow_softc { }; extern struct pflow_softc *pflowif; - #endif /* _KERNEL */ struct pflow_header { @@ -113,6 +120,11 @@ struct pflowreq { }; #ifdef _KERNEL +#ifdef __FreeBSD__ +#define SIOCSETPFLOW _IOW('i', 249, struct ifreq) +#define SIOCGETPFLOW _IOWR('i', 250, struct ifreq) +#endif + int export_pflow(struct pf_state *); int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t); #endif /* _KERNEL */ Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 18:24:54 2009 (r197938) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 19:54:45 2009 (r197939) @@ -104,9 +104,6 @@ __FBSDID("$FreeBSD$"); #include #endif #include -#ifdef __FreeBSD__ -#include -#endif #include #include #include @@ -3082,5 +3079,5 @@ static moduledata_t pfsync_mod = { DECLARE_MODULE(pfsync, pfsync_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); MODULE_VERSION(pfsync, PFSYNC_MODVER); -MODULE_DEPEND(pflog, pf, PF_MODVER, PF_MODVER, PF_MODVER); +MODULE_DEPEND(pfsync, pf, PF_MODVER, PF_MODVER, PF_MODVER); #endif /* __FreeBSD__ */ Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 18:24:54 2009 (r197938) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 19:54:45 2009 (r197939) @@ -1338,8 +1338,13 @@ pf_unlink_state(struct pf_state *cur) RB_REMOVE(pf_state_tree_id, &tree_id, cur); #if NPFLOW > 0 if (cur->state_flags & PFSTATE_PFLOW) +#ifdef __FreeBSD__ + if (export_pflow_ptr != NULL) + export_pflow_ptr(cur); +#else export_pflow(cur); #endif +#endif #if NPFSYNC > 0 #ifdef __FreeBSD__ if (pfsync_delete_state_ptr != NULL) Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 18:24:54 2009 (r197938) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 19:54:45 2009 (r197939) @@ -246,6 +246,7 @@ static struct cdevsw pf_cdevsw = { int pf_end_threads = 0; struct mtx pf_task_mtx; #ifdef __FreeBSD__ + /* pfsync */ pfsync_state_import_t *pfsync_state_import_ptr = NULL; pfsync_up_t *pfsync_up_ptr = NULL; pfsync_insert_state_t *pfsync_insert_state_ptr = NULL; @@ -253,6 +254,8 @@ static struct cdevsw pf_cdevsw = { pfsync_delete_state_t *pfsync_delete_state_ptr = NULL; pfsync_clear_states_t *pfsync_clear_states_ptr = NULL; pfsync_defer_t *pfsync_defer_ptr = NULL; + /* pflow */ + export_pflow_t *export_pflow_ptr = NULL; #if NPFLOG >0 pflog_packet_t *pflog_packet_ptr = NULL; #endif Modified: user/eri/pf45/head/sys/contrib/pf/net/pfvar.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Sat Oct 10 18:24:54 2009 (r197938) +++ user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Sat Oct 10 19:54:45 2009 (r197939) @@ -929,6 +929,7 @@ struct pfsync_state { } __packed; #ifdef __FreeBSD__ +/* pfsync */ typedef int pfsync_state_import_t(struct pfsync_state *, u_int8_t); typedef int pfsync_up_t(void); typedef void pfsync_insert_state_t(struct pf_state *); @@ -948,6 +949,11 @@ extern pfsync_defer_t *pfsync_defer_ptr void pfsync_state_export(struct pfsync_state *, struct pf_state *); +/* pflow */ +typedef int export_pflow_t(struct pf_state *); + +extern export_pflow_t *export_pflow_ptr; + /* Macros to set/clear/test flags. */ #ifdef _KERNEL #define SET(t, f) ((t) |= (f)) Added: user/eri/pf45/head/sys/modules/pflow/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/eri/pf45/head/sys/modules/pflow/Makefile Sat Oct 10 19:54:45 2009 (r197939) @@ -0,0 +1,25 @@ + +.include + +.PATH: ${.CURDIR}/../../contrib/pf/net + +KMOD= pflow +SRCS = if_pflow.c \ + opt_pf.h opt_inet.h opt_inet6.h opt_bpf.h + +CFLAGS+= -I${.CURDIR}/../../contrib/pf + +.if !defined(KERNBUILDDIR) +opt_inet.h: + echo "#define INET 1" > ${.TARGET} + +.if ${MK_INET6_SUPPORT} != "no" +opt_inet6.h: + echo "#define INET6 1" > ${.TARGET} +.endif + +opt_bpf.h: + echo "#define DEV_BPF 1" > ${.TARGET} +.endif + +.include Modified: user/eri/pf45/head/sys/net/if_types.h ============================================================================== --- user/eri/pf45/head/sys/net/if_types.h Sat Oct 10 18:24:54 2009 (r197938) +++ user/eri/pf45/head/sys/net/if_types.h Sat Oct 10 19:54:45 2009 (r197939) @@ -251,4 +251,5 @@ #define IFT_PFSYNC 0xf7 #define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */ #define IFT_IPXIP 0xf9 /* IPX over IP tunneling; no longer used. */ +#define IFT_PFLOW 0xfa /* pflow */ #endif /* !_NET_IF_TYPES_H_ */ From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 20:26:18 2009 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 5EB3C106568B; Sat, 10 Oct 2009 20:26:18 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3431B8FC14; Sat, 10 Oct 2009 20:26:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9AKQITe091531; Sat, 10 Oct 2009 20:26:18 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9AKQIIM091527; Sat, 10 Oct 2009 20:26:18 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910102026.n9AKQIIM091527@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 20:26:18 +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: r197940 - in user/eri/pf45/head/sys: contrib/pf/net modules/pf 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, 10 Oct 2009 20:26:18 -0000 Author: eri Date: Sat Oct 10 20:26:17 2009 New Revision: 197940 URL: http://svn.freebsd.org/changeset/base/197940 Log: Remove notyet defines for pflow(4). Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_lb.c user/eri/pf45/head/sys/modules/pf/Makefile Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 19:54:45 2009 (r197939) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 20:26:17 2009 (r197940) @@ -65,8 +65,12 @@ __FBSDID("$FreeBSD$"); #define NPFSYNC 0 #endif - /* XXX */ - #define NPFLOW 0 + #ifdef DEV_PFLOW + #define NPFLOW DEV_PFLOW + #else + #define NPFLOW 0 + #endif + #else #include "bpfilter.h" #include "pflog.h" @@ -140,9 +144,7 @@ __FBSDID("$FreeBSD$"); #endif #include #include -#ifdef notyet #include -#endif #if NPFSYNC > 0 #include Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_lb.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_lb.c Sat Oct 10 19:54:45 2009 (r197939) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_lb.c Sat Oct 10 20:26:17 2009 (r197940) @@ -65,12 +65,16 @@ __FBSDID("$FreeBSD$"); #define NPFSYNC 0 #endif + #ifdef DEV_PFLOW + #define NPFLOW DEV_PFLOW + #else + #define NPFLOW 0 + #endif + #else #include "bpfilter.h" #include "pflog.h" #include "pfsync.h" -#endif -#ifdef notyet #include "pflow.h" #endif @@ -130,9 +134,7 @@ __FBSDID("$FreeBSD$"); #endif #include #include -#ifdef notyet #include -#endif #if NPFSYNC > 0 #include Modified: user/eri/pf45/head/sys/modules/pf/Makefile ============================================================================== --- user/eri/pf45/head/sys/modules/pf/Makefile Sat Oct 10 19:54:45 2009 (r197939) +++ user/eri/pf45/head/sys/modules/pf/Makefile Sat Oct 10 20:26:17 2009 (r197940) @@ -31,6 +31,7 @@ opt_pf.h: echo "#define DEV_PF 1" > ${.TARGET} echo "#define DEV_PFLOG 1" >> ${.TARGET} echo "#define DEV_PFSYNC 1" >> ${.TARGET} + echo "#define DEV_PFLOW 1" >> ${.TARGET} .endif From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 21:32:34 2009 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 F27C41065670; Sat, 10 Oct 2009 21:32:33 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E16488FC0C; Sat, 10 Oct 2009 21:32:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9ALWX2K092911; Sat, 10 Oct 2009 21:32:33 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9ALWXLu092904; Sat, 10 Oct 2009 21:32:33 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910102132.n9ALWXLu092904@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 21:32: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: r197943 - user/eri/pf45/head/sys/contrib/pf/net 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, 10 Oct 2009 21:32:34 -0000 Author: eri Date: Sat Oct 10 21:32:33 2009 New Revision: 197943 URL: http://svn.freebsd.org/changeset/base/197943 Log: * Lock pflow(4) list with pf(4) lock. More advanced schemas needs changes in pf(4) locking itself. * Defer the sending of pflow(4) packets to avoid LORs. Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c user/eri/pf45/head/sys/contrib/pf/net/pf.c user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c Sat Oct 10 21:17:30 2009 (r197942) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflow.c Sat Oct 10 21:32:33 2009 (r197943) @@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$"); #ifdef __FreeBSD__ #include #endif + #define PFLOW_MINMTU \ (sizeof(struct pflow_header) + sizeof(struct pflow_flow)) @@ -106,6 +107,7 @@ void pflowattach(int); #ifdef __FreeBSD__ int pflow_clone_create(struct if_clone *, int, caddr_t); void pflow_clone_destroy(struct ifnet *); +void pflow_senddef(void *, int); #else int pflow_clone_create(struct if_clone *, int); int pflow_clone_destroy(struct ifnet *); @@ -205,10 +207,15 @@ pflow_clone_create(struct if_clone *ifc, ifp->if_start = pflowstart; ifp->if_type = IFT_PFLOW; ifp->if_snd.ifq_maxlen = ifqmaxlen; +#ifdef __FreeBSD__ + mtx_init(&pflowif->sc_ifq.ifq_mtx, ifp->if_xname, + "pflow send queue", MTX_DEF); + TASK_INIT(&pflowif->sc_send_task, 0, pflow_senddef, pflowif); +#endif ifp->if_hdrlen = PFLOW_HDRLEN; ifp->if_flags = IFF_UP; #ifdef __FreeBSD__ - ifp->if_flags &= ~IFF_DRV_RUNNING; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; #else ifp->if_flags &= ~IFF_RUNNING; /* not running, need receiver */ #endif @@ -231,7 +238,13 @@ pflow_clone_create(struct if_clone *ifc, #endif #endif /* Insert into list of pflows */ +#ifdef __FreeBSD__ + PF_LOCK(); +#endif SLIST_INSERT_HEAD(&pflowif_list, pflowif, sc_next); +#ifdef __FreeBSD__ + PF_UNLOCK(); +#endif return (0); } @@ -251,8 +264,14 @@ pflow_clone_destroy(struct ifnet *ifp) bpfdetach(ifp); #endif if_detach(ifp); +#ifdef __FreeBSD__ + PF_LOCK(); +#endif SLIST_REMOVE(&pflowif_list, sc, pflow_softc, sc_next); #ifdef __FreeBSD__ + PF_UNLOCK(); +#endif +#ifdef __FreeBSD__ free(sc->sc_imo.imo_membership, M_DEVBUF); #else free(sc->sc_imo.imo_membership, M_IPMOPTS); @@ -699,7 +718,9 @@ pflow_sendout_mbuf(struct pflow_softc *s struct ifnet *ifp = &sc->sc_if; #endif struct ip *ip; +#ifndef __FreeBSD__ int err; +#endif /* UDP Header*/ M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT); @@ -756,15 +777,21 @@ pflow_sendout_mbuf(struct pflow_softc *s sc->sc_if.if_obytes += m->m_pkthdr.len; #endif - if ((err = ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL))) { - pflowstats.pflow_oerrors++; #ifdef __FreeBSD__ - sc->sc_ifp->if_oerrors++; + if (!IF_HANDOFF(&sc->sc_ifq, m, NULL)) + pflowstats.pflow_oerrors++; + taskqueue_enqueue(taskqueue_thread, &sc->sc_send_task); #else + if ((err = ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL))) { + pflowstats.pflow_oerrors++; sc->sc_if.if_oerrors++; -#endif } +#endif +#ifdef __FreeBSD__ + return (0); +#else return (err); +#endif } int @@ -829,6 +856,23 @@ pflow_sysctl(int *name, u_int namelen, v #endif #ifdef __FreeBSD__ +void +pflow_senddef(void *arg, __unused int pending) +{ + struct pflow_softc *sc = (struct pflow_softc *)arg; + struct mbuf *m; + + for(;;) { + IF_DEQUEUE(&sc->sc_ifq, m); + if (m == NULL) + break; + if (ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL)) { + pflowstats.pflow_oerrors++; + sc->sc_ifp->if_oerrors++; + } + } +} + static int pflow_modevent(module_t mod, int type, void *data) { Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h Sat Oct 10 21:17:30 2009 (r197942) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pflow.h Sat Oct 10 21:32:33 2009 (r197943) @@ -73,6 +73,10 @@ struct pflow_softc { #else struct timeout sc_tmo; #endif +#ifdef __FreeBSD__ + struct ifqueue sc_ifq; + struct task sc_send_task; +#endif struct in_addr sc_sender_ip; u_int16_t sc_sender_port; struct in_addr sc_receiver_ip; Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 21:17:30 2009 (r197942) +++ user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Sat Oct 10 21:32:33 2009 (r197943) @@ -3044,6 +3044,7 @@ pfsync_modevent(module_t mod, int type, pfsync_update_state_ptr = pfsync_update_state; pfsync_delete_state_ptr = pfsync_delete_state; pfsync_clear_states_ptr = pfsync_clear_states; + pfsync_state_in_use_ptr = pfsync_state_in_use; pfsync_defer_ptr = pfsync_defer; #endif break; @@ -3057,6 +3058,7 @@ pfsync_modevent(module_t mod, int type, pfsync_update_state_ptr = NULL; pfsync_delete_state_ptr = NULL; pfsync_clear_states_ptr = NULL; + pfsync_state_in_use_ptr = NULL; pfsync_defer_ptr = NULL; #endif if_clone_detach(&pfsync_cloner); Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 21:17:30 2009 (r197942) +++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Sat Oct 10 21:32:33 2009 (r197943) @@ -1370,7 +1370,12 @@ pf_free_state(struct pf_state *cur) #endif #if NPFSYNC > 0 +#ifdef __FreeBSD__ + if (pfsync_state_in_use_ptr != NULL) + pfsync_state_in_use_ptr(cur); +#else if (pfsync_state_in_use(cur)) +#endif return; #endif #ifdef __FreeBSD__ @@ -3437,7 +3442,7 @@ pf_test_rule(struct pf_rule **rm, struct */ #ifdef __FreeBSD__ if (pfsync_defer_ptr != NULL) - pfsync_defer(*sm, m); + pfsync_defer_ptr(*sm, m); #else if (pfsync_defer(*sm, m)) #endif Modified: user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 21:17:30 2009 (r197942) +++ user/eri/pf45/head/sys/contrib/pf/net/pf_ioctl.c Sat Oct 10 21:32:33 2009 (r197943) @@ -248,12 +248,13 @@ static struct cdevsw pf_cdevsw = { #ifdef __FreeBSD__ /* pfsync */ pfsync_state_import_t *pfsync_state_import_ptr = NULL; - pfsync_up_t *pfsync_up_ptr = NULL; pfsync_insert_state_t *pfsync_insert_state_ptr = NULL; pfsync_update_state_t *pfsync_update_state_ptr = NULL; pfsync_delete_state_t *pfsync_delete_state_ptr = NULL; pfsync_clear_states_t *pfsync_clear_states_ptr = NULL; + pfsync_state_in_use_t *pfsync_state_in_use_ptr = NULL; pfsync_defer_t *pfsync_defer_ptr = NULL; + pfsync_up_t *pfsync_up_ptr = NULL; /* pflow */ export_pflow_t *export_pflow_ptr = NULL; #if NPFLOG >0 Modified: user/eri/pf45/head/sys/contrib/pf/net/pfvar.h ============================================================================== --- user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Sat Oct 10 21:17:30 2009 (r197942) +++ user/eri/pf45/head/sys/contrib/pf/net/pfvar.h Sat Oct 10 21:32:33 2009 (r197943) @@ -931,20 +931,22 @@ struct pfsync_state { #ifdef __FreeBSD__ /* pfsync */ typedef int pfsync_state_import_t(struct pfsync_state *, u_int8_t); -typedef int pfsync_up_t(void); typedef void pfsync_insert_state_t(struct pf_state *); typedef void pfsync_update_state_t(struct pf_state *); typedef void pfsync_delete_state_t(struct pf_state *); typedef void pfsync_clear_states_t(u_int32_t, const char *); +typedef int pfsync_state_in_use_t(struct pf_state *); typedef int pfsync_defer_t(struct pf_state *, struct mbuf *); +typedef int pfsync_up_t(void); extern pfsync_state_import_t *pfsync_state_import_ptr; -extern pfsync_up_t *pfsync_up_ptr; extern pfsync_insert_state_t *pfsync_insert_state_ptr; extern pfsync_update_state_t *pfsync_update_state_ptr; extern pfsync_delete_state_t *pfsync_delete_state_ptr; extern pfsync_clear_states_t *pfsync_clear_states_ptr; +extern pfsync_state_in_use_t *pfsync_state_in_use_ptr; extern pfsync_defer_t *pfsync_defer_ptr; +extern pfsync_up_t *pfsync_up_ptr; void pfsync_state_export(struct pfsync_state *, struct pf_state *); From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 21:43:06 2009 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 6EAB7106566B; Sat, 10 Oct 2009 21:43:06 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E6E98FC12; Sat, 10 Oct 2009 21:43:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9ALh4SH093128; Sat, 10 Oct 2009 21:43:04 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9ALh4DN093126; Sat, 10 Oct 2009 21:43:04 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910102143.n9ALh4DN093126@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 21:43:04 +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: r197944 - user/eri/pf45/head/sys/conf 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, 10 Oct 2009 21:43:06 -0000 Author: eri Date: Sat Oct 10 21:43:04 2009 New Revision: 197944 URL: http://svn.freebsd.org/changeset/base/197944 Log: Make if_pflow.c known to the kernel. Modified: user/eri/pf45/head/sys/conf/files Modified: user/eri/pf45/head/sys/conf/files ============================================================================== --- user/eri/pf45/head/sys/conf/files Sat Oct 10 21:32:33 2009 (r197943) +++ user/eri/pf45/head/sys/conf/files Sat Oct 10 21:43:04 2009 (r197944) @@ -343,6 +343,8 @@ contrib/ngatm/netnatm/sig/sig_verify.c o compile-with "${NORMAL_C} -I$S/contrib/ngatm" contrib/pf/net/if_pflog.c optional pflog pf inet \ compile-with "${NORMAL_C} -I$S/contrib/pf" +contrib/pf/net/if_pflow.c optional pflow pf inet \ + compile-with "${NORMAL_C} -I$S/contrib/pf" contrib/pf/net/if_pfsync.c optional pfsync pf inet \ compile-with "${NORMAL_C} -I$S/contrib/pf" contrib/pf/net/pf.c optional pf inet \ From owner-svn-src-user@FreeBSD.ORG Sat Oct 10 21:56:40 2009 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 61CCF106568B; Sat, 10 Oct 2009 21:56:40 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C27F8FC13; Sat, 10 Oct 2009 21:56:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9ALueHQ093473; Sat, 10 Oct 2009 21:56:40 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9ALuewf093470; Sat, 10 Oct 2009 21:56:40 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <200910102156.n9ALuewf093470@svn.freebsd.org> From: Ermal Luçi Date: Sat, 10 Oct 2009 21:56:40 +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: r197946 - user/eri/pf45/head/sbin/ifconfig 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, 10 Oct 2009 21:56:40 -0000 Author: eri Date: Sat Oct 10 21:56:39 2009 New Revision: 197946 URL: http://svn.freebsd.org/changeset/base/197946 Log: Add ifconfig support for pflow(4). Added: user/eri/pf45/head/sbin/ifconfig/ifpflow.c (contents, props changed) Modified: user/eri/pf45/head/sbin/ifconfig/Makefile Modified: user/eri/pf45/head/sbin/ifconfig/Makefile ============================================================================== --- user/eri/pf45/head/sbin/ifconfig/Makefile Sat Oct 10 21:49:04 2009 (r197945) +++ user/eri/pf45/head/sbin/ifconfig/Makefile Sat Oct 10 21:56:39 2009 (r197946) @@ -34,6 +34,7 @@ LDADD+= -lbsdxml -ljail -lsbuf SRCS+= ifcarp.c # SIOC[GS]VH support SRCS+= ifgroup.c # ... SRCS+= ifpfsync.c # pfsync(4) support +SRCS+= ifpflow.c # pflow(4) support SRCS+= ifbridge.c # bridge support SRCS+= iflagg.c # lagg support Added: user/eri/pf45/head/sbin/ifconfig/ifpflow.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/eri/pf45/head/sbin/ifconfig/ifpflow.c Sat Oct 10 21:56:39 2009 (r197946) @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2009 Ermal Luçi. 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. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "ifconfig.h" + +void pflow_status(int); +void setpflow_sender(const char *, int, int , const struct afswtch *); +void unsetpflow_sender(const char *, int, int , const struct afswtch *); +void setpflow_receiver(const char *, int, int , const struct afswtch *); +void unsetpflow_receiver(const char *, int, int , const struct afswtch *); + +static struct cmd pflow_cmds[] = { + DEF_CMD_ARG("flowsrc", setpflow_sender), + DEF_CMD_ARG("-flowsrc", unsetpflow_sender), + DEF_CMD_ARG("flowdst", setpflow_receiver), + DEF_CMD_ARG("-flowsrc", unsetpflow_receiver), +}; +static struct afswtch af_pflow = { + .af_name = "af_pflow", + .af_af = AF_UNSPEC, + .af_other_status = pflow_status, +}; + +void +pflow_status(int s) +{ + struct pflowreq preq; + + bzero((char *)&preq, sizeof(struct pflowreq)); + ifr.ifr_data = (caddr_t)&preq; + + if (ioctl(s, SIOCGETPFLOW, (caddr_t)&ifr) == -1) + return; + + printf("\tpflow: sender: %s ", inet_ntoa(preq.sender_ip)); + printf("receiver: %s:%u\n", inet_ntoa(preq.receiver_ip), + ntohs(preq.receiver_port)); +} + +/* ARGSUSED */ +void +setpflow_sender(const char *val, int d, int s, const struct afswtch *rafp) +{ + struct pflowreq preq; + struct addrinfo hints, *sender; + int ecode; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_DGRAM; /*dummy*/ + + if ((ecode = getaddrinfo(val, NULL, &hints, &sender)) != 0) + errx(1, "error in parsing address string: %s", + gai_strerror(ecode)); + + if (sender->ai_addr->sa_family != AF_INET) + errx(1, "only IPv4 addresses supported for the sender"); + + bzero((char *)&preq, sizeof(struct pflowreq)); + ifr.ifr_data = (caddr_t)&preq; + preq.addrmask |= PFLOW_MASK_SRCIP; + preq.sender_ip.s_addr = ((struct sockaddr_in *) + sender->ai_addr)->sin_addr.s_addr; + + + if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1) + err(1, "SIOCSETPFLOW"); + + freeaddrinfo(sender); +} + +void +unsetpflow_sender(const char *val, int d, int s, const struct afswtch *rafp) +{ + struct pflowreq preq; + + bzero((char *)&preq, sizeof(struct pflowreq)); + preq.addrmask |= PFLOW_MASK_SRCIP; + ifr.ifr_data = (caddr_t)&preq; + if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1) + err(1, "SIOCSETPFLOW"); +} + +/* ARGSUSED */ +void +setpflow_receiver(const char *val, int d, int s, const struct afswtch *rafp) +{ + struct pflowreq preq; + struct addrinfo hints, *receiver; + int ecode; + char *ip, *port, buf[MAXHOSTNAMELEN+sizeof (":65535")]; + + if (strchr (val, ':') == NULL) + errx(1, "%s bad value", val); + + if (strlcpy(buf, val, sizeof(buf)) >= sizeof(buf)) + errx(1, "%s bad value", val); + port = strchr(buf, ':'); + *port++ = '\0'; + ip = buf; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_DGRAM; /*dummy*/ + + if ((ecode = getaddrinfo(ip, port, &hints, &receiver)) != 0) + errx(1, "error in parsing address string: %s", + gai_strerror(ecode)); + + if (receiver->ai_addr->sa_family != AF_INET) + errx(1, "only IPv4 addresses supported for the receiver"); + + bzero((char *)&preq, sizeof(struct pflowreq)); + ifr.ifr_data = (caddr_t)&preq; + preq.addrmask |= PFLOW_MASK_DSTIP | PFLOW_MASK_DSTPRT; + preq.receiver_ip.s_addr = ((struct sockaddr_in *) + receiver->ai_addr)->sin_addr.s_addr; + preq.receiver_port = (u_int16_t) ((struct sockaddr_in *) + receiver->ai_addr)->sin_port; + + if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1) + err(1, "SIOCSETPFLOW"); + + freeaddrinfo(receiver); +} + +void +unsetpflow_receiver(const char *val, int d, int s, const struct afswtch *rafp) +{ + struct pflowreq preq; + + bzero((char *)&preq, sizeof(struct pflowreq)); + ifr.ifr_data = (caddr_t)&preq; + preq.addrmask |= PFLOW_MASK_DSTIP | PFLOW_MASK_DSTPRT; + if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1) + err(1, "SIOCSETPFLOW"); +} + +static __constructor void +pflow_ctor(void) +{ +#define N(a) (sizeof(a) / sizeof(a[0])) + int i; + + for (i = 0; i < N(pflow_cmds); i++) + cmd_register(&pflow_cmds[i]); + af_register(&af_pflow); +#undef N +}