mjschultz / py-radix

Python radix tree implementation for IPv4 and IPv6 prefix matching.
Other
119 stars 37 forks source link

adding 0.0.0.0/0 (default route) causes problems #9

Closed mjschultz closed 9 years ago

mjschultz commented 9 years ago

Submitted via email:

Program

The following program adds 3 routes (including a default route to radix)

import radix

radix_trie = radix.Radix()
radix_trie.add('192.168.30.0/24')
radix_trie.add('1.1.1.0/24')
radix_trie.add('0.0.0.0/0')

print('print table:')
for rnode in radix_trie:
     print(rnode.prefix)

entry = radix_trie.search_best("10.10.10.10")
print('Route lookup for 10.10.10.10 returned:', entry)

Output

When this program is executed, the following output is displayed:

print table:
None/0
1.1.1.0/24
192.168.30.0/24
Route lookup for 10.10.10.10 returned: None

Please note the 'None/0' entry.

Route lookup

As shown in the output, when a route table lookup is done in this table for a destination that would match with default route, The route lookup is returning no entries.

mjschultz commented 9 years ago

Corrected in https://github.com/mjschultz/py-radix/pull/10