Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jan 2022 09:34:20 -0800
From:      John Baldwin <jhb@FreeBSD.org>
To:        "Alexander V. Chernikov" <melifaro@FreeBSD.org>, src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: 779fd0534466 - main - ifconfig: improve vlan options parsing
Message-ID:  <fd5ac517-934c-d38a-a536-0ff10733db44@FreeBSD.org>
In-Reply-To: <202201170935.20H9ZOpr069571@gitrepo.freebsd.org>
References:  <202201170935.20H9ZOpr069571@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 1/17/22 1:35 AM, Alexander V. Chernikov wrote:
> The branch main has been updated by melifaro:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=779fd05344662aeec79c29470258bf657318eab3
> 
> commit 779fd05344662aeec79c29470258bf657318eab3
> Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
> AuthorDate: 2022-01-17 09:30:26 +0000
> Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
> CommitDate: 2022-01-17 09:35:15 +0000
> 
>      ifconfig: improve vlan options parsing
>      
>      PR:     261136
>      Reported by:    Daniel O'Connor
>      MFC after:      2 weeks
> ---
>   sbin/ifconfig/ifvlan.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
> index 60f97338ee27..1e74b504fc26 100644
> --- a/sbin/ifconfig/ifvlan.c
> +++ b/sbin/ifconfig/ifvlan.c
> @@ -144,8 +139,20 @@ vlan_parse_ethervid(const char *name)
>   	if ((*cp != '\0') || (vid & ~0xFFF))
>   		errx(1, "invalid vlan tag");
>   
> -	strlcpy(params.vlr_parent, ifname, IFNAMSIZ);
> -	params.vlr_tag = (vid & 0xFFF);
> +	/*
> +	 * allow "devX.Y vlandev devX vlan Y" syntax
> +	 */
> +	if (params.vlr_tag == NOTAG || params.vlr_tag == vid)
> +		params.vlr_tag = vid;
> +	else
> +		errx(1, "ambiguous vlan specification");
> +
> +	/* Restrict overriding interface name */
> +	if (params.vlr_parent[0] == '\0' || !strcmp(params.vlr_parent, ifname))
> +		strlcpy(params.vlr_parent, ifname, IFNAMSIZ);
> +	else
> +		errx(1, "ambiguous vlan specification");
> +	printf("CR: %s %d\n", params.vlr_parent, params.vlr_tag);

Did you mean to leave this printf in?  I see it when adding a vlan interface now:

root@frodo:~ # ifconfig cxl0.200 create
CR: cxl0 200

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?fd5ac517-934c-d38a-a536-0ff10733db44>