Skip to content

suggestion for supporting docker udp #305

Open
@realzero0

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.

_, 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions