TUN-6699: Add metric for packet too big dropped

This commit is contained in:
João Oliveirinha 2022-08-25 11:05:01 +01:00 committed by Igor Postelnik
parent af6bf5c4e5
commit e131125558
3 changed files with 10 additions and 3 deletions

View File

@ -46,8 +46,7 @@ func (dm *DatagramMuxer) mtu() int {
func (dm *DatagramMuxer) SendToSession(session *packet.Session) error { func (dm *DatagramMuxer) SendToSession(session *packet.Session) error {
if len(session.Payload) > dm.mtu() { if len(session.Payload) > dm.mtu() {
// TODO: TUN-5302 return ICMP packet too big message packetTooBigDropped.Inc()
// drop packet for now, eventually reply with ICMP for PMTUD
return fmt.Errorf("origin UDP payload has %d bytes, which exceeds transport MTU %d", len(session.Payload), dm.mtu()) return fmt.Errorf("origin UDP payload has %d bytes, which exceeds transport MTU %d", len(session.Payload), dm.mtu())
} }
payloadWithMetadata, err := suffixSessionID(session.ID, session.Payload) payloadWithMetadata, err := suffixSessionID(session.ID, session.Payload)

View File

@ -58,7 +58,7 @@ func NewDatagramMuxerV2(
// demultiplex the payload from multiple datagram sessions // demultiplex the payload from multiple datagram sessions
func (dm *DatagramMuxerV2) SendToSession(session *packet.Session) error { func (dm *DatagramMuxerV2) SendToSession(session *packet.Session) error {
if len(session.Payload) > dm.mtu() { if len(session.Payload) > dm.mtu() {
// TODO: TUN-5302 return ICMP packet too big message packetTooBigDropped.Inc()
return fmt.Errorf("origin UDP payload has %d bytes, which exceeds transport MTU %d", len(session.Payload), dm.mtu()) return fmt.Errorf("origin UDP payload has %d bytes, which exceeds transport MTU %d", len(session.Payload), dm.mtu())
} }
msgWithID, err := suffixSessionID(session.ID, session.Payload) msgWithID, err := suffixSessionID(session.ID, session.Payload)

View File

@ -144,6 +144,13 @@ var (
} }
registerClient = sync.Once{} registerClient = sync.Once{}
registerServer = sync.Once{} registerServer = sync.Once{}
packetTooBigDropped = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: perspectiveString(logging.PerspectiveClient),
Name: "packet_too_big_dropped",
Help: "Count of packets received from origin that are too big to send to the edge and are dropped as a result",
})
) )
// MetricsCollector abstracts the difference between client and server metrics from connTracer // MetricsCollector abstracts the difference between client and server metrics from connTracer
@ -264,6 +271,7 @@ func newClientCollector(index uint8) MetricsCollector {
clientMetrics.minRTT, clientMetrics.minRTT,
clientMetrics.latestRTT, clientMetrics.latestRTT,
clientMetrics.smoothedRTT, clientMetrics.smoothedRTT,
packetTooBigDropped,
) )
}) })
return &clientCollector{ return &clientCollector{