All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iptables 1/2] xtables-translate: add new field to identify the caller
@ 2016-07-22 15:48 Pablo M. Bermudo Garay
  2016-07-22 15:48 ` [PATCH iptables 2/2] xtables-translate: fix issue with quotes Pablo M. Bermudo Garay
  2016-07-23 11:24 ` [PATCH iptables 1/2] xtables-translate: add new field to identify the caller Pablo Neira Ayuso
  0 siblings, 2 replies; 7+ messages in thread
From: Pablo M. Bermudo Garay @ 2016-07-22 15:48 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Pablo M. Bermudo Garay

In some cases, xlate functions must print a different result if they are
invoked from nft and not from a xtables-translate command.

This commit adds a new boolean field to the xt_xlate struct. This
variable must be true when a xlate function is called from a nft
command. Additional code is required in nft in order to obtain this
behavior.

Signed-off-by: Pablo M. Bermudo Garay <pablombg@gmail.com>
---
 include/xtables.h    |  2 ++
 libxtables/xtables.c | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/xtables.h b/include/xtables.h
index 48be514..fd72623 100644
--- a/include/xtables.h
+++ b/include/xtables.h
@@ -576,6 +576,8 @@ void xt_xlate_add(struct xt_xlate *xl, const char *fmt, ...);
 void xt_xlate_add_comment(struct xt_xlate *xl, const char *comment);
 const char *xt_xlate_get_comment(struct xt_xlate *xl);
 const char *xt_xlate_get(struct xt_xlate *xl);
+void xt_xlate_set_nft_compat(struct xt_xlate *xl, bool nft_compat);
+bool xt_xlate_get_nft_compat(struct xt_xlate *xl);
 
 #ifdef XTABLES_INTERNAL
 
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index 921dfe9..1c3f63d 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -2011,6 +2011,7 @@ struct xt_xlate {
 		int	off;
 	} buf;
 	char comment[NFT_USERDATA_MAXLEN];
+	bool nft_compat;
 };
 
 struct xt_xlate *xt_xlate_alloc(int size)
@@ -2029,6 +2030,7 @@ struct xt_xlate *xt_xlate_alloc(int size)
 	xl->buf.rem = size;
 	xl->buf.off = 0;
 	xl->comment[0] = '\0';
+	xl->nft_compat = false;
 
 	return xl;
 }
@@ -2069,3 +2071,13 @@ const char *xt_xlate_get(struct xt_xlate *xl)
 {
 	return xl->buf.data;
 }
+
+void xt_xlate_set_nft_compat(struct xt_xlate *xl, bool nft_compat)
+{
+	xl->nft_compat = nft_compat;
+}
+
+bool xt_xlate_get_nft_compat(struct xt_xlate *xl)
+{
+	return xl->nft_compat;
+}
-- 
2.9.0


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

end of thread, other threads:[~2016-07-26 16:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-22 15:48 [PATCH iptables 1/2] xtables-translate: add new field to identify the caller Pablo M. Bermudo Garay
2016-07-22 15:48 ` [PATCH iptables 2/2] xtables-translate: fix issue with quotes Pablo M. Bermudo Garay
2016-07-23 10:15   ` Pablo Neira Ayuso
2016-07-25 15:31   ` Pablo Neira Ayuso
2016-07-26 16:22     ` Pablo M. Bermudo Garay
2016-07-26 16:27       ` Pablo Neira Ayuso
2016-07-23 11:24 ` [PATCH iptables 1/2] xtables-translate: add new field to identify the caller Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.