]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: drop obsolete hook argument form hook dump functions
authorFlorian Westphal <fw@strlen.de>
Wed, 31 Jul 2024 16:51:03 +0000 (18:51 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 1 Sep 2025 20:47:56 +0000 (22:47 +0200)
commit 4d66136082ce32f979bf992e68385ed033af057e upstream.

since commit b98fee20bfe2 ("mnl: revisit hook listing"), handle.chain is
never set in this path, so 'hook' is always set to -1, so the hook arg
can be dropped.

Signed-off-by: Florian Westphal <fw@strlen.de>
include/mnl.h
src/mnl.c
src/rule.c

index 8e0a7e3fccab9e0f7e101b0505f95e7c517c9f1c..6050beb74d4a810ed087504bc730e754085b5c97 100644 (file)
@@ -86,7 +86,7 @@ int mnl_nft_flowtable_add(struct netlink_ctx *ctx, struct cmd *cmd,
                          unsigned int flags);
 int mnl_nft_flowtable_del(struct netlink_ctx *ctx, struct cmd *cmd);
 
-int mnl_nft_dump_nf_hooks(struct netlink_ctx *ctx, int family, int hook,
+int mnl_nft_dump_nf_hooks(struct netlink_ctx *ctx, int family,
                          const char *devname);
 
 int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask,
index d8a5ffc051b58e2a81e06709373ef501d28681ff..776057fb1e2b095ee92a9ba7c29f3292a85fdbd5 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -2413,7 +2413,7 @@ static void print_hooks(struct netlink_ctx *ctx, int family, struct list_head *h
        fprintf(fp, "}\n");
 }
 
-static int mnl_nft_dump_nf(struct netlink_ctx *ctx, int family, int hook,
+static int mnl_nft_dump_nf(struct netlink_ctx *ctx, int family,
                           const char *devname, struct list_head *hook_list)
 {
        int i, err;
@@ -2429,7 +2429,7 @@ static int mnl_nft_dump_nf(struct netlink_ctx *ctx, int family, int hook,
        return err;
 }
 
-static int mnl_nft_dump_nf_arp(struct netlink_ctx *ctx, int family, int hook,
+static int mnl_nft_dump_nf_arp(struct netlink_ctx *ctx, int family,
                               const char *devname, struct list_head *hook_list)
 {
        int err1, err2;
@@ -2440,7 +2440,7 @@ static int mnl_nft_dump_nf_arp(struct netlink_ctx *ctx, int family, int hook,
        return err1 ? err2 : err1;
 }
 
-static int mnl_nft_dump_nf_netdev(struct netlink_ctx *ctx, int family, int hook,
+static int mnl_nft_dump_nf_netdev(struct netlink_ctx *ctx, int family,
                                  const char *devname, struct list_head *hook_list)
 {
        int err;
@@ -2464,7 +2464,7 @@ static void warn_if_device(struct nft_ctx *nft, const char *devname)
                nft_print(&nft->output, "# device keyword (%s) unexpected for this family\n", devname);
 }
 
-int mnl_nft_dump_nf_hooks(struct netlink_ctx *ctx, int family, int hook, const char *devname)
+int mnl_nft_dump_nf_hooks(struct netlink_ctx *ctx, int family, const char *devname)
 {
        LIST_HEAD(hook_list);
        int ret = -1, tmp;
@@ -2473,16 +2473,16 @@ int mnl_nft_dump_nf_hooks(struct netlink_ctx *ctx, int family, int hook, const c
 
        switch (family) {
        case NFPROTO_UNSPEC:
-               ret = mnl_nft_dump_nf_hooks(ctx, NFPROTO_ARP, hook, NULL);
-               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_INET, hook, NULL);
+               ret = mnl_nft_dump_nf_hooks(ctx, NFPROTO_ARP, NULL);
+               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_INET, NULL);
                if (tmp == 0)
                        ret = 0;
-               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_BRIDGE, hook, NULL);
+               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_BRIDGE, NULL);
                if (tmp == 0)
                        ret = 0;
 
                if (devname) {
-                       tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_NETDEV, hook, devname);
+                       tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_NETDEV, devname);
                        if (tmp == 0)
                                ret = 0;
                }
@@ -2493,10 +2493,10 @@ int mnl_nft_dump_nf_hooks(struct netlink_ctx *ctx, int family, int hook, const c
                if (devname)
                        ret = __mnl_nft_dump_nf_hooks(ctx, family, NFPROTO_NETDEV,
                                                      NF_NETDEV_INGRESS, devname, &hook_list);
-               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_IPV4, hook, NULL);
+               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_IPV4, NULL);
                if (tmp == 0)
                        ret = 0;
-               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_IPV6, hook, NULL);
+               tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_IPV6, NULL);
                if (tmp == 0)
                        ret = 0;
 
@@ -2505,14 +2505,14 @@ int mnl_nft_dump_nf_hooks(struct netlink_ctx *ctx, int family, int hook, const c
        case NFPROTO_IPV6:
        case NFPROTO_BRIDGE:
                warn_if_device(ctx->nft, devname);
-               ret = mnl_nft_dump_nf(ctx, family, hook, devname, &hook_list);
+               ret = mnl_nft_dump_nf(ctx, family, devname, &hook_list);
                break;
        case NFPROTO_ARP:
                warn_if_device(ctx->nft, devname);
-               ret = mnl_nft_dump_nf_arp(ctx, family, hook, devname, &hook_list);
+               ret = mnl_nft_dump_nf_arp(ctx, family, devname, &hook_list);
                break;
        case NFPROTO_NETDEV:
-               ret = mnl_nft_dump_nf_netdev(ctx, family, hook, devname, &hook_list);
+               ret = mnl_nft_dump_nf_netdev(ctx, family, devname, &hook_list);
                break;
        }
 
index 59defa5d5ab4f0094d721a1b9708b1357497f711..46fa4520465f4c1dbd999bed430d525bd40f70a6 100644 (file)
@@ -2539,12 +2539,8 @@ static int do_list_set(struct netlink_ctx *ctx, struct cmd *cmd,
 static int do_list_hooks(struct netlink_ctx *ctx, struct cmd *cmd)
 {
        const char *devname = cmd->handle.obj.name;
-       int hooknum = -1;
 
-       if (cmd->handle.chain.name)
-               hooknum = cmd->handle.chain_id;
-
-       return mnl_nft_dump_nf_hooks(ctx, cmd->handle.family, hooknum, devname);
+       return mnl_nft_dump_nf_hooks(ctx, cmd->handle.family, devname);
 }
 
 static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)