Skip to contentSkip to conversation

Introduce nfnl_listen_for_msecs

LIBNFNETLINK Pablo Neira Ayuso 2 participants 6 messages Feb 7, 2006 netfilter

lore
Share & tools
lore
#0 lore raw

Hi Harald,

The patch attached introduces a new function called nfnl_listen_for_msecs. This is useful for polling netlink events.

I have enqueued a patch for libnetfilter_conntrack that implements nfct_event_conntrack_for_msecs. I apply it by myself once this gets applied ;)

cheers,

Signature · 1 line
Pablo
libnfnetlink/libnfnetlink.h +5 -0
Index: include/libnfnetlink/libnfnetlink.h
===================================================================
@@ -76,6 +76,11 @@
 extern int nfnl_listen(struct nfnl_handle *,
                       int (*)(struct sockaddr_nl *, struct nlmsghdr *, void *),
                       void *);
+/* simple challenge/response with timeout (polling) */
+extern int nfnl_listen_for_msecs(struct nfnl_handle *,
+				 int (*)(struct sockaddr_nl *, 
+					 struct nlmsghdr *, void *),
+				 void *, int timeout);
 
 /* receiving */
 extern ssize_t nfnl_recv(const struct nfnl_handle *h, unsigned char *buf, size_t len);
libnfnetlink.c +48 -21

105 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Pablo Neira Ayuso

Hi Harald,

The patch attached introduces a new function called nfnl_listen_for_msecs. This is useful for polling netlink events.

Can you give an example how this is going to be used? Thanks.

#2 lore raw
Quoted 4 lines · Patrick McHardy
Quoted 2 lines

The patch attached introduces a new function called nfnl_listen_for_msecs. This is useful for polling netlink events.

Can you give an example how this is going to be used?

A program waits for some specific event, if it doesn't happen in a given period of time, it gives up.

Signature · 1 line
Pablo
#3 lore raw
Quoted 10 lines · Pablo Neira Ayuso
Quoted 4 lines · Patrick McHardy
Quoted 2 lines

The patch attached introduces a new function called nfnl_listen_for_msecs. This is useful for polling netlink events.

Can you give an example how this is going to be used?

A program waits for some specific event, if it doesn't happen in a given period of time, it gives up.

I got that :) What I actually wanted to know is what kind of program would need this, and if its not likely that most programs need their own select-loop for dealing with other fds anyway. Or in other words, I'm not convinced this feature belongs inside libnfnetlink.

#4 lore raw
Quoted 10 lines · Patrick McHardy
Quoted 8 lines · Pablo Neira Ayuso
Quoted 4 lines · Patrick McHardy
Quoted 2 lines

The patch attached introduces a new function called nfnl_listen_for_msecs. This is useful for polling netlink events.

Can you give an example how this is going to be used?

Quoted 7 lines
Quoted 2 lines

A program waits for some specific event, if it doesn't happen in a given period of time, it gives up.

I got that :) What I actually wanted to know is what kind of program would need this, and if its not likely that most programs need their own select-loop for dealing with other fds anyway. Or in other words, I'm not convinced this feature belongs inside libnfnetlink.

But if I want to poll events, I'll have to work with the netfilter netlink socket from, say libnetfilter_conntrack or a normal program. So it will have to know about the netlink details.

AFAICS that would be a layer violation since libnfnetlink contains all the low level communication system with the netlink socket.

Signature · 1 line
Pablo
#5 lore raw
Quoted 11 lines · Pablo Neira Ayuso
Quoted 4 lines · Patrick McHardy

I got that :) What I actually wanted to know is what kind of program would need this, and if its not likely that most programs need their own select-loop for dealing with other fds anyway. Or in other words, I'm not convinced this feature belongs inside libnfnetlink.

But if I want to poll events, I'll have to work with the netfilter netlink socket from, say libnetfilter_conntrack or a normal program. So it will have to know about the netlink details.

Not the details, just the fd.

Quoted 4 lines

AFAICS that would be a layer violation since libnfnetlink contains all the low level communication system with the netlink socket.

From a poll/select perspective, the fd itself has nothing to do with

nfnetlink, its just a fd. I don't think this belongs inside libnfnetlink, it has no direct relationship to nfnetlink. Even nfnl_listen is questionable, the only reason it exists is probably that it got copied from iproute's libnetlink.