diff --git a/pkg/ipam/ipam_linux.go b/pkg/ipam/ipam_linux.go index 013fe7f5b..63c18d689 100644 --- a/pkg/ipam/ipam_linux.go +++ b/pkg/ipam/ipam_linux.go @@ -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 { diff --git a/plugins/ipam/dhcp/daemon.go b/plugins/ipam/dhcp/daemon.go index 7fc949c30..867ead3fe 100644 --- a/plugins/ipam/dhcp/daemon.go +++ b/plugins/ipam/dhcp/daemon.go @@ -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 } diff --git a/plugins/ipam/dhcp/main.go b/plugins/ipam/dhcp/main.go index f49730c1d..190f08470 100644 --- a/plugins/ipam/dhcp/main.go +++ b/plugins/ipam/dhcp/main.go @@ -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).