diff options
author | Harsha Sharma <harshasharmaiitr@gmail.com> | 2018-01-19 00:22:56 +0530 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-03-05 17:53:08 +0100 |
commit | 832b2862df471e45142ea2f2a459723b4ad6f4eb (patch) | |
tree | 8fdd0e7bb884567433c0e692cb90a105afbfdc3f /src/netlink.c | |
parent | 9807bc39fd89431a6e26205eb1f86b949d505bde (diff) |
src: extend nft to list object handle and delete objects via handle
Print handle attributes in objects when listing via '-a' option and
delete objects via their unique object handles.
For e.g.
nft delete [<object-type>] [<family>] <table-name> [handle <handle>]
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/netlink.c')
-rw-r--r-- | src/netlink.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/netlink.c b/src/netlink.c index eaefbb5f..906568fe 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -297,6 +297,8 @@ __alloc_nftnl_obj(const struct handle *h, uint32_t type) nftnl_obj_set_str(nlo, NFTNL_OBJ_NAME, h->obj); nftnl_obj_set_u32(nlo, NFTNL_OBJ_TYPE, type); + if (h->handle.id) + nftnl_obj_set_u64(nlo, NFTNL_OBJ_HANDLE, h->handle.id); return nlo; } @@ -1457,6 +1459,8 @@ static struct obj *netlink_delinearize_obj(struct netlink_ctx *ctx, xstrdup(nftnl_obj_get_str(nlo, NFTNL_OBJ_TABLE)); obj->handle.obj = xstrdup(nftnl_obj_get_str(nlo, NFTNL_OBJ_NAME)); + obj->handle.handle.id = + nftnl_obj_get_u64(nlo, NFTNL_OBJ_HANDLE); type = nftnl_obj_get_u32(nlo, NFTNL_OBJ_TYPE); switch (type) { @@ -2419,6 +2423,7 @@ static void netlink_events_cache_delobj(struct netlink_mon_handler *monh, name = nftnl_obj_get_str(nlo, NFTNL_OBJ_NAME); type = nftnl_obj_get_u32(nlo, NFTNL_OBJ_TYPE); + h.handle.id = nftnl_obj_get_u64(nlo, NFTNL_OBJ_HANDLE); t = table_lookup(&h, monh->cache); if (t == NULL) { |