Skip to content

Commit 1c769af

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 particuliar 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 <martinolivier@google.com>
1 parent afe6bc6 commit 1c769af

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

plugins/ipam/dhcp/lease.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,13 @@ func (l *DHCPLease) Routes() []*types.Route {
474474
opt121Routes := ack.ClasslessStaticRoute()
475475
if len(opt121Routes) > 0 {
476476
for _, r := range opt121Routes {
477-
// Verify if nil before using the nil pointer.
478-
if r.Dest != nil {
479-
// set GW to nil for cloud based infrastructures with /32 host IPs
480-
routes = append(routes, &types.Route{Dst: *r.Dest, GW: nil})
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
481482
}
483+
routes = append(routes, route)
482484
}
483485
return routes
484486
}

0 commit comments

Comments
 (0)