datapath: Move flow allocation into a function.