On Tue, Nov 22, 2022 at 03:37:20PM +0000, Klemens Nanni wrote: > On Tue, Nov 22, 2022 at 08:09:11AM -0700, Theo de Raadt wrote: > > Florian Obser <flor...@openbsd.org> wrote: > > > ifconfig(8) already knows about these (see -C option). Which made me > > > think, it might be easier to just ask ifconfig(8). > > > > > > $ ifconfig -Q 00:80:41:7b:f3:c3 > > > vio0 > > > > > > Would that be helpful? > > > > I'm unsure about the rest of your proposal, where MAC works in place if > > the IF argument. Let's say we do this in ifcconfig. Do we do it in route? > > Or ten other commands? I think that is the wrong way to go. > > > > But this first idea is valid. We've now seen 3 monster functions trying to > > do this task of convering MAC to IF in shell. Here's code to do it in > > ifconfig. > > > > I've done it as -M > > Better than [Q]uery. > > > > > It fails if the same MAC is on multiple interfaces. Go back to using > > hostname.if# files, you heathen. > > This reads like a viable approach, much cleaner than the netstart > globbing attempts. > > Using ifconfig -M, I can give the shell bits a try later this week.
I agree that offloading mapping of the unique identifier to ifconfig makes the shell bits easier. We currently need to be able to go both directions, mostly to check existence of /etc/hostname.ure0 and /etc/hostname.$lladdr when when trying to netstart ure0 so we can complain that there are two configurations for the same interface. We can, of course, use the existing ifconfig parsing to look up the "lladdr ...". Maybe this is a case of letting folks shoot themselves in the foot. I do think that referring to it as -M for MAC lookup makes me expect it to return all interface names with that mac, not error if there is more than one. Unlike it it referred to a "unique identifier" that might be a mac or maybe IMEI. I could be wrong, but it might make swapping umb devices from different providers easer.