Skip to content

Commit

Permalink
Allow multiple routes to be added for the same prefix.
Browse files Browse the repository at this point in the history
Enables ECMP

Fixes: containernetworking#601

Signed-off-by: Michael Cambria <mcambria@redhat.com>
  • Loading branch information
mccv1r0 committed Mar 11, 2021
1 parent d385120 commit 55b3bfe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
13 changes: 8 additions & 5 deletions pkg/ipam/ipam_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ func ConfigureIface(ifName string, res *current.Result) error {
gw = v6gw
}
}
if err = ip.AddRoute(&r.Dst, gw, link); err != nil {
// we skip over duplicate routes as we assume the first one wins
if !os.IsExist(err) {
return fmt.Errorf("failed to add route '%v via %v dev %v': %v", r.Dst, gw, ifName, err)
}
route := netlink.Route{
Dst: &r.Dst,
LinkIndex: link.Attrs().Index,
Gw: gw,
}

if err = netlink.RouteAddEcmp(&route); err != nil {
return fmt.Errorf("failed to add route '%v via %v dev %v': %v", r.Dst, gw, ifName, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/main/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func calcGateways(result *current.Result, n *NetConf) (*gwInfo, *gwInfo, error)

// Add a default route for this family using the current
// gateway address if necessary.
if n.IsDefaultGW && !gws.defaultRouteFound {
if n.IsDefaultGW {
for _, route := range result.Routes {
if route.GW != nil && defaultNet.String() == route.Dst.String() {
gws.defaultRouteFound = true
Expand Down
12 changes: 12 additions & 0 deletions vendor/github.com/vishvananda/netlink/route_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 55b3bfe

Please sign in to comment.