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
@ -109,6 +109,11 @@ func (d *DHCP) Allocate(args *skel.CmdArgs, result *current.Result) error {
|
||||
Gateway: l.Gateway(),
|
||||
}}
|
||||
result.Routes = l.Routes()
|
||||
if conf.IPAM.Priority != 0 {
|
||||
for _, r := range result.Routes {
|
||||
r.Priority = conf.IPAM.Priority
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ type IPAMConfig struct {
|
||||
// To override default requesting fields, set `skipDefault` to `false`.
|
||||
// If an field is not optional, but the server failed to provide it, error will be raised.
|
||||
RequestOptions []RequestOption `json:"request"`
|
||||
// The metric of routes
|
||||
Priority int `json:"priority,omitempty"`
|
||||
}
|
||||
|
||||
// DHCPOption represents a DHCP option. It can be a number, or a string defined in manual dhcp-options(5).
|
||||
|
Reference in New Issue
Block a user