Merge pull request #169 from Cerberus98/master

RM7831 addendum
RM7980

A commit back in may introduced filtering on "do_not_use" when selecting
IP addresses from the database. Unfortunately, this had the unintended
side-effect of applying a cartesian product to the result set, crushing
neutron DB servers in the process. This patch refactors the join to be
more sensible, as well as an inner join for safety.