I have a question about the prefix_same function which has the code:
int
prefix_same (struct prefix *p1, struct prefix *p2)
{
if (p1->family == p2->family && p1->prefixlen == p2->prefixlen)
{
if (p1->family == AF_INET)
if (IPV4_ADDR_SAME (&p1->u.prefix, &p2->u.prefix))
return 1;
#ifdef HAVE_IPV6
if (p1->family == AF_INET6 )
if (IPV6_ADDR_SAME (&p1->u.prefix, &p2->u.prefix))
return 1;
#endif /* HAVE_IPV6 */
}
return 0;
}
It seems like this would return 0 if p1 was set (appropriately)
to 10.10.10.20/24, p2 was set to 10.10.10.30/24, even though
the 2 are really the same /24 prefix. This does not sound right.
If family is the same, and prefixlen is the same, shouldn't we just
be comparing prefixlen bits, instead of calling IPV4_ADDR_SAME()?
--Sowmini
int
prefix_same (struct prefix *p1, struct prefix *p2)
{
if (p1->family == p2->family && p1->prefixlen == p2->prefixlen)
{
if (p1->family == AF_INET)
if (IPV4_ADDR_SAME (&p1->u.prefix, &p2->u.prefix))
return 1;
#ifdef HAVE_IPV6
if (p1->family == AF_INET6 )
if (IPV6_ADDR_SAME (&p1->u.prefix, &p2->u.prefix))
return 1;
#endif /* HAVE_IPV6 */
}
return 0;
}
It seems like this would return 0 if p1 was set (appropriately)
to 10.10.10.20/24, p2 was set to 10.10.10.30/24, even though
the 2 are really the same /24 prefix. This does not sound right.
If family is the same, and prefixlen is the same, shouldn't we just
be comparing prefixlen bits, instead of calling IPV4_ADDR_SAME()?
--Sowmini