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; }
Responsible Changed From-To: freebsd-bugs->ru Assign to natd maintainer
Responsible Changed From-To: ru->freebsd-bugs ENOTIME.
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped
Keyword: patch or patch-ready – in lieu of summary line prefix: [patch] * bulk change for the keyword * summary lines may be edited manually (not in bulk). Keyword descriptions and search interface: <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>