From: Kruti Date: Mon, 18 Mar 2024 18:03:48 +0000 (-0700) Subject: [GDP][GdpPlugin] Subscriber presence interrogation (ZeroData). X-Git-Tag: stable-12.5.0~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc9c9503ee2d4a1a18aed73d001ef6340491d302;p=thirdparty%2Fopen-vm-tools.git [GDP][GdpPlugin] Subscriber presence interrogation (ZeroData). This change allows empty/0 byte payload to be sent from GDP Plugin on guest to the gdp daemon on host when querying for subscriber presence, without publishing the data to the subscribers. --- diff --git a/open-vm-tools/services/plugins/gdp/gdpPlugin.c b/open-vm-tools/services/plugins/gdp/gdpPlugin.c index 0e67ccac5..9f5e15e88 100644 --- a/open-vm-tools/services/plugins/gdp/gdpPlugin.c +++ b/open-vm-tools/services/plugins/gdp/gdpPlugin.c @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (c) 2020-2021,2023 VMware, Inc. All rights reserved. + * Copyright (c) 2020-2021,2023-2024 Broadcom. All rights reserved. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -1647,9 +1648,16 @@ GdpTaskBuildPacket(TaskContext *taskCtx, // IN/OUT GdpError gdpErr; ASSERT(topic != NULL); - ASSERT(data != NULL && dataLen > 0); - if (!Base64_Encode(data, dataLen, base64Data, sizeof base64Data, NULL)) { + if (data == NULL || dataLen == 0) { + /* + * ZeroData: Empty/no data is allowed only if requireSubs=true AND + * gPublishState.cacheData=false. + */ + ASSERT(requireSubs && !gPublishState.cacheData); /* see: GdpPublish() */ + base64Data[0] = '\0'; // ZeroData: set empty payload. + } else if (!Base64_Encode(data, dataLen, + base64Data, sizeof base64Data, NULL)) { g_info("%s: Base64_Encode failed, data length is %u.\n", __FUNCTION__, dataLen); return GDP_ERROR_DATA_SIZE; @@ -3388,8 +3396,13 @@ GdpPublish(gint64 createTime, // IN } if (data == NULL || dataLen == 0) { - g_info("%s: Topic '%s' has no data.\n", __FUNCTION__, topic); - return GDP_ERROR_INVALID_DATA; + /* + * ZeroData: Allow empty/no data when requireSubs=true and cacheData=false + */ + if (!requireSubs || cacheData) { + g_info("%s: Topic '%s' has no data.\n", __FUNCTION__, topic); + return GDP_ERROR_INVALID_DATA; + } } if (token != NULL && *token == '\0') {