[EMAIL PROTECTED] wrote:
> 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);
> }
If there are two interfaces in the system and it happens to be the first
one is with IPIF_POINTTOPOINT and the second one without
IPIF_UNNUMBERED, also suppose the first one's ipif_pp_dst_addr is equal
to the second one's ipif_lcl_addr (this can happen if one of the
interface is DOWN), the above code will result in different behavior
from what it does today. i.e. Nevada matches the second one while the
proposed code matches the first one.
I'm not sure the correct behavior under this situation. If either is OK
then it's fine we can eliminate twice lookups.
- yxn
> _______________________________________________
> networking-discuss mailing list
> [email protected]
_______________________________________________
networking-discuss mailing list
[email protected]