netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] expr: allow export of notrack expr
@ 2019-08-02  4:20 Ivan Babrou
  2019-08-02  9:35 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Ivan Babrou @ 2019-08-02  4:20 UTC (permalink / raw)
  To: netfilter-devel

Currently it's impossible to export notrack expr as json,
as it lacks snprintf member and triggers segmentation fault.

There are no parameters to notrack, so there's nothing
to do, but it should be an explicit function that does nothing.

Signed-off-by: Ivan Babrou <ivan@cloudflare.com>
---
 src/expr_ops.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/expr_ops.c b/src/expr_ops.c
index 3538dd6..a2e1dd3 100644
--- a/src/expr_ops.c
+++ b/src/expr_ops.c
@@ -42,8 +42,16 @@ extern struct expr_ops expr_ops_tunnel;
 extern struct expr_ops expr_ops_osf;
 extern struct expr_ops expr_ops_xfrm;

+static int
+nftnl_expr_notrack_snprintf(char *buf, size_t len, uint32_t type,
+   uint32_t flags, const struct nftnl_expr *e)
+{
+ return -1;
+}
+
 static struct expr_ops expr_ops_notrack = {
  .name = "notrack",
+ .snprintf = nftnl_expr_notrack_snprintf,
 };

 static struct expr_ops *expr_ops[] = {
--
2.22.0

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

* Re: [PATCH] expr: allow export of notrack expr
  2019-08-02  4:20 [PATCH] expr: allow export of notrack expr Ivan Babrou
@ 2019-08-02  9:35 ` Florian Westphal
  2019-08-02 17:39   ` Ivan Babrou
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2019-08-02  9:35 UTC (permalink / raw)
  To: Ivan Babrou; +Cc: netfilter-devel

Ivan Babrou <ivan@cloudflare.com> wrote:
> Currently it's impossible to export notrack expr as json,
> as it lacks snprintf member and triggers segmentation fault.

Hmm, works for me:

table ip raw {
        chain prerouting {
                type filter hook prerouting priority -300; policy accept;
                udp dport 53 notrack
}

gets exported as:

nft -j list ruleset
{"nftables": [{"metainfo": {"version": "0.9.1", "release_name": "Headless Horseman", "json_schema_version": 1}}, {"table": {"family": "ip", "name": "raw", "handle": 1}}, {"chain": {"family": "ip", "table": "raw", "name": "prerouting", "handle": 1, "type": "filter", "hook": "prerouting", "prio": -300, "policy": "accept"}}, {"rule": {"family": "ip", "table": "raw", "chain": "prerouting", "handle": 3, "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "udp", "field": "dport"}}, "right": 53}}, {"notrack": null}]}}]}

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

* Re: [PATCH] expr: allow export of notrack expr
  2019-08-02  9:35 ` Florian Westphal
@ 2019-08-02 17:39   ` Ivan Babrou
  0 siblings, 0 replies; 3+ messages in thread
From: Ivan Babrou @ 2019-08-02 17:39 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

You're right, it does indeed work in master. I've seen the issue on
Debian with libnftnl-1.0.7 and assumed it carried over to the latest
version by glancing over the code without actually trying it.

Sorry about that.

On Fri, Aug 2, 2019 at 2:35 AM Florian Westphal <fw@strlen.de> wrote:
>
> Ivan Babrou <ivan@cloudflare.com> wrote:
> > Currently it's impossible to export notrack expr as json,
> > as it lacks snprintf member and triggers segmentation fault.
>
> Hmm, works for me:
>
> table ip raw {
>         chain prerouting {
>                 type filter hook prerouting priority -300; policy accept;
>                 udp dport 53 notrack
> }
>
> gets exported as:
>
> nft -j list ruleset
> {"nftables": [{"metainfo": {"version": "0.9.1", "release_name": "Headless Horseman", "json_schema_version": 1}}, {"table": {"family": "ip", "name": "raw", "handle": 1}}, {"chain": {"family": "ip", "table": "raw", "name": "prerouting", "handle": 1, "type": "filter", "hook": "prerouting", "prio": -300, "policy": "accept"}}, {"rule": {"family": "ip", "table": "raw", "chain": "prerouting", "handle": 3, "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "udp", "field": "dport"}}, "right": 53}}, {"notrack": null}]}}]}

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

end of thread, other threads:[~2019-08-02 17:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-02  4:20 [PATCH] expr: allow export of notrack expr Ivan Babrou
2019-08-02  9:35 ` Florian Westphal
2019-08-02 17:39   ` Ivan Babrou

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