Commit 9946cfc
cilium, socklb: Terminate also v4-in-v6 mapped sockets
[ upstream commit b99a60b ]
@m0untains reported that v4-in-v6 mapped sockets connecting to a v4 UDP
backend are not properly terminated:
- Bind a SOCK_DGRAM AF_INET socket in a server.
- Create a corresponding kubernetes Service for this server.
- In a client, create a SOCK_DGRAM AF_INET6 socket. Configure the address
to use a v4-mapped-on-v6 address type. E.g. if the kubernetes service
address is 10.2.3.4, configure the address the client will connect to
as ::ffff:10.2.3.4.
- Use the connect() + send() syscalls to create a long-lived udp socket,
and send packets at some interval (e.g. every 10 seconds) from the client
to the server. Note: using sendto(), i.e. a short-lived socket effectively
works around the issue, and does not produce the undesired behavior.
- Restart the server
- Notice how the packets from the client are still sent to the old server
IP address.
For the client v4-in-v6 case we store the revnat entry in cilium_lb4_reverse_sk
map. When the backend goes down, we iterate all clients and the current logic
derives where to iterate in netlink based on the backend's address family (in
this case v4). But given the client is a v6 socket, it will never be found from
the v4 iteration. So this means for all v4 backends, we also need to iterate
all v6 sockets in addition to try and find a match.
Closes: cilium#39470
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>1 parent cabd410 commit 9946cfc
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
90 | 104 | | |
91 | 105 | | |
92 | 106 | | |
| |||
0 commit comments