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

Passing an empty Netns causes leak iptable rules #1872

Open
qkboy opened this issue Jan 18, 2023 · 1 comment
Open

Passing an empty Netns causes leak iptable rules #1872

qkboy opened this issue Jan 18, 2023 · 1 comment
Labels
area/network bug Something isn't working

Comments

@qkboy
Copy link

qkboy commented Jan 18, 2023

Description

Run or start a container will leak three iptables rules when using cni bridge plugin and set "ipMasq": true .

Steps to reproduce the issue

1.nerdctl run container
2.nerdctl stop container
3.nerdctl start container
This action will leak six iptables rules in the host.

Describe the results you received and expected

It'll create three iptable rules when run task.Start. But it didn't remove when run task.Delete.

The reason is that cni.Remove() just pass an empty Netns path to the bridge plugin.

if err := opts.cni.Remove(ctx, opts.fullID, "", namespaceOpts...); err != nil {
	logrus.WithError(err).Errorf("failed to call cni.Remove")
	return err
}

Bridge plugin just reclaim ipam pool and skip teardown ip masq when Netns is empty.

if args.Netns == "" {
	return ipamDel()
}

Why not pass the correct sandbox path into cni.Remove() ?

What version of nerdctl are you using?

latest

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

Client:
 Namespace:	default
 Debug Mode:	false

Server:
 Server Version: v1.6.6
 Storage Driver: overlayfs
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Log: fluentd journald json-file
  Storage: aufs native overlayfs
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.13.0-40-generic
 Operating System: Ubuntu 20.04.1 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.59GiB
 Name: env2-node02
 ID: eb7dbbb8-64a4-40c7-9a64-07e0b1de9d04
@qkboy qkboy added the kind/unconfirmed-bug-claim Unconfirmed bug claim label Jan 18, 2023
@qkboy
Copy link
Author

qkboy commented Jan 18, 2023

In fact, nerdctl only execute cni.Remove() when run rm/start container instead of stopping container.

At that time, it has run task.Kill, the container progress has exited. So bridge plugin can't obtain the ip address from Netns even we pass the correct sandbox path to it. It'll fail to get ipns then skip to teardown ip masq.

I think this problem may not be easy to solve in nerdctl. However it can be handled in the bridge plugin.

refer: containernetworking/plugins#810

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/network bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants