Skip to contentSkip to conversation

per flow stats collection using libnetfilter_conntrack

DISCUSSION Tarun Khanna 2 participants 5 messages Feb 27, 2017 – Mar 9, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

Is it possible to register for callbacks so that a user application is updated on a regular basis when the packet or bytes counts change for flows? I can poll the stats using something similar to "conntrack -L". However, I was wondering if it's possible to be notified regularly on updates.

maintainer
#1 lore raw
Quoted 2 lines · Tarun Khanna

Is it possible to register for callbacks so that a user application is updated on a regular basis when the packet or bytes counts change for flows?

No, update to packet/byte count doesn't trigger an event (it would trigger too often).

Quoted 2 lines

I can poll the stats using something similar to "conntrack -L". However, I was wondering if it's possible to be notified regularly on updates.

No. What semantics would you be interested in?

Dumping is quite fast, whats the problem you need to solve?

#2 lore raw
Quoted 5 lines · Florian Westphal
Quoted 2 lines · Tarun Khanna

Is it possible to register for callbacks so that a user application is updated on a regular basis when the packet or bytes counts change for flows?

No, update to packet/byte count doesn't trigger an event (it would trigger too often).

I was hoping if there was an option to set a timeout, so that an update would trigger every 5 seconds for flows where the counters have changed.

Quoted 6 lines
Quoted 3 lines

I can poll the stats using something similar to "conntrack -L". However, I was wondering if it's possible to be notified regularly on updates.

No. What semantics would you be interested in?

Dumping is quite fast, whats the problem you need to solve?

I have an application that needs to keep track of per flow stats for all tcp flows destined to port 80. The best way I have found so far is to call nfct_query regularly and to go through each flow returned to retrieve the counters. Would that be the best way to do it?

Thank you for your assistance.

maintainer
#3 lore raw
Quoted 9 lines · Tarun Khanna
Quoted 5 lines · Florian Westphal
Quoted 2 lines · Tarun Khanna

Is it possible to register for callbacks so that a user application is updated on a regular basis when the packet or bytes counts change for flows?

No, update to packet/byte count doesn't trigger an event (it would trigger too often).

I was hoping if there was an option to set a timeout, so that an update would trigger every 5 seconds for flows where the counters have changed.

No, there is no such feature at the moment.

Quoted 4 lines

I have an application that needs to keep track of per flow stats for all tcp flows destined to port 80. The best way I have found so far is to call nfct_query regularly and to go through each flow returned to retrieve the counters. Would that be the best way to do it?

Its your only option right now. If you need a periodic update feature we'll need to think about how to best make this.

We now have a periodic gc worker in conntrack so we could probably do this without re-adding a per-conntrack timer.

#4 lore raw
Quoted 16 lines
Quoted 8 lines · Tarun Khanna
Quoted 5 lines · Florian Westphal
Quoted 2 lines · Tarun Khanna

Is it possible to register for callbacks so that a user application is updated on a regular basis when the packet or bytes counts change for flows?

No, update to packet/byte count doesn't trigger an event (it would trigger too often).

I was hoping if there was an option to set a timeout, so that an update would trigger every 5 seconds for flows where the counters have changed.

No, there is no such feature at the moment.

Quoted 4 lines

I have an application that needs to keep track of per flow stats for all tcp flows destined to port 80. The best way I have found so far is to call nfct_query regularly and to go through each flow returned to retrieve the counters. Would that be the best way to do it?

Quoted 5 lines

Its your only option right now. If you need a periodic update feature we'll need to think about how to best make this.

We now have a periodic gc worker in conntrack so we could probably do this without re-adding a per-conntrack timer.

Thank you. The current way of polling works for me. I was thinking about it and it doesn't really make a difference if the library sends me updates periodically or if I check for them because in both cases I'll need to setup some event on epoll (either a timer or the netfilter fd). So, functionally both would be the same. Thanks again for your help.