Ping.
On Sat, May 22, 2021 at 09:58:46AM +0200, Martin Vahlensieck wrote:
> Hi
>
> The grammar for lladdr of interfaces is according to the manpage:
>
> [locked] lladdr [etheraddr]
>
> This implies that `locked lladdr' is OK but looking at parse.y this
> does not seem to be the case. Making it optional would lead to a
> `lladdr' all by itself being valid, which I find weird. So I copied
> the way ifconfig does it and now the syntax is:
>
> [locked] lladdr etheraddr|random
>
> so to have a random locked lladdr one would have to write
>
> locked lladdr random
>
> Is this a good approach?
>
> Best,
>
> Martin
>
> Index: parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmd/parse.y,v
> retrieving revision 1.56
> diff -u -p -r1.56 parse.y
> --- parse.y 23 Sep 2020 19:18:18 -0000 1.56
> +++ parse.y 22 May 2021 07:55:18 -0000
> @@ -685,14 +685,16 @@ string : STRING string {
> lladdr : STRING {
> struct ether_addr *ea;
>
> - if ((ea = ether_aton($1)) == NULL) {
> + if (strcmp($1, "random") == 0) {
> + memset($$, 0, ETHER_ADDR_LEN);
> + } else if ((ea = ether_aton($1)) != NULL) {
> + memcpy($$, ea, ETHER_ADDR_LEN);
> + } else {
> yyerror("invalid address: %s\n", $1);
> free($1);
> YYERROR;
> }
> free($1);
> -
> - memcpy($$, ea, ETHER_ADDR_LEN);
> }
> ;
>
> Index: vm.conf.5
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmd/vm.conf.5,v
> retrieving revision 1.56
> diff -u -p -r1.56 vm.conf.5
> --- vm.conf.5 1 Mar 2021 14:27:44 -0000 1.56
> +++ vm.conf.5 22 May 2021 07:55:18 -0000
> @@ -237,10 +237,12 @@ The
> must not be longer than 15 characters or end with a digit,
> as described in
> .Xr ifconfig 8 .
> -.It Oo Cm locked Oc Cm lladdr Op Ar etheraddr
> +.It Oo Cm locked Oc Cm lladdr Ar etheraddr Ns | Ns Cm random
> Change the link layer address (MAC address) of the interface on the
> VM guest side.
> -If not specified, a randomized address will be assigned by
> +If
> +.Cm random
> +is specified, a randomized address will be assigned by
> .Xr vmd 8 .
> If the
> .Cm locked
>