Bug 270083 - [netgraph] ng_netflow, NetFlow v9: maximum packets count between re-announcing data templates is ignored
Summary: [netgraph] ng_netflow, NetFlow v9: maximum packets count between re-announci...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.1-STABLE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Pouria Mousavizadeh Tehrani
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-10 08:09 UTC by Marek Zarychta
Modified: 2026-01-24 13:56 UTC (History)
2 users (show)

See Also:
zarychtam: mfc-stable15?
zarychtam: mfc-stable14?


Attachments
[PATCH] ng_netflow v9: fix template re-announcement using packet (991 bytes, patch)
2026-01-16 12:08 UTC, Marek Zarychta
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Zarychta 2023-03-10 08:09:44 UTC
The module seems to ignore the value of "packets" in "settemplate". It is NetFlow_v9 specific setting. To reproduce configure the export9 node with: 

msg netflow: settemplate { time=43200 packets=10 }

and wait for the template to be transmitted. 

Most likely the logic of "sent_packets" is not fully operational and re-announcements of the template are done only on a time basis. This is only a mild flaw since periodic re-announcements of the template work fine.
Comment 1 Marek Zarychta 2023-03-10 11:33:17 UTC
Unfortunately, the removal of code doing re-announcements on the basis of packet counter, according to RFC 3954, is forbidden[1], so maybe our respectable programmers can fix it. 

[1]   3. On a regular basis, the Exporter MUST send all the Template
      Records and Options Template Records to refresh the Collector.
      Template IDs have a limited lifetime at the Collector and MUST be
      periodically refreshed.  Two approaches are taken to make sure
      that Templates get refreshed at the Collector:
            * Every N number of Export Packets.
            * On a time basis, so every N number of minutes.
      Both options MUST be configurable by the user on the Exporter.
      When one of these expiry conditions is met, the Exporter MUST send
      the Template FlowSet and Options Template.
Comment 2 Marek Zarychta 2026-01-16 12:08:03 UTC
Created attachment 267199 [details]
[PATCH] ng_netflow v9: fix template re-announcement using packet

This patch fixes the issue for me.
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-01-16 18:40:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d836dae9f0d888d441234ea11e3cd91614c86aa2

commit d836dae9f0d888d441234ea11e3cd91614c86aa2
Author:     Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
AuthorDate: 2026-01-16 10:12:11 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-01-16 18:36:53 +0000

    ng_netflow v9: fix template re-announcement using packet count

    Increment fe->sent_packets after export9_send().
    Previously, NetFlow v9 templates were only re-announced based on
    time, ignoring the packet count parameter (`templ_packets`).

    PR:             270083
    Reviewed by:    glebius pouria
    Approved by:    glebius (mentor)
    MFC after:      1 week
    Sponsored by:   Subcarpathian BSD User Group

 sys/netgraph/netflow/netflow_v9.c | 1 +
 1 file changed, 1 insertion(+)
Comment 4 Pouria Mousavizadeh Tehrani freebsd_committer freebsd_triage 2026-01-16 18:43:36 UTC
Thank you for the report and patch.
Comment 5 Marek Zarychta 2026-01-23 19:52:45 UTC
Pouria, can you please MFC this fix to stable/14 and stable/15 ? MFC to stable/13 is also possible, but probably pointless.
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-01-24 09:18:57 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f51e0f5e69cf9e3806d64b3ce85d70aca63d922b

commit f51e0f5e69cf9e3806d64b3ce85d70aca63d922b
Author:     Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
AuthorDate: 2026-01-16 10:12:11 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-01-24 09:09:02 +0000

    ng_netflow v9: fix template re-announcement using packet count

    Increment fe->sent_packets after export9_send().
    Previously, NetFlow v9 templates were only re-announced based on
    time, ignoring the packet count parameter (`templ_packets`).

    PR:             270083
    Reviewed by:    glebius pouria
    Approved by:    glebius (mentor)
    MFC after:      1 week
    Sponsored by:   Subcarpathian BSD User Group

    (cherry picked from commit d836dae9f0d888d441234ea11e3cd91614c86aa2)

 sys/netgraph/netflow/netflow_v9.c | 1 +
 1 file changed, 1 insertion(+)
Comment 7 commit-hook freebsd_committer freebsd_triage 2026-01-24 09:28:59 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=40c0d6735538a1557a9b53306dd70aa2fc8ae7d1

commit 40c0d6735538a1557a9b53306dd70aa2fc8ae7d1
Author:     Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
AuthorDate: 2026-01-16 10:12:11 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-01-24 09:23:28 +0000

    ng_netflow v9: fix template re-announcement using packet count

    Increment fe->sent_packets after export9_send().
    Previously, NetFlow v9 templates were only re-announced based on
    time, ignoring the packet count parameter (`templ_packets`).

    PR:             270083
    Reviewed by:    glebius pouria
    Approved by:    glebius (mentor)
    MFC after:      1 week
    Sponsored by:   Subcarpathian BSD User Group

    (cherry picked from commit d836dae9f0d888d441234ea11e3cd91614c86aa2)

 sys/netgraph/netflow/netflow_v9.c | 1 +
 1 file changed, 1 insertion(+)
Comment 8 Marek Zarychta 2026-01-24 13:56:17 UTC
Thank you for the MFCs !
Now this bug is fixed in all supported FreeBSD versions, at least in versions that will have future releases.