Bug 270126 - net-mgmt/fastnetmon: unbreak rc script, fix log file creation, unbreak GoBGP API integration, try to re-enable Netmap support
Summary: net-mgmt/fastnetmon: unbreak rc script, fix log file creation, unbreak GoBGP ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Babak Farrokhi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-11 22:31 UTC by Marek Zarychta
Modified: 2023-03-24 14:58 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (farrokhi)


Attachments
Patch unbreaking rc.d script and providing some fixes (2.78 KB, patch)
2023-03-11 22:31 UTC, Marek Zarychta
no flags Details | Diff
Patch containing misc fixes (29.51 KB, patch)
2023-03-12 19:15 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-11 22:31:07 UTC
Created attachment 240758 [details]
Patch unbreaking rc.d script and providing some fixes

This patch primarily unbreaks rc.d scirpt, and additionally provides some improvements. Port passes testport and builds fine in poudriere.

1. %%ETCDIR%%/$name.conf expands to /usr/local/etc/fasnetmon/fastnetmon.conf, but we are installing the config file with path /usr/local/etc/fastnetmon.conf - let's unbreak it.

2. --daemonize wants to be first, otherwise, the startup script fails - fixed.

3. Oleksander okolita75@gmail.com submitted PR (bug 245751) with the apparent fix for Netmap support - let's try it.

4. Redis is now required, remove REDIS from options then.  

It's interesting software, thanks for taking care and updating to the most recent version farrokhi@ !
Comment 1 Marek Zarychta 2023-03-11 22:37:39 UTC
5. -DDISABLE_PF_RING_SUPPORT=ON removed as no more relevant after the transition to cmake
Comment 2 Marek Zarychta 2023-03-12 16:16:24 UTC
There is another problem with GoBGP API, Fastnetmon relies on the older, non-compatible version of GoBGP < 3.0. The upstream is aware of the problem, but it's hard to tell when they'll eventually come up with the solution[1]. The latest working version is GoBGP v2.34.0 from December 2021, but we don't have it in ports. We can either make the port partially broken (if possible) or create net/gobp2 for users who want this feature.


[1] https://github.com/pavel-odintsov/fastnetmon/issues/966
Comment 3 Marek Zarychta 2023-03-12 19:15:50 UTC
Created attachment 240798 [details]
Patch containing misc fixes

Fixes provided:

1. Path to config dir %%ETCDIR%%/$name.conf expanded to /usr/local/etc/fasnetmon/fastnetmon.conf, but we wer installing the config file with path /usr/local/etc/fastnetmon.conf - fixed.

2. --daemonize wanted to be first, otherwise, the startup script failed - fixed.

3. Oleksander okolita75@gmail.com submitted PR (bug 245751) with the apparent fix for Netmap support - let's try it.

4. Redis is now a dependency, remove REDIS from options then.
  
5. -DDISABLE_PF_RING_SUPPORT=ON removed as no more relevant after the transition to cmake

6. GoBGP v3.0.0 has different API, let's make it working again - fixed, tested  with net/gobgp v3.12.0 from ports.

7. Some logging files/directories were mising. Without writable /var/log/fastnetmon.log the daemon won't start - fixed.

The port passes testport and build fine in poudriere. The daemon installs and starts almost out of the box. The integration with GoBGP is possible again. I haven't tested Netmap though. Please don't hesitate to commit all this legwork done today.

Cheers !
Comment 4 Babak Farrokhi freebsd_committer freebsd_triage 2023-03-19 08:21:18 UTC
Thanks for your contribution. I have been trying to fix a few things with current port, including unbreaking build on 12.x and a few other improvements.
I tried to fix netmap and gobgp along the way. Enabling netmap is a bit more complicated than it seems (I am trying to get a build on 12.x and 13.x on various platforms), without many dirty hacks. 
As for GoBGP, I'd recommend we do not go with a huge patch, and create a net/gobgp2 port as a more generic solutions. Please feel free to create that port so we can enable gobgp support in fastnetmon in future.
Comment 5 Marek Zarychta 2023-03-19 09:07:23 UTC
(In reply to Babak Farrokhi from comment #4)
Thanks for the reply.  I have tried to create net/gobgp2 port, but it was non-trivial since the last 2.x was released 1.5 years ago, so it's a really deprecated version. Moreover, 2.x doesn't support the blacklisting of IPv6[1]. So in the meantime, the upstream transitioned to GoBGP 3.12 following our patch to solve problems with IPv6 bans[2], so I'd rather avoid switching to GoBGP 2.x.
 
With regard to improvements to the port, I found out that the creation of the log file I proposed is wrong, it should be held a different way since the log is now checked for mismatched checksum together with notify script and netwok_list files[3]. Perhaps we should move everything to /usr/local/etc/fastnetmon/ directory, and leave sample files only there (notify script, networks_ files and sample fastnetmon.conf file) and change logging to  fastnetmon.log in /var/log/fastnemon/ directory which we can create?


[1] https://github.com/pavel-odintsov/fastnetmon/issues/966 
[2] https://github.com/pavel-odintsov/fastnetmon/commit/61eb8c5edd1264c23c6d5ce2bf1e8f4b37d9cae0
[3]
Checking for packages with mismatched checksums:
fastnetmon-1.2.4_1: /usr/local/bin/notify_about_attack.sh
fastnetmon-1.2.4_1: /usr/local/etc/networks_list
fastnetmon-1.2.4_1: /var/log/fastnetmon.log
Comment 6 Babak Farrokhi freebsd_committer freebsd_triage 2023-03-24 14:55:50 UTC
@Marek: Thanks for your contribution. I cleaned up the patch, fixed a couple of other things and removed GoBGP changes. Let's wait for the future release with a proper GoBGP integration.
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-03-24 14:57:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3002262c9396ba38da42839a1a8c48ef444f80f0

commit 3002262c9396ba38da42839a1a8c48ef444f80f0
Author:     Babak Farrokhi <farrokhi@FreeBSD.org>
AuthorDate: 2023-03-24 14:56:36 +0000
Commit:     Babak Farrokhi <farrokhi@FreeBSD.org>
CommitDate: 2023-03-24 14:56:36 +0000

    net-mgmt/fastnetmon: Unreak build on 12.x

    - Unbreak build on 12.x
    - Enable netmap support
    - Cleanup unused options
    - Fix startup script

    PR: 270126

 net-mgmt/fastnetmon/Makefile                                | 13 ++++++-------
 net-mgmt/fastnetmon/files/fastnetmon.in                     |  6 +++---
 .../patch-src_netmap__plugin_netmap__collector.cpp (new)    | 10 ++++++++++
 net-mgmt/fastnetmon/pkg-plist                               |  2 +-
 4 files changed, 20 insertions(+), 11 deletions(-)