Both IPv4 and IPv6 fragmentation may derive the next fragment ID from
the running_fragment_id global variable which is shared across all VPP
worker threads, and the fragmentation code can be called from any of
the main thread or worker threads. Therefore, a data race exists
whereby fragments could be generated to the same destination with the
same fragment IDs and cause reassembly to fail.
Fix this by atomically fetching and incrementing
running_fragment_id. Whilst there, fix truncation of the IPv6 fragment
ID from 32-bits to 16-bits by changing the type of ip_frag_id to match
that of the IPv6 fragment header. Also convert the fragment ID from
host-endian to network-endian in both the IPv4 and IPv6 cases for
consistency.
In addition, allow TestIPv4Frag to work with multiple VPP workers
(demonstrating that the IPv4 fragmentation code can run on worker
threads) by changing VppNeighbor.get_stats to sum over all cores, and
not just return the stats for core 0.
Type: fix
Fixes: cb9cada
Change-Id: Icaa7192c5a77c2d40cd12a2220c7bc97460f11ab
Signed-off-by: Rob Shearman <robertshearman@gmail.com>
(cherry picked from commit ee04326)