231 Commits

Author SHA1 Message Date
Aaron U'Ren
a1e6de9f8f test(NSC): add endpoint checking to tests that need them 2026-02-01 11:07:13 -06:00
Aaron U'Ren
3157e85eb8 test(NSC): fix two DSR service tests to create pods 2026-02-01 11:07:13 -06:00
Aaron U'Ren
ca6b644d32 test(NSC): mock netlink calls - attempt 1 2026-02-01 11:07:13 -06:00
Aaron U'Ren
b9cd0de978 test(NSC): add DSR unit tests - series 1 2026-02-01 11:07:13 -06:00
Aaron U'Ren
10f366ace6 test(NSC): implement traffic policy unit testing
Logic errors & regressions relating to traffic policies make up
approximately 8 or so preventable historical issues with the project.
Therefore prioritizing them as a unit testing surface.
2026-02-01 11:07:13 -06:00
Aaron U'Ren
048680706c fix(NSC): cleanup historical bad IPv6 TCPMSS vals 2026-02-01 10:56:40 -06:00
Aaron U'Ren
8aaba6505e test(NSC): add comprehensive TCPMSS unit tests 2026-02-01 10:56:40 -06:00
Aaron U'Ren
d208307d43 fact(test): reuse existing ValToPtr functions 2026-01-31 12:15:35 -06:00
Aaron U'Ren
ae39f279a7 fact(NSC): use LinuxNetworkingMock instead of creating a new one 2026-01-31 12:15:35 -06:00
Aaron U'Ren
59814eb67b fix: convert ginkgo tests to standard go tests 2026-01-31 12:15:35 -06:00
Richard Kojedzinszky
ee0940b87c fix(dsr): set TCPMSS based on address family 2026-01-25 12:00:21 -06:00
Cat C
440ad4d0a1 fix: Replace all netlink functions that throw ErrDumpInterrupted with a retry wrapper 2026-01-09 09:17:43 -06:00
ccoVeille
e06ddccabe feat(test): use safecast.RequireConvert as a replacement for safecast.Convert in tests 2025-11-21 21:20:44 -06:00
ccoVeille
1e8976bd79 build(deps): update github.com/ccoveille/go-safecast to v2.0.0 2025-11-08 01:13:51 +01:00
ccoVeille
e8a59fda2e build(deps): bump github.com/ccoveille/go-safecast to 1.8.1 2025-11-03 12:04:58 +01:00
Aaron U'Ren
846fbd8500 fix(ipset): don't strip inet6 prefixing of ipsets
The problem here stems from the fact that when netpol generates its list of expected ipsets, it includes the inet6:
prefix, however, when the proxy and routing controller sent their list of expected ipsets, they did not do so. This
meant that no matter how we handled it in ipset.go it was wrong for one or the other use-cases.

I decided to standardize on the netpol way of sending the list of expected ipset names so that BuildIPSetRestore() can
function in the same way for all invocations.
2025-10-27 21:25:33 -05:00
Aaron U'Ren
f44598bcb1 test(ipset): add unit tests for ipset regression testing 2025-10-27 21:25:33 -05:00
Bukal, Tomáš
720e2ca2bd fix(ipset): store kube-router-local-ips ipset 2025-10-11 08:26:43 -05:00
Aaron U'Ren
6c44013bc5 fix(ipset): ignore non-kube-router ipsets
Attempt to filter out sets that we are not authoritative for to avoid
race conditions with other operators (like Istio) that might be
attempting to modify ipsets at the same time.
2025-10-04 18:30:28 -05:00
Aaron U'Ren
a4fb70a095 feat(lint): update golangci-lint v2.0.2 -> v2.4.0 2025-09-20 16:30:54 -05:00
Aaron U'Ren
d7214cec4f feat(Endpoints): convert Endpoints -> EndpointSlices 2025-09-06 16:27:03 -05:00
Aaron U'Ren
732d7a72dc fix(nsc): add loadbalancer IPs to metrics 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
c2fd633373 fix(nsc): sync field name 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
b4a9ba70fd fix(nsc): rename network_services_metrics.go 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
7533c183a1 feat(nsc): getMetricsServiceMap() rebuilds only after services changed 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
5efb999169 feat(nsc): replace unsafe.Pointer with atomic.Pointer 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
d0163ab725 feat(nsc): move part of Collect() to getMetricsServiceMap() 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
4e8bb705b5 feat(nsc): move metrics logic to separate file 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
a224198c89 feat(nsc): optimize key in temporary serviceMap 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
4ed0cf4117 feat(nsc): improve Service statistics 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
1b4b6d6b2b feat(nsc): eliminate nested loops in Collect() 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
766627645e feat(nsc): collect service statistics on demand 2025-09-01 21:04:49 -05:00
Richard Kojedzinszky
4b4ebec81f feat(nsc): prepare serviceMap to be accessed by collector thread 2025-09-01 21:04:49 -05:00
Anupam Ghosh
5e397e50e7 fix failed message 2025-08-06 17:01:22 -07:00
Anupam Ghosh
bbb8f3b0d9 disable sloppy_tcp if there is no DSR & Maglev service 2025-08-06 17:01:22 -07:00
Anupam Ghosh
598fc86349 enable sloppy_tcp when DSR and Maglev is enabled 2025-08-06 17:01:22 -07:00
Aaron U'Ren
700620509f feat(DSR): disable routing DSR traffic via kube-bridge
This was originally added in PR #210, but it appears to cause more
problems in my testing scenarios than it solves. When this is enabled,
it makes it so that services cannot be routed to from kube workers to
DSR enabled services when routed to other nodes in the cluster.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
2ebcac62ec feat(linux_networking): add some additional logging 2025-06-29 17:42:18 -05:00
Aaron U'Ren
8504c52e80 fix(DSR): setup source routing for all external IPs
Previously, kube-router was only considering externalIPs when setting up
source routing policy, notably absent was consideration of LoadBalancer
IPs which are equally important for getting right with DSR.

This appears to have been a long-standing use-case that was never
correctly considered since when kube-router added a LoadBalancer
controller.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
e6edc853fb fix(ipAddrDel): check to see if IP exists on interface before delete
Rather than yolo'ing a delete of the IP on the interface, check to see
if it exists and save the user some warning in their logs.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
69e58eda04 feat(NSC): add some additional debugging to traffic director 2025-06-29 17:42:18 -05:00
Aaron U'Ren
94bfc0d9ba fix(ipAddrDel): check for routes before trying to delete
Instead of deleting and just hoping for the best, this change makes it
so that we check first whether or not a route exists. This helps to
reduce needless warnings that the user receives and is just all around
more accurate.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
e29b6a3275 fix(NSC): pass fwmark to traffic director as an int
It used to be when we were using iproute2's CLI we needed to have the
fwmark as a hex number so we were passing it as a string in that format.

However, now that we use the netlink library directly, we already have
the fwmark in the condition that we need it. So instead of doing all of
these string <-> int conversions, lets just keep this simpler.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
3c895955f7 fact(utils): factor out single subnet ip logic
Removes repeated logic of calculating IP address subnets for single
subnet hosts and consolidates it in one place.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
b070531ec5 fix: add proper nil rule src handling
When ip rules are evaluated in the netlink library, default routes for
src and dst are equated to nil. This makes it difficult to evaluate
them and requires additional handling in order for them.

I filed an issue upstream so that this could potentially get fixed:
https://github.com/vishvananda/netlink/issues/1080 however if it doesn't
get resolved, this should allow us to move forward.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
f2b0d785a0 fact: add ip utils library & add unit testing
Consolidate IP utility functions into a new file and add proper unit
testing. Additionally consolidate logic and references to default route
subnets.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
4795a07e7c fix(ip rule): use NewRule() for all rule creations
It has proven to be tricky to insert new rules without calling the
designated NewRule() function from the netlink library. Usually attempts
will fail with an operation not supported message.

This improves the reliability of rule insertion.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
56076051f8 fix(linux_networking.go): add scope to local routes
In order for a local route to be valid it needs to have the scope set to
host. When we were executing ip commands iproute2 just did this for us
to make the command accurate. Now that we're communicating with the
netlink socket, we need to do this conversion for ourselves.

Without this we get an error that says "invalid argument" from the
netlink subsystem. But if the route isn't local, then most of the
routing logic for services doesn't work correctly because it acts upon
external traffic as well as local traffic which isn't correct.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
80328ace67 fix(linux_networking.go): filter routes to be deleted by table
Previously we were accidentally deleting all routes that were found,
this mimics the previous functionality better by only deleting external
IPs that were found in the externalIPRouteTable that are no longer in
the activeExternalIPs map.

Also improves logging around any routes that are deleted as this is
likely of interest to all kube-router administrators.
2025-06-29 17:42:18 -05:00
Aaron U'Ren
f59a4f5ae8 feat: convert execs to ip to netlink calls
Not making direct exec calls to user binary interfaces has long been a
principle of kube-router. When kube-router was first coded, the netlink
library was missing significant features that forced us to exec out.
However, now netlink seems to have most of the functionality that we
need.

This converts all of the places where we can use netlink to use the
netlink functionality.
2025-06-29 17:42:18 -05:00