From e19e0ed6cde3176b7ef519748f893aa1afc86fa7 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 18 Apr 2013 17:53:59 +0200 Subject: cmd/netlink: make sure we always have a location in netlink operations Improve error reporting by always using a location in netlink operations. Signed-off-by: Patrick McHardy --- include/netlink.h | 51 ++++++++++++++++++++++++++++++++++----------------- include/rule.h | 7 ++++++- 2 files changed, 40 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/netlink.h b/include/netlink.h index 3252569b..ccbb872c 100644 --- a/include/netlink.h +++ b/include/netlink.h @@ -52,38 +52,55 @@ extern struct rule *netlink_delinearize_rule(struct netlink_ctx *ctx, extern int netlink_add_rule(struct netlink_ctx *ctx, const struct handle *h, const struct rule *rule, uint32_t flags); -extern int netlink_delete_rule(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_get_rule(struct netlink_ctx *ctx, const struct handle *h); +extern int netlink_delete_rule(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_get_rule(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); extern int netlink_add_chain(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc, const struct chain *chain); extern int netlink_rename_chain(struct netlink_ctx *ctx, const struct handle *h, - const char *name); -extern int netlink_delete_chain(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_list_chains(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_get_chain(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_list_chain(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_flush_chain(struct netlink_ctx *ctx, const struct handle *h); + const struct location *loc, const char *name); +extern int netlink_delete_chain(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_list_chains(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_get_chain(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_list_chain(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_flush_chain(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); extern int netlink_add_table(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc, const struct table *table); -extern int netlink_delete_table(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_list_tables(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_get_table(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_list_table(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_flush_table(struct netlink_ctx *ctx, const struct handle *h); +extern int netlink_delete_table(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_list_tables(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_get_table(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_list_table(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_flush_table(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); extern int netlink_add_set(struct netlink_ctx *ctx, const struct handle *h, struct set *set); -extern int netlink_delete_set(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_list_sets(struct netlink_ctx *ctx, const struct handle *h); -extern int netlink_get_set(struct netlink_ctx *ctx, const struct handle *h); +extern int netlink_delete_set(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_list_sets(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); +extern int netlink_get_set(struct netlink_ctx *ctx, const struct handle *h, + const struct location *loc); extern int netlink_add_setelems(struct netlink_ctx *ctx, const struct handle *h, const struct expr *expr); extern int netlink_delete_setelems(struct netlink_ctx *ctx, const struct handle *h, const struct expr *expr); extern int netlink_get_setelems(struct netlink_ctx *ctx, const struct handle *h, - struct set *set); + const struct location *loc, struct set *set); #endif /* NFTABLES_NETLINK_H */ diff --git a/include/rule.h b/include/rule.h index a992489b..eda6b2c2 100644 --- a/include/rule.h +++ b/include/rule.h @@ -62,12 +62,14 @@ extern struct symbol *symbol_lookup(const struct scope *scope, * * @list: list node * @handle: table handle + * @location: location the table was defined at * @chains: chains contained in the table * @sets: sets contained in the table */ struct table { struct list_head list; struct handle handle; + struct location location; struct scope scope; struct list_head chains; struct list_head sets; @@ -92,6 +94,7 @@ enum chain_flags { * * @list: list node in table list * @handle: chain handle + * @location: location the chain was defined at * @flags: chain flags * @hooknum: hook number (base chains) * @priority: hook priority (base chains) @@ -100,6 +103,7 @@ enum chain_flags { struct chain { struct list_head list; struct handle handle; + struct location location; uint32_t flags; unsigned int hooknum; unsigned int priority; @@ -253,7 +257,8 @@ struct cmd { }; extern struct cmd *cmd_alloc(enum cmd_ops op, enum cmd_obj obj, - const struct handle *h, void *data); + const struct handle *h, const struct location *loc, + void *data); extern void cmd_free(struct cmd *cmd); #include -- cgit v1.2.3