dhcp: Add priority option to dhcp.
Currently, we can not set the metric of routes in dhcp. It's ok if there is only a network interface. But if there are multiple network interfaces, and both have a default route, We need to set the metric of the route to make the traffic go through the correct network interface. For host-local and static, we can set the metric with the route.priority option. But there is no such option for dhcp. Signed-off-by: Songmin Li <lisongmin@protonmail.com>
This commit is contained in:

committed by
Casey Callendrello

parent
03712a572b
commit
cc8b1bd80c
@ -117,6 +117,7 @@ func ConfigureIface(ifName string, res *current.Result) error {
|
||||
Dst: &r.Dst,
|
||||
LinkIndex: link.Attrs().Index,
|
||||
Gw: gw,
|
||||
Priority: r.Priority,
|
||||
}
|
||||
|
||||
if r.Table != nil {
|
||||
@ -128,7 +129,7 @@ func ConfigureIface(ifName string, res *current.Result) error {
|
||||
}
|
||||
|
||||
if err = netlink.RouteAddEcmp(&route); err != nil {
|
||||
return fmt.Errorf("failed to add route '%v via %v dev %v (Scope: %v, Table: %d)': %v", r.Dst, gw, ifName, route.Scope, route.Table, err)
|
||||
return fmt.Errorf("failed to add route '%v via %v dev %v metric %d (Scope: %v, Table: %d)': %v", r.Dst, gw, ifName, r.Priority, route.Scope, route.Table, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user