From owner-freebsd-net@FreeBSD.ORG Thu Apr 17 06:10:17 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4AF6106567C; Thu, 17 Apr 2008 06:10:17 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from smtp11.yandex.ru (smtp11.yandex.ru [213.180.223.93]) by mx1.freebsd.org (Postfix) with ESMTP id 9380C8FC38; Thu, 17 Apr 2008 06:10:16 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from ns.kirov.so-cdu.ru ([77.72.136.145]:22991 "EHLO [127.0.0.1]" smtp-auth: "bu7cher" TLS-CIPHER: "DHE-RSA-AES256-SHA keybits 256/256 version TLSv1/SSLv3" TLS-PEER-CN1: ) by mail.yandex.ru with ESMTP id S1246489AbYDQFrX (ORCPT + 1 other); Thu, 17 Apr 2008 09:47:23 +0400 X-Yandex-Spam: 1 X-Yandex-Front: smtp11 X-Yandex-TimeMark: 1208411243 X-MsgDayCount: 4 X-Comment: RFC 2476 MSA function at smtp11.yandex.ru logged sender identity as: bu7cher Message-ID: <4806E468.5030906@yandex.ru> Date: Thu, 17 Apr 2008 09:47:20 +0400 From: "Andrey V. Elsukov" User-Agent: Mozilla Thunderbird 1.5 (FreeBSD/20051231) MIME-Version: 1.0 To: Julian Elischer References: <4806BA59.4030106@elischer.org> In-Reply-To: <4806BA59.4030106@elischer.org> Content-Type: multipart/mixed; boundary="------------090204050606090409040801" Cc: FreeBSD Net , ipfw@freebsd.org, Luigi Rizzo Subject: Re: addition to ipfw table.. X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Apr 2008 06:10:18 -0000 This is a multi-part message in MIME format. --------------090204050606090409040801 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Julian Elischer wrote: > I do know it won't handle non contiguous masks well but as the > ipfw ABI code only accepts a network mask length instead of a > mask, there's not much that can be done. > I may suggest a later fix for that but it will break the ABI. > > comments? What you think about my patch? -- WBR, Andrey V. Elsukov --------------090204050606090409040801 Content-Type: text/plain; name="ipfw_table_mask.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ipfw_table_mask.diff.txt" Index: src/sbin/ipfw/ipfw2.c =================================================================== RCS file: /ncvs/src/sbin/ipfw/ipfw2.c,v retrieving revision 1.118 diff -u -p -r1.118 ipfw2.c --- src/sbin/ipfw/ipfw2.c 27 Feb 2008 13:52:33 -0000 1.118 +++ src/sbin/ipfw/ipfw2.c 17 Apr 2008 05:45:27 -0000 @@ -5833,7 +5833,7 @@ table_handler(int ac, char *av[]) ipfw_table_entry ent; ipfw_table *tbl; int do_add; - char *p; + char *p, md; socklen_t l; uint32_t a; @@ -5850,10 +5850,22 @@ table_handler(int ac, char *av[]) ac--; av++; if (!ac) errx(EX_USAGE, "IP address required"); - p = strchr(*av, '/'); + p = strpbrk(*av, "/:"); if (p) { + md = *p; *p++ = '\0'; - ent.masklen = atoi(p); + switch (md) { + case ':': + if (!inet_aton(p, (struct in_addr *)&a)) + errx(EX_DATAERR, "bad netmask ``%s''", p); + ent.masklen = contigmask((uint8_t *)&a, 32); + if (ent.masklen > 32) + errx(EX_DATAERR, + "netmask ``%s'' is not contiguous", p); + break; + case '/': + ent.masklen = atoi(p); + } if (ent.masklen > 32) errx(EX_DATAERR, "bad width ``%s''", p); } else --------------090204050606090409040801--