Skip to content

Commit 1c2d64c

Browse files
authored
Disable ipv6 inside workspace (#20326)
1 parent 13e66a2 commit 1c2d64c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

components/ws-daemon/nsinsider/main.go

+7
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,13 @@ func main() {
402402
return os.WriteFile("/proc/sys/net/ipv4/ip_forward", []byte("1"), 0644)
403403
},
404404
},
405+
{
406+
Name: "disable-ipv6",
407+
Usage: "disable IPv6",
408+
Action: func(c *cli.Context) error {
409+
return os.WriteFile("/proc/sys/net/ipv6/conf/all/disable_ipv6", []byte("1"), 0644)
410+
},
411+
},
405412
{
406413
Name: "dump-network-info",
407414
Usage: "dump network info",

components/ws-daemon/pkg/iws/iws.go

+7
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,13 @@ func (wbs *InWorkspaceServiceServer) MountProc(ctx context.Context, req *api.Mou
489489
masks = append(masks, procDefaultReadonlyPaths...)
490490
cleanupMaskedMount(wbs.Session.OWI(), nodeStaging, masks)
491491

492+
err = nsi.Nsinsider(wbs.Session.InstanceID, int(procPID), func(c *exec.Cmd) {
493+
c.Args = append(c.Args, "disable-ipv6")
494+
}, nsi.EnterNetNS(true), nsi.EnterMountNSPid(1))
495+
if err != nil {
496+
return nil, status.Errorf(codes.Internal, "cannot disable IPv6")
497+
}
498+
492499
return &api.MountProcResponse{}, nil
493500
}
494501

0 commit comments

Comments
 (0)