IB/uverbs: Factor out common idr code