Skip to content

Commit

Permalink
loader: Remove program and route when disable endpoint routes
Browse files Browse the repository at this point in the history
When per-endpoint routes are enabled, a route is added for each
endpoint. A BPF program is also attached to the lxc devices on the path
to the containers.

When per-endpoint routes are disabled, we need to remove the routes and
the programs.

Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
pchaigno authored and kkourt committed Mar 10, 2021
1 parent 991fd55 commit 72e6238
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/datapath/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,27 @@ func (l *Loader) reloadDatapath(ctx context.Context, ep datapath.Endpoint, dirs
}
return err
}
} else {
err := RemoveTCFilters(ep.InterfaceName(), netlink.HANDLE_MIN_EGRESS)
if err != nil {
log.WithField("device", ep.InterfaceName()).Error(err)
}
}
}

if ep.RequireEndpointRoute() {
if ip := ep.IPv4Address(); ip.IsSet() {
if ip := ep.IPv4Address(); ip.IsSet() {
if ep.RequireEndpointRoute() {
upsertEndpointRoute(ep, *ip.IPNet(32))
} else {
removeEndpointRoute(ep, *ip.IPNet(32))
}
}

if ip := ep.IPv6Address(); ip.IsSet() {
if ip := ep.IPv6Address(); ip.IsSet() {
if ep.RequireEndpointRoute() {
upsertEndpointRoute(ep, *ip.IPNet(128))
} else {
removeEndpointRoute(ep, *ip.IPNet(128))
}
}

Expand Down

0 comments on commit 72e6238

Please sign in to comment.