netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ebtables: Adding --noflush command line support for ebtables-restore
@ 2013-07-22 14:01 Sanket Shah
  2013-08-01 20:18 ` Bart De Schuymer
  0 siblings, 1 reply; 2+ messages in thread
From: Sanket Shah @ 2013-07-22 14:01 UTC (permalink / raw)
  To: netfilter-devel; +Cc: bdschuym, Sanket Shah, Ankit Shah

Similar to iptables-restore with noflush.

Signed-off-by: Ankit Shah <ankit.shah.sm@gmail.com>
Signed-off-by: Sanket Shah <sanket.shah@cyberoam.com>
---
 userspace/ebtables2/ebtables-restore.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/userspace/ebtables2/ebtables-restore.c b/userspace/ebtables2/ebtables-restore.c
index ea02960..bb4d0cf 100644
--- a/userspace/ebtables2/ebtables-restore.c
+++ b/userspace/ebtables2/ebtables-restore.c
@@ -22,13 +22,25 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#include <getopt.h>
 #include "include/ebtables_u.h"
 
+static const struct option options[] = {
+	{.name = "noflush", .has_arg = 0, .val = 'n'},
+	{ 0 }
+};
+
 static struct ebt_u_replace replace[3];
 void ebt_early_init_once();
 
 #define OPT_KERNELDATA  0x800 /* Also defined in ebtables.c */
 
+static void print_usage()
+{
+	fprintf(stderr, "Usage: ebtables-restore [ --noflush ]\n");
+	exit(1);
+}
+
 static void copy_table_names()
 {
 	strcpy(replace[0].name, "filter");
@@ -41,11 +53,20 @@ static void copy_table_names()
 int main(int argc_, char *argv_[])
 {
 	char *argv[EBTD_ARGC_MAX], cmdline[EBTD_CMDLINE_MAXLN];
-	int i, offset, quotemode = 0, argc, table_nr = -1, line = 0, whitespace;
+	int i, offset, quotemode = 0, argc, table_nr = -1, line = 0, whitespace, c, flush = 1;
 	char ebtables_str[] = "ebtables";
 
-	if (argc_ != 1)
-		ebtrest_print_error("options are not supported");
+	while ((c = getopt_long(argc_, argv_, "n", options, NULL)) != -1) {
+		switch(c) {
+			case 'n':
+				flush = 0;
+				break;
+			default:
+				print_usage();
+				break;
+		}
+	}
+
 	ebt_silent = 0;
 	copy_table_names();
 	ebt_early_init_once();
@@ -68,7 +89,7 @@ int main(int argc_, char *argv_[])
 				ebtrest_print_error("table '%s' was not recognized", cmdline+1);
 			table_nr = i;
 			replace[table_nr].command = 11;
-			ebt_get_kernel_table(&replace[table_nr], 1);
+			ebt_get_kernel_table(&replace[table_nr], flush);
 			replace[table_nr].command = 0;
 			replace[table_nr].flags = OPT_KERNELDATA; /* Prevent do_command from initialising replace */
 			continue;
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ebtables: Adding --noflush command line support for ebtables-restore
  2013-07-22 14:01 [PATCH] ebtables: Adding --noflush command line support for ebtables-restore Sanket Shah
@ 2013-08-01 20:18 ` Bart De Schuymer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart De Schuymer @ 2013-08-01 20:18 UTC (permalink / raw)
  To: Sanket Shah; +Cc: netfilter-devel, Ankit Shah

Op 22/07/2013 16:01, Sanket Shah schreef:
> Similar to iptables-restore with noflush.
>
> Signed-off-by: Ankit Shah <ankit.shah.sm@gmail.com>
> Signed-off-by: Sanket Shah <sanket.shah@cyberoam.com>
Applied, thanks.

Bart


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-01 20:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-22 14:01 [PATCH] ebtables: Adding --noflush command line support for ebtables-restore Sanket Shah
2013-08-01 20:18 ` Bart De Schuymer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).