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

suggestion for supporting docker udp #305

Open
realzero0 opened this issue Jul 2, 2024 · 0 comments
Open

suggestion for supporting docker udp #305

realzero0 opened this issue Jul 2, 2024 · 0 comments

Comments

@realzero0
Copy link

realzero0 commented Jul 2, 2024

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.

_, err = t.udpListeners[0].WriteTo(b, udpAddr)

I think it can be better there is an option that can separate udp sender and listener.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant