Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan /proc/net/{tcp,udp} for host network driver port bindings #7746

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Nino-K
Copy link
Member

@Nino-K Nino-K commented Nov 8, 2024

This introduces a scanner that monitors entries in /proc/net/{tcp,udp}. When using the host network driver (--net=host) in Docker or containerd, some port bindings are not exposed through the API. However, these bindings are still visible in /proc/net because the container shares the host network namespace.

The procnet scanner scans the corresponding files every 3 seconds and if a new entry is found or removed it calls the host switch API to expose and unexpose accordingly.

Fixes: #7378

@Nino-K Nino-K changed the title Add scanner to /proc/net/{tcp,udp} Scan /proc/net/{tcp,udp} for host network driver port bindings Nov 8, 2024
src/go/guestagent/main.go Fixed Show fixed Hide fixed
src/go/guestagent/main.go Fixed Show fixed Hide fixed
@jandubois
Copy link
Member

Can you fix the spelling errors (by adding the words to the dictionary)? That should re-trigger the actions...

@Nino-K Nino-K force-pushed the procnet-scanning-guest-agent branch 2 times, most recently from d621770 to b2aa16f Compare November 12, 2024 18:56
This introduces a scanner that monitors entries in /proc/net/{tcp,udp}.
When using the host network driver (--net=host) in Docker or containerd,
some port bindings are not exposed through the API. However, these bindings
are still visible in /proc/net because the container shares the host network
namespace.

The procnet scanner scans the corresponding files every 3 seconds and if
a new entry is found or removed it calls the host switch API to expose
and unexpose accordingly.

Signed-off-by: Nino Kodabande <[email protected]>
@Nino-K Nino-K force-pushed the procnet-scanning-guest-agent branch from b2aa16f to 348ef33 Compare November 12, 2024 19:21
@Nino-K Nino-K force-pushed the procnet-scanning-guest-agent branch from bc3af5b to a615fb7 Compare November 13, 2024 22:51
@Nino-K Nino-K marked this pull request as draft November 14, 2024 17:50
@Nino-K Nino-K force-pushed the procnet-scanning-guest-agent branch from a615fb7 to 473f1e2 Compare November 18, 2024 18:06
@Nino-K Nino-K marked this pull request as ready for review November 18, 2024 18:07
bats/tests/containers/host-network-ports.bats Fixed Show fixed Hide fixed
bats/tests/containers/host-network-ports.bats Fixed Show fixed Hide fixed
bats/tests/containers/host-network-ports.bats Fixed Show fixed Hide fixed
bats/tests/containers/host-network-ports.bats Fixed Show fixed Hide fixed
Signed-off-by: Nino Kodabande <[email protected]>
Added scanner_stub to accomodate for non-linux build

Signed-off-by: Nino Kodabande <[email protected]>
Bats test asserts on both scenarios:

- Binding a process port to 0.0.0.0
- Binding a process port to 127.0.0.1

Signed-off-by: Nino Kodabande <[email protected]>
@Nino-K Nino-K force-pushed the procnet-scanning-guest-agent branch from 473f1e2 to 665adb2 Compare November 18, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker network setting "--net=host" does not work with 1.15.x using windows and wsl
2 participants