From owner-freebsd-bugs Mon Jan 27 2:24:12 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4AC0437B405 for ; Mon, 27 Jan 2003 02:24:08 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7144443F9B for ; Mon, 27 Jan 2003 02:24:06 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (smmsp@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h0RAO6NU083958 for ; Mon, 27 Jan 2003 02:24:06 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h0RA0GL9066438; Mon, 27 Jan 2003 02:00:16 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D555337B401 for ; Mon, 27 Jan 2003 01:52:13 -0800 (PST) Received: from ocean.delfi.lt (ocean.delfi.lt [213.197.128.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0475043E4A for ; Mon, 27 Jan 2003 01:52:13 -0800 (PST) (envelope-from midom@ocean.delfi.lt) Received: from ocean.delfi.lt (localhost [127.0.0.1]) by ocean.delfi.lt (8.12.6/8.12.6) with ESMTP id h0R9qhGT075666 for ; Mon, 27 Jan 2003 11:52:43 +0200 (EET) (envelope-from midom@ocean.delfi.lt) Received: (from root@localhost) by ocean.delfi.lt (8.12.6/8.12.6/Submit) id h0R9nb2o075626; Mon, 27 Jan 2003 11:49:37 +0200 (EET) Message-Id: <200301270949.h0R9nb2o075626@ocean.delfi.lt> Date: Mon, 27 Jan 2003 11:49:37 +0200 (EET) From: Domas Mituzas Reply-To: Domas Mituzas To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/47540: Make natd configurable in running state without loss of dynamic connections Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 47540 >Category: bin >Synopsis: Make natd configurable in running state without loss of dynamic connections >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Jan 27 02:00:15 PST 2003 >Closed-Date: >Last-Modified: >Originator: Domas Mituzas >Release: FreeBSD 4.7-RELEASE i386 >Organization: MicroLink Data >Environment: System: FreeBSD ocean.delfi.lt 4.7-RELEASE FreeBSD 4.7-RELEASE #1: Mon Oct 21 16:43:58 EET 2002 root@:/usr/obj/usr/src/sys/OCEAN i386 As well: 5.0-CURRENT >Description: natd right now is configurable only during start, so any changes in address or port mappings require program restart, as well as losing dynamic rules for connections. I've made a simple patch that upon SIGUSR1 rereads configuration, by flushing and establishing again permanent rules, and possibly - some configuration parameters. >How-To-Repeat: Index: natd.c =================================================================== RCS file: /opt/ncvs/src/sbin/natd/natd.c,v retrieving revision 1.39 diff -u -r1.39 natd.c --- natd.c 15 Jan 2002 17:07:56 -0000 1.39 +++ natd.c 30 Dec 2002 12:33:15 -0000 @@ -86,6 +86,7 @@ static void InitiateShutdown (int); static void Shutdown (int); static void RefreshAddr (int); +static void ReConfigure (int); static void ParseOption (const char* option, const char* parms); static void ReadConfigFile (const char* fileName); static void SetupPortRedirect (const char* parms); @@ -121,6 +122,8 @@ static int logDropped; static int logFacility; static int logIpfwDenied; +static int Argc; +static char** Argv; int main (int argc, char** argv) { @@ -156,6 +159,9 @@ logFacility = LOG_DAEMON; logIpfwDenied = -1; + Argc = argc; + Argv = argv; + ParseArgs (argc, argv); /* * Log ipfw(8) denied packets by default in verbose mode. @@ -291,8 +297,10 @@ */ siginterrupt(SIGTERM, 1); siginterrupt(SIGHUP, 1); + siginterrupt(SIGUSR1, 1); signal (SIGTERM, InitiateShutdown); signal (SIGHUP, RefreshAddr); + signal (SIGUSR1, ReConfigure); /* * Set alias address if it has been given. */ @@ -791,6 +799,12 @@ { if (ifName) assignAliasAddr = 1; +} + +static void ReConfigure (int sig) +{ + CleanupPermAliasData(); + ParseArgs(Argc,Argv); } static void InitiateShutdown (int sig) Index: alias.h =================================================================== RCS file: /opt/ncvs/src/lib/libalias/alias.h,v retrieving revision 1.23 diff -u -r1.23 alias.h --- alias.h 1 Jul 2002 11:19:40 -0000 1.23 +++ alias.h 30 Dec 2002 12:15:20 -0000 @@ -70,6 +70,7 @@ PacketAliasRedirectAddr(struct in_addr _src_addr, struct in_addr _alias_addr); void PacketAliasRedirectDelete(struct alias_link *_link); +void CleanupPermAliasData(void); struct alias_link * PacketAliasRedirectPort(struct in_addr _src_addr, unsigned short _src_port, struct in_addr _dst_addr, Index: alias_db.c =================================================================== RCS file: /opt/ncvs/src/lib/libalias/alias_db.c,v retrieving revision 1.51 diff -u -r1.51 alias_db.c --- alias_db.c 18 Jul 2002 05:18:41 -0000 1.51 +++ alias_db.c 30 Dec 2002 12:21:56 -0000 @@ -383,6 +383,10 @@ static int deleteAllLinks; /* If equal to zero, DeleteLink() */ /* will not remove permanent links */ +static int deletePermanentOnly; /* If not equal to zero, */ + /* CleanupAliasData() would remove */ + /* permanent links only */ + static FILE *monitorFile; /* File descriptor for link */ /* statistics monitoring file */ @@ -527,6 +531,7 @@ Link creation and deletion: CleanupAliasData() - remove all link chains from lookup table + CleanupPermAliasData() - remove all permanent link chains IncrementalCleanup() - look for stale links in a single chain DeleteLink() - remove link AddLink() - add link @@ -856,12 +861,22 @@ struct alias_link *link_next; link_next = LIST_NEXT(link, list_out); icount++; - DeleteLink(link); + if (deletePermanentOnly && link->flags & LINK_PERMANENT) + DeleteLink(link); link = link_next; } } - cleanupIndex =0; + if (!deletePermanentOnly) + cleanupIndex =0; +} + +void +CleanupPermAliasData(void) +{ + deletePermanentOnly=1; + CleanupAliasData(); + deletePermanentOnly=0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message