[RFC] ip_frag: support IPv6 reassembly with extensions

Stephen Hemminger stephen at networkplumber.org
Wed Feb 14 04:51:13 CET 2024


On Tue, 13 Feb 2024 12:47:27 +0100
<vignesh.purushotham.srinivas at ericsson.com> wrote:

> +/*
> + * Function to crawl through the extension header stack.
> + * This function breaks as soon a the fragment header is
> + * found and returns the total length the traversed exts
> + * and the last extension before the fragment header
> + */
> +static inline uint32_t
> +ip_frag_get_last_exthdr(struct rte_ipv6_hdr *ip_hdr, uint8_t **last_ext)
> +{
> +	uint32_t total_len = 0;
> +	size_t ext_len = 0;
> +	*last_ext = (uint8_t *)(ip_hdr + 1);
> +	int next_proto = ip_hdr->proto;
> +
> +	while (next_proto != IPPROTO_FRAGMENT &&
> +		(next_proto = rte_ipv6_get_next_ext(
> +		*last_ext, next_proto, &ext_len)) >= 0) {
> +
> +		total_len += ext_len;
> +
> +		if (next_proto == IPPROTO_FRAGMENT)
> +			return total_len;
> +
> +		*last_ext += ext_len;
> +	}
> +
> +	return total_len;
> +}

Doing endless loop like this opens up DoS attacks.
Better to use rte_next_skip_ip6_ext() or do similar limited loop.


More information about the dev mailing list