moby / moby/moby

Function DeleteConntrackEntriesByPort contains an error

Open
#46,276 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/networking kind/bug status/more-info-needed version/24.0
Dominant language
Go
Stars
72.1k
Forks
19.2k
Avg merge
1d 17h
Merged PRs (30d)
164

Description

Description

https://github.com/moby/moby/blob/master/libnetwork/iptables/conntrack.go#L57
The DeleteConntrackEntriesByPort function deletes all entries in the conntrack table with the specified port without taking into account the IP address. Thus, if there are several IP addresses on the server, records of connections to other containers with the same port but different IP addresses are deleted.

Reproduce
  1. docker run -p 192.168.0.1:443:443/udp -d --name alpine1 container_with_UDP_service
  2. docker run -p 192.168.0.2:443:443/udp -d --name alpine2 container_with_UDP_service
  3. Connect to 192.168.0.1:443 and 192.168.0.2:443
  4. Check conntrack table entries
  5. Stop and start either container
  6. Check conntrack table entries again, will lose connection entries for both containers
Expected behavior

No response

docker version
Client: Docker Engine - Community
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:36:32 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.6
  Git commit:       a61e2b4
  Built:            Fri Jul 21 20:35:32 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker info
Client: Docker Engine - Community
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.20.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-scan

Server:
 Containers: 10
  Running: 5
  Paused: 0
  Stopped: 5
 Images: 6
 Server Version: 24.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 4.18.0-372.26.1.0.1.el8_6.x86_64
 Operating System: Oracle Linux Server 8.6
 OSType: linux
 Architecture: x86_64
 CPUs: 48
 Total Memory: 31.16GiB
 Name: ---
 ID: 4fceb588-d5c1-49bb-95f5-7958b39f7dcd
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
Additional Info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in libnetwork/iptables/conntrack.go at DeleteConntrackEntriesByPort, then reproduce the two-container UDP scenario using distinct host IPs and the commands in the issue. Trace how the function selects conntrack entries and verify that restarting one container does not remove entries for the other host IP; done means unrelated connection entries remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.