On 06/11/2009 06:28 PM, David Lutterkort wrote:
> On Wed, 2009-06-10 at 11:30 +0200, Jonas Eriksson wrote:
>> Looking through the driver API, I came across the
>> drv_lookup_by_mac_string. This function is prototyped in
>> internal.h, so I assume that it is a part of the public driver
>> API.
> 
> The drv_ is not, but there is a public function ncf_lookup_by_mac_string
> in netcf.h.
> 
>> However, a problem may arise when multiple top-level interfaces
>> share mac addresses, as drv_lookup_by_mac_string only may return
>> one struct netcf_if *. This can occurr when using vlan
>> interfaces, e.g. eth0.2 and eth0.3, or if vlan ifs are not to be
>> considered top-level interfaces, the bridges or bonds that these
>> interfaces are a part of. I therefore recommend a switch to a
>> drv_list_interfaces-prototype for drv_lookup_by_mac_string.
> 
> Yes, you are right .. it's a mess. So far I only had situations like a
> bridge and an enslaved physical NIC sharing a MAC address, and I made
> sure that the bridge, not the enslaved NIC is returned when you ask for
> an interface by NIC.
> 
>> For reference:
>> int drv_list_interfaces(struct netcf *ncf, int maxnames, char **names);
> 
> You are right - we need a slightly more complicated interface to cover
> those cases, something like
> 
>         int ncf_lookup_by_mac_string(struct netcf *, const char *mac, int 
> maxifs, struct netcf_if **interfaces);
>         
> where the return value gives the total number of toplevel interfaces
> that match the given MAC, the (randomly) first MAXIFS many are returned
> in INTERFACES. Does that sound better ?


In the libvirt code that I'd already written using the old version of 
this function, I was using the MAC address as a cookie that could get me 
back the original netcf_if at any point in the future (assuming the 
interface hadn't been deleted from the config). If multiple interfaces 
can have the same MAC address, that's not going to fly.

Will the interface's name always be unique? If so, I'll switch to using 
that, and that will solve all problems but one (the libvirt public API 
that retrieves interface by MAC address).
_______________________________________________
netcf-devel mailing list
netcf-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/netcf-devel

Reply via email to