Re: How to get rule handle when adding a rule using libnftnl?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 01, 2018 at 07:02:09PM +0300, Eric Grunt wrote:
> After adding a rule, one needs it's handle for eg deleting it again.
> On the command line it's aquired via the -a flag (nft list ruleset -a),
> but how is this done outside command line, programmatically?
> 
> As far as I understand, the handle is assigned by the kernel,
> so it should not be accessible before the mnl_socket_sendto() call.
> Can it be accessed using mnl_cb_run() or is a separate netlink command
> needed for this?

Yes.

Set the NLM_F_ECHO flag in the message you send to kernel, the message
coming back from the kernel as reply contains the rule description in
netlink format, including the rule handle has been allocated.

I'm refering to the netlink flags that you pass to
nftnl_nlmsg_build_hdr() when building the netlink header.
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux