mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Make sure route selected is direct
Signed-off-by: Clint Armstrong <clint@clintarmstrong.net>
This commit is contained in:
parent
ba36e2b75e
commit
fa68f9d017
1 changed files with 14 additions and 2 deletions
|
@ -83,17 +83,29 @@ func (n *networkNamespace) programGateway(gw net.IP, isAdd bool) error {
|
|||
return fmt.Errorf("route for the gateway %s could not be found: %v", gw, err)
|
||||
}
|
||||
|
||||
var linkIndex int
|
||||
for _, gwRoute := range gwRoutes {
|
||||
if gwRoute.Gw == nil {
|
||||
linkIndex = gwRoute.LinkIndex
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if linkIndex == 0 {
|
||||
return fmt.Errorf("Direct route for the gateway %s could not be found", gw)
|
||||
}
|
||||
|
||||
if isAdd {
|
||||
return n.nlHandle.RouteAdd(&netlink.Route{
|
||||
Scope: netlink.SCOPE_UNIVERSE,
|
||||
LinkIndex: gwRoutes[0].LinkIndex,
|
||||
LinkIndex: linkIndex,
|
||||
Gw: gw,
|
||||
})
|
||||
}
|
||||
|
||||
return n.nlHandle.RouteDel(&netlink.Route{
|
||||
Scope: netlink.SCOPE_UNIVERSE,
|
||||
LinkIndex: gwRoutes[0].LinkIndex,
|
||||
LinkIndex: linkIndex,
|
||||
Gw: gw,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue