netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Allow to compile for < 3.17 kernel version
@ 2014-09-25  0:57 Vadim Kochan
  2014-09-25 17:12 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Vadim Kochan @ 2014-09-25  0:57 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Vadim Kochan

Added declaration checking for NFT_EXPR_LOG_LEVEL enum
which was added for 3.17 kernel version.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
 configure.ac              | 2 ++
 src/netlink_delinearize.c | 2 ++
 src/netlink_linearize.c   | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index 3a7647f..d3971c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -99,6 +99,8 @@ AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
 
+AC_CHECK_DECLS([NFT_EXPR_LOG_LEVEL],[],[],[[#include <libnftnl/expr.h>]])
+
 # Checks for library functions.
 AC_CHECK_FUNCS([memmove memset strchr strdup strerror strtoull])
 
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index 796b632..cf2ec00 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -447,11 +447,13 @@ static void netlink_parse_log(struct netlink_parse_ctx *ctx,
 			nft_rule_expr_get_u16(nle, NFT_EXPR_LOG_QTHRESHOLD);
 		stmt->log.flags |= STMT_LOG_QTHRESHOLD;
 	}
+#if HAVE_DECL_NFT_EXPR_LOG_LEVEL
 	if (nft_rule_expr_is_set(nle, NFT_EXPR_LOG_LEVEL)) {
 		stmt->log.level =
 			nft_rule_expr_get_u32(nle, NFT_EXPR_LOG_LEVEL);
 		stmt->log.flags |= STMT_LOG_LEVEL;
 	}
+#endif
 	list_add_tail(&stmt->list, &ctx->rule->stmts);
 }
 
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index c46b6d4..2b116f9 100644
--- a/src/netlink_linearize.c
+++ b/src/netlink_linearize.c
@@ -586,10 +586,12 @@ static void netlink_gen_log_stmt(struct netlink_linearize_ctx *ctx,
 			nft_rule_expr_set_u16(nle, NFT_EXPR_LOG_QTHRESHOLD,
 					      stmt->log.qthreshold);
 	} else {
+#if HAVE_DECL_NFT_EXPR_LOG_LEVEL
 		if (stmt->log.flags & STMT_LOG_LEVEL) {
 			nft_rule_expr_set_u32(nle, NFT_EXPR_LOG_LEVEL,
 					      stmt->log.level);
 		}
+#endif
 	}
 	nft_rule_add_expr(ctx->nlr, nle);
 }
-- 
2.1.0


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

* Re: [PATCH] Allow to compile for < 3.17 kernel version
  2014-09-25  0:57 [PATCH] Allow to compile for < 3.17 kernel version Vadim Kochan
@ 2014-09-25 17:12 ` Pablo Neira Ayuso
  2014-09-25 17:16   ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2014-09-25 17:12 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: netfilter-devel

On Thu, Sep 25, 2014 at 03:57:04AM +0300, Vadim Kochan wrote:
> Added declaration checking for NFT_EXPR_LOG_LEVEL enum
> which was added for 3.17 kernel version.
> 
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> ---
>  configure.ac              | 2 ++
>  src/netlink_delinearize.c | 2 ++
>  src/netlink_linearize.c   | 2 ++
>  3 files changed, 6 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index 3a7647f..d3971c7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -99,6 +99,8 @@ AC_TYPE_UINT16_T
>  AC_TYPE_UINT32_T
>  AC_TYPE_UINT64_T
>  
> +AC_CHECK_DECLS([NFT_EXPR_LOG_LEVEL],[],[],[[#include <libnftnl/expr.h>]])
> +
>  # Checks for library functions.
>  AC_CHECK_FUNCS([memmove memset strchr strdup strerror strtoull])
>  
> diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
> index 796b632..cf2ec00 100644
> --- a/src/netlink_delinearize.c
> +++ b/src/netlink_delinearize.c
> @@ -447,11 +447,13 @@ static void netlink_parse_log(struct netlink_parse_ctx *ctx,
>  			nft_rule_expr_get_u16(nle, NFT_EXPR_LOG_QTHRESHOLD);
>  		stmt->log.flags |= STMT_LOG_QTHRESHOLD;
>  	}
> +#if HAVE_DECL_NFT_EXPR_LOG_LEVEL
>  	if (nft_rule_expr_is_set(nle, NFT_EXPR_LOG_LEVEL)) {
>  		stmt->log.level =
>  			nft_rule_expr_get_u32(nle, NFT_EXPR_LOG_LEVEL);
>  		stmt->log.flags |= STMT_LOG_LEVEL;
>  	}
> +#endif
>  	list_add_tail(&stmt->list, &ctx->rule->stmts);
>  }
>  

I don't want to pollute the source code with many ifdef's, sorry. And
if I apply this, more similar follow up patches will come in the
future.

I'll make a patch to some recommended libnftnl version at configure
stage using PKG_CHECK_MODULES.

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

* Re: [PATCH] Allow to compile for < 3.17 kernel version
  2014-09-25 17:12 ` Pablo Neira Ayuso
@ 2014-09-25 17:16   ` Pablo Neira Ayuso
  2014-09-25 17:33     ` Vadim Kochan
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2014-09-25 17:16 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: netfilter-devel

On Thu, Sep 25, 2014 at 07:12:57PM +0200, Pablo Neira Ayuso wrote:
> On Thu, Sep 25, 2014 at 03:57:04AM +0300, Vadim Kochan wrote:
> > Added declaration checking for NFT_EXPR_LOG_LEVEL enum
> > which was added for 3.17 kernel version.
> > 
[...]
> > diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
> > index 796b632..cf2ec00 100644
> > --- a/src/netlink_delinearize.c
> > +++ b/src/netlink_delinearize.c
> > @@ -447,11 +447,13 @@ static void netlink_parse_log(struct netlink_parse_ctx *ctx,
> >  			nft_rule_expr_get_u16(nle, NFT_EXPR_LOG_QTHRESHOLD);
> >  		stmt->log.flags |= STMT_LOG_QTHRESHOLD;
> >  	}
> > +#if HAVE_DECL_NFT_EXPR_LOG_LEVEL
> >  	if (nft_rule_expr_is_set(nle, NFT_EXPR_LOG_LEVEL)) {
> >  		stmt->log.level =
> >  			nft_rule_expr_get_u32(nle, NFT_EXPR_LOG_LEVEL);
> >  		stmt->log.flags |= STMT_LOG_LEVEL;
> >  	}
> > +#endif
> >  	list_add_tail(&stmt->list, &ctx->rule->stmts);
> >  }
> >  
> 
> I don't want to pollute the source code with many ifdef's, sorry. And
> if I apply this, more similar follow up patches will come in the
> future.
> 
> I'll make a patch to some recommended libnftnl version at configure
> stage using PKG_CHECK_MODULES.

BTW, regarding the patch title, you should be able to compile libnftnl
and nftables with no matter kernel version since we're caching the
header files.

So the subject is innacurate. The real problem is that you cannot
compile new nftables with old library version since
NFT_EXPR_LOG_LEVEL, which is a different thing.

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

* Re: [PATCH] Allow to compile for < 3.17 kernel version
  2014-09-25 17:16   ` Pablo Neira Ayuso
@ 2014-09-25 17:33     ` Vadim Kochan
  0 siblings, 0 replies; 4+ messages in thread
From: Vadim Kochan @ 2014-09-25 17:33 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Thanks for response, I agree.

On Thu, Sep 25, 2014 at 8:16 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Thu, Sep 25, 2014 at 07:12:57PM +0200, Pablo Neira Ayuso wrote:
>> On Thu, Sep 25, 2014 at 03:57:04AM +0300, Vadim Kochan wrote:
>> > Added declaration checking for NFT_EXPR_LOG_LEVEL enum
>> > which was added for 3.17 kernel version.
>> >
> [...]
>> > diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
>> > index 796b632..cf2ec00 100644
>> > --- a/src/netlink_delinearize.c
>> > +++ b/src/netlink_delinearize.c
>> > @@ -447,11 +447,13 @@ static void netlink_parse_log(struct netlink_parse_ctx *ctx,
>> >                     nft_rule_expr_get_u16(nle, NFT_EXPR_LOG_QTHRESHOLD);
>> >             stmt->log.flags |= STMT_LOG_QTHRESHOLD;
>> >     }
>> > +#if HAVE_DECL_NFT_EXPR_LOG_LEVEL
>> >     if (nft_rule_expr_is_set(nle, NFT_EXPR_LOG_LEVEL)) {
>> >             stmt->log.level =
>> >                     nft_rule_expr_get_u32(nle, NFT_EXPR_LOG_LEVEL);
>> >             stmt->log.flags |= STMT_LOG_LEVEL;
>> >     }
>> > +#endif
>> >     list_add_tail(&stmt->list, &ctx->rule->stmts);
>> >  }
>> >
>>
>> I don't want to pollute the source code with many ifdef's, sorry. And
>> if I apply this, more similar follow up patches will come in the
>> future.
>>
>> I'll make a patch to some recommended libnftnl version at configure
>> stage using PKG_CHECK_MODULES.
>
> BTW, regarding the patch title, you should be able to compile libnftnl
> and nftables with no matter kernel version since we're caching the
> header files.
>
> So the subject is innacurate. The real problem is that you cannot
> compile new nftables with old library version since
> NFT_EXPR_LOG_LEVEL, which is a different thing.

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

end of thread, other threads:[~2014-09-25 17:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25  0:57 [PATCH] Allow to compile for < 3.17 kernel version Vadim Kochan
2014-09-25 17:12 ` Pablo Neira Ayuso
2014-09-25 17:16   ` Pablo Neira Ayuso
2014-09-25 17:33     ` Vadim Kochan

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