summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-02-05 19:50:43 +0000
committerPatrick McHardy <kaber@trash.net>2014-02-05 19:53:47 +0000
commita144995d3920516f95e0d88ed3fd3e0240e87467 (patch)
tree9b3e0c2fea8a2aabd73137f23517df4d7873490d /src
parent782d57968590186e8f85b2310092d6008b00ac2c (diff)
netlink: add netlink specific location
Add a netlink_location and use it for error messages instead of internal_location. internal:0:0-0: Error: Could not add set: Operation not permitted => netlink: Error: Could not add set: Operation not permitted Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src')
-rw-r--r--src/netlink.c21
-rw-r--r--src/netlink_delinearize.c7
2 files changed, 16 insertions, 12 deletions
diff --git a/src/netlink.c b/src/netlink.c
index 98e7fc6c..6e797dcf 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -33,6 +33,15 @@
static struct mnl_socket *nf_sock;
+const struct input_descriptor indesc_netlink = {
+ .name = "netlink",
+ .type = INDESC_NETLINK,
+};
+
+const struct location netlink_location = {
+ .indesc = &indesc_netlink,
+};
+
static void __init netlink_open_sock(void)
{
nf_sock = mnl_socket_open(NETLINK_NETFILTER);
@@ -55,7 +64,7 @@ int netlink_io_error(struct netlink_ctx *ctx, const struct location *loc,
va_list ap;
if (loc == NULL)
- loc = &internal_location;
+ loc = &netlink_location;
va_start(ap, fmt);
erec = erec_vcreate(EREC_ERROR, loc, fmt, ap);
@@ -848,7 +857,7 @@ static int list_set_cb(struct nft_set *nls, void *arg)
} else
datatype = NULL;
- set = set_alloc(&internal_location);
+ set = set_alloc(&netlink_location);
set->handle.family = nft_set_attr_get_u32(nls, NFT_SET_ATTR_FAMILY);
set->handle.table =
xstrdup(nft_set_attr_get_str(nls, NFT_SET_ATTR_TABLE));
@@ -899,7 +908,7 @@ int netlink_get_set(struct netlink_ctx *ctx, const struct handle *h,
"Could not receive set from kernel: %s",
strerror(errno));
- set = set_alloc(&internal_location);
+ set = set_alloc(&netlink_location);
set->handle.family = nft_set_attr_get_u32(nls, NFT_SET_ATTR_FAMILY);
set->handle.table =
xstrdup(nft_set_attr_get_str(nls, NFT_SET_ATTR_TABLE));
@@ -984,7 +993,7 @@ static int list_setelem_cb(struct nft_set_elem *nlse, void *arg)
if (nft_set_elem_attr_is_set(nlse, NFT_SET_ELEM_ATTR_FLAGS))
flags = nft_set_elem_attr_get_u32(nlse, NFT_SET_ELEM_ATTR_FLAGS);
- expr = netlink_alloc_value(&internal_location, &nld);
+ expr = netlink_alloc_value(&netlink_location, &nld);
expr->dtype = set->keytype;
expr->byteorder = set->keytype->byteorder;
if (expr->byteorder == BYTEORDER_HOST_ENDIAN)
@@ -1004,7 +1013,7 @@ static int list_setelem_cb(struct nft_set_elem *nlse, void *arg)
} else
goto out;
- data = netlink_alloc_data(&internal_location, &nld,
+ data = netlink_alloc_data(&netlink_location, &nld,
set->datatype->type == TYPE_VERDICT ?
NFT_REG_VERDICT : NFT_REG_1);
data->dtype = set->datatype;
@@ -1012,7 +1021,7 @@ static int list_setelem_cb(struct nft_set_elem *nlse, void *arg)
if (data->byteorder == BYTEORDER_HOST_ENDIAN)
mpz_switch_byteorder(data->value, data->len / BITS_PER_BYTE);
- expr = mapping_expr_alloc(&internal_location, expr, data);
+ expr = mapping_expr_alloc(&netlink_location, expr, data);
}
out:
compound_expr_add(set->init, expr);
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index 59b50745..66683083 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -545,11 +545,6 @@ static const struct {
{ .name = "queue", .parse = netlink_parse_queue },
};
-static const struct input_descriptor indesc_netlink = {
- .name = "netlink",
- .type = INDESC_NETLINK,
-};
-
static int netlink_parse_expr(struct nft_rule_expr *nle, void *arg)
{
const char *type = nft_rule_expr_get_str(nle, NFT_RULE_EXPR_ATTR_NAME);
@@ -878,7 +873,7 @@ struct rule *netlink_delinearize_rule(struct netlink_ctx *ctx,
if (nft_rule_attr_is_set(nlr, NFT_RULE_ATTR_POSITION))
h.position = nft_rule_attr_get_u64(nlr, NFT_RULE_ATTR_POSITION);
- pctx->rule = rule_alloc(&internal_location, &h);
+ pctx->rule = rule_alloc(&netlink_location, &h);
pctx->table = table_lookup(&h);
assert(pctx->table != NULL);
nft_rule_expr_foreach((struct nft_rule *)nlr, netlink_parse_expr, pctx);