netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cmd: initialize cmd list and use list_splice_tail() for adding to command list
@ 2014-02-05 19:10 Patrick McHardy
  0 siblings, 0 replies; only message in thread
From: Patrick McHardy @ 2014-02-05 19:10 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel

With incremental evaluation we're first evaluating the command before
adding it to the global command list, so the command's list_head is
uninitialized during evaluation. We need to initialize it to handle the
case that an implicit set declaration will prepend a command to the list.

Also list_splice_tail() needs to be used instead of list_add_tail() to
add the entire list of commands.

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 src/parser.y | 4 ++--
 src/rule.c   | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/parser.y b/src/parser.y
index f6c9488..2050f8a 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -497,7 +497,7 @@ input			:	/* empty */
 						if (++state->nerrs == max_errors)
 							YYABORT;
 					} else
-						list_add_tail(&$2->list, &state->cmds);
+						list_splice_tail(&$2->list, &state->cmds);
 				}
 			}
 			;
@@ -560,7 +560,7 @@ line			:	common_block			{ $$ = NULL; }
 						if (++state->nerrs == max_errors)
 							YYABORT;
 					} else
-						list_add_tail(&$1->list, &state->cmds);
+						list_splice_tail(&$1->list, &state->cmds);
 				}
 				$$ = NULL;
 
diff --git a/src/rule.c b/src/rule.c
index 657695a..ab96e62 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -426,6 +426,7 @@ struct cmd *cmd_alloc(enum cmd_ops op, enum cmd_obj obj,
 	struct cmd *cmd;
 
 	cmd = xzalloc(sizeof(*cmd));
+	init_list_head(&cmd->list);
 	cmd->op       = op;
 	cmd->obj      = obj;
 	cmd->handle   = *h;
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-05 19:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 19:10 [PATCH] cmd: initialize cmd list and use list_splice_tail() for adding to command list Patrick McHardy

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).