moby/libnetwork/drivers
Albin Kerouanton b37d34307d
Clear conntrack entries for published UDP ports
Conntrack entries are created for UDP flows even if there's nowhere to
route these packets (ie. no listening socket and no NAT rules to
apply). Moreover, iptables NAT rules are evaluated by netfilter only
when creating a new conntrack entry.

When Docker adds NAT rules, netfilter will ignore them for any packet
matching a pre-existing conntrack entry. In such case, when
dockerd runs with userland proxy enabled, packets got routed to it and
the main symptom will be bad source IP address (as shown by #44688).

If the publishing container is run through Docker Swarm or in
"standalone" Docker but with no userland proxy, affected packets will
be dropped (eg. routed to nowhere).

As such, Docker needs to flush all conntrack entries for published UDP
ports to make sure NAT rules are correctly applied to all packets.

- Fixes #44688
- Fixes #8795
- Fixes #16720
- Fixes #7540
- Fixes moby/libnetwork#2423
- and probably more.

As a precautionary measure, those conntrack entries are also flushed
when revoking external connectivity to avoid those entries to be reused
when a new sandbox is created (although the kernel should already
prevent such case).

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-01-05 12:53:22 +01:00
..
bridge Clear conntrack entries for published UDP ports 2023-01-05 12:53:22 +01:00
host libnetwork: remove unused "testutils" imports 2021-08-18 14:20:37 +02:00
ipvlan libnetwork: drop InitOSContext() 2022-10-25 13:35:44 -04:00
macvlan libnetwork: drop InitOSContext() 2022-10-25 13:35:44 -04:00
null libnetwork: remove unused "testutils" imports 2021-08-18 14:20:37 +02:00
overlay libnetwork/drivers/overlay: getBridgeNamePrefix() simplify reading of resolv.conf 2022-11-29 20:10:42 +01:00
remote refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
windows libnetwork: use strconv instead of fmt.Sprintf() 2022-10-08 17:41:39 +02:00