nftables: add ct helper set support
Florian Westphal
maintainercover nftables: add ct helper set support
This series adds initial support to set conntrack helpers via the nft objref infrastructure.
As -next is closed I will not push this yet since kernel support is still missing.
Currently only supported attributes are:
type (e.g. "ftp", "sip)
protocol (udp or tcp)
l3proto (ip, ip6).
l3proto is optional, the kernel will infer it from
the family, i.e. in "inet" case kernel will check for both ipv4 and ipv6.
Let me know in case you spot any isses, patches #3 and #5 could already be pushed to nft master since they are just preparation patches.
Florian Westphal
maintainerPATCH 1/7 object: extend set/get api for u8/u16 types
--- include/libnftnl/object.h | 4 ++++ src/libnftnl.map | 8 ++++++++ src/object.c | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)
include/libnftnl/object.h +4 -0
@@ -44,12 +44,16 @@ void nftnl_obj_unset(struct nftnl_obj *ne, uint16_t attr);void nftnl_obj_set_data (struct nftnl_obj *ne,uint16_t attr,const void *data,uint32_t data_len);void nftnl_obj_set (struct nftnl_obj *ne,uint16_t attr,const void *data); +void nftnl_obj_set_u8 (struct nftnl_obj *ne,uint16_t attr,uint8_t val); +void nftnl_obj_set_u16 (struct nftnl_obj *ne,uint16_t attr,uint16_t val);void nftnl_obj_set_u32 (struct nftnl_obj *ne,uint16_t attr,uint32_t val);void nftnl_obj_set_u64 (struct nftnl_obj *obj,uint16_t attr,uint64_t val);void nftnl_obj_set_str (struct nftnl_obj *ne,uint16_t attr,const char *str);const void *nftnl_obj_get_data (struct nftnl_obj *ne,uint16_t attr,uint32_t *data_len);const void *nftnl_obj_get (struct nftnl_obj *ne,uint16_t attr); +uint8_t nftnl_obj_get_u8 (struct nftnl_obj *ne,uint16_t attr); +uint16_t nftnl_obj_get_u16 (struct nftnl_obj *obj,uint16_t attr);uint32_t nftnl_obj_get_u32 (struct nftnl_obj *ne,uint16_t attr);uint64_t nftnl_obj_get_u64 (struct nftnl_obj *obj,uint16_t attr);const char *nftnl_obj_get_str (struct nftnl_obj *ne,uint16_t attr);
src/libnftnl.map +8 -0
@@ -301,3 +301,11 @@ global: local: *; }; + +LIBNFTNL_5.1 { + nftnl_obj_get_u8; + nftnl_obj_get_u16; + + nftnl_obj_set_u8; + nftnl_obj_set_u16; +} LIBNFTNL_5;
src/object.c +26 -0
@@ -107,6 +107,18 @@ void nftnl_obj_set(struct nftnl_obj *obj, uint16_t attr, const void *data) }EXPORT_SYMBOL (nftnl_obj_set); +void nftnl_obj_set_u8 (struct nftnl_obj *obj,uint16_t attr,uint8_t val) +{ +nftnl_obj_set_data (obj, attr, &val,sizeof (uint8_t )); +} +EXPORT_SYMBOL (nftnl_obj_set_u8); + +void nftnl_obj_set_u16 (struct nftnl_obj *obj,uint16_t attr,uint16_t val) +{ +nftnl_obj_set_data (obj, attr, &val,sizeof (uint16_t )); +} +EXPORT_SYMBOL (nftnl_obj_set_u16); +void nftnl_obj_set_u32 (struct nftnl_obj *obj,uint16_t attr,uint32_t val) {nftnl_obj_set_data (obj, attr, &val,sizeof (uint32_t ));
@@ -164,6 +176,20 @@ const void *nftnl_obj_get(struct nftnl_obj *obj, uint16_t attr) }EXPORT_SYMBOL (nftnl_obj_get); +uint8_t nftnl_obj_get_u8 (struct nftnl_obj *obj,uint16_t attr) +{ +const void *ret =nftnl_obj_get (obj, attr); +return ret ==NULL ?0 : *((uint8_t *)ret); +} +EXPORT_SYMBOL (nftnl_obj_get_u8); + +uint16_t nftnl_obj_get_u16 (struct nftnl_obj *obj,uint16_t attr) +{ +const void *ret =nftnl_obj_get (obj, attr); +return ret ==NULL ?0 : *((uint16_t *)ret); +} +EXPORT_SYMBOL (nftnl_obj_get_u16); +uint32_t nftnl_obj_get_u32 (struct nftnl_obj *obj,uint16_t attr) {const void *ret =nftnl_obj_get (obj, attr);
Signature · 1 line
2.10.2
Florian Westphal
maintainerPATCH 2/7 src: ct helper support
In reply to Florian Westphaladd support for ct helper objects, these are used to assign helpers to connections, similar to iptables -j CT --set-helper target.
--- include/libnftnl/object.h | 6 ++ include/linux/netfilter/nf_tables.h | 12 ++- include/obj.h | 6 ++ src/Makefile.am | 1 + src/obj/ct_helper.c | 210 ++++++++++++++++++++++++++++++++++++ src/object.c | 3 +- 6 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 src/obj/ct_helper.c
include/libnftnl/object.h +6 -0
@@ -34,6 +34,12 @@ enum { NFTNL_OBJ_QUOTA_FLAGS, }; +enum { +NFTNL_OBJ_CT_HELPER_NAME =NFTNL_OBJ_BASE , +NFTNL_OBJ_CT_HELPER_L3PROTO , +NFTNL_OBJ_CT_HELPER_L4PROTO , +}; +struct nftnl_obj ;struct nftnl_obj *nftnl_obj_alloc (void );
include/linux/netfilter/nf_tables.h +11 -1
@@ -1246,10 +1246,20 @@ enum nft_fib_flags { NFTA_FIB_F_OIF = 1 << 4, /* restrict to oif */ }; +enum nft_ct_helper_attributes { +NFTA_CT_HELPER_UNSPEC , +NFTA_CT_HELPER_NAME , +NFTA_CT_HELPER_L3PROTO , +NFTA_CT_HELPER_L4PROTO , + __NFTA_CT_HELPER_MAX, +}; +#define NFTA_CT_HELPER_MAX (__NFTA_CT_HELPER_MAX - 1) +#define NFT_OBJECT_UNSPEC 0#define NFT_OBJECT_COUNTER 1#define NFT_OBJECT_QUOTA 2 -#define __NFT_OBJECT_MAX 3 +#define NFT_OBJECT_CT_HELPER 3 +#define __NFT_OBJECT_MAX 4#define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1)/**
include/obj.h +6 -0
@@ -30,6 +30,11 @@ struct nftnl_obj {uint64_t consumed;uint32_t flags; } quota; +struct nftnl_obj_ct_helper { +uint16_t l3proto; +uint8_t l4proto; +char name[16 ]; + } ct_helper; } data; };
@@ -49,6 +54,7 @@ struct obj_ops {extern struct obj_ops obj_ops_counter;extern struct obj_ops obj_ops_quota; +extern struct obj_ops obj_ops_ct_helper;#define nftnl_obj_data (obj) (void *)&obj->data
src/Makefile.am +1 -0
@@ -53,5 +53,6 @@ libnftnl_la_SOURCES = utils.c \ expr/redir.c \ expr/hash.c \ obj/counter.c \ + obj/ct_helper.c \ obj/quota.c \ libnftnl.map
src/obj/ct_helper.c new file +210 -0
210 lines not on this page · raw message
src/object.c +2 -1
@@ -28,11 +28,12 @@static struct obj_ops *obj_ops[] = { [NFT_OBJECT_COUNTER ] = &obj_ops_counter, [NFT_OBJECT_QUOTA ] = &obj_ops_quota, + [NFT_OBJECT_CT_HELPER ] = &obj_ops_ct_helper, };static struct obj_ops *nftnl_obj_ops_lookup (uint32_t type) { -if (type >NFT_OBJECT_QUOTA ) +if (type >NFT_OBJECT_CT_HELPER )return NULL ;return obj_ops[type];
Signature · 1 line
2.10.2
Florian Westphal
maintainerPATCH 3/7 netlink: BUG when object type is unknown
In reply to Florian WestphalThis will only trigger during development when adding new object types to the parser.
The BUG() gives a clear hint where the serialization code needs to go.
--- src/netlink.c | 3 +++ 1 file changed, 3 insertions(+)
src/netlink.c +3 -0
@@ -317,6 +317,9 @@ alloc_nftnl_obj(const struct handle *h, struct obj *obj)nftnl_obj_set_u32 (nlo,NFTNL_OBJ_QUOTA_FLAGS , obj->quota.flags);break ; +default : +BUG ("Unknown type %d\n" , obj->type); +break ; }return nlo; }
Signature · 1 line
2.10.2
Florian Westphal
maintainerPATCH 4/7 src: add initial ct helper support
In reply to Florian WestphalThis adds initial support for defining conntrack helper objects which can then be assigned to connections using the objref infrastructure:
table ip filter {
ct helper ftp-standard {
type "ftp"
protocol tcp
}
chain y {
tcp dport 21 ct helper set "ftp-standard"
}
}
--- include/ct.h | 1 + include/linux/netfilter/nf_tables.h | 3 +- include/rule.h | 7 ++++ src/ct.c | 10 +++++ src/netlink.c | 16 ++++++++ src/parser_bison.y | 80 ++++++++++++++++++++++++++++++++++++- src/rule.c | 35 +++++++++++++++- src/statement.c | 10 ++++- 8 files changed, 157 insertions(+), 5 deletions(-)
include/ct.h +1 -0
@@ -31,6 +31,7 @@ extern struct error_record *ct_dir_parse(const struct location *loc, const char *str, int8_t *dir);extern struct error_record *ct_key_parse (const struct location *loc,const char *str,unsigned int *key); +extern struct error_record *ct_objtype_parse (const struct location *loc,const char *str,int *type);extern struct stmt *notrack_stmt_alloc (const struct location *loc);
include/linux/netfilter/nf_tables.h +2 -1
@@ -1249,7 +1249,8 @@ enum nft_fib_flags {#define NFT_OBJECT_UNSPEC 0#define NFT_OBJECT_COUNTER 1#define NFT_OBJECT_QUOTA 2 -#define __NFT_OBJECT_MAX 3 +#define NFT_OBJECT_CT_HELPER 3 +#define __NFT_OBJECT_MAX 4#define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1)/**
include/rule.h +7 -0
@@ -260,6 +260,12 @@ struct quota {uint32_t flags; }; +struct ct { +char helper_name[16 ]; +uint16_t l3proto; +uint8_t l4proto; +}; +/** * struct obj - nftables stateful object statement *
@@ -277,6 +283,7 @@ struct obj {union {struct counter counter;struct quota quota; +struct ct ct; }; };
src/ct.c +10 -0
@@ -346,6 +346,16 @@ struct error_record *ct_key_parse(const struct location *loc, const char *str,return error (loc,"syntax error, unexpected %s, known keys are %s" , str, buf); } +struct error_record *ct_objtype_parse (const struct location *loc,const char *str,int *type) +{ +if (strcmp (str,"helper" ) ==0 ) { + *type =NFT_OBJECT_CT_HELPER ; +return NULL ; + } + +return error (loc,"unknown ct class '%s', want 'helper'" , str); +} +struct expr *ct_expr_alloc (const struct location *loc,enum nft_ct_keys key,int8_t direction) {
src/netlink.c +16 -0
@@ -317,6 +317,15 @@ alloc_nftnl_obj(const struct handle *h, struct obj *obj)nftnl_obj_set_u32 (nlo,NFTNL_OBJ_QUOTA_FLAGS , obj->quota.flags);break ; +case NFT_OBJECT_CT_HELPER : +nftnl_obj_set_str (nlo,NFTNL_OBJ_CT_HELPER_NAME , + obj->ct.helper_name); +nftnl_obj_set_u8 (nlo,NFTNL_OBJ_CT_HELPER_L4PROTO , + obj->ct.l4proto); +if (obj->ct.l3proto) +nftnl_obj_set_u16 (nlo,NFTNL_OBJ_CT_HELPER_L3PROTO , + obj->ct.l3proto); +break ;default :BUG ("Unknown type %d\n" , obj->type);break ;
@@ -1812,6 +1821,13 @@ static struct obj *netlink_delinearize_obj(struct netlink_ctx *ctx,nftnl_obj_get_u64 (nlo,NFTNL_OBJ_QUOTA_CONSUMED ); obj->quota.flags =nftnl_obj_get_u32 (nlo,NFTNL_OBJ_QUOTA_FLAGS ); +break ; +case NFT_OBJECT_CT_HELPER : +snprintf (obj->ct.helper_name,sizeof (obj->ct.helper_name),"%s" , +nftnl_obj_get_str (nlo,NFTNL_OBJ_CT_HELPER_NAME )); + obj->ct.l3proto =nftnl_obj_get_u16 (nlo,NFTNL_OBJ_CT_HELPER_L3PROTO ); + obj->ct.l4proto =nftnl_obj_get_u8 (nlo,NFTNL_OBJ_CT_HELPER_L4PROTO ); +break ; } obj->type = type;
src/parser_bison.y +78 -2
122 lines not on this page · raw message
src/rule.c +34 -1
@@ -1171,6 +1171,29 @@ struct obj *obj_lookup(const struct table *table, const char *name,return NULL ; } +static const char *proto_name_proto (uint8_t l4,char *b,size_t l) +{ +switch (l4) { +case IPPROTO_UDP :return "udp" ; +case IPPROTO_TCP :return "tcp" ; + } + +snprintf (b, l,"%d\n" , l4); +return b; +} + +static const char *proto_name_family (uint16_t family,char *b,size_t l) +{ +switch (family) { +case NFPROTO_IPV4 :return "ip" ; +case NFPROTO_IPV6 :return "ip6" ; +case NFPROTO_INET :return "inet" ; + } + +snprintf (b, l,"%d\n" , family); +return b; +} +static void obj_print_data (const struct obj *obj,struct print_fmt_options *opts) {
@@ -1201,6 +1224,15 @@ static void obj_print_data(const struct obj *obj, } }break ; +case NFT_OBJECT_CT_HELPER : { +char buf[16 ]; + +printf ("ct helper %s {\n" , obj->handle.obj); +printf ("\t\ttype \"%s\"\n" , obj->ct.helper_name); +printf ("\t\tl3proto %s\n" ,proto_name_family (obj->ct.l3proto, buf,sizeof (buf))); +printf ("\t\tprotocol %s" ,proto_name_proto (obj->ct.l4proto, buf,sizeof (buf))); +break ; + }default :printf ("unknown {%s" , opts->nl);break ;
@@ -1210,11 +1242,12 @@ static void obj_print_data(const struct obj *obj,static const char *obj_type_name_array[] = { [NFT_OBJECT_COUNTER ] ="counter" , [NFT_OBJECT_QUOTA ] ="quota" , + [NFT_OBJECT_CT_HELPER ] ="" , };const char *obj_type_name (enum stmt_types type) { -assert (type <=NFT_OBJECT_QUOTA && obj_type_name_array[type]); +assert (type <=NFT_OBJECT_CT_HELPER && obj_type_name_array[type]);return obj_type_name_array[type]; }
src/statement.c +9 -1
@@ -174,6 +174,7 @@ struct stmt *counter_stmt_alloc(const struct location *loc)static const char *objref_type[NFT_OBJECT_MAX +1 ] = { [NFT_OBJECT_COUNTER ] ="counter" , [NFT_OBJECT_QUOTA ] ="quota" , + [NFT_OBJECT_CT_HELPER ] ="cthelper" , };static const char *objref_type_name (uint32_t type)
@@ -186,7 +187,14 @@ static const char *objref_type_name(uint32_t type)static void objref_stmt_print (const struct stmt *stmt) { -printf ("%s name " ,objref_type_name (stmt->objref.type)); +switch (stmt->objref.type) { +case NFT_OBJECT_CT_HELPER : +printf ("ct helper set " ); +break ; +default : +printf ("%s name " ,objref_type_name (stmt->objref.type)); +break ; + }expr_print (stmt->objref.expr); }
Signature · 1 line
2.10.2
Florian Westphal
maintainerPATCH 5/7 evaluate: refactor CMD_OBJ_QUOTA/COUNTER handling
In reply to Florian Westphal... to make adding CMD_OBJ_CT_HELPER support easier.
--- src/evaluate.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
src/evaluate.c +20 -12
@@ -2916,12 +2916,29 @@ static int cmd_evaluate_delete(struct eval_ctx *ctx, struct cmd *cmd) } } +static int cmd_evaluate_list_obj (struct eval_ctx *ctx,const struct cmd *cmd, +uint32_t obj_type) +{ +const struct table *table; + +if (obj_type ==NFT_OBJECT_UNSPEC ) + obj_type =NFT_OBJECT_COUNTER ; + + table =table_lookup (&cmd->handle); +if (table ==NULL ) +return cmd_error (ctx,"Could not process rule: Table '%s' does not exist" , + cmd->handle.table); +if (obj_lookup (table, cmd->handle.obj, obj_type) ==NULL ) +return cmd_error (ctx,"Could not process rule: Object '%s' does not exist" , + cmd->handle.obj); +return 0 ; +} +static int cmd_evaluate_list (struct eval_ctx *ctx,struct cmd *cmd) {struct table *table;struct set *set;int ret; -uint32_t obj_type =NFT_OBJECT_UNSPEC ; ret =cache_update (cmd->op, ctx->msgs);if (ret <0 )
@@ -2977,18 +2994,9 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) cmd->handle.chain);return 0 ;case CMD_OBJ_QUOTA : - obj_type =NFT_OBJECT_QUOTA ; +return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_QUOTA );case CMD_OBJ_COUNTER : -if (obj_type ==NFT_OBJECT_UNSPEC ) - obj_type =NFT_OBJECT_COUNTER ; - table =table_lookup (&cmd->handle); -if (table ==NULL ) -return cmd_error (ctx,"Could not process rule: Table '%s' does not exist" , - cmd->handle.table); -if (obj_lookup (table, cmd->handle.obj, obj_type) ==NULL ) -return cmd_error (ctx,"Could not process rule: Object '%s' does not exist" , - cmd->handle.obj); -return 0 ; +return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_COUNTER );case CMD_OBJ_COUNTERS :case CMD_OBJ_QUOTAS :if (cmd->handle.table ==NULL )
Signature · 1 line
2.10.2
Florian Westphal
maintainerPATCH 6/7 src: allow listing all ct helpers
In reply to Florian Westphalthis implements
nft list ct helpers table filter
table ip filter {
ct helper ftp-standard {..
--- include/rule.h | 1 + src/evaluate.c | 1 + src/parser_bison.y | 19 +++++++++++++++++++ src/rule.c | 2 ++ 4 files changed, 23 insertions(+)
include/rule.h +1 -0
@@ -370,6 +370,7 @@ enum cmd_obj {CMD_OBJ_COUNTERS ,CMD_OBJ_QUOTA ,CMD_OBJ_QUOTAS , + CMD_OBJ_CT_HELPERS, }; struct export {
src/evaluate.c +1 -0
@@ -2999,6 +2999,7 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_COUNTER );case CMD_OBJ_COUNTERS :case CMD_OBJ_QUOTAS : +case CMD_OBJ_CT_HELPERS :if (cmd->handle.table ==NULL )return 0 ;if (table_lookup (&cmd->handle) ==NULL )
src/parser_bison.y +19 -0
@@ -985,6 +985,25 @@ list_cmd : TABLE table_spec { $$ = cmd_alloc(CMD_LIST, CMD_OBJ_MAP, &$2, &@$, NULL); } + | CT STRING TABLE table_spec + { + int cmd; + + if (strcmp($2, "helpers") == 0) { + cmd = CMD_OBJ_CT_HELPERS; + } else { + struct error_record *erec; + + erec = error(&@$, "unknown ct class '%s', want 'helpers'", $2); + + if (erec != NULL) { + erec_queue(erec, state->msgs); + YYERROR; + } + } + + $$ = cmd_alloc(CMD_LIST, cmd, &$4, &@$, NULL); + } ; reset_cmd : COUNTERS ruleset_spec
src/rule.c +2 -0
@@ -1468,6 +1468,8 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)case CMD_OBJ_QUOTA :case CMD_OBJ_QUOTAS :return do_list_obj (ctx, cmd,NFT_OBJECT_QUOTA ); +case CMD_OBJ_CT_HELPERS : +return do_list_obj (ctx, cmd,NFT_OBJECT_CT_HELPER );default :BUG ("invalid command object type %u\n" , cmd->obj); }
Signature · 1 line
2.10.2
Florian Westphal
maintainerPATCH 7/7 src: implement add/create/delete for ct helper objects
In reply to Florian Westphal--- include/rule.h | 4 ++++ src/evaluate.c | 4 ++++ src/parser_bison.y | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/rule.c | 22 +++++++++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-)
include/rule.h +4 -0
@@ -370,6 +370,7 @@ enum cmd_obj {CMD_OBJ_COUNTERS ,CMD_OBJ_QUOTA ,CMD_OBJ_QUOTAS , +CMD_OBJ_CT_HELPER , CMD_OBJ_CT_HELPERS, };
@@ -438,6 +439,9 @@ struct cmd {extern struct cmd *cmd_alloc (enum cmd_ops op,enum cmd_obj obj,const struct handle *h,const struct location *loc,void *data); +extern struct cmd *cmd_alloc_obj_ct (enum cmd_ops op,int type, +const struct handle *h, +const struct location *loc,void *data);extern void cmd_free (struct cmd *cmd);#include <payload.h>
src/evaluate.c +4 -0
@@ -2887,6 +2887,7 @@ static int cmd_evaluate_add(struct eval_ctx *ctx, struct cmd *cmd)return table_evaluate (ctx, cmd->table);case CMD_OBJ_COUNTER :case CMD_OBJ_QUOTA : +case CMD_OBJ_CT_HELPER :return 0 ;default :BUG ("invalid command object type %u\n" , cmd->obj);
@@ -2910,6 +2911,7 @@ static int cmd_evaluate_delete(struct eval_ctx *ctx, struct cmd *cmd)case CMD_OBJ_TABLE :case CMD_OBJ_COUNTER :case CMD_OBJ_QUOTA : +case CMD_OBJ_CT_HELPER :return 0 ;default :BUG ("invalid command object type %u\n" , cmd->obj);
@@ -2997,6 +2999,8 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_QUOTA );case CMD_OBJ_COUNTER :return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_COUNTER ); +case CMD_OBJ_CT_HELPER : +return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_CT_HELPER );case CMD_OBJ_COUNTERS :case CMD_OBJ_QUOTAS :case CMD_OBJ_CT_HELPERS :
src/parser_bison.y +61 -2
99 lines not on this page · raw message
src/rule.c +22 -0
@@ -883,6 +883,7 @@ void cmd_free(struct cmd *cmd)break ;case CMD_OBJ_COUNTER :case CMD_OBJ_QUOTA : +case CMD_OBJ_CT_HELPER :obj_free (cmd->object);break ;default :
@@ -999,6 +1000,7 @@ static int do_command_add(struct netlink_ctx *ctx, struct cmd *cmd, bool excl)return do_add_setelems (ctx, &cmd->handle, cmd->expr, excl);case CMD_OBJ_COUNTER :case CMD_OBJ_QUOTA : +case CMD_OBJ_CT_HELPER :return netlink_add_obj (ctx, &cmd->handle, cmd->object, excl);default :BUG ("invalid command object type %u\n" , cmd->obj);
@@ -1069,6 +1071,9 @@ static int do_command_delete(struct netlink_ctx *ctx, struct cmd *cmd)case CMD_OBJ_QUOTA :return netlink_delete_obj (ctx, &cmd->handle, &cmd->location,NFT_OBJECT_QUOTA ); +case CMD_OBJ_CT_HELPER : +return netlink_delete_obj (ctx, &cmd->handle, &cmd->location, +NFT_OBJECT_CT_HELPER );default :BUG ("invalid command object type %u\n" , cmd->obj); }
@@ -1468,6 +1473,7 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)case CMD_OBJ_QUOTA :case CMD_OBJ_QUOTAS :return do_list_obj (ctx, cmd,NFT_OBJECT_QUOTA ); +case CMD_OBJ_CT_HELPER :case CMD_OBJ_CT_HELPERS :return do_list_obj (ctx, cmd,NFT_OBJECT_CT_HELPER );default :
@@ -1616,6 +1622,22 @@ static int do_command_describe(struct netlink_ctx *ctx, struct cmd *cmd)return 0 ; } +struct cmd *cmd_alloc_obj_ct (enum cmd_ops op,int type,const struct handle *h, +const struct location *loc,void *data) +{ +enum cmd_obj cmd_obj; + +switch (type) { +case NFT_OBJECT_CT_HELPER : + cmd_obj =CMD_OBJ_CT_HELPER ; +break ; +default : +BUG ("missing type mapping" ); + } + +return cmd_alloc (op, cmd_obj, h, loc, data); +} +int do_command (struct netlink_ctx *ctx,struct cmd *cmd) {switch (cmd->op) {
Signature · 1 line
2.10.2
Quoted 12 lines · Florian Westphal
This series adds initial support to set conntrack helpers via the nft objref infrastructure.
As -next is closed I will not push this yet since kernel support is still missing.
Currently only supported attributes are:
type (e.g. "ftp", "sip)
protocol (udp or tcp)
l3proto (ip, ip6).
Quoted 5 lines
l3proto is optional, the kernel will infer it from
the family, i.e. in "inet" case kernel will check for both ipv4 and ipv6.Let me know in case you spot any isses, patches #3 and #5 could already be pushed to nft master since they are just preparation patches.
Series looks good, thanks Florian.