Date: Mon, 27 Jan 2003 11:49:37 +0200 (EET) From: Domas Mituzas <domas.mituzas@microlink.lt> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/47540: Make natd configurable in running state without loss of dynamic connections Message-ID: <200301270949.h0R9nb2o075626@ocean.delfi.lt>
index | next in thread | raw e-mail
>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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301270949.h0R9nb2o075626>
