brcompatd: Factor code out of prune_ports().