Previously, the function would always return the max_len parameter. This poses two issues: 1. the API requires to return the actual packet size 2. the API requires that if the packet is larger than max_len, the packet is flushed and -ENOBUFS is returned 3. this basically bypasses the packet flushing, consequtive _recv() would return the last packet again This commit fixes those issues.