On (10/17/07 21:29), Peter Memishian wrote:
>
> While I'm not too concerned about IPIF_CAN_WAIT() in particular, I *am*
> concerned about the amount of duplication present in code that makes use
> of it and its brethren. For instance, almost all of
> ill_lookup_on_ifindex() has been duplicated into ipif_lookup_on_ifindex(),
> rather than refactoring ipif_lookup_on_ifindex() to call
> ill_lookup_on_ifindex().
The issues with the ipif code are not so clear, though- unless we can resolve
the "is it really dead?" issue about the test in ipif_lookup_interface*
functions.
As far as reducing the double loop in ipif_lookup_addr() is concerned,
Erik suggested:
switch (ipif->ipif_flags & (IPIF_POINTOPOINT|IPIF_UNNUMBERED)) {
case IPIF_POINTOPOINT:
/* Match both local and remote */
if (ipif->ipif_pp_dst_addr == addr)
return (ipif);
/* FALLTHRU */
case 0:
if (ipif->ipif_lcl_addr == addr)
return (ipif);
break;
case (IPIF_POINTOPOINT|IPIF_UNNUMBERED):
/* Match just the remote address */
if (ipif->ipif_pp_dst_addr == addr)
return (ipif);
break;
default:
ASSERT(0);
}
In the existing ipif_lookup_addr(), if we have a IPIF_POINTOPOINT
interface without IPIF_UNNUMBERED, we would first try to match on the
local address, and if that failed, we would try to match on the dst
address. This would be the opposite of what the above switch is doing,
though I don't know which order of checking is the Right way.
If we want to keep the existing order, this would be
switch (ipif->ipif_flags & (IPIF_POINTOPOINT|IPIF_UNNUMBERED)) {
case IPIF_POINTOPOINT:
case 0:
if (ipif->ipif_lcl_addr == addr)
return (ipif);
/* Match both local and remote for pointopoint */
if ((ipif->ipif_flags & IPIF_POINTOPOINT) &&
ipif->ipif_pp_dst_addr == addr)
return (ipif);
break;
case (IPIF_POINTOPOINT|IPIF_UNNUMBERED):
/* Match just the remote address */
if (ipif->ipif_pp_dst_addr == addr)
return (ipif);
break;
default:
ASSERT(0);
}
_______________________________________________
networking-discuss mailing list
[email protected]