From 2c32ca4cebea02f993189f74ed7bbeeccc6a493c Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 25 Nov 2021 08:37:21 +0900 Subject: [PATCH] sock: Fix SPDK_ZEROCOPY do not work for IPV6 For IPV6, cm->cmsg_level is SOL_IPV6 and cm->cmsg_type is IPV6_RECVERR. However these combination was not included. To clarify the fix check if positive conditions are satisfied and then reverse the result. Signed-off-by: Shuhei Matsumoto Change-Id: I675f4337f383d3526fed1b86794697f41113ed4c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10428 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Konrad Sztyber Reviewed-by: Jim Harris --- module/sock/posix/posix.c | 4 +++- module/sock/uring/uring.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index 411d7a65d..ab9efd712 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -657,7 +657,9 @@ _sock_check_zcopy(struct spdk_sock *sock) } cm = CMSG_FIRSTHDR(&msgh); - if (!cm || cm->cmsg_level != SOL_IP || cm->cmsg_type != IP_RECVERR) { + if (!(cm && + ((cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_RECVERR) || + (cm->cmsg_level == SOL_IPV6 && cm->cmsg_type == IPV6_RECVERR)))) { SPDK_WARNLOG("Unexpected cmsg level or type!\n"); return 0; } diff --git a/module/sock/uring/uring.c b/module/sock/uring/uring.c index 59db9ef1b..80ac12db3 100644 --- a/module/sock/uring/uring.c +++ b/module/sock/uring/uring.c @@ -842,7 +842,8 @@ _sock_check_zcopy(struct spdk_sock *_sock, int status) } cm = CMSG_FIRSTHDR(&sock->recv_task.msg); - if (cm->cmsg_level != SOL_IP || cm->cmsg_type != IP_RECVERR) { + if (!((cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_RECVERR) || + (cm->cmsg_level == SOL_IPV6 && cm->cmsg_type == IPV6_RECVERR))) { SPDK_WARNLOG("Unexpected cmsg level or type!\n"); return 0; }