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

Signed-off-by: Michael Cambria <[email protected]>
  • Loading branch information
mccv1r0 committed Apr 20, 2021
1 parent 00e0219 commit 0b69457
Showing 1 changed file with 8 additions and 5 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

0 comments on commit 0b69457

Please sign in to comment.