Date: Thu, 25 Oct 2018 16:17:39 +0800 (CST) From: wendygao <guobin@xycar-dvr.com> To: ipfw@freebsd.org Subject: The Great Profit RC Bait Boat from Shenzhen Message-ID: <2f8853ee.cdfa.166aa4ceb54.Coremail.guobin@xycar-dvr.com>
next in thread | raw e-mail | index | archive | help
SGVsbG8sIFNpcgoKCkhvcGUgdGhpcyBlbWFpbCBjb3VsZCBmaW5kIHlvdSB3ZWxsLiBXZSBhcmUg dGhlIG9yaWdpbmFsIGZhY3RvcnkgZnJvbSBTaGVuemhlbiwgSSBhbSBoZXJlIGludHJvZHVjaW5n IG91ciBSQyBiYWl0IGJvYXRzIGZvciB5b3VyIHJlZmVyZW5jZS4KCgpUaGUgaW5mb3JtYXRpb24g b2YgdGhlIGJhaXQgYm9hdCBhcyBmb2xsb3dzOgoxLkQwNShncmVlbiBjb2xvcik6IFJDIGRpc3Rh bmNlIGlzIGFib3V0IDUwME0sIDMgYmFpdCBiaW5zLCBsb2FkIGFib3V0IDNrZ3MgYmFpdDsgYm9h dCBzaXplOkw1NSpXMjcqSDEwY20sIHR3byBicnVzaCBtb3RvcnMuCjIuRDA2KGJsYWNrIGNvbG9y KTogUkMgZGlzdGFuY2UgaXMgYWJvdXQgNDAwTSwgMiBiYWl0IGJpbnMsIGxvYWQgYWJvdXQgMmtn cyBiYWl0LiBib2F0IHNpemU6TDUzKlczNypIMjZjbSwgdHdvIGJydXNoIG1vdG9ycy4KCgpQbGVh c2Uga2luZGx5IGNvbnRhY3QgbWUgZnJlZWx5IGlmIHlvdSB3YW50IHRvIGtub3cgbW9yZSBpbmZv cm1hdGlvbiBhYm91dCB0aGVtLgoKCldhaXRpbmcgZm9yIHlvdXIga2luZCByZXBseSEKCgoKCgot LQoKV2VuZHkgRm9yZWlnbiBTYWxlcwpndW9iaW5AeHljYXItZHZyLmNvbQpTaGVuemhlbiBDaXR5 IEd1b2JpbiBUZWNobm9sb2d5IENvLiwgTHRkCkFkZDo0dGggRmxvb3IsIElEVCBCdWlsZGluZywg Q2hlbnRpYW4gSW5kdXN0cmlhbCwgU2hlbnpoZW4KaHR0cHM6Ly9zemdvYi5lbi5hbGliYWJhLmNv bS8KQ2VsbDo4Ni0xODg5ODU5NDA1OQ== From owner-freebsd-ipfw@freebsd.org Thu Oct 25 09:09:24 2018 Return-Path: <owner-freebsd-ipfw@freebsd.org> Delivered-To: freebsd-ipfw@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3E361008294 for <freebsd-ipfw@mailman.ysv.freebsd.org>; Thu, 25 Oct 2018 09:09:24 +0000 (UTC) (envelope-from ole@free.de) Received: from smtp.free.de (smtp.free.de [91.204.6.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3DC9C78306 for <freebsd-ipfw@freebsd.org>; Thu, 25 Oct 2018 09:09:24 +0000 (UTC) (envelope-from ole@free.de) Received: from bard (x4db68219.dyn.telefonica.de [77.182.130.25]) by smtp.free.de (Postfix) with ESMTPSA id BD563C787 for <freebsd-ipfw@freebsd.org>; Thu, 25 Oct 2018 11:09:22 +0200 (CEST) Date: Thu, 25 Oct 2018 11:09:19 +0200 From: Ole <ole@free.de> To: freebsd-ipfw@freebsd.org Subject: net.inet.ip.fw.dyn_keep_states (was: ipfw managing rules - best practice?) Message-ID: <20181025110919.61379c13.ole@free.de> In-Reply-To: <6bb037c2-643d-151b-cb34-f78c97f241d4@yandex.ru> References: <20180905112847.54287198.ole@free.de> <67544958-07fe-7ff4-b5d2-88bf85324061@yandex.ru> <20181023131220.20c700ba.ole@free.de> <20181024182252.49ee516b.ole@free.de> <6bb037c2-643d-151b-cb34-f78c97f241d4@yandex.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/irWQrmpBiHmBWoM5Lm84yzv"; protocol="application/pgp-signature" X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFW Technical Discussions <freebsd-ipfw.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-ipfw>, <mailto:freebsd-ipfw-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-ipfw/> List-Post: <mailto:freebsd-ipfw@freebsd.org> List-Help: <mailto:freebsd-ipfw-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-ipfw>, <mailto:freebsd-ipfw-request@freebsd.org?subject=subscribe> X-List-Received-Date: Thu, 25 Oct 2018 09:09:24 -0000 --Sig_/irWQrmpBiHmBWoM5Lm84yzv Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Wed, 24 Oct 2018 21:42:00 +0300 - "Andrey V. Elsukov" <bu7cher@yandex.ru>: > On 24.10.2018 19:22, Ole wrote: > > # ipfw -d list=20 > > (...) > > 01510 allow tcp from any to xx.xx.xx.xx 6514 out via epair0b setup > > keep-state :default (...) > > ## Dynamic rules (1 152): > > 01510 STATE tcp yy.yy.yy.yy 54451 <-> xx.xx.xx.xx 6514 :default > >=20 > > # ipfw -q flush > >=20 > > # ipfw -d list > > 65535 allow ip from any to any > > ## Dynamic rules (2 288): > > Segmentation fault (core dumped) > This problem is related to named states, the kernel doesn't dump list > of known states names, and this is the cause of SIGSEGV. Ok, I got a little bit confused. I was searching for a workaround. So I changed the rules from $cmd 01610 allow tcp from vpn.example.org to me 22 in via $pif setup limit src-addr 50 to $cmd 01610 allow tcp from vpn.example.org to me 22 in via $pif keep-state In my understanding of the IPFW(8) the 'setup' command puts new entries to the dynamic table if there=20 " Matches TCP packets that have the SYN bit set but no ACK bit."=20 So if there new TCP connection establishment. That is the reason why connections get broken after reload. (inkluding flush) My idea was just to use 'keep-state'. Because this also puts new entries to the dynamic table. But for every package. " Upon a match, the firewall will create a dynamic rule, whose default behaviour is to match bidirectional traffic between source and destination IP/port using the same protocol." But after reload. The dynamic rules are gone, and they will not get updated. TCP connections get broken. Intresting: if I set 'sysctl net.inet.ip.fw.dyn_keep_states=3D1' the firewall behaves like I expected above. But not because dynamic rules got recreated. The don't get flushed: # ipfw -da list (...) 01610 223 26457 (282s) STATE tcp xx.xx.xx.xx 36955 <-> xx.xx.xx.xx 22 :de= fault (...) # service ipfw restart Firewall rules loaded. # ipfw -da list (...) 01610 223 26457 (278s) STATE tcp xx.xx.xx.xx 36955 <-> xx.xx.xx.xx 22 :de= fault (...) So do you think the bug is only related to 'setup' and not to 'keep-state' rules? Or is this just a coincidence?=20 Im reloading rules now for 1h each minute, and a ssh connection is still st= able. > I have the WIP patch https://people.freebsd.org/~ae/keep_states.diff > It fixes this problem and also add support for all rule actions. > Also it adds new -D flag, that allows to show only states and delete > only states. I have tested it basically, but it probably needs some > work related to "limit" dynamic states. > So if you want to test some patches, you can try :) > I tried to apply the patch and observed that stable/11 has a small > difference in UMA code, so you need to use this patch: > https://people.freebsd.org/~ae/keep_states11.diff >=20 > Again, I did not yet teseted it widely, and on stable/11 did not > tested at all. Great, thanks I will give it a try in a testing setup! regards Ole --Sig_/irWQrmpBiHmBWoM5Lm84yzv Content-Type: application/pgp-signature Content-Description: Digitale Signatur von OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJb0YhCAAoJECWWkUao5JRQybsP+QEwwEF4AtxggoBsIMYxYhYx 2opOdZZdWs7zRHPMEimBlh9DGlDjxEfTYaqKgQNyLynTVAxeFKYStb/PXSmu1jWG Wgm9DAVyofDE8iowTS0PJzoa5NGrcRy4fy7yOtS3FhdAv/MS51IuGlG9Ws9/Up/4 exqu3ZFaX2gbCQIL8lk5MNLcjVVMQWMURDCCYlOQsrqagUqhLRE0eliltNv34G0C 3IPUIDalDy8URAP6po4jn+4s+UsoEsBmLlgiAJ0ABxGvD5czP0Qg18ztZkzfFLPH teY8+vTPoA5xbX124oOdW5yPkejbZAs9D4RMN38ohmBN5Sc2VkNzPrMrDBdjNC2V uluTpbKxWV9sIF/xyz9f1eqoY9gTnsilBPR6BJdB/HgVF5GsXpJTayTY+v+GdAhm HtRrDpfwP0ZTGiOY7hGBSUyCVxG9eQwFP/U7Psp71TmcaywqJ4OQpG77lPejux3X XAf+bp7aDC1vFzujl/rkxsQmctJBDQZFISbWZ4gYIpy19L5WJyR6L7lD20/FfKe7 KofitrquVw4w6U+UzoSfIUIv/opYmjzFfWtuj7+1v45uNfV6bdgO9uK6yhjo5xZu DgcyZksXcR+nfwpl7tSdcE+xzeWd0YpkEGfgUWZfwnQJwB7xT8zpFXwp8foqQpAw TtXuNeM5rDJQv4D27Hxu =KM1g -----END PGP SIGNATURE----- --Sig_/irWQrmpBiHmBWoM5Lm84yzv--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2f8853ee.cdfa.166aa4ceb54.Coremail.guobin>