Skip to content

Commit

Permalink
datapath/linux/node: use proto kernel for fib rules and routes
Browse files Browse the repository at this point in the history
Use RTPROT_KERNEL (proto kernel) when installing fib rules and routes to
make sure systemd doesn't play with them. Note that the patch doesn't
modify the routes installed when node encryption is enabled because
currently it relies on the route protocol to later recognize and remove
them (it overloads the route protocol basically). To see more about the
systemd issue check [1].

[1] cilium#18706

Signed-off-by: Nikolay Aleksandrov <nikolay@isovalent.com>
  • Loading branch information
Nikolay Aleksandrov authored and youngnick committed Mar 25, 2023
1 parent 1d319cf commit f29b435
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/datapath/linux/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ func createDirectRouteSpec(CIDR *cidr.CIDR, nodeIP net.IP) (routeSpec *netlink.R
var routes []netlink.Route

routeSpec = &netlink.Route{
Dst: CIDR.IPNet,
Gw: nodeIP,
Dst: CIDR.IPNet,
Gw: nodeIP,
Protocol: linux_defaults.RTProto,
}

routes, err = netlink.RouteGet(nodeIP)
Expand Down Expand Up @@ -314,8 +315,9 @@ func (n *linuxNodeHandler) deleteDirectRoute(CIDR *cidr.CIDR, nodeIP net.IP) {
}

filter := &netlink.Route{
Dst: CIDR.IPNet,
Gw: nodeIP,
Dst: CIDR.IPNet,
Gw: nodeIP,
Protocol: linux_defaults.RTProto,
}

routes, err := netlink.RouteListFiltered(family, filter, netlink.RT_FILTER_DST|netlink.RT_FILTER_GW)
Expand Down Expand Up @@ -383,6 +385,7 @@ func (n *linuxNodeHandler) createNodeRouteSpec(prefix *cidr.CIDR, isLocalNode bo
Prefix: *prefix.IPNet,
MTU: mtu,
Priority: option.Config.RouteMetric,
Proto: linux_defaults.RTProto,
}, nil
}

Expand Down Expand Up @@ -1235,6 +1238,7 @@ func (n *linuxNodeHandler) replaceHostRules() error {
Priority: 1,
Mask: linux_defaults.RouteMarkMask,
Table: linux_defaults.RouteTableIPSec,
Protocol: linux_defaults.RTProto,
}

if n.nodeConfig.EnableIPv4 {
Expand Down Expand Up @@ -1273,6 +1277,7 @@ func (n *linuxNodeHandler) removeEncryptRules() error {
Priority: 1,
Mask: linux_defaults.RouteMarkMask,
Table: linux_defaults.RouteTableIPSec,
Protocol: linux_defaults.RTProto,
}

rule.Mark = linux_defaults.RouteMarkDecrypt
Expand Down Expand Up @@ -1334,6 +1339,7 @@ func (n *linuxNodeHandler) createNodeIPSecOutRoute(ip *net.IPNet) route.Route {
Prefix: *ip,
Table: linux_defaults.RouteTableIPSec,
MTU: n.nodeConfig.MtuConfig.GetRoutePostEncryptMTU(),
Proto: linux_defaults.RTProto,
}
}

Expand Down

0 comments on commit f29b435

Please sign in to comment.