Commit e687a58f authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Fix bug allowing the comparison of v4 and v6 prefixes.

When the v6 prefix is ::/0, then it is considered as less specific than
any v4-mapped prefix.

Remark that "no source prefix" is encoded by "src_plen == 0".  This
might be an issue, since "src_plen == 0" means ::/0, a v6 prefix.  So
the route (1.1.1.1/32 from 0.0.0.0/0) is internally represented by
(1.1.1.1/32 from ::/0).  When compared with  (::/0 from 2001:db8::/32),
the two source prefixes are comparable.  This is not a problem in
practice, since 2 pairs of prefixes are disjoint whether the dst
prefixes or the src prefixes are disjoint.
parent 1a6135dc
......@@ -496,6 +496,9 @@ prefix_cmp(const unsigned char *p1, unsigned char plen1,
{
int plen = MIN(plen1, plen2);
if(v4mapped(p1) != v4mapped(p2))
return PST_DISJOINT;
if(memcmp(p1, p2, plen / 8) != 0)
return PST_DISJOINT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment