Hi Dave On Tue, Jun 01, 2021 at 08:23:45PM -0400, Dave Voutila wrote: > > Martin Vahlensieck writes: > > > 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? > > Part of me thinks just specifying: > > locked lladdr > > should give you a random address but enable the source mac > filtering. Having to specify "random" seems odd to me. Thoughts? Your variant matches what should be possible according to the man page. It is also how I tried it and discovered it didn't work. I don't have a preference between the two, a diff to make the syntax in the man page work is attached. Syntax is OK for the following config: vm "test" { memory 1G interface {lladdr f0:e4:08:ef:5f:0a} interface {lladdr} interface {locked lladdr} interface {locked lladdr f0:e4:08:ef:5f:0a} } > > I see what you're saying with how ifconfig(8) does it, but it's a bit > different in this context as there's the "locked" modifier, so it's not > exactly the same. > > I'm not sure about the man page changes regardless. Will need another > set of eyes on the syntax. Sure.
Thanks for the feedback! Best, Martin > > > > > 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 > Index: parse.y =================================================================== retrieving revision 1.56 diff -u -p -r1.56 parse.y --- parse.y 23 Sep 2020 19:18:18 -0000 1.56 +++ parse.y 2 Jun 2021 06:48:12 -0000 @@ -694,6 +694,9 @@ lladdr : STRING { memcpy($$, ea, ETHER_ADDR_LEN); } + | /* empty */ { + memset($$, 0, ETHER_ADDR_LEN); + } ; local : /* empty */ { $$ = 0; }