29 Commits

Author SHA1 Message Date
Vincent Bernat
0a18f447b9 common/helpers: remove deprecated reflect.PtrTo
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled
2025-11-14 23:30:01 +01:00
Vincent Bernat
abca5e983d chore: modernize some code 2025-11-14 23:22:02 +01:00
Vincent Bernat
7f5950f89c build: add more linting rules with revive 2025-11-12 22:37:44 +01:00
Vincent Bernat
217c484061 common/helpers: rename PrefixTo16 to PrefixTo6
Move it to common/helpers/ipv6.go and use it where needed.
2025-11-04 08:05:30 +01:00
Vincent Bernat
ffe696e0e1 common/helpers: rename NetIPTo6 to AddrTo6 2025-11-04 07:43:19 +01:00
Vincent Bernat
23518c3e2e common/helpers: add a NetIPTo6() function
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled
Update Nix dependency hashes / Update dependency hashes (push) Has been cancelled
This should be netip.To6() but it does not exist and it was rejected.
There is a benchmark showing the improvment of such optimisation:

BenchmarkNetIPTo6/safe_v4-12            170152954                7.054 ns/op
BenchmarkNetIPTo6/unsafe_v4-12          764772190                1.553 ns/op

See https://github.com/golang/go/issues/54365.
2025-11-03 21:36:33 +01:00
Vincent Bernat
e21e612259 common/helpers: use Modify() for subnet maps as well
Replace `table.Update()` with `table.Modify()`.
2025-09-06 20:01:19 +02:00
Vincent Bernat
fdb65c93a5 outlet/routing: store v4 routes into a v4 tree
This is improves performance significantly:

```
goos: linux
goarch: amd64
pkg: akvorado/outlet/routing/provider/bmp
cpu: AMD Ryzen 5 5600X 6-Core Processor
                                       │      1       │                  2                   │
                                       │  sec/route   │  sec/route    vs base                │
RIBInsertion/1000_routes,_1_peers-12     466.6n ± ∞ ¹   413.6n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/1000_routes,_2_peers-12     468.5n ± ∞ ¹   424.6n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/1000_routes,_5_peers-12     475.0n ± ∞ ¹   419.6n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/10000_routes,_1_peers-12    485.3n ± ∞ ¹   434.1n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/10000_routes,_2_peers-12    532.6n ± ∞ ¹   477.0n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/10000_routes,_5_peers-12    585.6n ± ∞ ¹   551.9n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/100000_routes,_1_peers-12   623.8n ± ∞ ¹   587.7n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/100000_routes,_2_peers-12   682.1n ± ∞ ¹   637.8n ± ∞ ¹       ~ (p=1.000 n=1) ²
RIBInsertion/100000_routes,_5_peers-12   804.9n ± ∞ ¹   740.8n ± ∞ ¹       ~ (p=1.000 n=1) ²
geomean                                  559.6n         510.1n        -8.85%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                                    │       1       │                   2                   │
                                    │    sec/op     │    sec/op     vs base                 │
RIBLookup/1000_routes,_1_peers-12      82.87n ± ∞ ¹   14.59n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/1000_routes,_2_peers-12      82.86n ± ∞ ¹   14.68n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/1000_routes,_5_peers-12      83.24n ± ∞ ¹   14.56n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/10000_routes,_1_peers-12     87.27n ± ∞ ¹   14.69n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/10000_routes,_2_peers-12     89.92n ± ∞ ¹   14.62n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/10000_routes,_5_peers-12     99.67n ± ∞ ¹   14.74n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/100000_routes,_1_peers-12   129.60n ± ∞ ¹   14.68n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/100000_routes,_2_peers-12   121.50n ± ∞ ¹   14.71n ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBLookup/100000_routes,_5_peers-12   122.90n ± ∞ ¹   14.69n ± ∞ ¹        ~ (p=1.000 n=1) ²
geomean                                98.40n         14.66n        -85.10%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                                   │      1       │                   2                   │
                                   │    ms/op     │    ms/op      vs base                 │
RIBFlush/1000_routes,_1_peers-12     268.9m ± ∞ ¹   214.4m ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/1000_routes,_2_peers-12     457.2m ± ∞ ¹   357.8m ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/1000_routes,_5_peers-12     954.7m ± ∞ ¹   697.6m ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/10000_routes,_1_peers-12     2.832 ± ∞ ¹    2.157 ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/10000_routes,_2_peers-12     5.660 ± ∞ ¹    4.247 ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/10000_routes,_5_peers-12     14.00 ± ∞ ¹    10.48 ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/100000_routes,_1_peers-12    48.33 ± ∞ ¹    41.31 ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/100000_routes,_2_peers-12    86.33 ± ∞ ¹    75.51 ± ∞ ¹        ~ (p=1.000 n=1) ²
RIBFlush/100000_routes,_5_peers-12    197.5 ± ∞ ¹    155.7 ± ∞ ¹        ~ (p=1.000 n=1) ²
geomean                               6.534          5.138        -21.36%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
```

Suggested in https://github.com/gaissmai/bart/issues/247#issuecomment-3257156436.
2025-09-05 20:49:16 +02:00
Vincent Bernat
6118bb7aac common/helpers: convert SubnetMap to github.com/gaissmai/bart
I did not benchmark it myself, but it was benchmarked here:
 https://github.com/osrg/gobgp/issues/1414#issuecomment-3067255941

Of course, no guarantee that this benchmark matches our use cases.
Moreover, SubnetMap have been optimized to avoid parsing keys all
the time.

Also, the interface is a bit nicer and it uses netip.Prefix directly.

The next step is to convert outlet/routing/provider/bmp.
2025-08-16 09:38:44 +02:00
Vincent Bernat
18beb310ee chore: replace interface{} with any 2025-07-29 07:42:49 +02:00
Vincent Bernat
e08331a286 common/helpers: switch to a blessed fork of mapstructure 2025-02-15 14:51:17 +01:00
Vincent Bernat
4a9430e74b inlet/metadata: merge SNMP communities and USM into credentials
This unifies both structure and allows a user to define exception for
some specific subnets. See #1606.
2025-01-18 17:05:43 +01:00
Vincent Bernat
faf58ba5bb common/helpers: be stricter when trying to look for subnets
Otherwise, if the map contains "cafe", we may think this is a subnet
while it is obviously not. But we want to catch user errors like
"2o01:db8::/64" to provide a better error message.
2025-01-18 13:50:35 +01:00
Francois Espinet
87a57bf82e Do geoip enrich in clickhouse instead of inlet
One solution to https://github.com/akvorado/akvorado/issues/62
2024-03-11 15:29:09 +01:00
Vincent Bernat
8ad3492579 commmon/helpers: fix decoding of SubnetMap that are already SubnetMap
Fix #1067
2024-02-01 23:22:14 +01:00
Itah
705e56cac4 inlet/metadata/static: allow exporters configuration refresh from http data source using common/remotedatasourcefetcher, refactored with orchestrator/clickhouse network-sources. 2024-01-17 11:11:34 +01:00
Vincent Bernat
6bfd3a0bd0 inlet/snmp: use netip.Addr internally instead of string
Also, make SubnetMap use `netip.Addr` as well.
2022-08-27 08:13:57 +02:00
Vincent Bernat
985e678e42 chore: replace map[string]interface{} by gin.H 2022-08-16 19:43:28 +02:00
Vincent Bernat
574ec7e79e inlet/snmp: add proper support for SNMPv3 2022-08-14 10:20:19 +02:00
Vincent Bernat
0a4275d87d inlet/snmp: add ability to set a version for SNMP
This is mostly useless as we don't provide a way to specify SNMPv3
authentication. We won't keep this config option as is.
2022-08-14 00:57:33 +02:00
Vincent Bernat
cd535c915d common/helpers: make subnetmap work with struct as values
The way it was converted from a mapstruct made it not possible to have
struct as values. Fix that by checking if keys look like IP or not.
2022-08-14 00:54:55 +02:00
Vincent Bernat
3f1dc38052 Revert "inlet/snmp: do not deprecate default-community"
This reverts commit e5d3d3fbc3. When
adding SNMPv3, it will be odd to have this. Just put the extra mile to
deprecate it correctly.
2022-08-13 21:33:53 +02:00
Vincent Bernat
61c8143fe8 build: fix linting issues introduced by latest revive release 2022-08-07 23:54:24 +02:00
Vincent Bernat
5691b13050 orchestrator/clickhouse: use SubnetMap for parsing networks 2022-08-01 09:03:48 +02:00
Vincent Bernat
e5d3d3fbc3 inlet/snmp: do not deprecate default-community
We did not handle all cases, notably the case where default-community
was not set explicitely by the user. This seems a lot of code for
little gain, let's keep things simple.
2022-08-01 07:15:50 +02:00
Vincent Bernat
1bbaf4de24 inlet/snmp: accept subnets for communities
Also deprecate `default-community`.
2022-07-31 23:38:54 +02:00
Vincent Bernat
f1585f3e6c helpers/subnetmap: fix bug when using IPv6-mapped IPv4 addresses
Go will display them as IPv4. We want everything to be IPv6.
2022-07-31 22:45:19 +02:00
Vincent Bernat
c0d9d301b3 helpers/subnetmap: allow to use IP addresses
They will be considered as /32 or /128.
2022-07-31 22:39:14 +02:00
Vincent Bernat
5cdc567828 inlet/core: also accept a map from subnet for default-sampling-rate
This should be generalized to other parts of configuration (SNMP
community), however, we need to check what happens with default
values. Also, network definition in orchestrator is likely to be able
to reuse that.
2022-07-31 20:36:46 +02:00