gvisor icon indicating copy to clipboard operation
gvisor copied to clipboard

Newly created sandbox in host networking mode has lo interface DOWN

Open syang998 opened this issue 8 months ago • 4 comments

Description

In our experiment we found that in a newly created gVisor Sandbox, if the network stack is set to none, then there is a lo interface and it is enabled with loopback address of 127.0.0.1. But if the network stack is set to host, the lo interface still exists, but is disabled (i.e. state DOWN). These can all be explained by the code here. https://github.com/google/gvisor/blob/master/runsc/sandbox/network.go#L71

The problem is that in none mode, there is no networking outside of the sandbox. We want to both enable loopback, and also network externally. Is there a way to have lo enabled in host mode?

I have tried to duplicates L60-63 to L72, but it does not work.

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

No response

syang998 avatar May 28 '25 16:05 syang998

When the network mode is host, the sandbox will use the host's network stack and if the host network has loopback interface disabled, sandbox should also have it disabled. For example in docker, the loopback interfaces are disabled by default when the container comes up and its the responsibility of the application to enable it.

I think changing the behavior of the sandbox to be other than what the host network has while using host network mode is not a good idea.

nybidari avatar Jun 04 '25 19:06 nybidari

@syang998 could you share more details on how you are starting a container? I think you might be starting it in a new network namespace. If that's true, it would explain why the lo device is down:

$ unshare -Urn ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

avagin avatar Jun 04 '25 22:06 avagin

Hi, @avagin You are right. We start it in a new network namepsace and the default for lo is DOWN. Is this usage something we can add? Perhaps another mode?

syang998 avatar Jun 06 '25 03:06 syang998

@syang998: If you want to use the host network mode and have internet connectivity, you need to run your sandbox in the host network namespace.

avagin avatar Jun 06 '25 19:06 avagin