From owner-freebsd-pf@freebsd.org Wed Mar 14 17:30:07 2018 Return-Path: Delivered-To: freebsd-pf@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 F2EF4F2D06D for ; Wed, 14 Mar 2018 17:30:06 +0000 (UTC) (envelope-from Steven@stream-technologies.com) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0060.outbound.protection.outlook.com [104.47.1.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT TLS CA 4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4E0716C84E for ; Wed, 14 Mar 2018 17:30:05 +0000 (UTC) (envelope-from Steven@stream-technologies.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamtechnologiesuk.onmicrosoft.com; s=selector1-streamtechnologies-com01e; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=fOo9r0om9AWHmR55BtrWxERBV6G11zWskTZJdeRPQJM=; b=sAvsT9KOn/4y4B6+xH3Y3Vihd9w+/+iXunOhe985Vdf5JY0sCOooZ8ufrrE1B5vD2NAIQ7q1fOOr/qd6CyZat5mEoCSavUviYimJ+z3YH8T0BcyRoAf1hOClSkcJrbyg713/X8eeD5mMuiAV+a7eG/nGxEjCM0QZUB1MzNyGMfM= Received: from AM4PR07MB3186.eurprd07.prod.outlook.com (10.171.188.151) by AM4PR07MB1236.eurprd07.prod.outlook.com (10.164.81.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.7; Wed, 14 Mar 2018 17:30:02 +0000 Received: from AM4PR07MB3186.eurprd07.prod.outlook.com ([fe80::d8fc:407:e8c0:e56c]) by AM4PR07MB3186.eurprd07.prod.outlook.com ([fe80::d8fc:407:e8c0:e56c%6]) with mapi id 15.20.0588.013; Wed, 14 Mar 2018 17:30:02 +0000 From: Steven Crangle To: "freebsd-pf@freebsd.org" Subject: Required modification for round robin napt with ip address prefixes Thread-Topic: Required modification for round robin napt with ip address prefixes Thread-Index: AQHTu7fDX4eUYNklBkma7Tav5LLNJA== Date: Wed, 14 Mar 2018 17:30:02 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Steven@stream-technologies.com; x-originating-ip: [212.250.79.109] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR07MB1236; 6:D6vaOqVibqQpw/44bOKmjlSSP0bBvDhEoL5IR6cEfwB8CklkHFBKrd2CbIsXMGLwKWClGkMBUlDcWN7GmCtM3LiEG/vJFloB9xAjohFO+lmOZg4xrL0uhO+pNmgkpsUawLCpqtsZG5F5wlmPEXd3GlhDt30SQkTL4eIpSiRp/8uxBaIkwO7kTXjFOqVcUm7N7Bixv+dWwczuSl2fZTyRdqTYQQhzSrsvIxvAMazYwnjykxjdwNKM7ih6clvnxEqoBeEQR192IwNj8KVkmpHHX913bN9n/R9le25zxDuLMTwhrrLP+Id4IrXDzeKM2qQhl93+cBb2jgXlpHL5HsajBcypEz/4eBvi5bD33jy42axHLng/ndGu8lAeiwu1ZmIf; 5:uG/rDYTtZLO0wjxs3rQ2wrS6A2CQyWLmaiREuczGkvjySUHwWxM05BHspV29lTnmSlKA/R9vu0FSRaq1qnPD9SjQnB3nSS4xAtj6zHxbp/auKBuN8bK0iSHO6xXVDBflZWo9Dj1Tz8p/pogmkHAMgT0kOQoj18hgX+8USPb7U1E=; 24:g7TXnxVaES6grnRKkgSt6AXIOqEb+9CmlAf6SAxWqXSUs4NfIZ+TVCxP9X77b9O0awaHkGwn5JNfgPXXFOd0sdGw92UIZFmSWZ7CWjcsVIU=; 7:DjAnoKXsRt9v69/Tam5mydFJQWVy0IxV+COaTCukDgowvFbFrPwPzNa4o9oNVOTv6DBex2zHOLZ38YH4eEMHSEX55klhsBRMScyP3AKJy8oKjjiqQ7azx0YJHRzZbzW+k+/S8JJBgNivSs/fZp2fjR1reR0OVWdufWW81f/vEOiLEUZrVEP29787mJRV4rUBwPo+U5pyqMYeUTTyJ80Pwr8wdv8baPLGQzhppIsPTzh62p9TD/XyLWaxG60QHKb5 x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 7d355e43-3643-4b77-2411-08d589d13848 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM4PR07MB1236; x-ms-traffictypediagnostic: AM4PR07MB1236: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231221)(944501244)(52105095)(6041310)(201703131423095)(201703011903075)(201702281528075)(20161123555045)(201703061421075)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:AM4PR07MB1236; BCL:0; PCL:0; RULEID:; SRVR:AM4PR07MB1236; x-forefront-prvs: 0611A21987 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(7966004)(396003)(39380400002)(366004)(376002)(346002)(39850400004)(189003)(199004)(8936002)(54896002)(9686003)(86362001)(6916009)(72206003)(68736007)(508600001)(81166006)(81156014)(55016002)(106356001)(6606003)(53936002)(186003)(102836004)(6506007)(7736002)(80792005)(8676002)(316002)(74316002)(5660300001)(59450400001)(7696005)(26005)(97736004)(33656002)(5250100002)(6116002)(2501003)(14454004)(2906002)(66066001)(105586002)(3280700002)(3660700001)(99286004)(19627405001)(2900100001)(3846002)(25786009)(2351001)(6436002)(5640700003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR07MB1236; H:AM4PR07MB3186.eurprd07.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: stream-technologies.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: uDO3udia8lDcClXJq3sYFg6wQJ7g1/wMyubxsnc+8ptwTWnK5V1AuWlIdQ8MzdSCNsc1zhWP0m2fOhOxG68a/JgLFBIgc/sMCbhnvzyOt8PZeukyLaWiLnnW99zVB5iQuvhrZyTHXeNmZc2M0NO9LuG2AWOx81RKUH9hJFI1q47BWHu+Lsz1fvryeuaQZHkHE8UYwn36hf/jm9WTy8zzxX3lwWvfQRclxKXPmPUwaQYKtc9nIu7dSrl1JMccNbAF33XtmLgvPIsrr6OSwjmxf23qM1e5ps0tM+0uaDCDvlpEClG3wsAd3QL7RJQCxeJhWEYkHG4D9vhwdKnD7UxohQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: stream-technologies.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d355e43-3643-4b77-2411-08d589d13848 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Mar 2018 17:30:02.7905 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 720fa073-5781-43bf-bc14-7bef2603ed21 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR07MB1236 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Mar 2018 17:30:07 -0000 Hi, I was looking for some advice on the type of locking required to stop a box= panicking that utilises both napt and ip address prefixes. My colleague made a post a while ago, and we ended up getting distracted fi= xing other panics that showed up. But we've now returned to try and figure = out the issue. The relevant code is in pf_lb.c : 424 Currently, I've tried adding a PF_RULES_WLOCK() around the sections of code= in the round robin code path that call pfr_pool_get(). In order to do this= I had to add in a few Macros so that I could upgrade the already held read= lock to a write lock. I then wasn't sure whether to return (1), or keep t= rying to obtain the write lock. The latter results in a crashed box (guessi= ng it could never obtain the lock), and I'm unsure of the implications of r= eturning a failure code so frequently from that code path, I'd imagine it w= ould result in napt not working correctly. The second solution suggested the use of atomics, which I'm going to try ne= xt. I just wanted to confirm that the correct area to look at would be with= in pfr_pool_get() ? I can see that pidx is being modified within there, an= d counter also seems to be being used. I also might well be looking in completely the wrong direction! Thanks for any help Steven