Re: [PATCH 4/8] bonding: Detect virtual bonding devices and create an ethernet device



On Fri, 2011-11-04 at 17:14 -0500, Dan Williams wrote:
> On Tue, 2011-10-18 at 13:48 +0200, Thomas Graf wrote:
> > A bonding device is like a virtual ethernet device. We therefore reuse
> > nm-device-ethernet and add some special handling to detect bonding
> > connections.
> 
> Does rtnl_link_get_type() really return a "char *"?  Any reason that's
> 'const char *'?  I'd expect callers not to be able to modify the
> returned string, and the code you've got here dupes it before returning.
> Especially when constants are assigned to io_name in say
> bonding.c/vlan.c/dummy.c too...

> Just something to think about for libnl4 I guess, since the libnl3 API
> probably can't be changed now.  I've caught quite a few errors and
> memory leaks over the years by making sure accessors return 'const'
> stuff.

Good point. The return value should really be const char * but as you
note yourself that's something that can't be changed before libnl4.

However, the reason I dup in nm_system_get_link_type() is because due to
the returning of the link reference there is a theoretical chance that
the module which is behind the link type will be unloaded. libnl
currently does not do so but that might happen in the future.

It might be better to compare the return type against a list of known
link types by NM and return a pointer to a type string owned by NM
memory. Thoughts?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]