From d9a7e9d02d14ad11c947a2ac29bbd20c3b2b3713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A4=E4=BA=86=E4=B8=8A=E7=8F=AD=E5=AF=B9=E5=95=A5?= =?UTF-8?q?=E9=83=BD=E6=84=9F=E5=85=B4=E8=B6=A3?= <2659187352@qq.com> Date: Thu, 27 Nov 2025 11:42:59 +0800 Subject: [PATCH 1/2] delete http server related code --- gala-gopher.spec | 6 +- huawei-delete-http-server-related-code.patch | 1271 ++++++++++++++++++ 2 files changed, 1276 insertions(+), 1 deletion(-) create mode 100644 huawei-delete-http-server-related-code.patch diff --git a/gala-gopher.spec b/gala-gopher.spec index 9633350..cf62235 100644 --- a/gala-gopher.spec +++ b/gala-gopher.spec @@ -28,7 +28,7 @@ Summary: Intelligent ops toolkit for openEuler Name: gala-gopher Version: 2.0.1 -Release: 2 +Release: 3 License: Mulan PSL v2 URL: https://gitee.com/openeuler/gala-gopher Source: %{name}-%{version}.tar.gz @@ -103,6 +103,7 @@ Patch6: fix-buffer-overflow-caused-by-strcpy.patch Patch7: fix-delete-unnecessary-judgments.patch Patch8: cadvisor_probe-fix-int-to-str-warnings.patch Patch9: bugfix-probe_define-access-out-of-bounds.patch +Patch10: huawei-delete-http-server-related-code.patch %description gala-gopher is a low-overhead eBPF-based probes framework @@ -197,6 +198,9 @@ fi %attr(0550,root,root) /usr/libexec/gala-gopher/init_probes.sh %changelog +* Thu Nov 27 2025 Tangxin Xie - 2.0.1-3 +- delete http server related code + * Wed May 8 2024 Liping Hu - 2.0.1-2 - fix delete unnecessary judgments fix buffer overflow caused by strcpy() diff --git a/huawei-delete-http-server-related-code.patch b/huawei-delete-http-server-related-code.patch new file mode 100644 index 0000000..1fe4ca6 --- /dev/null +++ b/huawei-delete-http-server-related-code.patch @@ -0,0 +1,1271 @@ +From 46140d08a29e5df20953d7008a85e106a16e1b71 Mon Sep 17 00:00:00 2001 +From: chenzhen +Date: Thu, 13 Jun 2024 21:49:02 +0800 +Subject: [PATCH] delete http server related code + +--- + config/gala-gopher.conf | 23 +- + src/api/rest_server.c | 127 ---------- + src/api/rest_server.h | 26 -- + src/daemon/CMakeLists.txt | 7 - + src/daemon/daemon.c | 55 ---- + src/lib/config/config.c | 121 --------- + src/lib/http_server/http_server.c | 239 ------------------ + src/lib/http_server/http_server.h | 65 ----- + src/lib/imdb/metrics.c | 2 +- + src/resource/resource.c | 71 ------ + src/resource/resource.h | 10 - + src/web_server/web_server.c | 128 ---------- + src/web_server/web_server.h | 27 -- + test/fuzz_test/CMakeLists.txt | 3 - + .../all_common_test/CMakeLists.txt | 4 - + test/test_modules/CMakeLists.txt | 2 - + test/test_probes/CMakeLists.txt | 3 - + 17 files changed, 2 insertions(+), 911 deletions(-) + delete mode 100644 src/api/rest_server.c + delete mode 100644 src/api/rest_server.h + delete mode 100644 src/lib/http_server/http_server.c + delete mode 100644 src/lib/http_server/http_server.h + delete mode 100644 src/web_server/web_server.c + delete mode 100644 src/web_server/web_server.h + +diff --git a/config/gala-gopher.conf b/config/gala-gopher.conf +index 08ba9ddea2c3..ad19105dce76 100644 +--- a/config/gala-gopher.conf ++++ b/config/gala-gopher.conf +@@ -2,12 +2,11 @@ global = + { + log_file_name = "gopher.log"; + log_level = "info"; # debug | info | warn | error +- listen_on = true; + }; + + metric = + { +- out_channel = "web_server"; # web_server | logs | json ++ out_channel = "logs"; # logs | json + }; + + imdb = +@@ -18,26 +17,6 @@ imdb = + record_timeout = 60; + }; + +-web_server = +-{ +- bind_addr = "127.0.0.1"; +- port = 8888; +- ssl_auth = "off"; +- private_key = ""; +- cert_file = ""; +- ca_file = ""; +-}; +- +-rest_api_server = +-{ +- bind_addr = "127.0.0.1"; +- port = 9999; +- ssl_auth = "off"; +- private_key = ""; +- cert_file = ""; +- ca_file = ""; +-}; +- + logs = + { + metric_total_size = 100; # unit is MB +diff --git a/src/api/rest_server.c b/src/api/rest_server.c +deleted file mode 100644 +index 89a6a76aea41..000000000000 +--- a/src/api/rest_server.c ++++ /dev/null +@@ -1,127 +0,0 @@ +-/****************************************************************************** +- * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +- * gala-gopher licensed under the Mulan PSL v2. +- * You can use this software according to the terms and conditions of the Mulan PSL v2. +- * You may obtain a copy of Mulan PSL v2 at: +- * http://license.coscl.org.cn/MulanPSL2 +- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +- * PURPOSE. +- * See the Mulan PSL v2 for more details. +- * Author: Vchanger +- * Create: 2023-12-05 +- * Description: Restful API Server +- ******************************************************************************/ +-#include +-#include +-#include +-#include +-#include +- +-#include "probe_mng.h" +-#include "rest_server.h" +- +-#define PUT_DATA_KEY "json=" +-#define ITER_BUFFER_SIZE 512 +-#define PUT_BUFFER_SIZE (1024 * 1024) // max post data size +- +-static void rest_handle_put_request(struct evhttp_request *req, const char *path) +-{ +- struct evbuffer *evbuf; +- char iter_buf[ITER_BUFFER_SIZE]; +- char *put_data; +- char *json_data; +- int offset = 0, read_len; +- +- evbuf = evhttp_request_get_input_buffer(req); +- if (evbuf == NULL) { +- return http_server_reply_code(req, HTTP_BADREQUEST); +- } +- +- /* use heap here to prevent stack overflow */ +- put_data = calloc(1, PUT_BUFFER_SIZE + 1); +- if (put_data == NULL){ +- return http_server_reply_code(req, HTTP_INTERNAL); +- } +- +- while (evbuffer_get_length(evbuf)) { +- read_len = evbuffer_remove(evbuf, iter_buf, sizeof(iter_buf)); +- if (read_len <= 0) { +- break; +- } +- if (offset + read_len > PUT_BUFFER_SIZE) { +- PARSE_ERR("put data size exceeds %d", PUT_BUFFER_SIZE); +- goto err; +- } +- strncpy(put_data + offset, iter_buf, read_len); +- offset += read_len; +- put_data[offset] = 0; +- } +- +- if (strncmp(put_data, PUT_DATA_KEY, strlen(PUT_DATA_KEY))) { +- PARSE_ERR("put data must start with %s", PUT_DATA_KEY); +- goto err; +- } +- +- path++; // skip prefix "/" +- json_data = put_data + strlen(PUT_DATA_KEY); +- if (parse_probe_json(path, json_data) == 0) { +- free(put_data); +- return http_server_reply_message(req, HTTP_OK, "New config takes effect"); +- } +- +-err: +- free(put_data); +- return http_server_reply_message(req, HTTP_BADREQUEST, g_parse_json_err); +-} +- +-static void rest_handle_get_request(struct evhttp_request *req, const char *path) +-{ +- int ret; +- char *buf; +- struct evbuffer *evbuffer = NULL; +- +- path++; // skip prefix "/" +- buf = get_probe_json(path); +- if (buf == NULL) { +- return http_server_reply_message(req, HTTP_NOTFOUND, HTTP_NOTFOUND_ERR_MSG); +- } +- +- http_server_reply_buffer(req, buf); +- free(buf); +-} +- +-static void rest_server_request_handler(struct evhttp_request *req, void *arg) +-{ +- enum evhttp_cmd_type method; +- char path[HTTP_URL_PATH_LEN]; +- +- if (http_get_request_uri_path(req, path, HTTP_URL_PATH_LEN)) { +- return http_server_reply_code(req, HTTP_BADREQUEST); +- } +- +- /* request url path must /xxx */ +- if (strlen(path) <= 1) { +- return http_server_reply_message(req, HTTP_NOTFOUND, HTTP_NOTFOUND_ERR_MSG); +- } +- +- method = evhttp_request_get_command(req); +- if (method == EVHTTP_REQ_GET) { +- return rest_handle_get_request(req, path); +- } +- +- if (method == EVHTTP_REQ_PUT) { +- return rest_handle_put_request(req, path); +- } +- +- http_server_reply_message(req, HTTP_BADMETHOD, HTTP_BADMETHOD_ERR_MSG); +-} +- +- +-int init_rest_server_mgr(http_server_mgr_s *rest_server, HttpServerConfig *config) +-{ +- (void)snprintf(rest_server->name, HTTP_THREAD_NAME_LEN, "%s", "RESTSERVER"); +- rest_server->req_handler = rest_server_request_handler; +- rest_server->allow_methods = EVHTTP_REQ_GET | EVHTTP_REQ_PUT; +- return init_http_server_mgr(rest_server, config); +-} +\ No newline at end of file +diff --git a/src/api/rest_server.h b/src/api/rest_server.h +deleted file mode 100644 +index 7d8cb020fd64..000000000000 +--- a/src/api/rest_server.h ++++ /dev/null +@@ -1,26 +0,0 @@ +-/****************************************************************************** +- * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +- * gala-gopher licensed under the Mulan PSL v2. +- * You can use this software according to the terms and conditions of the Mulan PSL v2. +- * You may obtain a copy of Mulan PSL v2 at: +- * http://license.coscl.org.cn/MulanPSL2 +- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +- * PURPOSE. +- * See the Mulan PSL v2 for more details. +- * Author: Vchanger +- * Create: 2023-12-05 +- * Description: +- ******************************************************************************/ +- +-#ifndef __REST_SERVER_H__ +-#define __REST_SERVER_H__ +- +-#include +- +-#include "config.h" +-#include "base.h" +-#include "http_server.h" +- +-int init_rest_server_mgr(http_server_mgr_s *rest_server, HttpServerConfig *config); +-#endif +\ No newline at end of file +diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt +index 273c66833959..3eff6e8bbb6c 100644 +--- a/src/daemon/CMakeLists.txt ++++ b/src/daemon/CMakeLists.txt +@@ -21,14 +21,12 @@ SET(RESOURCE_DIR ${SRC_DIR}/resource) + SET(CONFIG_DIR ${SRC_DIR}/lib/config) + SET(EGRESS_DIR ${SRC_DIR}/egress) + SET(INGRESS_DIR ${SRC_DIR}/ingress) +-SET(WEB_SERVER_DIR ${SRC_DIR}/web_server) + SET(FIFO_DIR ${SRC_DIR}/lib/fifo) + SET(META_DIR ${SRC_DIR}/lib/meta) + SET(PROBE_DIR ${SRC_DIR}/lib/probe) + SET(IMDB_DIR ${SRC_DIR}/lib/imdb) + SET(COMMON_DIR ${SRC_DIR}/common) + SET(RESTAPI_DIR ${SRC_DIR}/api) +-SET(HTTPSERVER_DIR ${SRC_DIR}/lib/http_server) + SET(EBPF_PROBE_DIR ${SRC_DIR}/probes/extends/ebpf.probe) + SET(CMD_DIR ${SRC_DIR}/cmd) + +@@ -62,7 +60,6 @@ SET(SOURCES main.c daemon.c + + ${FIFO_DIR}/fifo.c + ${META_DIR}/meta.c +- ${HTTPSERVER_DIR}/http_server.c + + ${PROBE_DIR}/probe.c + ${PROBE_DIR}/extend_probe.c +@@ -83,9 +80,6 @@ SET(SOURCES main.c daemon.c + ${COMMON_DIR}/histogram.c + ${COMMON_DIR}/core_btf.c + +- ${WEB_SERVER_DIR}/web_server.c +- ${RESTAPI_DIR}/rest_server.c +- + ${CMD_DIR}/cmd_common.c + ${CMD_DIR}/cmd_server.c + ) +@@ -119,7 +113,6 @@ SET(INC_DIRECTORIES + ${CONFIG_DIR} + ${EGRESS_DIR} + ${INGRESS_DIR} +- ${WEB_SERVER_DIR} + ${RESTAPI_DIR} + + ${FIFO_DIR} +diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c +index 10eba325145a..02f638d67e59 100644 +--- a/src/daemon/daemon.c ++++ b/src/daemon/daemon.c +@@ -50,20 +50,6 @@ static void *DaemonRunEgress(void *arg) + EgressMain(mgr); + } + +-static void *DaemonRunWebServer(void *arg) +-{ +- http_server_mgr_s *web_server = (http_server_mgr_s *)arg; +- prctl(PR_SET_NAME, "[WEBSERVER]"); +- run_http_server_daemon(web_server); +-} +- +-static void *DaemonRunRestServer(void *arg) +-{ +- http_server_mgr_s *rest_server = (http_server_mgr_s *)arg; +- prctl(PR_SET_NAME, "[RESTSERVER]"); +- run_http_server_daemon(rest_server); +-} +- + static void *DaemonRunProbeMng(void *arg) + { + struct probe_mng_s *probe_mng = (struct probe_mng_s *)arg; +@@ -106,7 +92,6 @@ static void CleanData(const ResourceMgr *mgr) + int DaemonRun(ResourceMgr *mgr) + { + int ret; +- int listen_on = mgr->configMgr->globalConfig->listenOn; + + // 0. clean data + CleanData(mgr); +@@ -128,20 +113,6 @@ int DaemonRun(ResourceMgr *mgr) + } + INFO("[DAEMON] create egress thread success.\n"); + +- // 3. start web_server thread +- if (listen_on != 0) { +- if (mgr->web_server_mgr == NULL) { +- INFO("[DAEMON] skip create web_server thread.\n"); +- } else { +- ret = pthread_create(&mgr->web_server_mgr->tid, NULL, DaemonRunWebServer, mgr->web_server_mgr); +- if (ret != 0) { +- ERROR("[DAEMON] create web_server thread failed.(errno:%d, %s)\n", errno, strerror(errno)); +- return -1; +- } +- INFO("[DAEMON] create web_server thread success.\n"); +- } +- } +- + // 4. start metadata_report thread + ret = pthread_create(&mgr->mmMgr->tid, NULL, DaemonRunMetadataReport, mgr->mmMgr); + if (ret != 0) { +@@ -166,16 +137,6 @@ int DaemonRun(ResourceMgr *mgr) + } + INFO("[DAEMON] create metrics_write_logs thread success.\n"); + +- if (listen_on != 0) { +- // 8. start rest_api_server thread +- ret = pthread_create(&mgr->rest_server_mgr->tid, NULL, DaemonRunRestServer, mgr->rest_server_mgr); +- if (ret != 0) { +- ERROR("[DAEMON] create rest api server thread failed.(errno:%d, %s)\n", errno, strerror(errno)); +- return -1; +- } +- INFO("[DAEMON] create rest api server thread success.\n"); +- } +- + // 9. start CmdServer thread + ret = pthread_create(&mgr->ctl_tid, NULL, CmdServer, NULL); + if (ret != 0) { +@@ -203,11 +164,6 @@ void destroy_daemon_threads(ResourceMgr *mgr) + pthread_join(mgr->egressMgr->tid, NULL); + } + +- if (mgr->web_server_mgr != NULL && mgr->web_server_mgr->tid != 0) { +- pthread_cancel(mgr->web_server_mgr->tid); +- pthread_join(mgr->web_server_mgr->tid, NULL); +- } +- + if (mgr->mmMgr != NULL && mgr->mmMgr->tid != 0) { + pthread_cancel(mgr->mmMgr->tid); + pthread_join(mgr->mmMgr->tid, NULL); +@@ -223,11 +179,6 @@ void destroy_daemon_threads(ResourceMgr *mgr) + pthread_join(mgr->imdbMgr->metrics_tid, NULL); + } + +- if (mgr->rest_server_mgr != NULL && mgr->rest_server_mgr->tid != 0) { +- pthread_cancel(mgr->rest_server_mgr->tid); +- pthread_join(mgr->rest_server_mgr->tid, NULL); +- } +- + if (mgr->ctl_tid != 0) { + pthread_cancel(mgr->ctl_tid); + pthread_join(mgr->ctl_tid, NULL); +@@ -243,9 +194,6 @@ int DaemonWaitDone(const ResourceMgr *mgr) + // 2. wait egress done + pthread_join(mgr->egressMgr->tid, NULL); + +- // 3. wait web_server mng done +- pthread_join(mgr->web_server_mgr->tid, NULL); +- + // 4. wait metadata_report done + pthread_join(mgr->mmMgr->tid, NULL); + +@@ -255,9 +203,6 @@ int DaemonWaitDone(const ResourceMgr *mgr) + // 6. wait metric_write_logs done + pthread_join(mgr->imdbMgr->metrics_tid, NULL); + +- // 7. wait rest_api_server mng done +- pthread_join(mgr->rest_server_mgr->tid, NULL); +- + // 8.wait ctl thread done + pthread_join(mgr->ctl_tid, NULL); + +diff --git a/src/lib/config/config.c b/src/lib/config/config.c +index b03c8e24a5bc..59ac1ae8574c 100644 +--- a/src/lib/config/config.c ++++ b/src/lib/config/config.c +@@ -175,12 +175,6 @@ static int ConfigMgrLoadGlobalConfig(void *config, config_setting_t *settings) + } + (void)snprintf(globalConfig->logLevel, sizeof(globalConfig->logLevel), "%s", strVal); + +- ret = config_setting_lookup_bool(settings, "listen_on", &globalConfig->listenOn); +- if (ret == 0) { +- ERROR("[CONFIG] load config for listen_on failed.\n"); +- return -1; +- } +- + return 0; + } + +@@ -273,115 +267,6 @@ static int ConfigMgrLoadIMDBConfig(void *config, config_setting_t *settings) + return 0; + } + +-static int ConfigMgrLoadWebServerConfig(void *config, config_setting_t *settings) +-{ +- HttpServerConfig *webServerConfig = (HttpServerConfig *)config; +- int ret = 0; +- const char *strVal = NULL; +- int intVal = 0; +- +- ret = config_setting_lookup_int(settings, "port", &intVal); +- if (ret == 0 || intVal <= 0) { +- ERROR("[CONFIG] load config for webServerConfig port failed.\n"); +- return -1; +- } +- webServerConfig->port = (uint16_t)intVal; +- +- +- ret = config_setting_lookup_string(settings, "bind_addr", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for webServerConfig bind_addr failed.\n"); +- return -1; +- } +- (void)snprintf(webServerConfig->bindAddr, sizeof(webServerConfig->bindAddr), "%s", strVal); +- +- ret = config_setting_lookup_string(settings, "ssl_auth", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for webServerConfig ssl_auth failed.\n"); +- return -1; +- } +- if (strcmp(strVal, "on") == 0) { +- webServerConfig->sslAuth = 1; +- } +- +- ret = config_setting_lookup_string(settings, "private_key", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for restServerConfig private_key failed.\n"); +- return -1; +- } +- (void)snprintf(webServerConfig->privateKey, sizeof(webServerConfig->privateKey), "%s", strVal); +- +- ret = config_setting_lookup_string(settings, "cert_file", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for webServerConfig cert_file failed.\n"); +- return -1; +- } +- (void)snprintf(webServerConfig->certFile, sizeof(webServerConfig->certFile), "%s", strVal); +- +- ret = config_setting_lookup_string(settings, "ca_file", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for webServerConfig ca_file failed.\n"); +- return -1; +- } +- (void)snprintf(webServerConfig->caFile, sizeof(webServerConfig->caFile), "%s", strVal); +- +- return 0; +-} +- +-static int ConfigMgrLoadRestServerConfig(void *config, config_setting_t *settings) +-{ +- HttpServerConfig *restServerConfig = (HttpServerConfig *)config; +- int ret = 0; +- const char *strVal = NULL; +- int intVal = 0; +- +- ret = config_setting_lookup_string(settings, "bind_addr", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for restServerConfig bind_addr failed.\n"); +- return -1; +- } +- (void)snprintf(restServerConfig->bindAddr, sizeof(restServerConfig->bindAddr), "%s", strVal); +- +- ret = config_setting_lookup_int(settings, "port", &intVal); +- if (ret == 0 || intVal <= 0) { +- ERROR("[CONFIG] load config for restServerConfig port failed.\n"); +- return -1; +- } +- restServerConfig->port = (uint16_t)intVal; +- +- ret = config_setting_lookup_string(settings, "ssl_auth", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for restServerConfig ssl_auth failed.\n"); +- return -1; +- } +- if (strcmp(strVal, "on") == 0) { +- restServerConfig->sslAuth = 1; +- } +- +- ret = config_setting_lookup_string(settings, "private_key", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for restServerConfig private_key failed.\n"); +- return -1; +- } +- (void)snprintf(restServerConfig->privateKey, sizeof(restServerConfig->privateKey), "%s", strVal); +- +- ret = config_setting_lookup_string(settings, "cert_file", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for restServerConfig cert_file failed.\n"); +- return -1; +- } +- (void)snprintf(restServerConfig->certFile, sizeof(restServerConfig->certFile), "%s", strVal); +- +- ret = config_setting_lookup_string(settings, "ca_file", &strVal); +- if (ret == 0) { +- ERROR("[CONFIG] load config for restServerConfig ca_file failed.\n"); +- return -1; +- } +- (void)snprintf(restServerConfig->caFile, sizeof(restServerConfig->caFile), "%s", strVal); +- +- return 0; +-} +- + static int ConfigMgrLoadLogsConfig(void *config, config_setting_t *settings) + { + LogsConfig *logsConfig = (LogsConfig *)config; +@@ -427,10 +312,6 @@ static int ConfigMgrLoadOutConfig(void *config, config_setting_t *settings) + } + if (!strcmp(strVal, "logs")) { + outConfig->outChnl = OUT_CHNL_LOGS; +- } else if (!strcmp(strVal, "kafka")) { +- outConfig->outChnl = OUT_CHNL_KAFKA; +- } else if (!strcmp(strVal, "web_server")) { +- outConfig->outChnl = OUT_CHNL_WEB_SERVER; + } else if (!strcmp(strVal, "json")) { + outConfig->outChnl = OUT_CHNL_JSON; + } else if (!strlen(strVal)) { +@@ -461,8 +342,6 @@ int ConfigMgrLoad(const ConfigMgr *mgr, const char *confPath) + ConfigLoadHandle configLoadHandles[] = { + { (void *)mgr->globalConfig, "global", ConfigMgrLoadGlobalConfig }, + { (void *)mgr->imdbConfig, "imdb", ConfigMgrLoadIMDBConfig }, +- { (void *)mgr->webServerConfig, "web_server", ConfigMgrLoadWebServerConfig }, +- { (void *)mgr->restServerConfig, "rest_api_server", ConfigMgrLoadRestServerConfig }, + { (void *)mgr->logsConfig, "logs", ConfigMgrLoadLogsConfig }, + { (void *)mgr->metricOutConfig, "metric", ConfigMgrLoadOutConfig } + }; +diff --git a/src/lib/http_server/http_server.c b/src/lib/http_server/http_server.c +deleted file mode 100644 +index 685aded0d254..000000000000 +--- a/src/lib/http_server/http_server.c ++++ /dev/null +@@ -1,239 +0,0 @@ +-/****************************************************************************** +- * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +- * gala-gopher licensed under the Mulan PSL v2. +- * You can use this software according to the terms and conditions of the Mulan PSL v2. +- * You may obtain a copy of Mulan PSL v2 at: +- * http://license.coscl.org.cn/MulanPSL2 +- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +- * PURPOSE. +- * See the Mulan PSL v2 for more details. +- * Author: Vchanger +- * Create: 2023-11-27 +- * Description: Lib for rest server and web server, implemented by libevent2 +- ******************************************************************************/ +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include "http_server.h" +- +-static struct bufferevent* http_server_bevcb_ssl(struct event_base *evbase, void *arg) +-{ +- SSL_CTX *ssl_ctx = (SSL_CTX *)arg; +- if (ssl_ctx == NULL) { +- return NULL; +- } +- +- return bufferevent_openssl_socket_new(evbase, -1, SSL_new(ssl_ctx), +- BUFFEREVENT_SSL_ACCEPTING, +- BEV_OPT_CLOSE_ON_FREE); +-} +- +-static struct bufferevent* http_server_bevcb_nossl(struct event_base *evbase, void *arg) +-{ +- return bufferevent_socket_new(evbase, -1, BEV_OPT_CLOSE_ON_FREE); +-} +- +-void http_server_reply_code(struct evhttp_request *req, int errorno) +-{ +- evhttp_send_reply(req, errorno, NULL, NULL); +-} +- +-void http_server_reply_message(struct evhttp_request *req, int resp_code, const char* message) +-{ +- struct evbuffer *evbuffer; +- char buf[HTTP_REPLY_MSG_LEN] = {0}; +- +- +- if (resp_code == HTTP_OK) { +- (void)snprintf(buf, sizeof(buf), "{ \"result\": \"success\", \"message\":\"%s\" }\n", message); +- } else { +- (void)snprintf(buf, sizeof(buf), "{ \"result\": \"failed\", \"message\":\"%s\" }\n", message); +- } +- +- evbuffer = evbuffer_new(); +- if (evbuffer == NULL) { +- return http_server_reply_code(req, HTTP_INTERNAL); +- } +- +- (void)evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type", "application/json"); +- (void)evbuffer_add_printf(evbuffer, "%s", buf); +- evhttp_send_reply(req, resp_code, NULL, evbuffer); +- evbuffer_free(evbuffer); +-} +- +-void http_server_reply_buffer(struct evhttp_request *req, const char* resp_buf) +-{ +- struct evbuffer *evbuffer; +- +- evbuffer = evbuffer_new(); +- if (evbuffer == NULL) { +- return http_server_reply_code(req, HTTP_INTERNAL); +- } +- +- (void)evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type", "application/json"); +- (void)evbuffer_add_printf(evbuffer, "%s", resp_buf); +- evhttp_send_reply(req, HTTP_OK, NULL, evbuffer); +- evbuffer_free(evbuffer); +-} +- +-int http_get_request_uri_path(struct evhttp_request *req, char *path, int size) +-{ +- const char *uri = evhttp_request_get_uri(req); +- struct evhttp_uri *decoded = evhttp_uri_parse(uri); +- +- if (decoded == NULL) { +- return -1; +- } +- +- if (evhttp_uri_get_path(decoded) == NULL) { +- evhttp_uri_free(decoded); +- return -1; +- } +- +- path[0] = 0; +- snprintf(path, size, "%s", evhttp_uri_get_path(decoded)); +- evhttp_uri_free(decoded); +- return 0; +-} +- +-void run_http_server_daemon(http_server_mgr_s *server_mgr) +-{ +- struct evhttp_bound_socket *handle; +- +- handle = evhttp_bind_socket_with_handle(server_mgr->evhttp, server_mgr->bind_addr, server_mgr->port); +- if (handle == NULL) { +- ERROR("[%s] Failed to bind to addr %s, port %d\n", server_mgr->name, server_mgr->bind_addr, server_mgr->port); +- return; +- } +- +- DEBUG("[%s] Start running, listening on %s:%d\n", server_mgr->name, server_mgr->bind_addr, server_mgr->port); +- // handling request here in a loop +- event_base_dispatch(server_mgr->evbase); +-} +- +-static int init_http_ssl_ctx(http_server_mgr_s *server_mgr, const char *key_file, const char *cert_file, const char *ca_file) +-{ +- SSL_CTX *ssl_ctx = NULL; +- +- ssl_ctx = SSL_CTX_new(TLS_server_method()); +- if (!ssl_ctx) { +- ERROR("[%s] Could not create TLS context\n", server_mgr->name); +- return -1; +- } +- +- SSL_CTX_set_options(ssl_ctx, +- SSL_OP_ALL | SSL_OP_NO_SSL_MASK | +- SSL_OP_NO_COMPRESSION | +- SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION); +- +- SSL_CTX_clear_options(ssl_ctx, SSL_OP_NO_TLSv1_3); +- +- if (SSL_CTX_set1_curves_list(ssl_ctx, "P-256") != 1) { +- ERROR("[%s] SSL set curves list failed\n", server_mgr->name); +- goto err; +- } +- +- if (SSL_CTX_use_PrivateKey_file(ssl_ctx, key_file, SSL_FILETYPE_PEM) != 1) { +- ERROR("[%s] Could not read private key file: %s\n", server_mgr->name, key_file); +- goto err; +- } +- +- if (SSL_CTX_use_certificate_chain_file(ssl_ctx, cert_file) != 1) { +- ERROR("[%s] Could not read certificate file: %s\n", server_mgr->name, cert_file); +- goto err; +- } +- +- if (SSL_CTX_check_private_key(ssl_ctx) != 1) { +- ERROR("[%s] Could not verify private key file %s\n", server_mgr->name, key_file); +- goto err; +- } +- +- if (strlen(ca_file)) { +- SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); +- if (SSL_CTX_load_verify_locations(ssl_ctx, ca_file, NULL) != 1) { +- ERROR("[%s] could not load ca file.\n", server_mgr->name); +- goto err; +- } +- } +- +- server_mgr->ssl_ctx = ssl_ctx; +- return 0; +- +-err: +- if (ssl_ctx) { +- // clear private key from memory +- SSL_CTX_use_PrivateKey(ssl_ctx, NULL); +- +- SSL_CTX_free(ssl_ctx); +- } +- return -1; +-} +- +-int init_http_server_mgr(http_server_mgr_s *server_mgr, HttpServerConfig *config) +-{ +- server_mgr->port = config->port; +- (void)snprintf(server_mgr->bind_addr, sizeof(server_mgr->bind_addr), "%s", config->bindAddr); +- server_mgr->evbase = event_base_new(); +- if (server_mgr->evbase == NULL) { +- ERROR("[%s] Failed to create base event mgr\n", server_mgr->name); +- return -1; +- } +- +- /* Note: do free in destroy_web_server_mgr() if error happens */ +- server_mgr->evhttp = evhttp_new(server_mgr->evbase); +- if (server_mgr->evhttp == NULL) { +- ERROR("[%s] Failed to create http event mgr\n", server_mgr->name); +- return -1; +- } +- +- if (config->sslAuth) { +- if (init_http_ssl_ctx(server_mgr, config->privateKey, config->certFile, config->caFile) == -1) { +- return -1; +- } +- } +- +- if (server_mgr->ssl_ctx) { +- evhttp_set_bevcb(server_mgr->evhttp, http_server_bevcb_ssl, server_mgr->ssl_ctx); +- } else { +- evhttp_set_bevcb(server_mgr->evhttp, http_server_bevcb_nossl, NULL); +- } +- +- evhttp_set_gencb(server_mgr->evhttp, server_mgr->req_handler, NULL); +- evhttp_set_allowed_methods(server_mgr->evhttp, server_mgr->allow_methods); +- return 0; +-} +- +-void destroy_http_server_mgr(http_server_mgr_s *server_mgr) +-{ +- if (server_mgr == NULL) { +- return; +- } +- +- if (server_mgr->evbase) { +- event_base_free(server_mgr->evbase); +- } +- +- if (server_mgr->ssl_ctx) { +- // clear private key from memory +- SSL_CTX_use_PrivateKey(server_mgr->ssl_ctx, NULL); +- +- SSL_CTX_free(server_mgr->ssl_ctx); +- server_mgr->ssl_ctx = NULL; +- } +- +- if (server_mgr->evhttp) { +- evhttp_free(server_mgr->evhttp); +- } +- +- free(server_mgr); +-} +diff --git a/src/lib/http_server/http_server.h b/src/lib/http_server/http_server.h +deleted file mode 100644 +index 378c4b95cc0d..000000000000 +--- a/src/lib/http_server/http_server.h ++++ /dev/null +@@ -1,65 +0,0 @@ +-/****************************************************************************** +- * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +- * gala-gopher licensed under the Mulan PSL v2. +- * You can use this software according to the terms and conditions of the Mulan PSL v2. +- * You may obtain a copy of Mulan PSL v2 at: +- * http://license.coscl.org.cn/MulanPSL2 +- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +- * PURPOSE. +- * See the Mulan PSL v2 for more details. +- * Author: Vchanger +- * Create: 2023-11-27 +- * Description: Lib for rest server and web server, implemented by libevent2 +- ******************************************************************************/ +- +-#ifndef __GOPHER_HTTP_SERVER_H__ +-#define __GOPHER_HTTP_SERVER_H__ +- +-#include +-#include +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include "base.h" +-#include "config.h" +- +-#define HTTP_THREAD_NAME_LEN 16 +-#define HTTP_URL_PATH_LEN 64 +-#define HTTP_REPLY_MSG_LEN 128 +- +-//http error msg +-#define HTTP_NOTFOUND_ERR_MSG "url not found" +-#define HTTP_BADMETHOD_ERR_MSG "method not allowed" +- +-typedef void (*request_handler_cb)(struct evhttp_request *, void *); +- +-typedef struct { +- char name[HTTP_THREAD_NAME_LEN]; +- uint16_t port; +- uint16_t allow_methods; +- request_handler_cb req_handler; +- char bind_addr[IP_STR_LEN]; +- SSL_CTX *ssl_ctx; // Indicate that if we enable https and client auth +- struct event_base *evbase; +- struct evhttp *evhttp; +- pthread_t tid; +-} http_server_mgr_s; +- +- +-void http_server_reply_code(struct evhttp_request *req, int errorno); +-void http_server_reply_message(struct evhttp_request *req, int resp_code, const char* message); +-void http_server_reply_buffer(struct evhttp_request *req, const char* resp_buf); +-int http_get_request_uri_path(struct evhttp_request *req, char *path, int size); +-void run_http_server_daemon(http_server_mgr_s *server_mgr); +-int init_http_server_mgr(http_server_mgr_s *server_mgr, HttpServerConfig *config); +-void destroy_http_server_mgr(http_server_mgr_s *server_mgr); +-#endif +\ No newline at end of file +diff --git a/src/lib/imdb/metrics.c b/src/lib/imdb/metrics.c +index 5cc153dda244..d793d8081fc6 100644 +--- a/src/lib/imdb/metrics.c ++++ b/src/lib/imdb/metrics.c +@@ -70,7 +70,7 @@ void WriteMetricsLogsMain(IMDB_DataBaseMgr *mgr) + int ret; + + if (mgr->writeLogsType != METRIC_LOG_PROM && mgr->writeLogsType != METRIC_LOG_JSON) { +- ERROR("[METRICLOG] metric outchannel isn't web_server, logs or json, break.\n"); ++ ERROR("[METRICLOG] metric outchannel isn't logs or json, break.\n"); + return; + } + +diff --git a/src/resource/resource.c b/src/resource/resource.c +index 9b8d3c205b4e..ee1805b3bad2 100644 +--- a/src/resource/resource.c ++++ b/src/resource/resource.c +@@ -39,10 +39,6 @@ static int IngressMgrInit(ResourceMgr *resourceMgr); + static void IngressMgrDeinit(ResourceMgr *resourceMgr); + static int EgressMgrInit(ResourceMgr *resourceMgr); + static void EgressMgrDeinit(ResourceMgr *resourceMgr); +-static int WebServerInit(ResourceMgr *resourceMgr); +-static void WebServerDeinit(ResourceMgr *resourceMgr); +-static int RestServerInit(ResourceMgr *resourceMgr); +-static void RestServerDeinit(ResourceMgr *resourceMgr); + static int LogsMgrInit(ResourceMgr *resourceMgr); + static void LogsMgrDeinit(ResourceMgr *resourceMgr); + #ifdef ENABLE_REPORT_EVENT +@@ -69,8 +65,6 @@ SubModuleInitor gSubModuleInitorTbl[] = { + { IMDBMgrInit, IMDBMgrDeinit }, // IMDB must precede ingress + { EgressMgrInit, EgressMgrDeinit }, // egress must precede ingress + { IngressMgrInit, IngressMgrDeinit }, +- { WebServerInit, WebServerDeinit }, +- { RestServerInit, RestServerDeinit }, + { LogsMgrInit, LogsMgrDeinit } + }; + +@@ -469,71 +463,6 @@ static void EgressMgrDeinit(ResourceMgr *resourceMgr) + return; + } + +-static int WebServerInit(ResourceMgr *resourceMgr) +-{ +- int ret; +- ConfigMgr *configMgr = resourceMgr->configMgr; +- http_server_mgr_s *web_server_mgr; +- +- if (configMgr->metricOutConfig->outChnl != OUT_CHNL_WEB_SERVER) { +- INFO("[RESOURCE] metirc out channel isn't web_server, skip create webServer.\n"); +- return 0; +- } +- +- web_server_mgr = (http_server_mgr_s *)calloc(1, sizeof(http_server_mgr_s)); +- if (web_server_mgr == NULL) { +- ERROR("[RESOURCE] create web server mgr failed.\n"); +- return -1; +- } +- +- resourceMgr->web_server_mgr = web_server_mgr; +- ret = init_web_server_mgr(web_server_mgr, configMgr->webServerConfig); +- if (ret) { +- return -1; +- } +- +- if (resourceMgr->imdbMgr) { +- resourceMgr->imdbMgr->writeLogsType = METRIC_LOG_PROM; +- } +- +- return 0; +-} +- +-static void WebServerDeinit(ResourceMgr *resourceMgr) +-{ +- destroy_http_server_mgr(resourceMgr->web_server_mgr); +- resourceMgr->web_server_mgr = NULL; +- return; +-} +- +-static int RestServerInit(ResourceMgr *resourceMgr) +-{ +- int ret; +- ConfigMgr *configMgr = resourceMgr->configMgr; +- http_server_mgr_s *rest_server_mgr; +- +- rest_server_mgr = (http_server_mgr_s *)calloc(1, sizeof(http_server_mgr_s)); +- if (rest_server_mgr == NULL) { +- ERROR("[RESOURCE] create rest server mgr failed\n"); +- return -1; +- } +- +- resourceMgr->rest_server_mgr = rest_server_mgr; +- ret = init_rest_server_mgr(rest_server_mgr, configMgr->restServerConfig); +- if (ret) { +- return -1; +- } +- +- return 0; +-} +- +-static void RestServerDeinit(ResourceMgr *resourceMgr) +-{ +- destroy_http_server_mgr(resourceMgr->rest_server_mgr); +- resourceMgr->rest_server_mgr = NULL; +- return; +-} +- + static int LogsMgrInit(ResourceMgr *resourceMgr) + { + ConfigMgr *configMgr = resourceMgr->configMgr; +diff --git a/src/resource/resource.h b/src/resource/resource.h +index 3cb98e10b117..27dd7cff7f87 100644 +--- a/src/resource/resource.h ++++ b/src/resource/resource.h +@@ -36,10 +36,6 @@ + #include "ingress.h" + #include "egress.h" + +-#include "web_server.h" +-#include "rest_server.h" +-#include "http_server.h" +- + #include "logs.h" + + #include "event.h" +@@ -70,12 +66,6 @@ typedef struct { + IngressMgr *ingressMgr; + EgressMgr *egressMgr; + +- // web server(libevent) +- http_server_mgr_s *web_server_mgr; +- +- // rest api server(libevent) +- http_server_mgr_s *rest_server_mgr; +- + // logs + LogsMgr *logsMgr; + +diff --git a/src/web_server/web_server.c b/src/web_server/web_server.c +deleted file mode 100644 +index 5ce2b6ee6033..000000000000 +--- a/src/web_server/web_server.c ++++ /dev/null +@@ -1,128 +0,0 @@ +-/****************************************************************************** +- * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +- * gala-gopher licensed under the Mulan PSL v2. +- * You can use this software according to the terms and conditions of the Mulan PSL v2. +- * You may obtain a copy of Mulan PSL v2 at: +- * http://license.coscl.org.cn/MulanPSL2 +- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +- * PURPOSE. +- * See the Mulan PSL v2 for more details. +- * Author: Vchanger +- * Create: 2023-10-28 +- * Description: +- ******************************************************************************/ +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include "imdb.h" +-#include "http_server.h" +-#include "web_server.h" +- +- +-static int is_request_uri_invalid(struct evhttp_request *req) +-{ +- char path[HTTP_URL_PATH_LEN]; +- +- if (http_get_request_uri_path(req, path, HTTP_URL_PATH_LEN)) { +- return 1; +- } +- +- if (strcmp(path, "/") && strcmp(path, "/metrics")) { +- return 1; +- } +- +- return 0; +-} +- +-static int evbuffer_add_file_content(struct evbuffer *buf, int fd, ev_off_t offset, ev_off_t length) +-{ +- struct evbuffer_file_segment *seg; +- unsigned flags = EVBUF_FS_CLOSE_ON_FREE; +- int r; +- +- seg = evbuffer_file_segment_new(fd, offset, length, flags); +- if (!seg) { +- return 1; +- } +- +- r = evbuffer_add_file_segment(buf, seg, 0, length); +- if (r == 0) { +- evbuffer_file_segment_free(seg); +- } +- return r; +-} +- +-static void web_server_request_handler(struct evhttp_request *req, void *arg) +-{ +- char log_file_name[256]; +- struct evbuffer *evbuffer = NULL; +- struct stat buf; +- int fd, ret; +- +- // Disallow any input data and any method except GET +- if (evhttp_request_get_command(req) != EVHTTP_REQ_GET) { +- return http_server_reply_code(req, HTTP_BADMETHOD); +- } +- +- if (is_request_uri_invalid(req)) { +- return http_server_reply_code(req, HTTP_NOTFOUND); +- } +- +- // The log file may has not been created if we get here between que_get_next_file() and LOG4CPLUS_DEBUG_FMT() +- if (ReadMetricsLogs(log_file_name) < 0 || access(log_file_name, F_OK) == -1) { +- return http_server_reply_code(req, HTTP_NOCONTENT); +- } +- +- fd = open(log_file_name, O_RDONLY); +- if (fd < 0) { +- ERROR("[WEBSERVER] Failed to open '%s': %s\n", log_file_name, strerror(errno)); +- return http_server_reply_code(req, HTTP_NOCONTENT); +- } +- +- if ((fstat(fd, &buf) == -1) || !S_ISREG(buf.st_mode)) { +- (void)close(fd); +- return http_server_reply_code(req, HTTP_NOCONTENT); +- } +- +- evbuffer = evbuffer_new(); +- if (evbuffer == NULL) { +- (void)close(fd); +- ERROR("[WEBSERVER] Failed to allocate reply buffer\n"); +- return http_server_reply_code(req, HTTP_INTERNAL); +- } +- +- ret = evbuffer_add_file_content(evbuffer, fd, 0, buf.st_size); +- if (ret == 1) { +- (void)close(fd); +- } +- +- if(ret != 0) { +- evbuffer_free(evbuffer); +- ERROR("[WEBSERVER] Error occurs when accessing metrics\n"); +- return http_server_reply_code(req, HTTP_INTERNAL); +- } +- +- RemoveMetricsLogs(log_file_name); +- (void)evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type", "text/plain"); +- evhttp_send_reply(req, HTTP_OK, NULL, evbuffer); +- evbuffer_free(evbuffer); +-} +- +- +-int init_web_server_mgr(http_server_mgr_s *web_server, HttpServerConfig *config) +-{ +- (void)snprintf(web_server->name, HTTP_THREAD_NAME_LEN, "%s", "WEBSERVER"); +- web_server->req_handler = web_server_request_handler; +- web_server->allow_methods = EVHTTP_REQ_GET; +- return init_http_server_mgr(web_server, config); +-} +diff --git a/src/web_server/web_server.h b/src/web_server/web_server.h +deleted file mode 100644 +index ce6918281d77..000000000000 +--- a/src/web_server/web_server.h ++++ /dev/null +@@ -1,27 +0,0 @@ +-/****************************************************************************** +- * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +- * gala-gopher licensed under the Mulan PSL v2. +- * You can use this software according to the terms and conditions of the Mulan PSL v2. +- * You may obtain a copy of Mulan PSL v2 at: +- * http://license.coscl.org.cn/MulanPSL2 +- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +- * PURPOSE. +- * See the Mulan PSL v2 for more details. +- * Author: Vchanger +- * Create: 2023-11-06 +- * Description: +- ******************************************************************************/ +- +-#ifndef __WEB_SERVER_H__ +-#define __WEB_SERVER_H__ +- +-#include +- +-#include "config.h" +-#include "base.h" +-#include "http_server.h" +- +-int init_web_server_mgr(http_server_mgr_s *web_server, HttpServerConfig *config); +-#endif +- +diff --git a/test/fuzz_test/CMakeLists.txt b/test/fuzz_test/CMakeLists.txt +index 8c3bb5328442..a1e0876df6ff 100644 +--- a/test/fuzz_test/CMakeLists.txt ++++ b/test/fuzz_test/CMakeLists.txt +@@ -48,7 +48,6 @@ SET(SOURCES processRequest_fuzzer.c + + ${FIFO_DIR}/fifo.c + ${META_DIR}/meta.c +- ${HTTPSERVER_DIR}/http_server.c + + ${PROBE_DIR}/probe.c + ${PROBE_DIR}/extend_probe.c +@@ -73,8 +72,6 @@ SET(SOURCES processRequest_fuzzer.c + ${COMMON_DIR}/histogram.c + ${COMMON_DIR}/core_btf.c + +- ${WEB_SERVER_DIR}/web_server.c +- ${RESTAPI_DIR}/rest_server.c + ${EBPF_PROBE_DIR}/src/lib/java_support.c + + ${CMD_DIR}/cmd_common.c +diff --git a/test/test_extend_probes/all_common_test/CMakeLists.txt b/test/test_extend_probes/all_common_test/CMakeLists.txt +index f57709a334e6..ea376b934e10 100644 +--- a/test/test_extend_probes/all_common_test/CMakeLists.txt ++++ b/test/test_extend_probes/all_common_test/CMakeLists.txt +@@ -84,7 +84,6 @@ message("RESTAPI_DIR: ${RESTAPI_DIR}") + + SET(SOURCE + test_common_main.cpp +- test_rest_server.cpp + warp_header.cpp + test_ingress.cpp + common_stub.cpp +@@ -99,7 +98,6 @@ SET(SOURCE + + ${FIFO_DIR}/fifo.c + ${META_DIR}/meta.c +- ${HTTPSERVER_DIR}/http_server.c + + ${PROBE_DIR}/probe.c + ${PROBE_DIR}/extend_probe.c +@@ -122,8 +120,6 @@ SET(SOURCE + ${COMMON_DIR}/histogram.c + ${COMMON_DIR}/core_btf.c + +- ${WEB_SERVER_DIR}/web_server.c +- ${RESTAPI_DIR}/rest_server.c + ${EBPF_PROBE_DIR}/src/lib/java_support.c + + ${CMD_DIR}/cmd_common.c +diff --git a/test/test_modules/CMakeLists.txt b/test/test_modules/CMakeLists.txt +index f4688a145f04..4644f0813529 100644 +--- a/test/test_modules/CMakeLists.txt ++++ b/test/test_modules/CMakeLists.txt +@@ -42,7 +42,6 @@ SET(SOURCES main.c + + ${FIFO_DIR}/fifo.c + ${META_DIR}/meta.c +- ${HTTPSERVER_DIR}/http_server.c + + ${IMDB_DIR}/imdb.c + ${IMDB_DIR}/metrics.c +@@ -58,7 +57,6 @@ SET(SOURCES main.c + ${COMMON_DIR}/histogram.c + ${COMMON_DIR}/ipc.c + +- ${WEB_SERVER_DIR}/web_server.c + ${EBPF_PROBE_DIR}/src/lib/java_support.c + ) + +diff --git a/test/test_probes/CMakeLists.txt b/test/test_probes/CMakeLists.txt +index 4e1a044cdf4a..2d3618fc2570 100644 +--- a/test/test_probes/CMakeLists.txt ++++ b/test/test_probes/CMakeLists.txt +@@ -56,7 +56,6 @@ SET(SOURCES + + ${FIFO_DIR}/fifo.c + ${META_DIR}/meta.c +- ${HTTPSERVER_DIR}/http_server.c + + ${PROBE_DIR}/probe.c + ${PROBE_DIR}/extend_probe.c +@@ -85,8 +84,6 @@ SET(SOURCES + ${COMMON_DIR}/histogram.c + ${COMMON_DIR}/core_btf.c + +- ${WEB_SERVER_DIR}/web_server.c +- ${RESTAPI_DIR}/rest_server.c + ${EBPF_PROBE_DIR}/src/lib/java_support.c + ) + FOREACH(FILE ${PROBES_C_LIST}) +-- +2.33.0 + -- Gitee From a7f011fdb2488f56dea34d348d8107e19cba7dac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A4=E4=BA=86=E4=B8=8A=E7=8F=AD=E5=AF=B9=E5=95=A5?= =?UTF-8?q?=E9=83=BD=E6=84=9F=E5=85=B4=E8=B6=A3?= Date: Thu, 27 Nov 2025 07:22:46 +0000 Subject: [PATCH 2/2] protect strdup for probe name and probe bin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 除了上班对啥都感兴趣 --- ...-strdup-for-probe-name-and-probe-bin.patch | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 huawei-protect-strdup-for-probe-name-and-probe-bin.patch diff --git a/huawei-protect-strdup-for-probe-name-and-probe-bin.patch b/huawei-protect-strdup-for-probe-name-and-probe-bin.patch new file mode 100644 index 0000000..2ceafe6 --- /dev/null +++ b/huawei-protect-strdup-for-probe-name-and-probe-bin.patch @@ -0,0 +1,106 @@ +From 2aa719bc3e24f6dae7ab9206ad499678acee2775 Mon Sep 17 00:00:00 2001 +From: yangyongguang +Date: Fri, 6 Dec 2024 18:28:00 +0800 +Subject: [PATCH] 2 + +--- + src/lib/probe/probe_mng.c | 31 ++++++++++++++++++++++++------- + 1 file changed, 24 insertions(+), 7 deletions(-) + +diff --git a/src/lib/probe/probe_mng.c b/src/lib/probe/probe_mng.c +index 769c6f3..058bfc0 100644 +--- a/src/lib/probe/probe_mng.c ++++ b/src/lib/probe/probe_mng.c +@@ -38,7 +38,7 @@ + #include "probe_mng.h" + + static int set_probe_bin(struct probe_s *probe, const char *bin); +-static void init_probe_bin(struct probe_s *probe, enum probe_type_e probe_type); ++static int init_probe_bin(struct probe_s *probe, enum probe_type_e probe_type); + + struct probe_define_s probe_define[] = { + {"baseinfo", "system_infos", PROBE_BASEINFO, ENABLE_BASEINFO}, +@@ -388,6 +388,9 @@ static struct probe_s* new_probe(const char* name, enum probe_type_e probe_type) + + memset(probe, 0, sizeof(struct probe_s)); + probe->name = strdup(name); ++ if (probe->name == NULL) { ++ goto err; ++ } + + ret = pthread_rwlock_init(&probe->rwlock, NULL); + if (ret) { +@@ -404,7 +407,10 @@ static struct probe_s* new_probe(const char* name, enum probe_type_e probe_type) + } + probe->fifo->probe = probe; + probe->probe_type = probe_type; +- init_probe_bin(probe, probe_type); ++ ret = init_probe_bin(probe, probe_type); ++ if (ret) { ++ goto err; ++ } + set_default_params(probe); + + ret = attach_probe_fd(g_probe_mng, probe); +@@ -500,14 +506,17 @@ static int set_probe_bin(struct probe_s *probe, const char *bin) + } + + probe->bin = strdup(bin); ++ if (probe->bin == NULL) { ++ return -1; ++ } + return 0; + } + #endif + +-static void init_probe_bin(struct probe_s *probe, enum probe_type_e probe_type) ++static int init_probe_bin(struct probe_s *probe, enum probe_type_e probe_type) + { + if (probe_type >= PROBE_TYPE_MAX) { +- return; ++ return -1; + } + + if (probe_type != PROBE_CUSTOM) { +@@ -515,6 +524,9 @@ static void init_probe_bin(struct probe_s *probe, enum probe_type_e probe_type) + } else { + probe->bin = strdup("/extern"); + } ++ if (probe->bin == NULL) { ++ return -1; ++ } + + if (is_extend_probe(probe)) { + probe->is_extend_probe = 1; +@@ -522,13 +534,12 @@ static void init_probe_bin(struct probe_s *probe, enum probe_type_e probe_type) + } else { + int ret = set_probe_entry(probe); + if (ret) { +- return; ++ return -1; + } + probe->is_extend_probe = 0; + probe->cb = native_probe_thread_cb; + } +- +- return; ++ return 0; + } + + static int get_probe_pid(struct probe_s *probe) +@@ -1564,6 +1575,12 @@ static struct probe_s* new_custom(const char* name, const u32 custom_index) + } + + probe->name = strdup(name); ++ if (probe->name == NULL) { ++ ERROR("[CUSTOM INI]Probe name memory strdup failure.\n"); ++ free(probe); ++ return NULL; ++ } ++ + probe->probe_type = PROBE_CUSTOM; + probe->custom.index = custom_index; + probe->bin = NULL; +-- +2.33.0 + -- Gitee