UDP proxy

Attention

UDP proxy support should be considered alpha and not production ready.

  • v2 API reference

  • This filter should be configured with the name envoy.filters.udp_listener.udp_proxy

Overview

The UDP proxy listener filter allows Envoy to operate as a non-transparent proxy between a UDP client and server. The lack of transparency means that the upstream server will see the source IP and port of the Envoy instance versus the client. All datagrams flow from the client, to Envoy, to the upstream server, back to Envoy, and back to the client.

Because UDP is not a connection oriented protocol, Envoy must keep track of a client’s session such that the response datagrams from an upstream server can be routed back to the correct client. Each session is index by the 4-tuple consisting of source IP/port and local IP/port that the datagram is received on. Sessions last until the idle timeout is reached.

Load balancing and unhealthy host handling

Envoy will fully utilize the configured load balancer for the configured upstream cluster when load balancing UDP datagrams. When a new session is created, Envoy will associate the session with an upstream host selected using the configured load balancer. All future datagrams that belong to the session will be routed to the same upstream host.

When an upstream host becomes unhealthy (due to active health checking), Envoy will attempt to create a new session to a healthy host when the next datagram is received.

Circuit breaking

The number of sessions that can be created per upstream cluster is limited by the cluster’s maximum connection circuit breaker. By default this is 1024.

Example configuration

The following example configuration will cause Envoy to listen on UDP port 1234 and proxy to a UDP server listening on port 1235.

  1. admin:
  2. access_log_path: /tmp/admin_access.log
  3. address:
  4. socket_address:
  5. protocol: TCP
  6. address: 127.0.0.1
  7. port_value: 9901
  8. static_resources:
  9. listeners:
  10. - name: listener_0
  11. address:
  12. socket_address:
  13. protocol: UDP
  14. address: 127.0.0.1
  15. port_value: 1234
  16. listener_filters:
  17. name: envoy.filters.udp_listener.udp_proxy
  18. typed_config:
  19. '@type': type.googleapis.com/envoy.config.filter.udp.udp_proxy.v2alpha.UdpProxyConfig
  20. stat_prefix: service
  21. cluster: service_udp
  22. clusters:
  23. - name: service_udp
  24. connect_timeout: 0.25s
  25. type: STATIC
  26. lb_policy: ROUND_ROBIN
  27. load_assignment:
  28. cluster_name: service_udp
  29. endpoints:
  30. - lb_endpoints:
  31. - endpoint:
  32. address:
  33. socket_address:
  34. address: 127.0.0.1
  35. port_value: 1235

Statistics

The UDP proxy filter emits both its own downstream statistics as well as many of the cluster upstream statistics where applicable. The downstream statistics are rooted at udp.. with the following statistics:

Name

Type

Description

downstream_sess_no_route

Counter

Number of datagrams not routed due to no cluster

downstream_sess_rx_bytes

Counter

Number of bytes received

downstream_sess_rx_datagrams

Counter

Number of datagrams received

downstream_sess_rx_errors

Counter

Number of datagram receive errors

downstream_sess_total

Counter

Number sessions created in total

downstream_sess_tx_bytes

Counter

Number of bytes transmitted

downstream_sess_tx_datagrams

Counter

Number of datagrams transmitted

downstream_sess_tx_errors

counter

Number of datagram transmission errors

idle_timeout

Counter

Number of sessions destroyed due to idle timeout

downstream_sess_active

Gauge

Number of sessions currently active

The following standard upstream cluster stats are used by the UDP proxy:

Name

Type

Description

upstream_cx_none_healthy

Counter

Number of datagrams dropped due to no healthy hosts

upstream_cx_overflow

Counter

Number of datagrams dropped due to hitting the session circuit breaker

upstream_cx_rx_bytes_total

Counter

Number of bytes received

upstream_cx_tx_bytes_total

Counter

Number of bytes transmitted

The UDP proxy filter also emits custom upstream cluster stats prefixed with cluster..udp.:

Name

Type

Description

sess_rx_datagrams

Counter

Number of datagrams received

sess_rx_errors

Counter

Number of datagram receive errors

sess_tx_datagrams

Counter

Number of datagrams transmitted

sess_tx_errors

Counter

Number of datagrams tramsitted