[PATCH nft 2/3] parser_bison: store location of basechain definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wrap basechain definition field around structure, add field later.
This is useful for error reporting.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 include/rule.h     | 17 ++++++++++-------
 src/parser_bison.y |  1 +
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/rule.h b/include/rule.h
index 06fefef8a5d8..ac69b30673e8 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -217,13 +217,16 @@ struct chain {
 	struct location		location;
 	unsigned int		refcnt;
 	uint32_t		flags;
-	struct prio_spec	priority;
-	struct hook_spec	hook;
-	struct expr		*policy;
-	const char		*type;
-	const char		**dev_array;
-	struct expr		*dev_expr;
-	int			dev_array_len;
+	struct {
+		struct location		loc;
+		struct prio_spec	priority;
+		struct hook_spec	hook;
+		struct expr		*policy;
+		const char		*type;
+		const char		**dev_array;
+		struct expr		*dev_expr;
+		int			dev_array_len;
+	};
 	struct scope		scope;
 	struct list_head	rules;
 };
diff --git a/src/parser_bison.y b/src/parser_bison.y
index ebaef17c904c..735f2dffc6e6 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -2057,6 +2057,7 @@ hook_spec		:	TYPE		STRING		HOOK		STRING		dev_spec	prio_spec
 				$<chain>0->type		= xstrdup(chain_type);
 				xfree($2);
 
+				$<chain>0->loc = @$;
 				$<chain>0->hook.loc = @4;
 				$<chain>0->hook.name = chain_hookname_lookup($4);
 				if ($<chain>0->hook.name == NULL) {
-- 
2.11.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux