xsk: Return error code if force_zc is set
authorZhang Changzhong <zhangchangzhong@huawei.com>
Fri, 4 Dec 2020 10:21:16 +0000 (18:21 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 4 Dec 2020 15:48:31 +0000 (16:48 +0100)
If force_zc is set, we should exit out with an error, not fall back to
copy mode.

Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/1607077277-41995-1-git-send-email-zhangchangzhong@huawei.com
net/xdp/xsk_buff_pool.c

index 9287edd..d5adeee 100644 (file)
@@ -175,6 +175,7 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool,
 
        if (!pool->dma_pages) {
                WARN(1, "Driver did not DMA map zero-copy buffers");
+               err = -EINVAL;
                goto err_unreg_xsk;
        }
        pool->umem->zc = true;