bpf: Refactor and streamline bounds check into helper