* [PATCH nft v3] src: netlink: Subscribe nft monitor and nft monitor trace to respective groups.
@ 2017-07-30 18:22 Varsha Rao
2017-07-31 17:37 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Varsha Rao @ 2017-07-30 18:22 UTC (permalink / raw)
To: pablo, netfilter-devel
Subscribe nft monitor to both NFNLGRP_NFTABLES and NFNLGRP_NFTRACE.
nft monitor trace subscribes only to NFNLGRP_NFTRACE. Other event
reporting options to only NFNLGRP_NFTABLES.
Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
Changes in v1:
- Subscribe nft monitor to only _NFTABLES.
- Subsribe nft monitor trace to only _NFTRACE.
Changes in v2:
- Subsribe nft monitor to both _NFTABLES and _NFTRACE.
- Subscribe other events to _NFTABLES.
- Modified commit message.
Changes in v3:
- Define constant NFT_MONTRACE.
src/netlink.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/src/netlink.c b/src/netlink.c
index 9cef4c4..123088a 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -39,6 +39,9 @@
#include <erec.h>
#include <iface.h>
+#define NFT_MONTRACE 131439
+/* This value is OR of monitor_flags for trace event and NFNLGRP_NFTABLES */
+
const struct input_descriptor indesc_netlink = {
.name = "netlink",
.type = INDESC_NETLINK,
@@ -3078,21 +3081,34 @@ static int netlink_events_cb(const struct nlmsghdr *nlh, void *data)
int netlink_monitor(struct netlink_mon_handler *monhandler,
struct mnl_socket *nf_sock)
{
- int group;
+ int group = NFNLGRP_NFTRACE, val;
- group = NFNLGRP_NFTABLES;
- if (mnl_socket_setsockopt(nf_sock, NETLINK_ADD_MEMBERSHIP, &group,
- sizeof(int)) < 0)
- return netlink_io_error(monhandler->ctx, monhandler->loc,
+ val = monhandler->monitor_flags | NFNLGRP_NFTABLES;
+ if (val == NFT_MONTRACE) {
+ if (mnl_socket_setsockopt(nf_sock, NETLINK_ADD_MEMBERSHIP,
+ &group, sizeof(int)) < 0)
+ return netlink_io_error(monhandler->ctx,
+ monhandler->loc,
"Could not bind to netlink socket %s",
strerror(errno));
-
- group = NFNLGRP_NFTRACE;
- if (mnl_socket_setsockopt(nf_sock, NETLINK_ADD_MEMBERSHIP, &group,
- sizeof(int)) < 0)
- return netlink_io_error(monhandler->ctx, monhandler->loc,
+ } else {
+ if (val < 0) {
+ if (mnl_socket_setsockopt(nf_sock,
+ NETLINK_ADD_MEMBERSHIP, &group,
+ sizeof(int)) < 0)
+ return netlink_io_error(monhandler->ctx,
+ monhandler->loc,
+ "Could not bind to netlink socket %s",
+ strerror(errno));
+ }
+ group = NFNLGRP_NFTABLES;
+ if (mnl_socket_setsockopt(nf_sock, NETLINK_ADD_MEMBERSHIP,
+ &group, sizeof(int)) < 0)
+ return netlink_io_error(monhandler->ctx,
+ monhandler->loc,
"Could not bind to netlink socket %s",
strerror(errno));
+ }
return mnl_nft_event_listener(nf_sock, netlink_events_cb,
monhandler);
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH nft v3] src: netlink: Subscribe nft monitor and nft monitor trace to respective groups.
2017-07-30 18:22 [PATCH nft v3] src: netlink: Subscribe nft monitor and nft monitor trace to respective groups Varsha Rao
@ 2017-07-31 17:37 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-07-31 17:37 UTC (permalink / raw)
To: Varsha Rao; +Cc: netfilter-devel
On Sun, Jul 30, 2017 at 11:52:29PM +0530, Varsha Rao wrote:
> Subscribe nft monitor to both NFNLGRP_NFTABLES and NFNLGRP_NFTRACE.
> nft monitor trace subscribes only to NFNLGRP_NFTRACE. Other event
> reporting options to only NFNLGRP_NFTABLES.
>
> Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
> ---
> Changes in v1:
> - Subscribe nft monitor to only _NFTABLES.
> - Subsribe nft monitor trace to only _NFTRACE.
>
> Changes in v2:
> - Subsribe nft monitor to both _NFTABLES and _NFTRACE.
> - Subscribe other events to _NFTABLES.
> - Modified commit message.
>
> Changes in v3:
> - Define constant NFT_MONTRACE.
>
> src/netlink.c | 36 ++++++++++++++++++++++++++----------
> 1 file changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/src/netlink.c b/src/netlink.c
> index 9cef4c4..123088a 100644
> --- a/src/netlink.c
> +++ b/src/netlink.c
> @@ -39,6 +39,9 @@
> #include <erec.h>
> #include <iface.h>
>
> +#define NFT_MONTRACE 131439
> +/* This value is OR of monitor_flags for trace event and NFNLGRP_NFTABLES */
This is still no enough.
Sorry, please respin and send v4. Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-31 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-30 18:22 [PATCH nft v3] src: netlink: Subscribe nft monitor and nft monitor trace to respective groups Varsha Rao
2017-07-31 17:37 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).