summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/rule.h1
-rw-r--r--src/evaluate.c4
-rw-r--r--src/netlink.c16
-rw-r--r--src/rule.c2
4 files changed, 21 insertions, 2 deletions
diff --git a/include/rule.h b/include/rule.h
index f5160daf..ed12774d 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -479,6 +479,7 @@ enum udata_type {
enum udata_set_type {
UDATA_SET_KEYBYTEORDER,
+ UDATA_SET_DATABYTEORDER,
__UDATA_SET_MAX,
};
#define UDATA_SET_MAX (__UDATA_SET_MAX - 1)
diff --git a/src/evaluate.c b/src/evaluate.c
index 07a61180..54985166 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1174,7 +1174,9 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr)
ctx->ectx.len,
ctx->ectx.byteorder,
mappings);
- mappings->set->datatype = ectx.dtype;
+
+ mappings->set->datatype = set_datatype_alloc(ectx.dtype,
+ ectx.byteorder);
mappings->set->datalen = ectx.len;
map->mappings = mappings;
diff --git a/src/netlink.c b/src/netlink.c
index d643034f..8b0fc940 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1112,6 +1112,7 @@ static int set_parse_udata_cb(const struct nftnl_udata *attr, void *data)
switch (type) {
case UDATA_SET_KEYBYTEORDER:
+ case UDATA_SET_DATABYTEORDER:
if (len != sizeof(uint32_t))
return -1;
break;
@@ -1128,6 +1129,7 @@ static struct set *netlink_delinearize_set(struct netlink_ctx *ctx,
const struct nftnl_udata *ud[UDATA_SET_MAX + 1] = {};
uint32_t flags, key, data, data_len, objtype = 0;
enum byteorder keybyteorder = BYTEORDER_INVALID;
+ enum byteorder databyteorder = BYTEORDER_INVALID;
const struct datatype *keytype, *datatype;
const char *udata;
struct set *set;
@@ -1142,6 +1144,8 @@ static struct set *netlink_delinearize_set(struct netlink_ctx *ctx,
if (ud[UDATA_SET_KEYBYTEORDER])
keybyteorder = *((uint32_t *)nftnl_udata_get(ud[UDATA_SET_KEYBYTEORDER]));
+ if (ud[UDATA_SET_DATABYTEORDER])
+ databyteorder = *((uint32_t *)nftnl_udata_get(ud[UDATA_SET_DATABYTEORDER]));
}
key = nftnl_set_get_u32(nls, NFTNL_SET_KEY_TYPE);
@@ -1181,7 +1185,11 @@ static struct set *netlink_delinearize_set(struct netlink_ctx *ctx,
set->objtype = objtype;
- set->datatype = datatype;
+ if (datatype)
+ set->datatype = set_datatype_alloc(datatype, databyteorder);
+ else
+ set->datatype = NULL;
+
if (nftnl_set_is_set(nls, NFTNL_SET_DATA_LEN)) {
data_len = nftnl_set_get_u32(nls, NFTNL_SET_DATA_LEN);
set->datalen = data_len * BITS_PER_BYTE;
@@ -1279,6 +1287,12 @@ static int netlink_add_set_batch(struct netlink_ctx *ctx,
if (!nftnl_udata_put(udbuf, UDATA_SET_KEYBYTEORDER, sizeof(uint32_t),
&set->keytype->byteorder))
memory_allocation_error();
+
+ if (set->flags & NFT_SET_MAP &&
+ !nftnl_udata_put(udbuf, UDATA_SET_DATABYTEORDER, sizeof(uint32_t),
+ &set->datatype->byteorder))
+ memory_allocation_error();
+
nftnl_set_set_data(nls, NFTNL_SET_USERDATA, nftnl_udata_buf_data(udbuf),
nftnl_udata_buf_len(udbuf));
nftnl_udata_buf_free(udbuf);
diff --git a/src/rule.c b/src/rule.c
index 60457477..f5ff1103 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -211,6 +211,8 @@ void set_free(struct set *set)
expr_free(set->init);
handle_free(&set->handle);
set_datatype_destroy(set->keytype);
+ if (set->datatype)
+ set_datatype_destroy(set->datatype);
xfree(set);
}