jow- / nlbwmon

Simple conntrack based traffic accounting
ISC License
152 stars 34 forks source link

Nlbwmon cannot work immediately after booting on OpenWrt 23.05.3 #59

Open LemonCrab666 opened 3 weeks ago

LemonCrab666 commented 3 weeks ago

Nlbwmon cannot work immediately after booting on Immortalwrt 23.05.3 image When OpenWRT is set to the 1st of the following month, nlbwmon will start working immediately, but it will cease to function after a restart.Can you please advise on how to solve this problem

unprintable123 commented 5 days ago

I have the same issue and I find that allow_insert is always false, keeping the database empty. So I modified the code to force it try to insert everytime.

LemonCrab666 commented 5 days ago

I have the same issue and I find that allow_insert is always false, keeping the database empty. So I modified the code to force it try to insert everytime.

I couldn't find any nlbwmo related repositories on your homepage. Can you share the ones you have modified?Thank you

unprintable123 commented 5 days ago

I use a patch file and it may not be the best solution. Here it is

Index: nlbwmon-2024-02-21-c7616bcf/nfnetlink.c
===================================================================
--- nlbwmon-2024-02-21-c7616bcf.orig/nfnetlink.c
+++ nlbwmon-2024-02-21-c7616bcf/nfnetlink.c
@@ -78,10 +78,9 @@ struct delayed_record {
 static void
 database_insert_immediately(struct record *r)
 {
-   if (r->count != 0)
-       database_insert(gdbh, r);
-   else
-       database_update(gdbh, r);
+   int err = 0;
+   err = database_insert(gdbh, r);
+   if (err < 0) fprintf(stderr, "failed to insert, count %lld, err %d\n", r->count, err);
 }

 static void
LemonCrab666 commented 5 days ago

I use a patch file and it may not be the best solution. Here it is

Thank you for your contribution

langit7 commented 2 days ago

I use a patch file and it may not be the best solution. Here it is

Index: nlbwmon-2024-02-21-c7616bcf/nfnetlink.c
===================================================================
--- nlbwmon-2024-02-21-c7616bcf.orig/nfnetlink.c
+++ nlbwmon-2024-02-21-c7616bcf/nfnetlink.c
@@ -78,10 +78,9 @@ struct delayed_record {
 static void
 database_insert_immediately(struct record *r)
 {
- if (r->count != 0)
-     database_insert(gdbh, r);
- else
-     database_update(gdbh, r);
+ int err = 0;
+ err = database_insert(gdbh, r);
+ if (err < 0) fprintf(stderr, "failed to insert, count %lld, err %d\n", r->count, err);
 }

 static void

Do you have connection recorded with this patch. image

unprintable123 commented 2 days ago

No connection count either. It seems that any new connection is not captured in my system, thus no count and insert into database. I don't know whether it's a problem of netlink or nlbwmon. The patch just fixes the empty db problem but i don't know how to debug the loss of new connections.