Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Drivers: hv: vmbus: Ignore CHANNELMSG_TL_CONNECT_RESULT(23)

When a Linux hv_sock app tries to connect to a Service GUID on which no
host app is listening, a recent host (RS3+) sends a
CHANNELMSG_TL_CONNECT_RESULT (23) message to Linux and this triggers such
a warning:

unknown msgtype=23
WARNING: CPU: 2 PID: 0 at drivers/hv/vmbus_drv.c:1031 vmbus_on_msg_dpc

Actually Linux can safely ignore the message because the Linux app's
connect() will time out in 2 seconds: see VSOCK_DEFAULT_CONNECT_TIMEOUT
and vsock_stream_connect(). We don't bother to make use of the message
because: 1) it's only supported on recent hosts; 2) a non-trivial effort
is required to use the message in Linux, but the benefit is small.

So, let's not see the warning by silently ignoring the message.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

authored by

Dexuan Cui and committed by
Sasha Levin
ddc9d357 382a4622

+13 -14
+7 -14
drivers/hv/channel_mgmt.c
··· 1351 1351 { CHANNELMSG_19, 0, NULL }, 1352 1352 { CHANNELMSG_20, 0, NULL }, 1353 1353 { CHANNELMSG_TL_CONNECT_REQUEST, 0, NULL }, 1354 + { CHANNELMSG_22, 0, NULL }, 1355 + { CHANNELMSG_TL_CONNECT_RESULT, 0, NULL }, 1354 1356 }; 1355 1357 1356 1358 /* ··· 1364 1362 { 1365 1363 struct hv_message *msg = context; 1366 1364 struct vmbus_channel_message_header *hdr; 1367 - int size; 1368 1365 1369 1366 hdr = (struct vmbus_channel_message_header *)msg->u.payload; 1370 - size = msg->header.payload_size; 1371 1367 1372 1368 trace_vmbus_on_message(hdr); 1373 1369 1374 - if (hdr->msgtype >= CHANNELMSG_COUNT) { 1375 - pr_err("Received invalid channel message type %d size %d\n", 1376 - hdr->msgtype, size); 1377 - print_hex_dump_bytes("", DUMP_PREFIX_NONE, 1378 - (unsigned char *)msg->u.payload, size); 1379 - return; 1380 - } 1381 - 1382 - if (channel_message_table[hdr->msgtype].message_handler) 1383 - channel_message_table[hdr->msgtype].message_handler(hdr); 1384 - else 1385 - pr_err("Unhandled channel message type %d\n", hdr->msgtype); 1370 + /* 1371 + * vmbus_on_msg_dpc() makes sure the hdr->msgtype here can not go 1372 + * out of bound and the message_handler pointer can not be NULL. 1373 + */ 1374 + channel_message_table[hdr->msgtype].message_handler(hdr); 1386 1375 } 1387 1376 1388 1377 /*
+4
drivers/hv/vmbus_drv.c
··· 1033 1033 } 1034 1034 1035 1035 entry = &channel_message_table[hdr->msgtype]; 1036 + 1037 + if (!entry->message_handler) 1038 + goto msg_handled; 1039 + 1036 1040 if (entry->handler_type == VMHT_BLOCKING) { 1037 1041 ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC); 1038 1042 if (ctx == NULL)
+2
include/linux/hyperv.h
··· 425 425 CHANNELMSG_19 = 19, 426 426 CHANNELMSG_20 = 20, 427 427 CHANNELMSG_TL_CONNECT_REQUEST = 21, 428 + CHANNELMSG_22 = 22, 429 + CHANNELMSG_TL_CONNECT_RESULT = 23, 428 430 CHANNELMSG_COUNT 429 431 }; 430 432