* [PATCH nft] ct: use nftables sysconf location for connlabel configuration
@ 2016-07-20 10:17 Florian Westphal
2016-07-20 16:19 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2016-07-20 10:17 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
Instead of using /etc/xtables use the nftables syconfdir.
Also update error message to tell which label failed translation
and which config file was used for this:
nft add filter input ct label foo
<cmdline>:1:27-29: Error: /etc/nftables/connlabel.conf: could not parse conntrack label "foo"
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/Makefile.am | 2 ++
src/ct.c | 7 +++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c59449..ff1dd6e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,8 @@ parser_bison.o scanner.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-decl
BUILT_SOURCES = parser_bison.h
+ct.o: AM_CFLAGS += -DCONNLABEL_PATH="\"${sysconfdir}/\""
+
nft_SOURCES = main.c \
rule.c \
statement.c \
diff --git a/src/ct.c b/src/ct.c
index b971ba1..e974307 100644
--- a/src/ct.c
+++ b/src/ct.c
@@ -29,6 +29,8 @@
#include <utils.h>
#include <statement.h>
+#define CONNLABEL_CONF CONNLABEL_PATH "connlabel.conf"
+
static const struct symbol_table ct_state_tbl = {
.symbols = {
SYMBOL("invalid", NF_CT_STATE_INVALID_BIT),
@@ -128,7 +130,8 @@ static struct error_record *ct_label_type_parse(const struct expr *sym,
dtype = sym->dtype;
if (s->identifier == NULL)
- return error(&sym->location, "Could not parse %s", dtype->desc);
+ return error(&sym->location, "%s: could not parse %s \"%s\"", CONNLABEL_CONF,
+ dtype->desc, sym->identifier);
if (s->value >= CT_LABEL_BIT_SIZE)
return error(&sym->location, "%s: out of range (%u max)",
@@ -158,7 +161,7 @@ static const struct datatype ct_label_type = {
static void __init ct_label_table_init(void)
{
- ct_label_tbl = rt_symbol_table_init("/etc/xtables/connlabel.conf");
+ ct_label_tbl = rt_symbol_table_init(CONNLABEL_CONF);
}
#ifndef NF_CT_HELPER_NAME_LEN
--
2.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nft] ct: use nftables sysconf location for connlabel configuration
2016-07-20 10:17 [PATCH nft] ct: use nftables sysconf location for connlabel configuration Florian Westphal
@ 2016-07-20 16:19 ` Pablo Neira Ayuso
2016-07-20 22:27 ` Florian Westphal
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-07-20 16:19 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]
On Wed, Jul 20, 2016 at 12:17:05PM +0200, Florian Westphal wrote:
> Instead of using /etc/xtables use the nftables syconfdir.
> Also update error message to tell which label failed translation
> and which config file was used for this:
>
> nft add filter input ct label foo
> <cmdline>:1:27-29: Error: /etc/nftables/connlabel.conf: could not parse conntrack label "foo"
>
> Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> src/Makefile.am | 2 ++
> src/ct.c | 7 +++++--
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 8c59449..ff1dd6e 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -27,6 +27,8 @@ parser_bison.o scanner.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-decl
>
> BUILT_SOURCES = parser_bison.h
>
> +ct.o: AM_CFLAGS += -DCONNLABEL_PATH="\"${sysconfdir}/\""
I think we can simplify this by using DEFAULT_INCLUDE_PATH.
See patch attached, it applies on top of this one. Feel free to
collapse them.
[-- Attachment #2: x.patch --]
[-- Type: text/x-diff, Size: 1207 bytes --]
diff --git a/src/Makefile.am b/src/Makefile.am
index ff1dd6e..8c59449 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,8 +27,6 @@ parser_bison.o scanner.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-decl
BUILT_SOURCES = parser_bison.h
-ct.o: AM_CFLAGS += -DCONNLABEL_PATH="\"${sysconfdir}/\""
-
nft_SOURCES = main.c \
rule.c \
statement.c \
diff --git a/src/ct.c b/src/ct.c
index e974307..f383f29 100644
--- a/src/ct.c
+++ b/src/ct.c
@@ -29,7 +29,7 @@
#include <utils.h>
#include <statement.h>
-#define CONNLABEL_CONF CONNLABEL_PATH "connlabel.conf"
+#define CONNLABEL_CONF DEFAULT_INCLUDE_PATH "connlabel.conf"
static const struct symbol_table ct_state_tbl = {
.symbols = {
@@ -130,8 +130,8 @@ static struct error_record *ct_label_type_parse(const struct expr *sym,
dtype = sym->dtype;
if (s->identifier == NULL)
- return error(&sym->location, "%s: could not parse %s \"%s\"", CONNLABEL_CONF,
- dtype->desc, sym->identifier);
+ return error(&sym->location, "%s: could not parse %s \"%s\"",
+ CONNLABEL_CONF, dtype->desc, sym->identifier);
if (s->value >= CT_LABEL_BIT_SIZE)
return error(&sym->location, "%s: out of range (%u max)",
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nft] ct: use nftables sysconf location for connlabel configuration
2016-07-20 16:19 ` Pablo Neira Ayuso
@ 2016-07-20 22:27 ` Florian Westphal
0 siblings, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2016-07-20 22:27 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Florian Westphal, netfilter-devel
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Wed, Jul 20, 2016 at 12:17:05PM +0200, Florian Westphal wrote:
> > Instead of using /etc/xtables use the nftables syconfdir.
> > Also update error message to tell which label failed translation
> > and which config file was used for this:
> >
> > nft add filter input ct label foo
> > <cmdline>:1:27-29: Error: /etc/nftables/connlabel.conf: could not parse conntrack label "foo"
> >
> > Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > Signed-off-by: Florian Westphal <fw@strlen.de>
> > ---
> > src/Makefile.am | 2 ++
> > src/ct.c | 7 +++++--
> > 2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/Makefile.am b/src/Makefile.am
> > index 8c59449..ff1dd6e 100644
> > --- a/src/Makefile.am
> > +++ b/src/Makefile.am
> > @@ -27,6 +27,8 @@ parser_bison.o scanner.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-decl
> >
> > BUILT_SOURCES = parser_bison.h
> >
> > +ct.o: AM_CFLAGS += -DCONNLABEL_PATH="\"${sysconfdir}/\""
>
> I think we can simplify this by using DEFAULT_INCLUDE_PATH.
>
> See patch attached, it applies on top of this one. Feel free to
> collapse them.
Okay, I pushed it to nftables.git (with your patch collapsed).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-20 22:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-20 10:17 [PATCH nft] ct: use nftables sysconf location for connlabel configuration Florian Westphal
2016-07-20 16:19 ` Pablo Neira Ayuso
2016-07-20 22:27 ` Florian Westphal
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).