Skip to content

Commit 8f375f8

Browse files
committed
add classless static route support to the forknet dhcp client so that the ipv4.dhcp.routes setting works with OCI containers
Signed-off-by: Gwendolyn <[email protected]>
1 parent 44fb640 commit 8f375f8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cmd/incusd/main_forknet.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,21 @@ func (c *cmdForknet) RunDHCP(cmd *cobra.Command, args []string) error {
391391
return nil
392392
}
393393

394+
for _, staticRoute := range lease.Offer.ClasslessStaticRoute() {
395+
route := &ip.Route{
396+
DevName: iface,
397+
Route: staticRoute.Dest.String(),
398+
Via: staticRoute.Router.String(),
399+
Family: ip.FamilyV4,
400+
}
401+
402+
err = route.Add()
403+
if err != nil {
404+
fmt.Fprintf(os.Stderr, "Giving up on DHCP, couldn't add classless static route to %q: %v\n", iface, err)
405+
return nil
406+
}
407+
}
408+
394409
// Create PID file.
395410
err = os.WriteFile(filepath.Join(args[0], "dhcp.pid"), []byte(fmt.Sprintf("%d", os.Getpid())), 0644)
396411
if err != nil {

0 commit comments

Comments
 (0)