Skip to content

Commit c2da841

Browse files
committed
Set value of SCOPE to SCOPE_LINK for opt121 routes with router unspecified with DHCP
Default behavior of the plugin is to try and install routes without specifying SCOPE which results in not installing certain routes that do not have a gateway set in the DHCP server response. If the SCOPE is not set to LINK (in particular for NICs in some cloud environment that get assigned /32 IPs to them). This change enables routes to be installed without the router being specified, but sets to SCOPE_LINK. Signed-off-by: Olivier Martin <[email protected]>
1 parent 48a4ae5 commit c2da841

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugins/ipam/dhcp/lease.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,13 @@ func (l *DHCPLease) Routes() []*types.Route {
474474
opt121Routes := ack.ClasslessStaticRoute()
475475
if len(opt121Routes) > 0 {
476476
for _, r := range opt121Routes {
477-
routes = append(routes, &types.Route{Dst: *r.Dest, GW: r.Router})
477+
route := &types.Route{Dst: *r.Dest, GW: r.Router}
478+
// if router is not specified, add SCOPE_LINK so routes are installed
479+
if r.Router.IsUnspecified() {
480+
scopeLinkValue := int(netlink.SCOPE_LINK)
481+
route.Scope = &scopeLinkValue
482+
}
483+
routes = append(routes, route)
478484
}
479485
return routes
480486
}

0 commit comments

Comments
 (0)