From owner-freebsd-net@FreeBSD.ORG Fri Jun 6 03:23:31 2014 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B7549955 for ; Fri, 6 Jun 2014 03:23:31 +0000 (UTC) Received: from mail-wg0-x229.google.com (mail-wg0-x229.google.com [IPv6:2a00:1450:400c:c00::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E4A82BDE for ; Fri, 6 Jun 2014 03:23:31 +0000 (UTC) Received: by mail-wg0-f41.google.com with SMTP id z12so2166116wgg.24 for ; Thu, 05 Jun 2014 20:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=JLjKmfYnL2kM6sFpk2JpuPxlEqfpc7tH7qppgyiKwkk=; b=KiQ71sw9ToN4hpbAOJ5ACeC+vHLPDBR8ynX1VgdB6xK4iWpy1xlD3gkxgAhcjDqZcW cVuysuKfFVqxo2Gz6NU+rrp9tce74w3x7KhnFh3/LU4/HBcAXBSdOz4Lua9scs0AfxEu p8JfuM3U7YKXGu6/aSnQ77plWgPSilhKANN1eKtyT9Bs34bp+T0Jwn0JS1UdY7ICIwl/ pOBm+H0CEnHrXn7/CBwSX4ccbAskKQPKBxtx9+/4oT7+MnvK2UVc5H49dSfUsvlygFf+ 4JoVN8BI/H3A4NRFzLsEcgf0TIdepBIJRcQLihJL5a25hp9HHDmgItR26Nh4EFI8y+Ux QaWg== MIME-Version: 1.0 X-Received: by 10.195.11.132 with SMTP id ei4mr45622wjd.95.1402025009515; Thu, 05 Jun 2014 20:23:29 -0700 (PDT) Received: by 10.216.232.68 with HTTP; Thu, 5 Jun 2014 20:23:29 -0700 (PDT) In-Reply-To: <20140605165806.GC81905@onelab2.iet.unipi.it> References: <20140522154740.GA76448@onelab2.iet.unipi.it> <537E2153.1040005@FreeBSD.org> <20140522163812.GA77634@onelab2.iet.unipi.it> <538B2FE5.6070407@FreeBSD.org> <539044E4.1020904@ipfw.ru> <000c01cf80be$41194370$c34bca50$@gmail.com> <20140605134256.GA81234@onelab2.iet.unipi.it> <000001cf80cd$5dc1d9b0$19458d10$@gmail.com> <20140605155402.GA81905@onelab2.iet.unipi.it> <000401cf80d8$ad1bb840$075328c0$@gmail.com> <20140605165806.GC81905@onelab2.iet.unipi.it> Date: Fri, 6 Jun 2014 11:23:29 +0800 Message-ID: Subject: Re: [CFT]: ipfw named tables / different tabletypes From: Sato Kentney To: Luigi Rizzo Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18 Cc: bycn82 , "Alexander V. Chernikov" , FreeBSD Net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jun 2014 03:23:31 -0000 Your original porpose of pps is good enough for me, it controls packets number for each second. it is simple and make sence, As a network administrator, I think if you provide "packets per second" or "packets per minute" ,that is good enough for 99% percent of users. Thanks, Sato K(=E4=BD=90=E8=97=A4=E6=9F=AF=E5=BE=B7) On Fri, Jun 6, 2014 at 12:58 AM, Luigi Rizzo wrote: > On Fri, Jun 06, 2014 at 12:10:26AM +0800, bycn82 wrote: > > Sorry for waste you time to explain it again, I will read the code firs= t. > > > > And the latest patch of `PPS` should be OK, I checked the logic > carefully this time. I sent it out last weekend. > > > > logic as below, PPS actually will be fulfilled using `PPT`,(N packets > per M ticks). > > Bill, > sorry but even this version has multiple issues -- performance, > correctness, style. > > performance: > duration_in_ticks and limit do not need to be recomputed > on every packet, just once when you install the rule. > > correctness > limit should be not lower than the user-specified value, > so if the equation has the form \lceil{a}{b} \rceil, > the correct computation using integer arithmetic is > (a + b - 1)/b and not (a + b/2) / b > > You should also check for corner cases, overflows etc. > I haven't actually checked that the equation you use is > correct, so a comment explaining why it is would be appropriate. > > BTW you have no checks on the input arguments, so you can > have duration =3D0 and then you have a division by 0 in the kernel. > > style > boring as it might be, we use spaces around keywords and { } > > I am also unhappy on the ppt option, because the duration of a tick > can change across reboots, so this option would give variable > behaviour. With all sources of uncertainty on packet arrivals > and when the timer fires to advance 'ticks', there is really > no point in having PPT to avoid the rounding error with some > strange values of HZ. > > > Now before you think i am too picky: > some of the above (style) are trivial issues, but they require > manual editing of the patch before applying and this is the reason > many project and people usually bounce patches just because of style > (the process does not scale otherwise). > If it were just for that, i would not mind. > > But many of the other problems are more serious, and the fact they > keep coming out after so many iterations suggest me that _you_ > should spend more time reviewing your code before submitting it > and asking others to find and fix problems. > > cheers > luigi > > > > > + case O_PPT: > > + case O_PPS:{ > > + ipfw_insn_pps *pps =3D (ipfw_insn_pps *)c= md; > > + if(pps->limit=3D=3D0){ > > + int limit,duration_in_ticks; > > + if(1000/hz > pps->duration){ > > + duration_in_ticks=3D1; > > + }else{ > > + > duration_in_ticks=3D(pps->duration * hz +500)/1000; > > + } > > + limit=3D(cmd->arg1 *1000 * > duration_in_ticks + hz * pps->duration/2)/(hz * pps->duration); > > + pps->limit=3Dlimit; > > + > pps->duration_in_ticks=3Dduration_in_ticks; > > + } > > + > if(pps->start_time+pps->duration_in_ticks>=3D ticks){ > > + if(pps->count < pps->limit){ > > + retval =3D IP_FW_PASS; > > + }else{ > > + retval =3D IP_FW_DENY; > > + } > > + pps->count++; > > + }else{ > > + pps->start_time=3Dticks; > > + pps->count=3D1; > > + retval =3D IP_FW_PASS; > > + } > > + l =3D 0; > > + done =3D 1; > > + break; > > + } > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >