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, Dec 9, 1:43 PM
Unknown Object (File)
Thu, Dec 5, 10:30 AM
Unknown Object (File)
Mon, Nov 25, 3:15 PM
Unknown Object (File)
Sat, Nov 23, 6:31 AM
Unknown Object (File)
Fri, Nov 22, 8:05 AM
Unknown Object (File)
Thu, Nov 21, 4:39 PM
Unknown Object (File)
Wed, Nov 20, 2:11 AM
Unknown Object (File)
Tue, Nov 19, 1:33 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
2528

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

2641

Looks like len becomes write-only and can be removed

sys/net/if_vxlan.c
2528

Good catch !

2641
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
2641
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.