Subject: Re: [PATCH net-next-2.6] ipv4: more compliant RFC 3168 support

From: Stefanos Harhalakis <[email-masked]>
Date: Sun, 15 May 2011 18:08:38 +0300

Hello,

On Sunday 15 of May 2011, Eric Dumazet wrote:
> +static inline int ip4_frag_ecn_fold(u8 ecn)
> +{
> +	switch (ecn) {
> +	/* If same ECN combination was observed on all fragments, do nothing */
> +	case IPFRAG_ECN_NOT_ECT:
> +	case IPFRAG_ECN_ECT_1:
> +	case IPFRAG_ECN_ECT_0:
> +	case IPFRAG_ECN_CE:
> +	/* if a ECT_1 ECT_0 combination was observed, do nothing as well */
> +	case IPFRAG_ECN_ECT_0 | IPFRAG_ECN_ECT_1:
> +		return 0;
> +	/* at least one fragment had CE, and others ECT_0 or ECT_1 */
> +	case IPFRAG_ECN_CE | IPFRAG_ECN_ECT_0:
> +	case IPFRAG_ECN_CE | IPFRAG_ECN_ECT_1:
> +	case IPFRAG_ECN_CE | IPFRAG_ECN_ECT_0 | IPFRAG_ECN_ECT_1:
> +		return INET_ECN_CE;
> +	/* other combinations are invalid : drop frame */
> +	default:
> +		return -1;
> +	}
>  }

You may wish to simplify this exhaustive check to:

if (unlikely((ecn & IPFRAG_ECN_NOT_ECT) && ecn!=IPFRAG_ECN_NOT_ECT))
  return -1;
else if (ecn & IPFRAG_ECN_CE)
  return INET_ECN_CE;
else
  return 0;

although I'm not sure which method will be faster.

Also, returning the exact same value for NOT_ECT and ECT_X and then ORing
this with the TOS seems like it will make it loose the ECT_X info. No? (but
also, I'm not sure if this is needed anyway from that point on).

p.s. I'm not sure whether this message will make it to the netdev list.