[verse]
____
*list hooks* ['family']
-*list hooks netdev device* 'DEVICE_NAME'
+*list hooks netdev* [ *device* 'DEVICE_NAME' ]
____
*list hooks* is enough to display everything that is active
-on the system, however, it does currently omit hooks that are
-tied to a specific network device (netdev family). To obtain
-those, the network device needs to be queried by name.
+on the system. Hooks in the netdev family are tied to a network
+device. If no device name is given, nft will query all network
+devices in the current network namespace.
Example Usage:
.List all active netfilter hooks in either the ip or ip6 stack
#define _NFTABLES_IFACE_H_
#include <net/if.h>
+#include <list.h>
struct iface {
struct list_head list;
void iface_cache_update(void);
void iface_cache_release(void);
+const struct iface *iface_cache_get_next_entry(const struct iface *prev);
#endif
}
return NULL;
}
+
+const struct iface *iface_cache_get_next_entry(const struct iface *prev)
+{
+ if (!iface_cache_init)
+ iface_cache_update();
+
+ if (list_empty(&iface_list))
+ return NULL;
+
+ if (!prev)
+ return list_first_entry(&iface_list, struct iface, list);
+
+ if (list_is_last(&prev->list, &iface_list))
+ return NULL;
+
+ return list_next_entry(prev, list);
+}
*/
#include <nft.h>
+#include <iface.h>
#include <libmnl/libmnl.h>
#include <libnftnl/common.h>
list_for_each_entry(hook, head, list) {
if (hook->family != b->family)
continue;
- if (hook->num != b->num)
+ if (!basehook_eq(hook, b))
continue;
if (hook->prio < b->prio)
continue;
if (tmp == 0)
ret = 0;
- if (devname) {
- tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_NETDEV, devname);
- if (tmp == 0)
- ret = 0;
- }
+ tmp = mnl_nft_dump_nf_hooks(ctx, NFPROTO_NETDEV, devname);
+ if (tmp == 0)
+ ret = 0;
return ret;
case NFPROTO_INET:
ret = mnl_nft_dump_nf_arp(ctx, family, devname, &hook_list);
break;
case NFPROTO_NETDEV:
- ret = mnl_nft_dump_nf_netdev(ctx, family, devname, &hook_list);
+ if (devname) {
+ ret = mnl_nft_dump_nf_netdev(ctx, family, devname, &hook_list);
+ } else {
+ const struct iface *iface;
+
+ iface = iface_cache_get_next_entry(NULL);
+ ret = 0;
+
+ while (iface) {
+ tmp = mnl_nft_dump_nf_netdev(ctx, family, iface->name, &hook_list);
+ if (tmp == 0)
+ ret = 0;
+
+ iface = iface_cache_get_next_entry(iface);
+ }
+ }
+
break;
}