svn commit: r360068 - in head/sys: kern net sys

Eric van Gyzen eric at vangyzen.net
Tue Apr 21 01:15:16 UTC 2020


>>>> +	sz = asprintf(&buf, M_TEMP, "%s-%s-%s", uuid, if_name(ifp),
>>>> +	    jailname);
>>>> +	if (sz < 0) {
>>>> +		/* Fall back to a random mac address. */
>>>
>>>
>>> I was wondering if it would be valuable to give this fall back something
>>> like:
>>>
>>>             printf("%s: unable to create fixed mac address; using random
>>> mac address", if_name(ifp));
>>>
>>> This will only be printed in rare circumstances. But in that case will
>>> provide valuable information.
>>>
>> That would potentially be valuable, yes. On the other hand, we traditionally
>> don???t sprinkle a lot of printf()s around in the kernel. This is extremely
>> unlikely to happen, and if it does odds are attaching the interface will
>> fail at an earlier or later point, you may struggle to pass packets and run
>> into any number of other issues.
>> It???s also possible to diagnose absent the printf(), because the MAC
>> address will be locally administered rather than within the FreeBSD OUI.
>>
>> So, in short: not a bad idea. You can argue it both ways, and I find myself
>> (weakly) on the opposite side.
> 
> Would displaying the message only when verbose boot mode is enabled be
> a suitable compromise?

We could completely avoid the problems of dynamic allocation by calling 
SHA1Update three times, feeding each piece of data separately.

For bonus points, use a single char[] to save stack space, too.  Maybe 
use a union, for legibility, and to ensure the proper size without ugly 
assertions.

Eric


More information about the svn-src-all mailing list