Page MenuHomeFreeBSD

if_vxlan(4): Correct the statistic for output bytes
ClosedPublic

Authored by zlei on Oct 2 2022, 9:24 AM.
Referenced Files
Unknown Object (File)
Mon, Nov 11, 4:37 AM
Unknown Object (File)
Thu, Nov 7, 8:23 AM
Unknown Object (File)
Wed, Nov 6, 11:26 PM
Unknown Object (File)
Sat, Oct 26, 12:30 AM
Unknown Object (File)
Thu, Oct 17, 6:48 AM
Unknown Object (File)
Wed, Oct 16, 2:57 AM
Unknown Object (File)
Mon, Oct 14, 10:09 PM
Unknown Object (File)
Mon, Oct 14, 3:53 PM

Details

Summary

The vxlan interface encapsulates the Ethernet frame by prepending IP/UDP and vxlan headers. For statistics, only the payload, i.e. the encapsulated (inner) frame should be counted.

Test Plan

Setup two vxlan boxes (should test both tunnel over IPv4 and IPv6), verify the cumulative statistics for output while ping

One session ping:

root@:~ # ping -s 100 -c 4 10.10.20.0 
PING 10.10.20.0 (10.10.20.0): 100 data bytes
108 bytes from 10.10.20.0: icmp_seq=0 ttl=64 time=0.922 ms
108 bytes from 10.10.20.0: icmp_seq=1 ttl=64 time=1.368 ms
108 bytes from 10.10.20.0: icmp_seq=2 ttl=64 time=1.299 ms
108 bytes from 10.10.20.0: icmp_seq=3 ttl=64 time=1.499 ms

--- 10.10.20.0 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.922/1.272/1.499/0.214 ms

while another netstat:

root@:~ # netstat -w1 -I vxlan0
            input         vxlan0           output
   packets  errs idrops      bytes    packets  errs      bytes colls
         0     0     0          0          0     0          0     0
         0     0     0          0          0     0          0     0
         0     0     0        142          1     0        142     0
         0     0     0        142          1     0        142     0
         0     0     0        142          1     0        142     0
         0     0     0        142          1     0        142     0
         0     0     0          0          0     0          0     0

The output bytes per ICMP request packet should be ethernet(14) + IP(20) + ICMP(8) + payload(100) = 142

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

zlei requested review of this revision.Oct 2 2022, 9:24 AM
zlei edited the test plan for this revision. (Show Details)
bryanv added inline comments.
sys/net/if_vxlan.c
2527–2528

Looks like len only has one remaining use a few lines down, so I'd remove the variable to avoid any confusion.

2638–2639

Looks like len becomes write-only and can be removed

sys/net/if_vxlan.c
2527–2528

Good catch !

2638–2639
ip6->ip6_plen = 0;

The payload length is set to zero unconditionally. I'll invest further more.

zlei edited the test plan for this revision. (Show Details)

The IPv4/IPv6 over IPv6 vxlan looks good after test.

  1. Rebase
  2. Update as @bryanv suggested.
zlei marked 2 inline comments as done.Oct 6 2022, 4:38 PM
zlei added inline comments.
sys/net/if_vxlan.c
2638–2639
ip6->ip6_plen = 0;

The payload length is set to zero unconditionally. I'll invest further more.

ip6_output() will set payload length (ip6_plen) correctly.

558         plen = m->m_pkthdr.len - sizeof(*ip6);
 559 
 560         /* If this is a jumbo payload, insert a jumbo payload option. */
 561         if (plen > IPV6_MAXPACKET) {
 562                 if (!hdrsplit) {
 563                         if ((error = ip6_splithdr(m, &exthdrs)) != 0) {
 564                                 m = NULL;
 565                                 goto freehdrs;
 566                         }
 567                         m = exthdrs.ip6e_ip6;
 568                         ip6 = mtod(m, struct ip6_hdr *);
 569                         hdrsplit = true;
 570                 }
 571                 if ((error = ip6_insert_jumboopt(&exthdrs, plen)) != 0)
 572                         goto freehdrs;
 573                 ip6->ip6_plen = 0;
 574         } else
 575                 ip6->ip6_plen = htons(plen);
This revision was not accepted when it landed; it landed in state Needs Review.Oct 7 2022, 11:46 AM
This revision was automatically updated to reflect the committed changes.