-
Notifications
You must be signed in to change notification settings - Fork 468
Description
This might be related with docker udp issues in Consul.
hashicorp/docker-consul#60
UDP Protocol seems using nf_conntrack table.
If a record in nf_conntrack is same source port(8301) and destination port(8301), host server assume that the connection is made.
container -> host -> other server
if a client sent a packet to other server like above, a conntrack record will be created and host server assume that udp stream is created.
And if other server sends a packet to the host, the packet will be sent to container because of host server's nf_conntrack even if there is no binding port.
In this case, we are not able to use bridge network in docker because sometimes if container ip changes, it will fail.
I wanna suggest a solution in this case.
In net_transport.go, memberlist reuses udp listener to send the payload.
Line 204 in 3f82dc1
| _, err = t.udpListeners[0].WriteTo(b, udpAddr) |
I think it can be better there is an option that can separate udp sender and listener.
Lines 49 to 60 in 3f82dc1
| type NetTransport struct { | |
| config *NetTransportConfig | |
| packetCh chan *Packet | |
| streamCh chan net.Conn | |
| logger *log.Logger | |
| wg sync.WaitGroup | |
| tcpListeners []*net.TCPListener | |
| udpListeners []*net.UDPConn | |
| shutdown int32 | |
| metricLabels []metrics.Label | |
| } |
In NetTransport struct, we can have
udpSenders []*net.UDPConn.In this case, sender might be created using random port like
udpSender, err := net.ListenUDP("udp", nil)
If this kind of implementaion is done, we can deploy consul client in docker environment. And all connection can be done because the payload always have source ip and port.