udp: fix byte counts to not include headers 23/42923/3
authorFlorin Coras <[email protected]>
Sat, 3 May 2025 23:36:55 +0000 (19:36 -0400)
committerDave Barach <[email protected]>
Mon, 5 May 2025 18:30:14 +0000 (18:30 +0000)
Type: fix

Change-Id: Ia3a8bbafedf2ee99a1a78c8fcc08e2b9420f938a
Signed-off-by: Florin Coras <[email protected]>
src/vnet/udp/udp.c
src/vnet/udp/udp_input.c

index 5cee206..0848936 100644 (file)
@@ -266,6 +266,9 @@ udp_push_one_header (vlib_main_t *vm, udp_connection_t *uc, vlib_buffer_t *b,
   /* reuse tcp medatada for now */
   vnet_buffer (b)->tcp.connection_index = uc->c_c_index;
 
+  uc->bytes_out += vlib_buffer_length_in_chain (vm, b);
+  uc->dgrams_out += 1;
+
   if (!is_cless)
     {
       uh = vlib_buffer_push_udp (b, uc->c_lcl_port, uc->c_rmt_port);
@@ -303,8 +306,6 @@ udp_push_one_header (vlib_main_t *vm, udp_connection_t *uc, vlib_buffer_t *b,
       vnet_buffer (b)->tcp.flags |= UDP_CONN_F_LISTEN;
     }
 
-  uc->bytes_out += vlib_buffer_length_in_chain (vm, b);
-  uc->dgrams_out += 1;
   uh->checksum =
     udp_compute_checksum (vm, b, udp_csum_offload (uc), uc->c_is_ip4);
 
index e4aaa0c..ea53db5 100644 (file)
@@ -153,7 +153,7 @@ udp_connection_enqueue (udp_connection_t *uc0, session_t *s0,
        }
       else
        {
-         uc0->bytes_in += wrote0;
+         uc0->bytes_in += wrote0 - sizeof (session_dgram_hdr_t);
          uc0->dgrams_in += 1;
        }
 
@@ -191,7 +191,7 @@ udp_connection_enqueue (udp_connection_t *uc0, session_t *s0,
     }
   else
     {
-      uc0->bytes_in += wrote0;
+      uc0->bytes_in += wrote0 - sizeof (session_dgram_hdr_t);
       uc0->dgrams_in += 1;
     }
 }