MCPcopy Create free account
hub / github.com/F-Stack/f-stack / csum_flags_to_inner_flags

Function csum_flags_to_inner_flags

freebsd/net/if_vxlan.c:2425–2462  ·  view source on GitHub ↗

* Return the CSUM_INNER_* equivalent of CSUM_* caps. */

Source from the content-addressed store, hash-verified

2423 * Return the CSUM_INNER_* equivalent of CSUM_* caps.
2424 */
2425static uint32_t
2426csum_flags_to_inner_flags(uint32_t csum_flags_in, const uint32_t encap)
2427{
2428 uint32_t csum_flags = encap;
2429 const uint32_t v4 = CSUM_IP | CSUM_IP_UDP | CSUM_IP_TCP;
2430
2431 /*
2432 * csum_flags can request either v4 or v6 offload but not both.
2433 * tcp_output always sets CSUM_TSO (both CSUM_IP_TSO and CSUM_IP6_TSO)
2434 * so those bits are no good to detect the IP version. Other bits are
2435 * always set with CSUM_TSO and we use those to figure out the IP
2436 * version.
2437 */
2438 if (csum_flags_in & v4) {
2439 if (csum_flags_in & CSUM_IP)
2440 csum_flags |= CSUM_INNER_IP;
2441 if (csum_flags_in & CSUM_IP_UDP)
2442 csum_flags |= CSUM_INNER_IP_UDP;
2443 if (csum_flags_in & CSUM_IP_TCP)
2444 csum_flags |= CSUM_INNER_IP_TCP;
2445 if (csum_flags_in & CSUM_IP_TSO)
2446 csum_flags |= CSUM_INNER_IP_TSO;
2447 } else {
2448#ifdef INVARIANTS
2449 const uint32_t v6 = CSUM_IP6_UDP | CSUM_IP6_TCP;
2450
2451 MPASS((csum_flags_in & v6) != 0);
2452#endif
2453 if (csum_flags_in & CSUM_IP6_UDP)
2454 csum_flags |= CSUM_INNER_IP6_UDP;
2455 if (csum_flags_in & CSUM_IP6_TCP)
2456 csum_flags |= CSUM_INNER_IP6_TCP;
2457 if (csum_flags_in & CSUM_IP6_TSO)
2458 csum_flags |= CSUM_INNER_IP6_TSO;
2459 }
2460
2461 return (csum_flags);
2462}
2463
2464static int
2465vxlan_encap4(struct vxlan_softc *sc, const union vxlan_sockaddr *fvxlsa,

Callers 2

vxlan_encap4Function · 0.85
vxlan_encap6Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected