Documentation
¶
Overview ¶
Package accessroute keeps the access port of a web-exposed device pod out of the pod's main routing table.
The Kubernetes CNI (Cilium) puts "default via <gw> dev accessport" and "<gw> dev accessport scope link" into the main table. A lab interface with a default gateway of its own (the author's, or DHCP's) then replaces that default, and the replies to the L7 proxy go into the lab and time out. The fix is source routing, like the sbr CNI meta plugin: every route of the port moves into a table of its own, and a rule "from <port address> lookup <table>" sends what leaves with the port's address back out of the port. The main table is left with no route through the port, so the pod never uses it for its own traffic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoPort = errors.New("access port not found")
ErrNoPort means the access port is not in the netns (deleted from inside the pod, or not wired yet).
Functions ¶
Types ¶
type Result ¶
type Result struct {
// Routes is the content of the port's table after the call; keep it and pass it back as known so that a table that was
// flushed from inside the pod can be restored.
Routes []netlink.Route
// Changed is true when something had to be put right: a route moved or restored, a rule added.
Changed bool
}
Result says what Ensure found and did.
func Ensure ¶
Ensure makes the access port ifname of the netns at netnsPath use the source routing described in the package comment. It is idempotent: it moves what is still in the main table (RouteReplace into the port's table, then delete from main), adds the rule of every address of the port for IPv4 and IPv6 when absent, and puts back the routes from known (what an earlier call returned) that the table lacks. It fails when the port is not there or has no address, or when a route or rule cannot be written.