Bug 47540 - [patch] Make natd(8) configurable in running state without loss of dynamic connections
Summary: [patch] Make natd(8) configurable in running state without loss of dynamic co...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.7-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2003-01-27 10:00 UTC by Domas Mituzas
Modified: 2022-10-17 12:38 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Domas Mituzas 2003-01-27 10:00:15 UTC
	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;
 }
Comment 1 Kris Kennaway freebsd_committer freebsd_triage 2003-07-18 23:10:44 UTC
Responsible Changed
From-To: freebsd-bugs->ru

Assign to natd maintainer
Comment 2 ru freebsd_committer freebsd_triage 2004-04-17 07:17:45 UTC
Responsible Changed
From-To: ru->freebsd-bugs

ENOTIME.
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:38 UTC
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
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:38:44 UTC
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>