Subject: Re: [PATCH v3 iproute2 net-next] erspan: add erspan version II support

From: David Ahern <[email-masked]>
Date: Tue, 19 Dec 2017 18:28:24 -0700

Hi William:

On 12/19/17 6:08 PM, William Tu wrote:
> @@ -343,6 +355,26 @@ get_failed:
>  				invarg("invalid erspan index\n", *argv);
>  			if (erspan_idx & ~((1<<20) - 1) || erspan_idx == 0)
>  				invarg("erspan index must be > 0 and <= 20-bit\n", *argv);
> +		} else if (strcmp(*argv, "erspan_ver") == 0) {
> +			NEXT_ARG();
> +			if (get_u8(&erspan_ver, *argv, 0))
> +				invarg("invalid erspan version\n", *argv);
> +			if (erspan_ver != 1 && erspan_ver != 2)
> +				invarg("erspan version must be 1 or 2\n", *argv);
> +		} else if (strcmp(*argv, "erspan_dir") == 0) {
> +			NEXT_ARG();
> +			if (strcmp(*argv, "ingress") == 0 ||
> +			    strcmp(*argv, "in") == 0)
> +				erspan_dir = 0;
> +			else if (strcmp(*argv, "egress") == 0 ||
> +				 strcmp(*argv, "e") == 0)

iproute2 has a matches() function that should be used -- it basically
allows whatever shorthand notation matches -- in this case e, eg, egr,
egres, egress all match. Checkout ip/iplink.c and search for matches.