From 096bbda71ea301fe6dbdc603b5cbf06bfc0d73ed Mon Sep 17 00:00:00 2001 From: 鏉ㄥ▉ Date: Tue, 20 Jun 2023 16:01:35 +0800 Subject: 馃 refactor(Remove obsolete code): makefile and dictator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Makefile | 345 -------- src/common/Makefile | 52 -- src/common/sapp_mem.c | 36 +- src/config/Makefile | 52 -- src/config/config_parse.cpp | 2 - src/dealpkt/Makefile | 111 --- src/dealpkt/deal_tcp.c | 36 - src/dealpkt/plug_support.c | 41 - src/entry/CMakeLists.txt | 10 +- src/entry/Makefile | 117 --- src/extensions/CMakeLists.txt | 15 +- src/extensions/Makefile | 150 ---- src/extensions/sapp_assistant.cpp | 432 +--------- src/extensions/sapp_metrics.cpp | 433 +++++++++++ src/packet_io/CMakeLists.txt | 26 +- src/packet_io/Makefile | 195 ----- src/plugin/Makefile | 8 - src/plugin/src/Makefile | 40 - src/project/Makefile | 41 - src/project/project_requirement.c | 26 - src/project/terminal_tag.c | 391 ---------- src/project/terminal_tag.h | 61 -- src/readme_GBK.txt | 748 ------------------ src/readme_UTF8.txt | 748 ------------------ src/sapp_dev/sapp_global_val.c | 3 - src/sapp_dev/sapp_init.c | 27 - src/support/CMakeLists.txt | 1 - src/support/MESA_sleep/Makefile | 22 - src/support/MESA_socket_wrap/Makefile | 9 - src/support/MESA_socket_wrap/example/Makefile | 28 - src/support/MESA_socket_wrap/src/Makefile | 26 - src/support/dictator2/lib/.gitignore | 6 - src/support/dictator2/readme.txt | 4 - src/support/dictator2/src/CMakeLists.txt | 19 - .../dictator2/src/D_internal/D_kernel_list.cpp | 88 --- .../dictator2/src/D_internal/D_kernel_list.h | 39 - .../dictator2/src/D_internal/MESA_hash_v2.cpp | 655 ---------------- .../dictator2/src/D_internal/MESA_hash_v2.h | 262 ------- .../dictator2/src/D_internal/MESA_list_v2.cpp | 361 --------- .../dictator2/src/D_internal/MESA_list_v2.h | 43 - src/support/dictator2/src/D_internal/Makefile | 20 - .../dictator2/src/D_internal/list_common.cpp | 155 ---- src/support/dictator2/src/D_internal/list_common.h | 18 - src/support/dictator2/src/D_internal/readme.txt | 4 - src/support/dictator2/src/Makefile | 7 - src/support/dictator2/src/Makefile_debug | 43 - src/support/dictator2/src/Makefile_nodebug | 44 -- src/support/dictator2/src/dictator.cpp | 866 --------------------- src/support/dictator2/src/dictator.h | 30 - src/support/dictator2/src/dictator_core.h | 191 ----- src/support/dictator2/src/dictator_debuger.cpp | 816 ------------------- src/support/dictator2/src/dummy_hash.h | 67 -- src/support/dictator2/src/internal_mp.h | 11 - src/support/dictator2/src/mr_hugepage.h | 20 - src/support/dictator2/test/Makefile | 4 - src/support/dictator2/test/test.cpp | 90 --- src/support/md5/Makefile | 13 - src/support/symbol_check/Makefile | 24 - src/support/timestamp_record/Makefile | 19 - src/support/tomlc99_wrap/Makefile | 49 -- src/timer/Makefile | 52 -- 61 files changed, 448 insertions(+), 7804 deletions(-) delete mode 100644 src/Makefile delete mode 100644 src/common/Makefile delete mode 100644 src/config/Makefile delete mode 100644 src/dealpkt/Makefile delete mode 100644 src/entry/Makefile delete mode 100644 src/extensions/Makefile create mode 100644 src/extensions/sapp_metrics.cpp delete mode 100644 src/packet_io/Makefile delete mode 100644 src/plugin/Makefile delete mode 100644 src/plugin/src/Makefile delete mode 100644 src/project/Makefile delete mode 100644 src/project/terminal_tag.c delete mode 100644 src/project/terminal_tag.h delete mode 100644 src/readme_GBK.txt delete mode 100644 src/readme_UTF8.txt delete mode 100644 src/support/MESA_sleep/Makefile delete mode 100644 src/support/MESA_socket_wrap/Makefile delete mode 100644 src/support/MESA_socket_wrap/example/Makefile delete mode 100644 src/support/MESA_socket_wrap/src/Makefile delete mode 100644 src/support/dictator2/lib/.gitignore delete mode 100644 src/support/dictator2/readme.txt delete mode 100644 src/support/dictator2/src/CMakeLists.txt delete mode 100644 src/support/dictator2/src/D_internal/D_kernel_list.cpp delete mode 100644 src/support/dictator2/src/D_internal/D_kernel_list.h delete mode 100644 src/support/dictator2/src/D_internal/MESA_hash_v2.cpp delete mode 100644 src/support/dictator2/src/D_internal/MESA_hash_v2.h delete mode 100644 src/support/dictator2/src/D_internal/MESA_list_v2.cpp delete mode 100644 src/support/dictator2/src/D_internal/MESA_list_v2.h delete mode 100644 src/support/dictator2/src/D_internal/Makefile delete mode 100644 src/support/dictator2/src/D_internal/list_common.cpp delete mode 100644 src/support/dictator2/src/D_internal/list_common.h delete mode 100644 src/support/dictator2/src/D_internal/readme.txt delete mode 100644 src/support/dictator2/src/Makefile delete mode 100644 src/support/dictator2/src/Makefile_debug delete mode 100644 src/support/dictator2/src/Makefile_nodebug delete mode 100644 src/support/dictator2/src/dictator.cpp delete mode 100644 src/support/dictator2/src/dictator.h delete mode 100644 src/support/dictator2/src/dictator_core.h delete mode 100644 src/support/dictator2/src/dictator_debuger.cpp delete mode 100644 src/support/dictator2/src/dummy_hash.h delete mode 100644 src/support/dictator2/src/internal_mp.h delete mode 100644 src/support/dictator2/src/mr_hugepage.h delete mode 100644 src/support/dictator2/test/Makefile delete mode 100644 src/support/dictator2/test/test.cpp delete mode 100644 src/support/md5/Makefile delete mode 100644 src/support/symbol_check/Makefile delete mode 100644 src/support/timestamp_record/Makefile delete mode 100644 src/support/tomlc99_wrap/Makefile delete mode 100644 src/timer/Makefile (limited to 'src') diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 4288742..0000000 --- a/src/Makefile +++ /dev/null @@ -1,345 +0,0 @@ -##################### MESA Makefile Common Definition Start ################# -MESA_MAKE_VERSION=20170626 - -#CC=gcc -CC=g++ -CCC=g++ -CFLAGS = -#CFLAGS = -march=native -#CFLAGS += -D__FAVOR_BSD=1 -D__USE_BSD=1 -D_GNU_SOURCE=1 -Werror -DMESA_SAPP_PLATFORM=1 -CFLAGS += -D__FAVOR_BSD=1 -D__USE_BSD=1 -D_GNU_SOURCE=1 -DMESA_SAPP_PLATFORM=1 -LIBS= -L/opt/MESA/lib -INC=-I./ -INC+=-I/opt/MESA/include -OBJS= - -target_mode=elf - -_MODE_PCAP=pcap -_MODE_PAG=pag -_MODE_PPF=ppf -_MODE_PFRING=pfring -_MODE_DPDK=dpdk -_MODE_PAG_N95=pag_n95 -_MODE_TOPSEC=topsec -_MODE_MARSIO=marsio -_MODE_SMITH=smith -_MODE_DPDK_VXLAN=dpdk_vxlan -_MODE_PAG_MARSIO=pag_marsio -_MODE_IPFILE=ipfile -_MODE_TUN=tun -_MODE_CHK=0 -iomode=tun - -_OPT0=0 -_OPT1=1 -_OPT2=2 -_OPT3=3 -_OPT_HIGH_PERF=high_perf -#default level is 0 -opt=0 -_OPT_CHK=0 - -_DEBUG_CHK=0 -_DEBUG0=0 -_DEBUG1=1 -_DEBUG2=2 -#default is 2 -debug=2 -__TARGET_MODE_ELF=elf -__TARGET_MODE_SO=so - -ifeq ($(target_mode), $(__TARGET_MODE_ELF)) - # -else - ifeq ($(target_mode), $(__TARGET_MODE_SO)) - #CFLAGS += -DSAPP_AS_TARGET_SO=1 -fvisibility=hidden - CFLAGS += -DSAPP_AS_TARGET_SO=1 - debug=0 - else - $(error target mode args error, please use make help) - exit - endif -endif - -ifeq ($(debug), $(_DEBUG0)) -#do nothing -_DEBUG_CHK=1 -endif - -ifeq ($(debug), $(_DEBUG1)) -CFLAGS += -g -_DEBUG_CHK=1 -#do nothing -endif -ifeq ($(debug), $(_DEBUG2)) -CFLAGS += -g -DDEBUG=1 -_DEBUG_CHK=1 -endif - -ifneq ($(_DEBUG_CHK), 0) -else - ifeq ($(debug), 0) - # - else - $(error args debug error) - exit - endif -endif - -ifeq ($(iomode), $(_MODE_PCAP)) -_MODE_CHK=1 -LIBS += -lpcap -endif -ifeq ($(iomode), $(_MODE_PAG)) -LIBS += -lpag -lpthread -_MODE_CHK=1 -endif -ifeq ($(iomode), $(_MODE_PPF)) -LIBS += -lppf -_MODE_CHK=1 -endif -ifeq ($(iomode), $(_MODE_PFRING)) -LIBS += -lpfring -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_DPDK)) -LIBS += -lmarsio -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_TOPSEC)) -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_MARSIO)) -LIBS += -lmarsio -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_SMITH)) -LIBS += -lagent_smith -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_DPDK_VXLAN)) -LIBS += -lmarsio -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_PAG_MARSIO)) -LIBS += -lpag -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_IPFILE)) -_MODE_CHK=1 -endif - -ifeq ($(iomode), $(_MODE_TUN)) -_MODE_CHK=1 -endif - - -ifneq ($(_MODE_CHK), 0) -else - ifeq ($(iomode), "pcap") - else - $(error args iomode error) - exit - endif -endif - -ifeq ($(opt), $(_OPT0)) -opt=0 -CFLAGS += -O0 -_OPT_CHK=1 -endif -ifeq ($(opt), $(_OPT1)) -opt=1 -CFLAGS += -O1 -_OPT_CHK=1 -endif -ifeq ($(opt), $(_OPT2)) -opt=2 -CFLAGS += -O2 -_OPT_CHK=1 -endif -ifeq ($(opt), $(_OPT3)) -opt=3 -CFLAGS += -O3 -_OPT_CHK=1 -endif -ifeq ($(opt), $(_OPT_HIGH_PERF)) -opt=2 -CFLAGS += -O2 -DHIGH_PERF=1 -UDEBUG -march=native -_OPT_CHK=1 -endif - -ifneq ($(_OPT_CHK), 0) -else - ifeq ($(opt), 0) - # - else - $(error args opt error) - exit - endif -endif - -__LINK_MODE_DYNAMIC=dynamic -__LINK_MODE_STATIC=static -link_mode=static - -ifeq ($(link_mode), $(__LINK_MODE_STATIC)) - CFLAGS += -DLINK_MODE_STATIC=1 -else - ifeq ($(link_mode), $(__LINK_MODE_DYNAMIC)) - CFLAGS += -DLINK_MODE_DYNAMIC=1 - else - $(error link_mode args error, please use make help) - exit - endif -endif -.PHONY:help clean target - -export CC -export CCC -export CFLAGS -export LIBS -export INC -export iomode -export debug -export _OPT_HIGH_PERF -export _DEBUG0 -export _DEBUG1 -export _DEBUG2 -export _MODE_PCAP -export _MODE_PAG -export _MODE_PPF -export _MODE_PFRING -export _MODE_DPDK -export _MODE_TOPSEC -export _MODE_MARSIO -export _MODE_SMITH -export _MODE_DPDK_VXLAN -export _MODE_IPFILE -export _MODE_PAG_MARSIO -export target_mode -export __TARGET_MODE_ELF -export __TARGET_MODE_SO -export link_mode -export __LINK_MODE_STATIC -export __LINK_MODE_DYNAMIC - -target:all - -version: - @echo -e "MESA Makefile version:\033[31;49;1m $(MESA_MAKE_VERSION)\033[0m" - -help: - @echo -e "MESA Makefile version:\033[31;49;1m $(MESA_MAKE_VERSION)\033[0m" - @echo "MESA-Makefile usage:" - @echo -e "\treserved args:" - @echo -e "\t\t\033[31;49;1m debug={0,1,2},0:release version; 1:-g; 2:-g -DDEBUG, default is 2.\033[0m" - @echo -e "\t\t\033[31;49;1m opt={0,1,2,3,high_perf}, optimize level, default is 0.\033[0m" - @echo -e "\t\t\033[31;49;1m iomode={pcap,ppf,pag,prfing,dpdk,tilera,topsec,ipfile,marsio,smith,dpdk_vxlan,pag_marsio}, default is pcap.\033[0m" - @echo -e "\t\t\033[31;49;1m target_mode={elf, so}, default is elf.\033[0m" - @echo -e "\t\t\033[31;49;1m link_mode={dynamic, static}, default is dynamic.\033[0m" - -##################### MESA Makefile Common Definition End #################### - -YES=1 -NO=0 -USE_MEM_POOL=$(YES) -#USE_MEM_POOL=$(NO) -USE_PAG_GET_FRAME=$(YES) -#USE_PAG_GET_FRAME=$(NO) -INSTALL_PATH=./run - - - -MD5_STREAM_BASE=$(shell md5sum "../include/public/stream_inc/stream_base.h"|cut -d ' ' -f1) -MD5_STREAM_ENTRY=$(shell md5sum "../include/public/stream_inc/stream_entry.h"|cut -d ' ' -f1) -MD5_STREAM_CONTROL=$(shell md5sum "../include/public/stream_inc/stream_control.h"|cut -d ' ' -f1) -MD5_STREAM_INJECT=$(shell md5sum "../include/public/stream_inc/stream_inject.h"|cut -d ' ' -f1) -MD5_STREAM_PROJECT=$(shell md5sum "../include/public/stream_inc/stream_project.h"|cut -d ' ' -f1) -MD5_STREAM_PROXY=$(shell md5sum "../include/public/stream_inc/stream_proxy.h"|cut -d ' ' -f1) -MD5_STREAM_RAWPKT=$(shell md5sum "../include/public/stream_inc/stream_rawpkt.h"|cut -d ' ' -f1) -MD5_STREAM_TUNNEL=$(shell md5sum "../include/public/stream_inc/stream_tunnel.h"|cut -d ' ' -f1) - -HEADER_CHECK_FLAGS += -DSTREAM_BASE_MD5_CHECK=\"$(MD5_STREAM_BASE)\" -HEADER_CHECK_FLAGS += -DSTREAM_CONTROL_MD5_CHECK=\"$(MD5_STREAM_CONTROL)\" -HEADER_CHECK_FLAGS += -DSTREAM_ENTRY_MD5_CHECK=\"$(MD5_STREAM_ENTRY)\" -HEADER_CHECK_FLAGS += -DSTREAM_INJECT_MD5_CHECK=\"$(MD5_STREAM_INJECT)\" -HEADER_CHECK_FLAGS += -DSTREAM_PROJECT_MD5_CHECK=\"$(MD5_STREAM_PROJECT)\" -HEADER_CHECK_FLAGS += -DSTREAM_PROXY_MD5_CHECK=\"$(MD5_STREAM_PROXY)\" -HEADER_CHECK_FLAGS += -DSTREAM_RAWPKT_MD5_CHECK=\"$(MD5_STREAM_RAWPKT)\" -HEADER_CHECK_FLAGS += -DSTREAM_TUNNEL_MD5_CHECK=\"$(MD5_STREAM_TUNNEL)\" - -GIT_BRANCH=$(shell git symbolic-ref --short -q HEAD) -GIT_SHA1=$(shell git rev-parse HEAD) -MAKE_TIME=$(shell date "+%Y-%m-%d_%H:%M:%S") -VERSION_FLAGS += -DGITVER=\"3.0.0-$(GIT_BRANCH)-$(GIT_SHA1)-$(MAKE_TIME)\" - -CFLAGS += ${HEADER_CHECK_FLAGS} ${VERSION_FLAGS} -CXXFLAGS += ${HEADER_CHECK_FLAGS} ${VERSION_FLAGS} - - -export USE_MEM_POOL -export USE_PAG_GET_FRAME -export YES -export NO - -all: - cd support/tomlc99_wrap; $(MAKE); - cd support/libping; $(MAKE); - cd support/avl_tree; $(MAKE); - cd support/MESA_sleep; $(MAKE); - cd support/dictator2/src; $(MAKE); - cd support/md5; $(MAKE); - cd support/rb_tree; $(MAKE); - cd support/symbol_check; $(MAKE); - cd support/timestamp_record; $(MAKE); - cd support/iknow; $(MAKE); - cd support/MESA_socket_wrap; $(MAKE); - cd support/c3_client; $(MAKE); - cd config; $(MAKE); - cd common; $(MAKE); - cd dealpkt; $(MAKE); - cd packet_io; $(MAKE); - cd project; $(MAKE); - cd plugin; $(MAKE); - cd inner_plug; $(MAKE); - cd timer; $(MAKE); - cd entry; $(MAKE); - -clean: - cd common; $(MAKE) clean; - cd dealpkt; $(MAKE) clean; - cd packet_io; $(MAKE) clean; - cd project; $(MAKE) clean; - cd plugin; $(MAKE) clean; - cd inner_plug; $(MAKE) clean; - cd entry; $(MAKE) clean; - cd config; $(MAKE) clean; - cd timer; $(MAKE) clean; - cd support/c3_client; $(MAKE) clean; - cd support/dictator2/src; $(MAKE) clean; - cd support/MESA_sleep; $(MAKE) clean; - cd support/md5; $(MAKE) clean; - cd support/rb_tree; $(MAKE) clean; - cd support/symbol_check; $(MAKE) clean; - cd support/timestamp_record; $(MAKE) clean; - cd support/iknow; $(MAKE) clean; - cd support/MESA_socket_wrap; $(MAKE) clean; - cd support/avl_tree; $(MAKE) clean; - cd support/libping; $(MAKE) clean; - cd support/tomlc99_wrap; $(MAKE) clean; - -install: - mkdir -p /opt/MESA/include; - mkdir -p /opt/MESA/lib; - cp -r -f include/support/pcap* /opt/MESA/include - ln -sf /usr/lib64/libpcap.so.1 /opt/MESA/lib/libpcap.so; - cp packet_io/*.so $(INSTALL_PATH)/platform_lib/ diff --git a/src/common/Makefile b/src/common/Makefile deleted file mode 100644 index df11f31..0000000 --- a/src/common/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -#opt: OPTFLAGS = -O2 -#export OPTFLAGS - -CC = g++ -CCC = g++ -CFLAGS += -Wall -CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -CFLAGS += $(OPTFLAGS) -CFLAGS += $(PACKET_TAG_863) -CFLAGS += -DPLATFORM_NSDPF_PAPP=1 - -LIBPATH = ../lib - -H_DIR += $(INC) -H_DIR += -I../../include -H_DIR += -I../../include/private -H_DIR += -I../../include/public -H_DIR += -I../../include/support - -H_DIR += -I/opt/MESA/include -H_DIR += -I/opt/MESA/include/MESA - -TARGET = libcommon.a - -OBJS= net_common.o stream_addr_inet.o linux_kernel_jhash.o sapp_log.o - -ifeq ($(IIEFD_DUAL_STACK), $(YES)) -CFLAGS += -g -DIIEFD_DUAL_STACK=1 -endif - -ifeq ($(USE_MEM_POOL), 1) -CFLAGS += -DUSE_MEMPOOL=1 -endif - - -all: $(TARGET) - -$(TARGET): $(OBJS) - rm -f $@ ;ar -r $@ $^; - cp $(TARGET) $(LIBPATH) - -.c.o: - $(CC) -c $(CFLAGS) -I. $(H_DIR) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(H_DIR) $< - -clean: - rm -f *.o $(TARGET) *~ - -opt: - $(MAKE) all diff --git a/src/common/sapp_mem.c b/src/common/sapp_mem.c index 465e58c..e921de0 100644 --- a/src/common/sapp_mem.c +++ b/src/common/sapp_mem.c @@ -6,11 +6,7 @@ extern "C" { #endif -extern void *__dictator_malloc(int t_seq,size_t size); -extern void __dictator_free(int t_seq,void*p); -/* 此处单独使用一个全局变量, 为了判断是否开启了dictator, 不能预先分配内存 */ -int g_sapp_mem_use_dictator = 1; int g_sapp_global_mem_used_block = 0; int g_sapp_global_mem_used_bytes = 0; @@ -61,15 +57,7 @@ void *sapp_mem_malloc(sapp_mem_type_t type, int thread_seq, int size) sapp_private_mem_t *mhdr; sapp_mem_used_stat_t *mem_used_stat; -#if USE_MEMPOOL - if(g_sapp_mem_use_dictator){ - ptr = __dictator_malloc(thread_seq, size+sizeof(sapp_private_mem_t)); - }else{ - ptr = (char *)malloc(size+sizeof(sapp_private_mem_t)); - } -#else ptr = (char *)malloc(size+sizeof(sapp_private_mem_t)); -#endif mhdr = (sapp_private_mem_t *)ptr; @@ -99,17 +87,7 @@ void *sapp_mem_calloc(sapp_mem_type_t type, int thread_seq, int size) char *ptr; sapp_private_mem_t *mhdr; sapp_mem_used_stat_t *mem_used_stat; - -#if USE_MEMPOOL - if(g_sapp_mem_use_dictator){ - ptr = __dictator_malloc(thread_seq, size+sizeof(sapp_private_mem_t)); - memset(ptr, 0, size+sizeof(sapp_private_mem_t)); - }else{ - ptr = (char *)calloc(1, size+sizeof(sapp_private_mem_t)); - } -#else ptr = (char *)calloc(1, size+sizeof(sapp_private_mem_t)); -#endif mhdr = (sapp_private_mem_t *)ptr; @@ -156,19 +134,7 @@ void sapp_mem_free(sapp_mem_type_t type, int thread_seq, void *data) mem_used_stat->mem_used_block[SAPP_MEM_DYN_MEM_HDR]--; mem_used_stat->mem_used_bytes[SAPP_MEM_DYN_MEM_HDR] -= sizeof(sapp_private_mem_t); - - -#if USE_MEMPOOL - if(g_sapp_mem_use_dictator){ - __dictator_free(thread_seq, (void *)mhdr); - }else{ - free((void *)mhdr); - } -#else - free((void *)mhdr); -#endif - - + free((void *)mhdr); } void *sapp_mem_realloc(sapp_mem_type_t type, int thread_seq, void *old_ptr, int size) diff --git a/src/config/Makefile b/src/config/Makefile deleted file mode 100644 index d76eaaf..0000000 --- a/src/config/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -#opt: OPTFLAGS = -O2 -#export OPTFLAGS - -CC = g++ -CCC = g++ -CFLAGS += -Wall -CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -CFLAGS += $(OPTFLAGS) -CFLAGS += $(PACKET_TAG_863) -CFLAGS += -DPLATFORM_NSDPF_PAPP=1 - -LIBPATH = ../lib - -H_DIR += $(INC) -H_DIR += -I../../include -H_DIR += -I../../include/private -H_DIR += -I../../include/public -H_DIR += -I../../include/support - -H_DIR += -I/opt/MESA/include -H_DIR += -I/opt/MESA/include/MESA - -TARGET = libconfig.a - -OBJS=cmd_args.o config_parse.o - -ifeq ($(IIEFD_DUAL_STACK), $(YES)) -CFLAGS += -g -DIIEFD_DUAL_STACK=1 -endif - -ifeq ($(USE_MEM_POOL), 1) -CFLAGS += -DUSE_MEMPOOL=1 -endif - - -all: $(TARGET) - -$(TARGET): $(OBJS) - rm -f $@ ;ar -r $@ $^; - cp $(TARGET) $(LIBPATH) - -.c.o: - $(CC) -c $(CFLAGS) -I. $(H_DIR) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(H_DIR) $< - -clean: - rm -f *.o $(TARGET) *~ - -opt: - $(MAKE) all diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp index 8c9fecb..a469111 100644 --- a/src/config/config_parse.cpp +++ b/src/config/config_parse.cpp @@ -1756,8 +1756,6 @@ int sapp_parse_config(void) } - /******************************* MEM *********************************/ - tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"MEM", (char *)"dictator_enable", (int *)&pconfig->mem.dictator_enable, 1); /******************************* PACKET_IO ******************************/ diff --git a/src/dealpkt/Makefile b/src/dealpkt/Makefile deleted file mode 100644 index c338f28..0000000 --- a/src/dealpkt/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -#opt: OPTFLAGS = -O2 -#export OPTFLAGS - -CC = g++ -CCC = g++ -CFLAGS += -Wall -CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -CFLAGS += $(OPTFLAGS) -CFLAGS += $(PACKET_TAG_863) -CFLAGS += -DPLATFORM_NSDPF_PAPP=1 - -LIBPATH = ../lib - -H_DIR += $(INC) - -H_DIR += -I../../include/ -H_DIR += -I../../include/public -H_DIR += -I../../include/private -H_DIR += -I../../include/support -H_DIR += -I/opt/MESA/include -H_DIR += -I/opt/MESA/include/MESA -H_DIR += -I/opt/mrzcpd/include - -TARGET = libdealpkt.a - -OBJS=deal_udp.o deal_tcp.o stream_manage.o callapp.o deal_ipv6.o deal_ipv4.o deal_vlan.o ip_reassembly.o hash.o synflood_detect.o -OBJS+=deal_ethernet.o deal_arp.o deal_pppoe.o deal_gre.o deal_teredo.o -OBJS += deal_icmp.o -OBJS += g_device.o -OBJS += deal_mpls.o -OBJS += deal_proxy.o -OBJS += deal_ppp.o -OBJS += deal_pptp.o -OBJS += plug_support.o -OBJS += deal_l2tp.o -OBJS += deal_mac_in_mac.o -OBJS += deal_gprs_tunnel.o - - -ifeq ($(IIEFD_DUAL_STACK), $(YES)) -CFLAGS += -g -DIIEFD_DUAL_STACK=1 -endif - -ifeq ($(USE_MEM_POOL), 1) -CFLAGS += -DUSE_MEMPOOL=1 -endif - -ifeq ($(iomode), $(_MODE_PCAP)) -CFLAGS += -DIOMODE_PCAP=1 -endif - -ifeq ($(iomode), $(_MODE_PAG)) -CFLAGS += -DIOMODE_PAG=1 -endif - -ifeq ($(iomode), $(_MODE_PPF)) -CFLAGS += -DIOMODE_PPF=1 -endif - -ifeq ($(iomode), $(_MODE_PFRING)) -CFLAGS += -DIOMODE_PFRING=1 -endif - -ifeq ($(iomode), $(_MODE_DPDK)) -CFLAGS += -DIOMODE_DPDK=1 -endif - -ifeq ($(iomode), $(_MODE_TOPSEC)) -CFLAGS += -DIOMODE_TOPSEC=1 -endif - -ifeq ($(iomode), $(_MODE_IPFILE)) -CFLAGS += -DIOMODE_IPFILE=1 -endif - -ifeq ($(iomode), $(_MODE_MARSIO)) -CFLAGS += -DIOMODE_MARSIO=1 -endif - -ifeq ($(iomode), $(_MODE_SMITH)) -CFLAGS += -DIOMODE_SMITH=1 -endif - -ifeq ($(iomode), $(_MODE_DPDK_VXLAN)) -CFLAGS += -DIOMODE_DPDK_VXLAN=1 -endif - -ifeq ($(iomode), $(_MODE_PAG_MARSIO)) -CFLAGS += -DIOMODE_PAG_MARSIO=1 -endif - -all: $(TARGET) - -$(TARGET): $(OBJS) - rm -f $@ ;ar -r $@ $^; - cp $(TARGET) $(LIBPATH) - -linux_kernel_jhash.o:linux_kernel_jhash.c - $(CC) -c $(CFLAGS) -O3 -I. $(H_DIR) $< - -.c.o: - $(CC) -c $(CFLAGS) -I. $(H_DIR) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(H_DIR) $< - -clean: - rm -f *.o $(TARGET) *~ - -opt: - $(MAKE) all diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c index baa79cd..1db73f8 100644 --- a/src/dealpkt/deal_tcp.c +++ b/src/dealpkt/deal_tcp.c @@ -2051,32 +2051,7 @@ static int tcp_save_unorder(struct streaminfo *a_tcp,struct half_tcpstream *rc struct buf_unorder *packet=NULL; unsigned int this_seq = ntohl (this_tcphdr->th_seq); -#if 0 /* 2015-01-12 lijia modify */ - pakiet = (struct buf_unorder*)dictator_malloc(threadnum,sizeof(struct buf_unorder)); - memset(pakiet, 0, sizeof(struct buf_unorder)); - -/* 2014-10-20 lijia modify, 因IP分片重组后, raw_pkt和tcpdatalen不对应 -raw_pkt指向最后一个分片包, 而tcpdatalen是重组完成后的完整IP包负载! -分别存储! -*/ - if(tcpdatalen > 0){ - pakiet->data = dictator_malloc(threadnum,tcpdatalen); - pakiet->len = tcpdatalen; - memcpy (pakiet->data, tcpdata, tcpdatalen); - } - memcpy(&(pakiet->raw_pkt), stack_raw_pkt, sizeof(raw_pkt_t)); - pakiet->raw_pkt.raw_pkt_data = dictator_malloc(threadnum, stack_raw_pkt->raw_pkt_len); - memcpy((void *)pakiet->raw_pkt.raw_pkt_data, stack_raw_pkt->raw_pkt_data, stack_raw_pkt->raw_pkt_len); - - pakiet->tcpdatalen=tcpdatalen; - pakiet->fin = (this_tcphdr->th_flags & TH_FIN); - pakiet->rst = (this_tcphdr->th_flags & TH_RST); - pakiet->seq = this_seq; - pakiet->urg = (this_tcphdr->th_flags & TH_URG); - pakiet->urg_ptr = ntohs (this_tcphdr->th_urp); -#else packet = tcp_save_unorder_pkt(a_tcp, this_iphdr, stack_raw_pkt, this_tcphdr, tcpdata, tcpdatalen); -#endif for (;;) { @@ -2103,18 +2078,8 @@ raw_pkt指 || (p->seq+p->tcpdatalen) == (this_seq+packet->tcpdatalen) ||after(p->seq+p->tcpdatalen,this_seq+packet->tcpdatalen)) { -#if 0/* 2015-01-12 lijia modify */ - if(pakiet->data){ - dictator_free(threadnum,pakiet->data); - } - dictator_free(threadnum,(void *)pakiet->raw_pkt.raw_pkt_data); - pakiet->data = NULL; - dictator_free(threadnum,pakiet); - pakiet = NULL; -#else tcp_free_unorder_pkt(threadnum, packet); -#endif return PASS; } @@ -2846,7 +2811,6 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s { pstream_pr = &pindex_tcp->stream; pstream = &pstream_pr->stream_public; - //terminal_tag_probe(pstream, this_tcphdr, this_iphdr); //add by lqy 20130822 pdetail_pr = (struct tcpdetail_private *)(pindex_tcp->stream.stream_public.pdetail); pdetail = (struct tcpdetail *)(&pdetail_pr->tcpdetail_public); diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c index ea7f9e9..c757f33 100644 --- a/src/dealpkt/plug_support.c +++ b/src/dealpkt/plug_support.c @@ -1766,20 +1766,6 @@ int get_current_thread_cpu_affinity_id(void) -extern int project_req_terminal_tag_id; -/* For863, 用于应用层插件获取本TCP流中对应的用户标签 */ -const unsigned char *get_terminal_tag(struct streaminfo *stream) -{ - unsigned char *terminal_tag; - - if(project_req_terminal_tag_id < 0){ - return NULL; - } - - terminal_tag = (unsigned char *)project_req_get_struct(stream, project_req_terminal_tag_id); - - return (const unsigned char *)terminal_tag; -} int number_is_2powerN(uint n) { @@ -1794,45 +1780,18 @@ int number_is_2powerN(uint n) void *dictator_malloc(int thread_seq,size_t size) { - /* - if(malloccount%100000==0) - { - printf("malloc=%d,free=%d\n",malloccount,freecount); - } - */ - - if(G_DICTATOR_SW){ -#if USE_MEMPOOL - return __dictator_malloc(thread_seq, size); -#endif - } - return malloc(size); } void dictator_free(int thread_seq,void *pbuf) { -#if USE_MEMPOOL - if(G_DICTATOR_SW){ - __dictator_free(thread_seq, pbuf); - } - else -#endif - { #if SAPP_INSECTICIDE *((char *)pbuf) = 0xFE; #endif free(pbuf); - } } void *dictator_realloc(int thread_seq, void *ptr, size_t size) { -#if USE_MEMPOOL - if(G_DICTATOR_SW){ - return __dictator_realloc(thread_seq, ptr, size); - } -#endif - return realloc(ptr, size); } diff --git a/src/entry/CMakeLists.txt b/src/entry/CMakeLists.txt index e871739..c533670 100644 --- a/src/entry/CMakeLists.txt +++ b/src/entry/CMakeLists.txt @@ -28,7 +28,7 @@ add_executable(sapp sapp_main.c) target_compile_options(sapp PUBLIC ${MEM_POOL_DEFINITIONS}) target_link_libraries(sapp nsl pthread dl m pcap) target_link_libraries(sapp MESA_handle_logger MESA_prof_load) -target_link_libraries(sapp sapp_assistant) +target_link_libraries(sapp sapp_assistant sapp_metrics) target_link_libraries(sapp breakpad_mini) target_include_directories(sapp PRIVATE ${SYSTEMD_INCLUDE_DIRS}) @@ -42,18 +42,12 @@ set(SAPP_MODULES timestamp_record md5 packet_io dealpkt project plugctrl common config timer tomlc99_wrap dpdk_ip_hash gdev_assistant inline_keepalive libdabloom-static - sapp_dev sapp_assistant cpu_limit timeout) + sapp_dev sapp_assistant sapp_metrics cpu_limit timeout) if(LIBEVENT_ENABLED STREQUAL "ON") set(SAPP_MODULES ${SAPP_MODULES} libevent-static) endif() -if(MEM_POOL MATCHES "DICTATOR_DEBUG") - set(SAPP_MODULES ${SAPP_MODULES} dictator2_debug) -elseif(MEM_POOL MATCHES "DICTATOR") - set(SAPP_MODULES ${SAPP_MODULES} dictator2) -endif() - target_link_libraries(sapp -Wl,--whole-archive ${SAPP_MODULES} -Wl,--no-whole-archive ${SAPP_DEPEND_DYN_LIB} ${SYSTEMD_LIBRARIES}) target_link_libraries(sapp packet_io_pcap) diff --git a/src/entry/Makefile b/src/entry/Makefile deleted file mode 100644 index 636648e..0000000 --- a/src/entry/Makefile +++ /dev/null @@ -1,117 +0,0 @@ -ifeq ($(target_mode), $(__TARGET_MODE_ELF)) -TARGET=sapp -else -TARGET=MESA_IP_PLUG.so -endif - -all: $(TARGET) -LIB= -LIB_PATH=-L../lib -L/opt/mrzcpd/lib -CFLAGS += -fPIC -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -CFLAGS += -DPLATFORM_NSDPF_PAPP=1 - -ifeq ($(USE_PAG_GET_FRAME), $(YES)) -CFLAGS += -DUSE_PAG_GET_FRAME=1 -else -CFLAGS += -DUSE_PAG_GET_FRAME=0 -endif - -ifeq ($(USE_MEM_POOL), $(YES)) -CFLAGS += -DUSE_MEMPOOL=1 -endif - -CFLAGS += -rdynamic - -ifeq ($(USE_MEM_POOL), $(YES)) -#LD_DICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc -WHOLE_ARCH=../lib/libdealpkt.a ../lib/libproject.a ../lib/libMESA_sleep.a ../lib/libdictator.a ../lib/libtimestamp_record.a -WHOLE_ARCH+=../lib/libavltree.a -WHOLE_ARCH+=../lib/libpacket_io.a -WHOLE_ARCH+=../lib/libcommon.a -else -WHOLE_ARCH=../lib/libdealpkt.a ../lib/libproject.a ../lib/libMESA_sleep.a ../lib/libtimestamp_record.a -WHOLE_ARCH+=../lib/libavltree.a -WHOLE_ARCH+=../lib/libpacket_io.a -WHOLE_ARCH+=../lib/libcommon.a -endif - -ifeq ($(link_mode), $(__LINK_MODE_STATIC)) - WHOLE_ARCH += ../lib/libinner_plug.a -else - LIB += -lsapp_assistant -endif -LDFLAGS = -LDFLAGS += $(LD_DICTATOR) - -LIB+=../lib/plugctrl.a -LIB+=../lib/libmd5.a -LIB+=../lib/librbtree.a -LIB+= ../lib/libsymbol_check.a -LIB+= ../lib/libMESA_socket_wrap.a -ifeq ($(target_mode), $(__TARGET_MODE_SO)) -WHOLE_ARCH += ../lib/libpacket_io.a ../lib/plugctrl.a ../lib/libmd5.a ../lib/librbtree.a ../lib/libsymbol_check.a ../lib/libMESA_socket_wrap.a ../lib/libiknow.a -endif - -WHOLE_ARCH += ../lib/libtomlc99_wrap.a -WHOLE_ARCH += ../lib/libconfig.a -WHOLE_ARCH += ../lib/libtimer.a - -ifeq ($(debug), $(_DEBUG2)) -LIB += ../lib/libiknow.a -lpcap -endif - -ifeq ($(IIEFD_DUAL_STACK), $(YES)) -CFLAGS += -g -DIIEFD_DUAL_STACK=1 -endif -ifeq ($(iomode), $(_MODE_DPDK)) -CFLAGS += -DIOMODE_DPDK=1 -endif - -INC += -I../../include/ -INC += -I../../include/public -INC += -I../../include/private -INC += -I../../include/support -INC+=-I/opt/MESA/include -INC+=-I/opt/MESA/include/MESA -INC+=-I/opt/MESA/include/MESA/stream_inc - -LIB += -L/opt/MESA/lib -lpthread -ldl -LIB += -lMESA_htable -lMESA_handle_logger -lMESA_prof_load -LIB += -lMESA_field_stat2 -#LIB += -lsapp_assistant -LIB += -lcjson -#LIB += -lsesame_door -LIB += -l event - -ifeq ($(iomode), $(_MODE_MARSIO)) -LIB += -lmarsio -endif - -#DEP=support/libMESA_prof_load.so -#DEP+=support/libMESA_htable.so -#DEP+=support/libnet_common.so -#DEP+=support/old_Profile.so -#DEP+=support/libMESA_handle_logger.so -#DEP+=support/liblogger.so - -iiefd_dual_stack: sapp_main.o sapp_init.o - -sapp:sapp_main.o sapp_init.o sapp_global_val.o - g++ -g -Wl,--export-dynamic -o $@ $(CFLAGS) $(INC) $^ $(LDFLAGS) $(LIB_PATH) -Wl,--whole-archive $(WHOLE_ARCH) -Wl,--no-whole-archive $(LIB) - cp ../packet_io/*.so ../../bin/platform_lib/; - cp $@ ../../bin/; - -MESA_IP_PLUG.so:sapp_plug.o sapp_init.o sapp_global_val.o - g++ -g -o $@ -fPIC -shared $^ -Wl,--whole-archive $(WHOLE_ARCH) -Wl,--no-whole-archive $(LIB) - cp $@ ../../bin/ - cp $@ /opt/MESA/lib/libMESA_IP_PLUG.so -sapp_plug.o:sapp_plug.c - g++ -c -g -o $@ -fPIC $^ $(INC) -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DSAPP_AS_TARGET_SO=1 -.c.o: - $(CC) -c $(CFLAGS) -I. $(INC) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(INC) $< - -clean: - rm -f $(TARGET) *.o diff --git a/src/extensions/CMakeLists.txt b/src/extensions/CMakeLists.txt index 897f33c..86581af 100644 --- a/src/extensions/CMakeLists.txt +++ b/src/extensions/CMakeLists.txt @@ -26,14 +26,9 @@ set_target_properties(isakmp_protocol_plug PROPERTIES PREFIX "") add_library(inline_keepalive STATIC inline_keepalive.cpp) -if(ENABLE_STATIC_LINK) - add_library(sapp_assistant STATIC sapp_assistant.cpp) - add_library(gdev_assistant STATIC gdev_assistant.c) -else() - add_definitions(-fPIC) - add_library(sapp_assistant SHARED sapp_assistant.cpp) - add_library(gdev_assistant SHARED gdev_assistant.c) - install(TARGETS sapp_assistant DESTINATION ${MESA_SDK_PREFIX}/lib/) - install(TARGETS gdev_assistant DESTINATION ${MESA_SDK_PREFIX}/lib/) -endif() +add_library(sapp_assistant STATIC sapp_assistant.cpp) +add_library(gdev_assistant STATIC gdev_assistant.c) + +add_library(sapp_metrics STATIC sapp_metrics.cpp) + diff --git a/src/extensions/Makefile b/src/extensions/Makefile deleted file mode 100644 index 4642a90..0000000 --- a/src/extensions/Makefile +++ /dev/null @@ -1,150 +0,0 @@ -#opt: OPTFLAGS = -O2 -#export OPTFLAGS - -#CC = g++ -#CCC = g++ -CFLAGS += -Wall -CFLAGS += -g -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -CFLAGS += $(OPTFLAGS) -CFLAGS += -DPLATFORM_NSDPF_PAPP=1 - - -RELEASE_PLT_PATH=../../bin/plug/platform -RELEASE_PRO_PATH=../../bin/plug/protocol -RELEASE_BIZ_PATH=../../bin/plug/business - -H_DIR += $(INC) -H_DIR += -I../../include/ -H_DIR += -I../../include/public -H_DIR += -I../../include/private -H_DIR += -I../../include/support -H_DIR += -I/opt/MESA/include -H_DIR += -I/opt/MESA/include/MESA -H_DIR += -I/opt/mrzcpd/include - -LIB=-L/opt/MESA/lib -L/opt/mrzcpd/lib - -TARGET = isakmp_protocol_plug.so ipsec_biz_sample.so l2tp_protocol_plug.so l2tp_biz_sample.so -TARGET += pptp_protocol_plug.so pptp_biz_sample.so -TARGET += g_device_plug.so -TARGET += wy_keepalive_plug.so - -OBJS= - -ifeq ($(link_mode), $(__LINK_MODE_STATIC)) - OBJS += sapp_assistant.o - TARGET += libinner_plug.a -else - TARGET += libsapp_assistant.so -endif - - -ifeq ($(iomode), $(_MODE_PCAP)) -CFLAGS += -DIOMODE_PCAP=1 -endif - -ifeq ($(iomode), $(_MODE_PAG)) -CFLAGS += -DIOMODE_PAG=1 -endif - -ifeq ($(iomode), $(_MODE_PPF)) -CFLAGS += -DIOMODE_PPF=1 -endif - -ifeq ($(iomode), $(_MODE_PFRING)) -CFLAGS += -DIOMODE_PFRING=1 -endif - -ifeq ($(iomode), $(_MODE_DPDK)) -CFLAGS += -DIOMODE_DPDK=1 -endif - -ifeq ($(iomode), $(_MODE_TOPSEC)) -CFLAGS += -DIOMODE_TOPSEC=1 -endif - -ifeq ($(iomode), $(_MODE_IPFILE)) -CFLAGS += -DIOMODE_IPFILE=1 -endif - -ifeq ($(iomode), $(_MODE_MARSIO)) -CFLAGS += -DIOMODE_MARSIO=1 -LIB += -lmarsio -endif - -ifeq ($(iomode), $(_MODE_SMITH)) -CFLAGS += -DIOMODE_SMITH=1 -endif - -all: $(TARGET) - -libinner_plug.a:sapp_assistant.o gdev_assistant.o - rm -f $@; - ar -r $@ $^; - cp $@ ../lib; - -.c.o: - $(CC) -c $(CFLAGS) -I. $(H_DIR) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(H_DIR) $< - - -#isakmp_protocol_plug.so:isakmp_protocol_plug.o -isakmp_protocol_plug.so:isakmp_protocol_plug_add_nat.o - $(CC) -o $@ -fPIC -shared -g -Wall $^; - mkdir -p $(RELEASE_PRO_PATH)/isakmp_protocol_plug; - cp $@ $(RELEASE_PRO_PATH)/isakmp_protocol_plug/ ; - -ipsec_biz_sample.so:ipsec_biz_sample.o - $(CC) -o $@ -fPIC -shared -g -Wall $^; - mkdir -p $(RELEASE_BIZ_PATH)/ipsec_biz_sample; - cp $@ $(RELEASE_BIZ_PATH)/ipsec_biz_sample/ ; - -l2tp_protocol_plug.so:l2tp_protocol_plug.o - $(CC) -o $@ -fPIC -shared -g -Wall $^; - mkdir -p $(RELEASE_PRO_PATH)/l2tp_protocol_plug; - cp $@ $(RELEASE_PRO_PATH)/l2tp_protocol_plug/ ; - -l2tp_biz_sample.so:l2tp_biz_sample.o - $(CC) -o $@ -fPIC -shared -g -Wall $^; - mkdir -p $(RELEASE_BIZ_PATH)/l2tp_biz_sample; - cp $@ $(RELEASE_BIZ_PATH)/l2tp_biz_sample/ ; - -pptp_protocol_plug.so:pptp_protocol_plug.o - $(CC) -o $@ -fPIC -shared -g -Wall $^; - mkdir -p $(RELEASE_PRO_PATH)/pptp_protocol_plug; - cp $@ $(RELEASE_PRO_PATH)/pptp_protocol_plug/ ; - -pptp_biz_sample.so:pptp_biz_sample.o - $(CC) -o $@ -fPIC -shared -g -Wall $^; - mkdir -p $(RELEASE_BIZ_PATH)/pptp_biz_sample; - cp $@ $(RELEASE_BIZ_PATH)/pptp_biz_sample/ ; - -g_device_plug.so: g_device_plug.o - $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES); - mkdir -p $(RELEASE_PLT_PATH)/g_device_plug; - cp $@ $(RELEASE_PLT_PATH)/g_device_plug/ - -wy_keepalive_plug.so:wy_keepalive_plug.c - $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES) $(H_DIR) $(LIB); - mkdir -p $(RELEASE_PLT_PATH)/wy_keepalive_plug; - -libsapp_assistant.so: sapp_assistant.o gdev_assistant.o - mkdir -p /opt/MESA/lib; - cp ../lib/libc3client.so /opt/MESA/lib/; - ldconfig; - $(CC) -o $@ -shared -fPIC $(H_DIR) $(CFLAGS) $^ $(MODULES) -L/opt/MESA/lib -lMESA_field_stat2; - - -libanti_flood_hijack.so:anti_flood_plug.o anti_flood_hijack.o - $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES); - mkdir -p $(RELEASE_BIZ_PATH)/anti_flood; - cp $@ $(RELEASE_BIZ_PATH)/anti_flood/; - cp $@ /opt/MESA/lib/libanti_flood_hijack.so; - -clean: - rm -f *.o *.so *.a $(TARGET) - -opt: - $(MAKE) all diff --git a/src/extensions/sapp_assistant.cpp b/src/extensions/sapp_assistant.cpp index 666605e..4ad351a 100644 --- a/src/extensions/sapp_assistant.cpp +++ b/src/extensions/sapp_assistant.cpp @@ -6,13 +6,11 @@ #include "sapp_api.h" #include "sapp_private_api.h" #include "sapp_declaration.h" -#include "field_stat2.h" -#include "fieldstat.h" + #include "marsio.h" -static int sapp_fs2_init(sapp_global_t *global_parameters); -static int sapp_fs3_init(sapp_global_t *global_parameters); + //extern time_t g_CurrentTime;//add by lqy 20070606 //extern int g_packet_io_thread_num; @@ -25,7 +23,6 @@ static pthread_t *g_plug_Independent_thread_pid; static const unsigned char G_BROADCAST_ADDR[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; -int sapp_assistant_version_VERSION_20181024; extern "C" int MESA_get_dev_ipv4(const char *device, int *ip_add); extern "C" int MESA_get_dev_mac(const char *device, unsigned char mac[6]); @@ -872,136 +869,6 @@ extern "C" int sapp_get_device_opt(const char *device, enum sapp_device_opt opt_ return ret; } -void sapp_fs2_update_count(int field_index, unsigned long long value) -{ - if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ - FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, - sapp_global_val->individual_fixed.fs2_runtime.fs_id_count_array[field_index], - 0, FS_OP_SET, (long long)value); - } -} - -void sapp_fs2_update_length(int field_index, unsigned long long value) -{ - if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ - FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, - sapp_global_val->individual_fixed.fs2_runtime.fs_id_length_array[field_index], - 0, FS_OP_SET, (long long)value); - } -} - - -void sapp_fs2_set_latency(int thead_seq, long long time_cost) -{ - if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ - FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, - sapp_global_val->individual_fixed.fs2_runtime.fs_latency_id_array[thead_seq], - 0, FS_OP_SET, time_cost); - } -} - - -void sapp_fs2_set_plug_entry_latency(int entry_id, long long time_cost) -{ - if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){ - return; - } - if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ - FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, - sapp_global_val->individual_fixed.fs2_runtime.fs_latency_plug_entrg_id_array[entry_id], - 0, FS_OP_SET, time_cost); - } -} - -/* - 模糊计算包处理延时, 不用每个包都调用一次FS_operate(), - 由sapp timer线程每隔一段时间调用sapp_fuzzy_latency_update(), 更新filed_stat2计数. -*/ -extern "C" void sapp_fs2_fuzzy_latency_update_per_thread(int thead_seq, long long time_cost) -{ - sapp_fuzzy_latency_stat_t *this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_thread; - - if(time_cost < this_thread_stat->min_time_cost){ - this_thread_stat->min_time_cost = time_cost; - } - - if(time_cost > this_thread_stat->max_time_cost){ - this_thread_stat->max_time_cost = time_cost; - } - - this_thread_stat->time_cost_sum += time_cost; - this_thread_stat->stat_count++; -} - -extern "C" void sapp_fs2_fuzzy_latency_update_per_entry(int thead_seq, int entry_id, long long time_cost) -{ - sapp_fuzzy_latency_stat_t *this_thread_stat; - if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){ - return; - } - - this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id]; - - if(time_cost < this_thread_stat->min_time_cost){ - this_thread_stat->min_time_cost = time_cost; - } - - if(time_cost > this_thread_stat->max_time_cost){ - this_thread_stat->max_time_cost = time_cost; - } - - this_thread_stat->time_cost_sum += time_cost; - this_thread_stat->stat_count++; - -} - - -/* - 由sapp timer独立线程调用, 每隔一段时间, 将积累的包处理延时数据刷新给field_stat2. -*/ -void sapp_fuzzy_latency_update(void) -{ - int tid, entry_id, this_stat_count; - long long min_latency, max_latency; - double avg_latency; - sapp_fuzzy_latency_stat_t *this_thread_stat, *this_entry_stat; - - for(tid = 0; tid < g_packet_io_thread_num; tid++){ - this_thread_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_thread; - avg_latency = (double)this_thread_stat->time_cost_sum/(double)this_thread_stat->stat_count; - min_latency = this_thread_stat->min_time_cost; - max_latency = this_thread_stat->max_time_cost; - this_stat_count = this_thread_stat->stat_count; - - if(this_stat_count > 0){ - memset(this_thread_stat, 0, sizeof(sapp_fuzzy_latency_stat_t)); - this_thread_stat->min_time_cost = 999999999; /* 要记录最小值, 初始化要设成最大值 */ - - /* 每次更新三个值, 最大,最小和平均值 */ - sapp_fs2_set_latency(tid, min_latency); - sapp_fs2_set_latency(tid, max_latency); - sapp_fs2_set_latency(tid, (long long)avg_latency); - } - - for(entry_id = 1; entry_id < g_plug_global_entry_index; entry_id++){ - this_entry_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id]; - avg_latency = (double)this_entry_stat->time_cost_sum/(double)this_entry_stat->stat_count; - min_latency = this_entry_stat->min_time_cost; - max_latency = this_entry_stat->max_time_cost; - this_stat_count = this_entry_stat->stat_count; - if(this_stat_count > 0){ - memset(this_entry_stat, 0, sizeof(sapp_fuzzy_latency_stat_t)); - this_entry_stat->min_time_cost = 999999999; /* 要记录最小值, 初始化要设成最大值 */ - - sapp_fs2_set_latency(tid, min_latency); - sapp_fs2_set_latency(tid, max_latency); - sapp_fs2_set_plug_entry_latency(entry_id, (long long)avg_latency); - } - } - } -} - - int sapp_independent_thread_init(void) { pthread_mutex_init(&g_plug_Independent_thread_mutex, NULL); @@ -1012,298 +879,3 @@ int sapp_independent_thread_init(void) return 0; } - -int sapp_metric_init(void) -{ - int ret = 0; - if( sapp_global_val->config.profiling.fs2.enabled == 1) - { - sapp_fs2_init(sapp_global_val); - } - if( sapp_global_val->config.profiling.fs3.enabled == 1) - { - sapp_fs3_init(sapp_global_val); - } - - return ret; -} - - -static int fs2_plug_entry_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt) -{ - int i; - /* 0保留给sapp内置插件, index从1开始 */ - for(i = 1; i < g_plug_global_entry_index; i++){ - fs_rt->fs_latency_plug_entrg_id_array[i] = FS_register_histogram(fs_rt->fs_metric_handle, //Field Stat句柄 - FS_CALC_SPEED, //输出累计值或瞬时值 - g_plug_global_entry[i].plug_entry_name, //统计项名称,字符串 - 1, //可追踪的最小值 - 1000000, //可追踪的最大值 - 2); //精度,即小数点后几位,范围1~4 - if(fs_rt->fs_latency_plug_entrg_id_array[i] < 0){ - sapp_runtime_log(RLOG_LV_FATAL, "FS_register_histogram() error, plug name:%s", g_plug_global_entry[i].plug_entry_name); - return -1; - } - } - - return 0; -} - -void sapp_fs2_set_tcp_unorder_historgram(int thead_seq, long long unorder_num) -{ - if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ - FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, - sapp_global_val->individual_fixed.fs2_runtime.fs_tcp_unorder_id_array[thead_seq], - 0, FS_OP_SET, unorder_num); - } -} - -static int fs2_tcp_unorder_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt) -{ - int i; - char histogram_name[16]; - /* 0保留给sapp内置插件, index从1开始 */ - for (i = 1; i < g_packet_io_thread_num; i++) - { - sprintf(histogram_name, "OoO_num(tid_%d)", i); - fs_rt->fs_tcp_unorder_id_array[i] = - FS_register_histogram(fs_rt->fs_metric_handle, // Field Stat句柄 - FS_CALC_SPEED, //输出累计值或瞬时值 - histogram_name, //统计项名称,字符串 - 1, //可追踪的最小值 - 65536, //可追踪的最大值 - 2); //精度,即小数点后几位,范围1~4 - if (fs_rt->fs_tcp_unorder_id_array[i] < 0) - { - sapp_runtime_log(RLOG_LV_FATAL, "FS_fs2_tcp_unorder_historgram_init() error, name:%s", - histogram_name); - return -1; - } - } - - return 0; -} - -/************************ C++ compiler **************************************/ -static int sapp_fs2_init(sapp_global_t *global_paramters) -{ - void *fs2_handle=NULL; - int fs2_opt; - sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime; - sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2; - int fs2_local_enabled = 0; - int fs2_prometheus_enabled = 0; - - if(strlen(p_fs2_para->local_file) > 0) - { - fs2_local_enabled = 1; - } - if(strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0) - { - fs2_prometheus_enabled = 1; - } - - p_fs2_rt->fs_metric_handle = FS_create_handle(); - if(NULL == p_fs2_rt->fs_metric_handle){ - sapp_log(RLOG_LV_FATAL, 30, 30, "FS_create_handle() error: %s!\n", strerror(errno)); - return -1; - } - fs2_handle = p_fs2_rt->fs_metric_handle; - if(fs2_prometheus_enabled){ - FS_library_set_prometheus_port((unsigned short)p_fs2_para->prometheus_service_port); - FS_library_set_prometheus_url_path(p_fs2_para->prometheus_service_uri); - if(FS_library_init() < 0){ - sapp_log(RLOG_LV_FATAL, 30, 30, "FS_library_init() error, port:%d, url:%s\n", - p_fs2_para->prometheus_service_port, - p_fs2_para->prometheus_service_uri); - return -1; - } - fs2_opt = 1; - FS_set_para(fs2_handle, OUTPUT_PROMETHEUS, &fs2_opt, sizeof(int)); - } - - FS_set_para(fs2_handle, STAT_CYCLE, &p_fs2_para->refresh_interval_s, sizeof(int)); - - fs2_opt = 1; /* 1:Rewrite ,2: Append. */ - FS_set_para(fs2_handle, PRINT_MODE, &fs2_opt, sizeof(int)); - - fs2_opt = 1; - FS_set_para(fs2_handle, PRINT_TRIGGER, &fs2_opt, sizeof(int)); - - fs2_opt = 1; - FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &fs2_opt, sizeof(int)); - - if(fs2_local_enabled){ - FS_set_para(fs2_handle, OUTPUT_DEVICE, ABBR_FS2_LOG_DATA_FILE, strlen(ABBR_FS2_LOG_DATA_FILE)+1); - }else{ - sapp_log(RLOG_LV_INFO, 10, 10, "profiling.log.local.enabled is 0, not save local stat log file.\n"); - FS_set_para(fs2_handle, OUTPUT_DEVICE, "/dev/null", strlen("/dev/null") + 1); - } - FS_set_para(fs2_handle, APP_NAME, sapp_global_val->config.system.instance_name, strlen(sapp_global_val->config.system.instance_name)+1); - - - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Bit"); - - if((DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin) - || (DEPOLYMENT_MODE_TRANSPARENT == sapp_global_val->config.packet_io.depolyment_mode_bin)){ - p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Inbound"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Inbound"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Outbound"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Outbound"); - } - - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Pkt"); - //pfs_para->fs_id_length_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bit"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Bit"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_LOST_PKT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_Bit"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_STM"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_DUP_IDENTIFY_ERR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Key_Err"); /* dup重复包识别添加key错误计数 */ - - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byT"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byK"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bit"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byT"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byK"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_New"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_Del"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DATA] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Concurrent"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_New"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_Del"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_MORE] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Concurrent"); - - - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double_ALL"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S_ALL"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C_ALL"); - - - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double_ALL"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S_ALL"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C_ALL"); - - - p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_RST] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_Rst"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_SYNACK] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_S/A"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Udp"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_GLOBAL_BYPASS] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "DDOS_Bypass"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_STM"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_STM"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_STM"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Bit"); - - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_STM"); - p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Pkt"); - p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Bit"); - - if (unlikely(g_timestamp_record_sw)) - { - if (fs2_tcp_unorder_historgram_init(p_fs2_rt) < 0) - { - return -1; - } - for (int i = 0; i < g_packet_io_thread_num; i++) - { - char histogram_name[16]; - sprintf(histogram_name, "TD_ns(tid_%d)", i); - p_fs2_rt->fs_latency_id_array[i] = FS_register_histogram(fs2_handle, // Field Stat句柄 - FS_CALC_SPEED, //输出累计值或瞬时值 - histogram_name, //统计项名称,字符串 - 1, //可追踪的最小值 - 1000000, //可追踪的最大值 - 2); //精度,即小数点后几位,范围1~4 - FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &p_fs2_rt->fs_latency_id_array[i], sizeof(int)); - } - - if (fs2_plug_entry_historgram_init(p_fs2_rt) < 0) - { - return -1; - } - } - FS_start(fs2_handle); - - return 0; -} - -static void sapp_fs2_destroy(sapp_global_t *global_paramters) -{ - sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2; - sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime; - if (strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0) - { - FS_library_destroy(); - } - - if (p_fs2_rt->fs_metric_handle) - { - FS_stop(&p_fs2_rt->fs_metric_handle); - } -} - -static int sapp_fs3_init(sapp_global_t *global_paramters) -{ - sapp_config_profiling_metric_t *p_fs3_para = &global_paramters->config.profiling.fs3; - sapp_gval_individual_fixed_fs_t *p_fs3_rt = &global_paramters->individual_fixed.fs3_runtime; - return 0; -} - -static void sapp_fs3_destroy(sapp_global_t *global_paramters) -{ - return; -} - -void sapp_metric_destroy(void) -{ - - if( sapp_global_val->config.profiling.fs2.enabled == 1) - { - sapp_fs2_destroy(sapp_global_val); - } - if( sapp_global_val->config.profiling.fs3.enabled == 1) - { - sapp_fs3_destroy(sapp_global_val); - } -} - - diff --git a/src/extensions/sapp_metrics.cpp b/src/extensions/sapp_metrics.cpp new file mode 100644 index 0000000..6fd1f63 --- /dev/null +++ b/src/extensions/sapp_metrics.cpp @@ -0,0 +1,433 @@ +#include "field_stat2.h" +#include "fieldstat.h" + +#include "sapp_declaration.h" + +static int sapp_fs2_init(sapp_global_t *global_parameters); +static int sapp_fs3_init(sapp_global_t *global_parameters); + + +void sapp_fs2_update_count(int field_index, unsigned long long value) +{ + if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ + FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, + sapp_global_val->individual_fixed.fs2_runtime.fs_id_count_array[field_index], + 0, FS_OP_SET, (long long)value); + } +} + +void sapp_fs2_update_length(int field_index, unsigned long long value) +{ + if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ + FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, + sapp_global_val->individual_fixed.fs2_runtime.fs_id_length_array[field_index], + 0, FS_OP_SET, (long long)value); + } +} + + +void sapp_fs2_set_latency(int thead_seq, long long time_cost) +{ + if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ + FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, + sapp_global_val->individual_fixed.fs2_runtime.fs_latency_id_array[thead_seq], + 0, FS_OP_SET, time_cost); + } +} + + +void sapp_fs2_set_plug_entry_latency(int entry_id, long long time_cost) +{ + if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){ + return; + } + if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ + FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, + sapp_global_val->individual_fixed.fs2_runtime.fs_latency_plug_entrg_id_array[entry_id], + 0, FS_OP_SET, time_cost); + } +} + +/* + 模糊计算包处理延时, 不用每个包都调用一次FS_operate(), + 由sapp timer线程每隔一段时间调用sapp_fuzzy_latency_update(), 更新filed_stat2计数. +*/ +extern "C" void sapp_fs2_fuzzy_latency_update_per_thread(int thead_seq, long long time_cost) +{ + sapp_fuzzy_latency_stat_t *this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_thread; + + if(time_cost < this_thread_stat->min_time_cost){ + this_thread_stat->min_time_cost = time_cost; + } + + if(time_cost > this_thread_stat->max_time_cost){ + this_thread_stat->max_time_cost = time_cost; + } + + this_thread_stat->time_cost_sum += time_cost; + this_thread_stat->stat_count++; +} + +extern "C" void sapp_fs2_fuzzy_latency_update_per_entry(int thead_seq, int entry_id, long long time_cost) +{ + sapp_fuzzy_latency_stat_t *this_thread_stat; + if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){ + return; + } + + this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id]; + + if(time_cost < this_thread_stat->min_time_cost){ + this_thread_stat->min_time_cost = time_cost; + } + + if(time_cost > this_thread_stat->max_time_cost){ + this_thread_stat->max_time_cost = time_cost; + } + + this_thread_stat->time_cost_sum += time_cost; + this_thread_stat->stat_count++; + +} + + +/* + 由sapp timer独立线程调用, 每隔一段时间, 将积累的包处理延时数据刷新给field_stat2. +*/ +void sapp_fuzzy_latency_update(void) +{ + int tid, entry_id, this_stat_count; + long long min_latency, max_latency; + double avg_latency; + sapp_fuzzy_latency_stat_t *this_thread_stat, *this_entry_stat; + + for(tid = 0; tid < g_packet_io_thread_num; tid++){ + this_thread_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_thread; + avg_latency = (double)this_thread_stat->time_cost_sum/(double)this_thread_stat->stat_count; + min_latency = this_thread_stat->min_time_cost; + max_latency = this_thread_stat->max_time_cost; + this_stat_count = this_thread_stat->stat_count; + + if(this_stat_count > 0){ + memset(this_thread_stat, 0, sizeof(sapp_fuzzy_latency_stat_t)); + this_thread_stat->min_time_cost = 999999999; /* 要记录最小值, 初始化要设成最大值 */ + + /* 每次更新三个值, 最大,最小和平均值 */ + sapp_fs2_set_latency(tid, min_latency); + sapp_fs2_set_latency(tid, max_latency); + sapp_fs2_set_latency(tid, (long long)avg_latency); + } + + for(entry_id = 1; entry_id < g_plug_global_entry_index; entry_id++){ + this_entry_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id]; + avg_latency = (double)this_entry_stat->time_cost_sum/(double)this_entry_stat->stat_count; + min_latency = this_entry_stat->min_time_cost; + max_latency = this_entry_stat->max_time_cost; + this_stat_count = this_entry_stat->stat_count; + if(this_stat_count > 0){ + memset(this_entry_stat, 0, sizeof(sapp_fuzzy_latency_stat_t)); + this_entry_stat->min_time_cost = 999999999; /* 要记录最小值, 初始化要设成最大值 */ + + sapp_fs2_set_latency(tid, min_latency); + sapp_fs2_set_latency(tid, max_latency); + sapp_fs2_set_plug_entry_latency(entry_id, (long long)avg_latency); + } + } + } +} + + + + +int sapp_metric_init(void) +{ + int ret = 0; + if( sapp_global_val->config.profiling.fs2.enabled == 1) + { + sapp_fs2_init(sapp_global_val); + } + if( sapp_global_val->config.profiling.fs3.enabled == 1) + { + sapp_fs3_init(sapp_global_val); + } + + return ret; +} + + +static int fs2_plug_entry_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt) +{ + int i; + /* 0保留给sapp内置插件, index从1开始 */ + for(i = 1; i < g_plug_global_entry_index; i++){ + fs_rt->fs_latency_plug_entrg_id_array[i] = FS_register_histogram(fs_rt->fs_metric_handle, //Field Stat句柄 + FS_CALC_SPEED, //输出累计值或瞬时值 + g_plug_global_entry[i].plug_entry_name, //统计项名称,字符串 + 1, //可追踪的最小值 + 1000000, //可追踪的最大值 + 2); //精度,即小数点后几位,范围1~4 + if(fs_rt->fs_latency_plug_entrg_id_array[i] < 0){ + sapp_runtime_log(RLOG_LV_FATAL, "FS_register_histogram() error, plug name:%s", g_plug_global_entry[i].plug_entry_name); + return -1; + } + } + + return 0; +} + +void sapp_fs2_set_tcp_unorder_historgram(int thead_seq, long long unorder_num) +{ + if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){ + FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle, + sapp_global_val->individual_fixed.fs2_runtime.fs_tcp_unorder_id_array[thead_seq], + 0, FS_OP_SET, unorder_num); + } +} + +static int fs2_tcp_unorder_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt) +{ + int i; + char histogram_name[16]; + /* 0保留给sapp内置插件, index从1开始 */ + for (i = 1; i < g_packet_io_thread_num; i++) + { + sprintf(histogram_name, "OoO_num(tid_%d)", i); + fs_rt->fs_tcp_unorder_id_array[i] = + FS_register_histogram(fs_rt->fs_metric_handle, // Field Stat句柄 + FS_CALC_SPEED, //输出累计值或瞬时值 + histogram_name, //统计项名称,字符串 + 1, //可追踪的最小值 + 65536, //可追踪的最大值 + 2); //精度,即小数点后几位,范围1~4 + if (fs_rt->fs_tcp_unorder_id_array[i] < 0) + { + sapp_runtime_log(RLOG_LV_FATAL, "FS_fs2_tcp_unorder_historgram_init() error, name:%s", + histogram_name); + return -1; + } + } + + return 0; +} + +/************************ C++ compiler **************************************/ +static int sapp_fs2_init(sapp_global_t *global_paramters) +{ + void *fs2_handle=NULL; + int fs2_opt; + sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime; + sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2; + int fs2_local_enabled = 0; + int fs2_prometheus_enabled = 0; + + if(strlen(p_fs2_para->local_file) > 0) + { + fs2_local_enabled = 1; + } + if(strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0) + { + fs2_prometheus_enabled = 1; + } + + p_fs2_rt->fs_metric_handle = FS_create_handle(); + if(NULL == p_fs2_rt->fs_metric_handle){ + sapp_log(RLOG_LV_FATAL, 30, 30, "FS_create_handle() error: %s!\n", strerror(errno)); + return -1; + } + fs2_handle = p_fs2_rt->fs_metric_handle; + if(fs2_prometheus_enabled){ + FS_library_set_prometheus_port((unsigned short)p_fs2_para->prometheus_service_port); + FS_library_set_prometheus_url_path(p_fs2_para->prometheus_service_uri); + if(FS_library_init() < 0){ + sapp_log(RLOG_LV_FATAL, 30, 30, "FS_library_init() error, port:%d, url:%s\n", + p_fs2_para->prometheus_service_port, + p_fs2_para->prometheus_service_uri); + return -1; + } + fs2_opt = 1; + FS_set_para(fs2_handle, OUTPUT_PROMETHEUS, &fs2_opt, sizeof(int)); + } + + FS_set_para(fs2_handle, STAT_CYCLE, &p_fs2_para->refresh_interval_s, sizeof(int)); + + fs2_opt = 1; /* 1:Rewrite ,2: Append. */ + FS_set_para(fs2_handle, PRINT_MODE, &fs2_opt, sizeof(int)); + + fs2_opt = 1; + FS_set_para(fs2_handle, PRINT_TRIGGER, &fs2_opt, sizeof(int)); + + fs2_opt = 1; + FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &fs2_opt, sizeof(int)); + + if(fs2_local_enabled){ + FS_set_para(fs2_handle, OUTPUT_DEVICE, ABBR_FS2_LOG_DATA_FILE, strlen(ABBR_FS2_LOG_DATA_FILE)+1); + }else{ + sapp_log(RLOG_LV_INFO, 10, 10, "profiling.log.local.enabled is 0, not save local stat log file.\n"); + FS_set_para(fs2_handle, OUTPUT_DEVICE, "/dev/null", strlen("/dev/null") + 1); + } + FS_set_para(fs2_handle, APP_NAME, sapp_global_val->config.system.instance_name, strlen(sapp_global_val->config.system.instance_name)+1); + + + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Bit"); + + if((DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin) + || (DEPOLYMENT_MODE_TRANSPARENT == sapp_global_val->config.packet_io.depolyment_mode_bin)){ + p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Inbound"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Inbound"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Outbound"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Outbound"); + } + + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Pkt"); + //pfs_para->fs_id_length_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bit"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Bit"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_LOST_PKT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_Bit"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_STM"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_DUP_IDENTIFY_ERR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Key_Err"); /* dup重复包识别添加key错误计数 */ + + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byT"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byK"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bit"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byT"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byK"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_New"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_Del"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DATA] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Concurrent"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_New"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_Del"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_MORE] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Concurrent"); + + + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double_ALL"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S_ALL"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C_ALL"); + + + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double_ALL"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S_ALL"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C_ALL"); + + + p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_RST] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_Rst"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_SYNACK] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_S/A"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Udp"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_GLOBAL_BYPASS] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "DDOS_Bypass"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_STM"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_STM"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_STM"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Bit"); + + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_STM"); + p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Pkt"); + p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Bit"); + + if (unlikely(g_timestamp_record_sw)) + { + if (fs2_tcp_unorder_historgram_init(p_fs2_rt) < 0) + { + return -1; + } + for (int i = 0; i < g_packet_io_thread_num; i++) + { + char histogram_name[16]; + sprintf(histogram_name, "TD_ns(tid_%d)", i); + p_fs2_rt->fs_latency_id_array[i] = FS_register_histogram(fs2_handle, // Field Stat句柄 + FS_CALC_SPEED, //输出累计值或瞬时值 + histogram_name, //统计项名称,字符串 + 1, //可追踪的最小值 + 1000000, //可追踪的最大值 + 2); //精度,即小数点后几位,范围1~4 + FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &p_fs2_rt->fs_latency_id_array[i], sizeof(int)); + } + + if (fs2_plug_entry_historgram_init(p_fs2_rt) < 0) + { + return -1; + } + } + FS_start(fs2_handle); + + return 0; +} + +static void sapp_fs2_destroy(sapp_global_t *global_paramters) +{ + sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2; + sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime; + if (strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0) + { + FS_library_destroy(); + } + + if (p_fs2_rt->fs_metric_handle) + { + FS_stop(&p_fs2_rt->fs_metric_handle); + } +} + +static int sapp_fs3_init(sapp_global_t *global_paramters) +{ + sapp_config_profiling_metric_t *p_fs3_para = &global_paramters->config.profiling.fs3; + sapp_gval_individual_fixed_fs_t *p_fs3_rt = &global_paramters->individual_fixed.fs3_runtime; + return 0; +} + +static void sapp_fs3_destroy(sapp_global_t *global_paramters) +{ + return; +} + +void sapp_metric_destroy(void) +{ + + if( sapp_global_val->config.profiling.fs2.enabled == 1) + { + sapp_fs2_destroy(sapp_global_val); + } + if( sapp_global_val->config.profiling.fs3.enabled == 1) + { + sapp_fs3_destroy(sapp_global_val); + } +} diff --git a/src/packet_io/CMakeLists.txt b/src/packet_io/CMakeLists.txt index 0cc23c1..f739c7f 100644 --- a/src/packet_io/CMakeLists.txt +++ b/src/packet_io/CMakeLists.txt @@ -19,40 +19,24 @@ add_definitions(-fPIC) #always add libpcap set(PACKET_IO_SOURCE ${PACKET_IO_SOURCE} packet_io_pcap.c) -if(ENABLE_STATIC_LINK) - add_library(packet_io_pcap STATIC ${PACKET_IO_SOURCE}) -else() - add_library(packet_io_pcap SHARED ${PACKET_IO_SOURCE}) -endif() +add_library(packet_io_pcap STATIC ${PACKET_IO_SOURCE}) + set_target_properties(packet_io_pcap PROPERTIES PREFIX "") if(CAPTURE_MODE MATCHES "PAG") set(PACKET_IO_SOURCE packet_io_pag_marsio.c) - if(ENABLE_STATIC_LINK) - add_library(packet_io_pag_marsio STATIC ${PACKET_IO_SOURCE}) - else() - add_library(packet_io_pag_marsio SHARED ${PACKET_IO_SOURCE}) - endif() + add_library(packet_io_pag_marsio STATIC ${PACKET_IO_SOURCE}) endif() if(CAPTURE_MODE MATCHES "MARSIO") set(PACKET_IO_SOURCE packet_io_marsio.c) - if(ENABLE_STATIC_LINK) - add_library(packet_io_marsio STATIC ${PACKET_IO_SOURCE}) - else() - add_library(packet_io_marsio SHARED ${PACKET_IO_SOURCE}) - endif() - ##target_link_libraries(packet_io_marsio marsio) + add_library(packet_io_marsio STATIC ${PACKET_IO_SOURCE}) set_target_properties(packet_io_marsio PROPERTIES PREFIX "") endif() if(CAPTURE_MODE MATCHES "TUN") set(PACKET_IO_SOURCE packet_io_tun.c) - if(ENABLE_STATIC_LINK) - add_library(packet_io_tun STATIC ${PACKET_IO_SOURCE}) - else() - add_library(packet_io_tun SHARED ${PACKET_IO_SOURCE}) - endif() + add_library(packet_io_tun STATIC ${PACKET_IO_SOURCE}) endif() set(PACKET_IO_STATIC_SOURCE cycle_pkt_dump_through_write_offset.c packet_io_lib_load.c diff --git a/src/packet_io/Makefile b/src/packet_io/Makefile deleted file mode 100644 index fd0d3c4..0000000 --- a/src/packet_io/Makefile +++ /dev/null @@ -1,195 +0,0 @@ -#opt: OPTFLAGS = -O2 -#export OPTFLAGS - -#CC = g++ -#CCC = g++ -CFLAGS += -Wall -CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -CFLAGS += $(OPTFLAGS) -CFLAGS += $(PACKET_TAG_863) -CFLAGS += -DPLATFORM_NSDPF_PAPP=1 - -ifeq ($(USE_PAG_GET_FRAME), 1) -CFLAGS += -DUSE_PAG_GET_FRAME=1 -endif - -RELEASE_PATH=../../bin/platform_lib/ -LIBPATH = -L../lib -L/opt/mrzcpd/lib -DEP = ../support/libnet_common.so - -H_DIR += $(INC) -H_DIR += -I../../include/ -H_DIR += -I../../include/public -H_DIR += -I../../include/private -H_DIR += -I../../include/support -H_DIR += -I/opt/MESA/include -H_DIR += -I/opt/MESA/include/MESA -H_DIR += -I/opt/mrzcpd/include - -OBJS=sendpacket.o packet_io.o packet_io_log.o -OBJS+=packet_io_lib_load.o -OBJS+=packet_io_status.o -OBJS+=packet_io_status_new.o -#OBJS += cycle_pkt_dump.o -#OBJS += cycle_pkt_dump_unix.o -OBJS += cycle_pkt_dump_through_write_offset.o -OBJS += packet_io_device.o -OBJS += sapp_compat_old_papp_api.o -OBJS += sapp_inject.o - - -DLL_LIB= -#ifeq ($(iomode), $(_MODE_PCAP)) -CFLAGS += -DIOMODE_PCAP=1 -DLL_LIB += packet_io_pcap.so -ifeq ($(link_mode), $(__LINK_MODE_STATIC)) - OBJS += packet_io_pcap.o -endif -#endif - -ifeq ($(iomode), $(_MODE_PAG)) -CFLAGS += -DIOMODE_PAG=1 -DLL_LIB += packet_io_pag.so - ifeq ($(link_mode), $(__LINK_MODE_STATIC)) - OBJS += packet_io_pag.o - endif -endif - -ifeq ($(iomode), $(_MODE_PPF)) -CFLAGS += -DIOMODE_PPF=1 -DLL_LIB += packet_io_ppf.so -endif - -ifeq ($(iomode), $(_MODE_PFRING)) -CFLAGS += -DIOMODE_PFRING=1 -DLL_LIB += packet_io_pfring.so -endif - -ifeq ($(iomode), $(_MODE_DPDK)) -CFLAGS += -DIOMODE_DPDK=1 -DLL_LIB += packet_io_dpdk.so -endif - -ifeq ($(iomode), $(_MODE_TOPSEC)) -CFLAGS += -DIOMODE_TOPSEC=1 -DLL_LIB += packet_io_topsec.so -endif - -ifeq ($(iomode), $(_MODE_IPFILE)) -CFLAGS += -DIOMODE_IPFILE=1 -DLL_LIB += packet_io_ipfile.so -endif - -ifeq ($(iomode), $(_MODE_MARSIO)) -CFLAGS += -DIOMODE_MARSIO=1 -DLL_LIB += packet_io_marsio.so - ifeq ($(link_mode), $(__LINK_MODE_STATIC)) - OBJS += packet_io_marsio.o - endif -endif - -ifeq ($(iomode), $(_MODE_SMITH)) -CFLAGS += -DIOMODE_SMITH=1 -DLL_LIB += packet_io_agent_smith.so -endif - -ifeq ($(IIEFD_DUAL_STACK), $(YES)) -CFLAGS += -g -DIIEFD_DUAL_STACK=1 -endif - -ifeq ($(iomode), $(_MODE_DPDK_VXLAN)) -CFLAGS += -DIOMODE_DPDK_VXLAN=1 -DLL_LIB += packet_io_dpdk_vxlan.so -endif - -ifeq ($(iomode), $(_MODE_PAG_MARSIO)) -CFLAGS += -DIOMODE_PAG_MARSIO=1 -DLL_LIB += packet_io_pag_marsio.so -endif - -ifeq ($(iomode), $(_MODE_TUN)) -CFLAGS += -DIOMODE_TUN=1 -DLL_LIB += packet_io_tun.so -ifeq ($(link_mode), $(__LINK_MODE_STATIC)) - OBJS += packet_io_tun.o -endif -endif - - -TARGET = libpacket_io.a - -ifeq ($(debug), $(_DEBUG2)) -OBJS += iknow_info.o -endif - -all: $(TARGET) $(DLL_LIB) - -.c.o: - $(CC) -c $(CFLAGS) -I. $(H_DIR) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(H_DIR) $< - - -$(TARGET): $(OBJS) - rm -f $@ ;ar -r $@ $^; - cp $(TARGET) ../lib - -packet_io_pcap.so:packet_io_pcap.o - $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lpcap; - cp $@ $(RELEASE_PATH) - -packet_io_pag.so:packet_io_pag.o - #$(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lpag; - gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lpag; - cp $@ $(RELEASE_PATH) - -packet_io_ppf.so:packet_io_ppf.o - $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lppf; - cp $@ $(RELEASE_PATH) - -packet_io_pfring.so:packet_io_pfring.o - $(CC) -o $@ -fPIC -shared -g -Wall $^ $(IBPATH) $(LIBS) -lpfring; - cp $@ $(RELEASE_PATH) - -packet_io_qnf.so:packet_io_qnf.o - $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lqnfapi; - cp $@ $(RELEASE_PATH) - -packet_io_dpdk.so:packet_io_dpdk.o - $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio; - cp $@ $(RELEASE_PATH) - -packet_io_topsec.so:packet_io_topsec.o - gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lpag; - cp $@ $(RELEASE_PATH) - -packet_io_ipfile.so:packet_io_ipfile.o - gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH); - cp $@ $(RELEASE_PATH) - -packet_io_agent_smith.so:packet_io_agent_smith.o - gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lagent_smith; - cp $@ $(RELEASE_PATH) - -packet_io_marsio.so:packet_io_marsio.o - gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio; - cp $@ $(RELEASE_PATH) - -packet_io_dpdk_vxlan.so:packet_io_dpdk_vxlan.o - $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio; - cp $@ $(RELEASE_PATH) - -packet_io_pag_marsio.so:packet_io_pag_marsio.o - gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio; - cp $@ $(RELEASE_PATH) - -packet_io_tun.so:packet_io_tun.o - gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH); - cp $@ $(RELEASE_PATH) - -clean: - rm -f *.o packet_io*.so *.a $(TARGET) $(DLL_LIB) *~ - -opt: - $(MAKE) all diff --git a/src/plugin/Makefile b/src/plugin/Makefile deleted file mode 100644 index 93781cd..0000000 --- a/src/plugin/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: - cd src && $(MAKE) - cp ./lib/plugctrl.a ../lib -clean: - cd src && $(MAKE) clean -opt: - $(MAKE) all - diff --git a/src/plugin/src/Makefile b/src/plugin/src/Makefile deleted file mode 100644 index 39d64f7..0000000 --- a/src/plugin/src/Makefile +++ /dev/null @@ -1,40 +0,0 @@ - -CC = gcc -CFLAGS += -g -Wall -fPIC -CFLAGS += $(OPTFLAGS) -OBJECTS = plugin_proc.o plugin.o plugin_platform.o plugin_protocol.o plugin_business.o -TARGET = plugctrl.a - -INCS = -I../inc -INCS += -I../../../include/ -INCS += -I../../../include/public -INCS += -I../../../include/private -INCS += -I../../../include/support -INCS +=-I/opt/MESA/include/MESA -LIB = - -LIBPATH += ../lib - -.cpp.o: - $(CC) -c -o $@ $(CFLAGS) $(INCS) $< - -.c.o: - $(CC) -c -o $@ $(CFLAGS) $(INCS) $< - -.PHONY: all clean -all:$(SUPPORT) $(TARGET) -$(TARGET):$(OBJECTS) -#$(TARGET):$(OBJECTS) $(LIB) - ar -rs $(TARGET) $^ - cp $(TARGET) $(LIBPATH) - -plugin_proc.o:plugin_proc.c -plugin.o:plugin.c -plugin_platform.o:plugin_platform.c -plugin_protocol.o:plugin_protocol.c -plugin_business.o:plugin_business.c - - -clean: - rm -f $(TARGET) $(OBJECTS) *.a - diff --git a/src/project/Makefile b/src/project/Makefile deleted file mode 100644 index 82dca3a..0000000 --- a/src/project/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -#opt: OPTFLAGS = -O2 -#export OPTFLAGS - -#CC = g++ -#CCC = g++ -CFLAGS += -Wall -CFLAGS += -fPIC -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -CFLAGS += $(OPTFLAGS) -CFLAGS += -DPLATFORM_NSDPF_PAPP=1 - -LIBPATH = ../lib - -H_DIR += $(INC) -H_DIR += -I../../include/ -H_DIR += -I../../include/public -H_DIR += -I../../include/private -H_DIR += -I../../include/support -H_DIR += -I/opt/MESA/include/MESA - -TARGET = libproject.a - -OBJS= project_requirement.o -#terminal_tag.o -OBJS+= raw_ip_frag_list.o - -.c.o: - $(CC) -c $(CFLAGS) -I. $(H_DIR) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(H_DIR) $< - -all: $(TARGET) - -$(TARGET): $(OBJS) - rm -f $@ ;ar -r $@ $^; - cp $(TARGET) $(LIBPATH) -clean: - rm -f *.o $(TARGET) *~ - -opt: - $(MAKE) all diff --git a/src/project/project_requirement.c b/src/project/project_requirement.c index 00ef898..3440b08 100644 --- a/src/project/project_requirement.c +++ b/src/project/project_requirement.c @@ -8,7 +8,6 @@ extern "C" { #include "MESA_list.h" //extern int g_packet_io_thread_num; -extern int project_req_terminal_tag_init(void); extern int raw_ip_frag_list_v4_init(void); extern int raw_ip_frag_list_v6_init(void); extern void del_last_rn(char *data, int max_len); @@ -441,29 +440,6 @@ static int teredo_identify_init(void) return G_UDP_TEREDO_IDENTIFY_PROJECT_ID; } - -static void terminal_tag_free_struct(int thread_num, void *project_req_value) -{ - dictator_free(thread_num, project_req_value); -} - -int project_req_terminal_tag_id = -1; - -int project_req_terminal_tag_init(void) -{ - int project_req_id; - - project_req_id = project_producer_register("terminal_tag", "struct", terminal_tag_free_struct); - if(project_req_id >= 0){ - project_req_terminal_tag_id = project_req_id; - }else{ - /* 配置文件没有'terminal_tag'项, 关闭此功能 */ - project_req_terminal_tag_id = -1; - } - - return 0; -} - static void udp_flow_stat_free(int thread_seq, void *project_req_value) { sapp_mem_free(SAPP_MEM_DYN_UDP_FLOW_STAT, thread_seq, project_req_value); @@ -527,8 +503,6 @@ int project_requirement_global_init(void) //parse_project_req_conf(); - /* 平台内置project模块初始化, 功能是否启用取决于配置文件开关 */ - //project_req_terminal_tag_init(); /* project注册改为动态, 不靠project_list.conf控制了, 但是下面这些内置功能为了向前兼容,还是检查一下project_list.conf是否存在, 不存在则不开启 */ diff --git a/src/project/terminal_tag.c b/src/project/terminal_tag.c deleted file mode 100644 index 1ba4453..0000000 --- a/src/project/terminal_tag.c +++ /dev/null @@ -1,391 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __FAVOR_BSD -#define __FAVOR_BSD 1 -#endif - -#include "sapp_api.h" -#include "sapp_private_api.h" - -//pcap_t* pcap_handle; -//#define GET_TAG_DEVICE "eth1" -//#define GET_TAG_FILTER "tcp[13]=0x02 and host 10.0.6.187" - -//static int terminal_tag_switch = 0; -static int project_req_terminal_tag_id = -1; - -#define TERMINAL_TAG_SIZE_MAX (48) - -unsigned char terminal_tag_checksum_hash(unsigned char rand_num, - unsigned int ip_addr, unsigned short dev_id) -{ - unsigned char checksum_key = 0x5A; - unsigned char *p; - - checksum_key += rand_num; - p = (unsigned char *)&ip_addr; - checksum_key += p[0]; - checksum_key += p[1]; - checksum_key += p[2]; - checksum_key += p[3]; - p = (unsigned char *)&dev_id; - checksum_key += p[0]; - checksum_key += p[1]; - - return checksum_key; -} - -unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag, - unsigned char checksum_key) -{ - unsigned char checksum = 0x77; - unsigned char *p = (unsigned char *)terminal_tag; - - terminal_tag->check_sum = 0; - - checksum += p[0]; - checksum += p[1]; - checksum += p[2]; - checksum += p[3]; - checksum += p[4]; - checksum += p[5]; - checksum += p[6]; - checksum += p[7]; - checksum += p[8]; - checksum += p[9]; - checksum += checksum_key; - - return checksum; -} - -unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr) -{ - unsigned char encrypt_key = 0xA5; - unsigned char *p; - - encrypt_key ^= rand_num; - p = (unsigned char *)&ip_addr; - encrypt_key ^= p[0]; - encrypt_key ^= p[1]; - encrypt_key ^= p[2]; - encrypt_key ^= p[3]; - - return encrypt_key; -} - -static void *terminal_tag_create_struct(int thread_num) -{ - void *info = dictator_malloc(thread_num, TERMINAL_TAG_SIZE_MAX); - memset(info, 0, TERMINAL_TAG_SIZE_MAX); - - return info; -} - -static void terminal_tag_transform(struct terminal_tag_t *terminal_tag, - struct streaminfo *stream, unsigned char *stack_tag_string) -{ - char ip_str[16]; - unsigned char *mac; - struct stream_tuple4_v4 *st4; - int sip_addr; - void *stream_tag_value; - - if(ADDR_TYPE_IPV4 == stream->addr.addrtype){ - st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4; - sip_addr = st4->saddr; - }else{ - return; /* 不支持ipv6 */ - } - - switch(terminal_tag->type) - { - case TERMINAL_ADDR_TYPE_MAC: - mac = (unsigned char *)terminal_tag->local_addr.local_mac; - snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%02x%02x-%02x%02x-%02x%02x", - "M",ntohs(terminal_tag->dev_id), mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]); - break; - - case TERMINAL_ADDR_TYPE_IP: - inet_ntop(AF_INET, &terminal_tag->local_addr.local_ip.ipaddr, ip_str, 16); - snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%s", - "I", ntohs(terminal_tag->dev_id), ip_str); - break; - - case TERMINAL_ADDR_TYPE_TRACE: - // to do! - break; - - case TERMINAL_ADDR_TYPE_GLOBAL_SIP: - break; - - default: - inet_ntop(AF_INET, &sip_addr, ip_str, 16); - snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%s", "G:00000", ip_str); - break; - } - -#if 0 - if(terminal_tag->type < 2) - { - printf("Tagv4 is: %s\n", stream->terminal_tag); - } - //mac = (unsigned char *)terminal_tag; - //printf("Clear-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", - //mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]); -#endif - - stream_tag_value = terminal_tag_create_struct(stream->threadnum); - strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX); - project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value); - - return; -} - -static int terminal_tag_checksum_check(struct terminal_tag_t *terminal_tag_clear, - struct streaminfo *stream, unsigned char *stack_tag_string) -{ - unsigned char checksum_key; - unsigned char raw_checksum, new_checksum; - struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4; - int dip_addr; - - if(ADDR_TYPE_IPV4 == stream->addr.addrtype){ - st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4; - dip_addr = st4->daddr; - }else{ - return -1; /* 不支持ipv6 */ - } - - checksum_key = terminal_tag_checksum_hash(terminal_tag_clear->random, - dip_addr, - ntohs(terminal_tag_clear->dev_id)); - - raw_checksum = terminal_tag_clear->check_sum; - - new_checksum = terminal_tag_checksum(terminal_tag_clear, checksum_key); - - if(raw_checksum != new_checksum) - { - //printf("Checksum error!\n"); - goto err; /* 校验和不对,可能传输错误、或被篡改、或恶意伪造包 */ - } - - switch(terminal_tag_clear->type) - { - case TERMINAL_ADDR_TYPE_MAC: - break; - - case TERMINAL_ADDR_TYPE_IP: /* IP类型,空余两个字节用于完整性校验 */ - if(IP_STRUCT_MAGIC != terminal_tag_clear->local_addr.local_ip.ip_magic_num) - { - goto err; - } - break; - - default: /* 用户标签设备添加的标志只能是MAC或IP */ - return -1; - break; - } - - terminal_tag_transform(terminal_tag_clear, stream, stack_tag_string); - return 0; - -err: - return -1; -} - -/* 用户标签解密 */ -static int terminal_tag_decrypt(struct terminal_tag_t *terminal_tag_enc, - struct streaminfo *stream, unsigned char *stack_tag_string) -{ - struct terminal_tag_t terminal_tag; - unsigned char rand_num, encrypt_key; - unsigned char *clear, *encrypt; - struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4; - int dip_addr; - - if(ADDR_TYPE_IPV4 == stream->addr.addrtype){ - st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4; - dip_addr = st4->daddr; - }else{ - return -1; /* 不支持ipv6 */ - } - - /* copy到一个临时空间,不修改原始数据包 */ - memcpy(&terminal_tag, terminal_tag_enc, sizeof(struct terminal_tag_t)); - -#if 0 - unsigned char * mac = (unsigned char *)&terminal_tag; - printf("Encrypt-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", - mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]); -#endif - - clear = (unsigned char *)&terminal_tag; - encrypt = (unsigned char *)terminal_tag_enc; - - clear[0] = ror(encrypt[0], 4); - rand_num = terminal_tag.random; - - encrypt_key = terminal_tag_encrypt_hash(rand_num, dip_addr); - - /* 跳过第一个字节,type和random字段不参与此方式解密 */ - - clear[1] = encrypt[1] ^ encrypt_key; - clear[2] = encrypt[2] ^ encrypt_key; - clear[3] = encrypt[3] ^ encrypt_key; - clear[4] = encrypt[4] ^ encrypt_key; - clear[5] = encrypt[5] ^ encrypt_key; - clear[6] = encrypt[6] ^ encrypt_key; - clear[7] = encrypt[7] ^ encrypt_key; - clear[8] = encrypt[8] ^ encrypt_key; - clear[9] = encrypt[9] ^ encrypt_key; - - return terminal_tag_checksum_check(&terminal_tag, stream, stack_tag_string); -} - - -static int terminal_tag_trace(struct streaminfo *stream, unsigned char *stack_tag_string) -{ - struct terminal_tag_t terminal_tag; - /* 溯源系统查询 */ - /* to do: - terminal_tag_trace(); - if(err) - { - goto def_tag; - } - terminal_tag_clear->type = TERMINAL_ADDR_TYPE_TRACE; - */ - terminal_tag.type = TERMINAL_ADDR_TYPE_GLOBAL_SIP; - terminal_tag_transform(&terminal_tag, stream, stack_tag_string); - return 0; -} - - -static int terminal_tag_set_ipv6(struct streaminfo *stream, unsigned char *stack_tag_string, const void *rawippkt) -{ - void *stream_tag_value; - const struct mesa_ip6_hdr *ip6h = (struct mesa_ip6_hdr *)rawippkt; - - /* 暂时使用IPv6的源地址做为v6_tag */ - if(NULL == inet_ntop(AF_INET6, &ip6h->ip6_src, (char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX)) - { - return -1; - } - - stream_tag_value = terminal_tag_create_struct(stream->threadnum); - strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX); - project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value); - - return 0; -} - - -/* 设备获取用户TAG, 判断是否正确,解密后存于stream结构中 */ -int terminal_tag_probe(struct streaminfo *stream, struct tcphdr *api_tcp_hdr, - const void *rawippkt) -{ - struct mesa_tcp_hdr *this_tcphdr; - unsigned char *stream_tag_string = NULL; - unsigned char stack_tag_string[TERMINAL_TAG_SIZE_MAX]; - u_int8_t *option; - int tcp_hdr_len; - u_int16_t option_len; - int ret = 0; - - if(likely(-1 == project_req_terminal_tag_id)){ - return -1; - } - - this_tcphdr = (struct mesa_tcp_hdr *)api_tcp_hdr; - option = (u_int8_t *)this_tcphdr + 20; /* TCP标准头部长度=20 */ - tcp_hdr_len = 4 * this_tcphdr->th_off; - - stream_tag_string = (unsigned char *)project_req_get_struct(stream, project_req_terminal_tag_id); - if((NULL != stream_tag_string) && (stream_tag_string[0] != '\0')){ /* 已经获取到标签 */ - return 0; - } - - if(ADDR_TYPE_IPV6 == stream->addr.addrtype) - { - return terminal_tag_set_ipv6(stream, stack_tag_string, rawippkt); - }else if(ADDR_TYPE_IPV4 != stream->addr.addrtype){ - return -1; - } - - if(this_tcphdr->th_flags != TH_SYN) - { - ret = -2; - goto trace_tag; - } - tcp_hdr_len -= 20; - if(tcp_hdr_len < TCP_SYN_TAG_LEN) - { - ret = -3; - goto trace_tag; - } - - while(tcp_hdr_len > 0) - { - switch(*option) - { - case 0: /* type=0原意是选项结束,因追加了新选项,所以要继续往后检查 */ - case 1: - option_len = 1; - break; - - case TCP_SYN_TAG_TYPE: - option_len = *(option+1); - if(TCP_SYN_TAG_LEN == option_len) - { - ret = terminal_tag_decrypt((struct terminal_tag_t *)(option+2), stream, stack_tag_string); - if(0 == ret) - { - return 0; - } - } - break; - - default: - option_len = *(option+1); - } - if(0 == option_len) - { - goto trace_tag; - } - if(option_len > tcp_hdr_len) - { - goto trace_tag; - } - option += option_len; - tcp_hdr_len -= option_len; - } - -trace_tag: - return terminal_tag_trace(stream, stack_tag_string); - //return -1; -} - -char terminal_tag_tcp_all_entry(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet) -{ - const struct mesa_ip4_hdr *ip4h = (const struct mesa_ip4_hdr *)a_packet; - - if(OP_STATE_PENDING == a_tcp->pktstate){ - terminal_tag_probe(a_tcp, (struct tcphdr *)((char *)a_packet + ip4h->ip_hl*4), a_packet); - } - - return APP_STATE_DROPME; -} - -int terminal_tag_init(void) -{ - return 0; -} - - -#ifdef __cplusplus -} -#endif - diff --git a/src/project/terminal_tag.h b/src/project/terminal_tag.h deleted file mode 100644 index 335ce39..0000000 --- a/src/project/terminal_tag.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef _TERMINAL_TAG_H_ -#define _TERMINAL_TAG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "mesa_net.h" -#include -#include - -#define TERMINAL_MODULE_NAME "terminal_tag" - -#define TCP_SYN_TAG_TYPE (0xF1) -#define TCP_SYN_TAG_LEN (12) /* 6BMAC+2B设备ID+1B类型+1B校验和+1B类型+1B长度 */ -#define TCP_HDR_MAX_LEN (60) /* TCP头部最大长度 */ - -#define rol(x,n) (((x)<<(n)) | ((x)>>(8*sizeof(x)-(n)))) -#define ror(x,n) (((x)>>(n)) | ((x)<<(8*sizeof(x)-(n)))) - - -#define IP_STRUCT_MAGIC (0x8633) -struct local_ip_t{ - unsigned int ipaddr; /* 终端设备内网IP, 网络序 */ - unsigned short ip_magic_num; /* 魔数,存储IP时会空余两个字节,可用于验证 */ -}BYTE_ALIGNED(1); //sizeof(this)=6B - -union local_addr_t{ - unsigned char local_mac[6]; /* 终端设备MAC地址 */ - struct local_ip_t local_ip; /* 终端设备内网IP结构 */ -}BYTE_ALIGNED(1); //sizeof(this)=6B - -#define TERMINAL_ADDR_TYPE_MAC (0) -#define TERMINAL_ADDR_TYPE_IP (1) -#define TERMINAL_ADDR_TYPE_TRACE (2) -#define TERMINAL_ADDR_TYPE_GLOBAL_SIP (3) -struct terminal_tag_t{ -#if __BYTE_ORDER == __BIG_ENDIAN - unsigned char type:2; /* 内网参数获取方式, 1:MAC; 2:IP */ - unsigned char random:6; /* 随机数,用于加密 */ -#elif __BYTE_ORDER == __LITTLE_ENDIAN - unsigned char random:6; /* 随机数,用于加密 */ - unsigned char type:2; /* 内网参数获取方式, 1:MAC; 2:IP */ -#endif - - unsigned char check_sum; /* 校验和,用于完整性认证、防伪造 */ - unsigned short dev_id; /* 设备ID (区域ID),网络序 */ - union local_addr_t local_addr; /* 设备内网地址结构 */ -}BYTE_ALIGNED(1); //sizeof(this)=10B - -extern unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr); -extern unsigned char terminal_tag_checksum_hash(unsigned char rand_num, unsigned int ip_addr, unsigned short dev_id); -extern unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag,unsigned char checksum_key); - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/readme_GBK.txt b/src/readme_GBK.txt deleted file mode 100644 index 0743e2d..0000000 --- a/src/readme_GBK.txt +++ /dev/null @@ -1,748 +0,0 @@ -#if 0 -1.本部分代码主要两个功能 - 1)完成底层数据包的获取, 支持多种数据获取方式pag,ppf,pfring, - 2) 完成tcp、udp的流还原功能 - 3) 完成插件挂载功能 -********************************************************************* -20130802 刘庆云 -1)tcp建立链接时,为了抗攻击,对单侧流必须有第三个包 -2)增加控制开关,选择建立链接的方式 -**************************************************************************** -20130803 刘庆云 优化流还原模块的处理 -1) 每个包到来时按照两侧端口号,建立临时流表; - 如果出现小端口为服务端时,通过syn判断出后,颠倒四元组; - 每个流表进行hash时不在进行判断,直接用四元组; -2) 流表加入hash时按照四元组大小进行排序,插入的位置在findstream时提前算好,减少插入时的计算; -3) dealpkt部分的代码重新梳理,后得出能够独立运行的代码,不在依赖外层的 stack,support -4) 编写测试部分的独立测试函数,并进行测试; -**************************************************************************** -20130805 刘庆云 -1) 建立流表的端口的改为判断主机序列; -2)双向流收到第三个包后,直接进入数据表,起到保护真实链接的目标; -**************************************************************************** -20130813 刘庆云 -1)tcp流表的查找改为折半查找 -********************************************************************************************* -20130821 李佳 -1)针对某项目需求: 如果IP包是由多个IP分片包重组而成, 应用层插件可以获取所有原始IP分片包, - 新增加raw_ipfrag_list结构, 并在streaminfo结构中添加原始IP分片列表头指针. - 修改stream.h、dealpkt.c、dealtcp.c、deal_ipv4.c、deal_ipv6.c、ip_reassembly.c等与IP分片相关代码. -**************************************************************************** -20130822 刘庆云 -1)增加tcp全包回调接口,全包回调时可能会没有pdetail, -2)为了能够判断正确是否有pdetail,之前服用pdetail信息来存储synseq的方式不再可行,增加了变量用于临时记录seq - 同时,为了能够同时支持两种模式增加了pktstate和用于函数上下文的变量pktallme - pktstate的变换逻辑如下:第一个包为pending,如果有函数需要则该为data,如无需要改为close,链接淘汰时为close -3)当有全包获取函数挂载时,正常的fin,rst不会淘汰链接只能等淘汰 -4)为了在不同tcp接口情况下,挂载函数能够统一管理,函数调用链表函数需要传入xxstat和xxpme; -5) streaimindex改为预先分配需要的个数,这样是为了防止当处理过程中调用tcp_free_stream之后又进行使用出现野指针 - 另外一种避免的方法是没错传入**,接口比较麻烦,暂未使用 - -6)增加takeover模式,目前只支持注册一个接管函数; -7) syn+rst的报文也建立链接 -********************************************************************** -20130826 刘庆云 -1) mkstreamhash 用frand参与hash运算多了一次拷贝, 并且大部分情况为0,造成hash冲突,因此只用地址参与运算 - -********************************************************************** -20130917,18 刘庆云 - 1) hash_add_stream 必须在streamaddlist前进行,否则streamaddlist内淘汰一些链接后会造成 - hash_add_stream利用的之前查找的结果为错误结果 - 2) 每次淘汰的链接数目为总链接数目的2% - -****************************************************************************************** -20130922 李佳 -1)增加NPacket捕包方式, 编译参数"CAPTURE_MODE=$(LINK_NP)", 对应配置文件"capdatamodlel=5" -****************************************************************************************** -20140302 刘庆云 从dealpkt到platform 合并之前的各种修改 -1)dealpkt目录增加ipv6支持 -2)dealpkt目录合并之前修改的tcp_allpkt接口,调整等 -3)dealpkt目录合并之前修改的丢包计数分侧的bug -4)dealpkt目录中dealpkt.c dealtcp.c未合入108相关代码, - call_app未合入863_control的代码 -5)合并plugin 支持插件管理功能 - (1)程序调用接口:plugctrl_proc() ;(无参数) - (2)程序作用: - a、自动扫描解析层、业务层、兼容插件三个文件夹下插件(默认路径分别是./plug/protocol,./plug/business,./plug/general,可通过./wyqd.conf中参数更改此路径),调用其初始化函数; - b、并将IP_ENTRY,TCP_ENTRY,UDP_ENTRY三个入口指针分别挂载到对应函数调用链上; - c、保存其他入口函数指针,解析层调用时使用; -****************************************************************************************** -20140322 刘庆云 为了支持代理嵌套,进行了若干修改 -1)tcp部分原来设计只有当进入data状态后,才分配pdetail的空间;现在修改为 - 流一建立就分配pdetail的空间,当进入data后才分配half的空间 -2)重新规整了stream结构体的定义, - 原来和流相关的一些变量,全部移入pdetail,包括apme等; -3)流表的管理,用最里层的地址做hash,用多层地址递归进行比较 -4)初步添加了对vlan的处理函数,待完善 -****************************************************************************************** -20140323 刘庆云 为了支持应用层代理,进行修改 -1) tcpdetail结构体内增加proxylist指针,记录代理情况 -2) proxylist的申请,释放,有代理解析层控制; -3) 代理结构体内自带pme,opstate,用这两个变量回调所有的接口函数 -****************************************************************** -20140406 李佳 -1)增加对隧道的处理,理论上支持无限嵌套模式; -2)修改stream.h中ADDR_TYPE_IPV4地址类型定义,不再代表基于IPv4地址的四元组, - 而是真正的IPv4地址对, 四元组使用struct stream_tuple4表示; -3)细化分层结构,TCP层不再存储四元组信息,而是仅存储本层的端口信息, - 计算HASH以及地址比较时,再通过fstream找到IP地址; -4)修改计算HASH函数、HASH冲突后的比较函数; -5)将某项目的特殊应用,如标签、stream_id、原始IP分片包剥离并模块化, - 使用开关灵活控制某个模块的启用; -6)把底层捕包库封装成.so模式,在不同的捕包模式间切换时,只要修改配置文件即可,无需从编译。 -****************************************************************** -20140422 李佳 -1)为了处理效率,减少内存占用,及插件获取四元组的易用性, - 将TCP、UDP的端口存储于IP层,TCP层用指针指向IP层此块内存,即可以直接获取四元组信息。 -****************************************************************** -20140515 李佳 -针对863-UDP流还原测试硬件环境,增加QNF捕包接口. -****************************************************************** -20140616 李佳 -1)增加project管理模块,在stream->pproject结构中,可以任意挂载多个应用信息; -****************************************************************** -20140619 李佳 -1)增加raw_pkt_t结构,存储从捕包库获取的原始包信息; -2)插件入口函数增加原始包参数; -3)修改IP分片重组流程,支持隧道多层嵌套模式 -****************************************************************** -20140721 李佳 -1)IP分片重组HASH支持多层嵌套模式; -2)将原IP分片重组HASH模块改成基于MESA_htable实现; -****************************************************************** -20140901 李佳 -1)串联模式下,应用可能会误改原始包,增加对原始包数据校验功能。 -****************************************************************** -20140910 李佳 -1)增加MESA_inject_pkt()发包接口,简化造包操作,减少传参数量. -****************************************************************** -20140922 李佳 -1)增加MESA_kill_tcp_synack()接口, 用于IP-HMD的欺骗连接; -****************************************************************** -20141011 李佳 -1)增加读取配置文件变量maxrandval, randkeyval,用于识别系统发出的RST包; -2)fd补救由平台实现, 插件可以认为MESA_kill_tcp()是可靠的! -****************************************************************** -20141113 李佳 -1)修改创建连接有地址翻转时,因TCP流表查找错误,造成无法识别某些流的BUG。 -****************************************************************** -20141115 李佳 -1)增加MESA_kill_connection()函数,除了可以实现MESA_kill_tcp()原有功能外, - 还可以在串联模式下,对基于流的非TCP协议做fd(drop packet). -****************************************************************** -20141120 李佳 -1)增加pcap读大包模式进度条显示,预测处理时间. -****************************************************************** -20141125 李佳 -1)修改pcap模式下, 多线程分流BUG,其他模式(pag、pfring、dpdk等等)不受影响。 -2)更新plunin模块,version:2014-11-24 -****************************************************************** -20141127 李佳 -1)修改最大乱序包数最大值,由255扩展为65535, 修改了stream.h中关于maxunorder的定义. -****************************************************************** -20141202 李佳 -1)修改在pcap读包模式下,读包线程调用freeall_stream()早于工作线程导致的BUG; -2)增加平台和packet_io_lib版本号对比判断,如果不一致会打印警告信息; -3)修改淘汰UDP流时,pktstate没有正确设置为CLOSE状态BUG; -4)配置文件增加"UdpStreamTimeout", 用于设置开启UDP流还原时,超时淘汰时间; - 增加"load_plug_switch", 用于动态开启是否加载插件; -5)增加了sysinfo.log统计信息显示. -****************************************************************** -20141204 李佳 -1)修复在pag模式下运行时,IPv4和IPv6共存时的BUG, - 在顶级Makefile中增加"USE_PAG_GET_FRAME", - 根据环境选择是否使用pag_get_frame()直接获取mac包. -****************************************************************** -20141205 李佳 -1)修复IPv6-UDP数据包, 在开启UDP流还原的情况下, 无法找到对应的流, 造成HASH冲突链表爆炸BUG。 -****************************************************************** -20141208 李佳 -1)增加build_net_layer_gre()函数,可以构造带GRE协议的rst包. -****************************************************************** -20141211 李佳 -1)修改因IP分片重组后的包,而触发调用MESA_kill_tcp()的BUG; -2)修改MESA_kill_tcp()计算包长度BUG; -3)原始包结构raw_pkt_t中增加__magic__, 用于在papp和sapp平台之间区分原始包void *的实际类型. -****************************************************************** -20141217 李佳 -1)增加pag模式下,使用pag_get_frame接口功能, 用顶层Makefile的USE_PAG_GET_FRAME选项控制; -2)修改流还原按data建连接时,以大端口为源的规则; -3)修改了因重载了系统标准库exit(), 造成程序退出时莫名其妙的BUG. -****************************************************************** -20141219 李佳 -1)为了兼容之前插件, 修改IPv4, IPv6层插件原始包指针为本层IP包指针. -****************************************************************** -20141223 李佳, 刘庆云 -1)增加SAPP_PKT_CB_FUN_T回调函数类型: - char SAPP_PKT_EXAMPLE(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt); -****************************************************************** -20141224 李佳 -1)修改stream.h,将内部变量与外部变量分离,根据功能的不同,将stream.h分拆为: - #include "stream_inc/stream_base.h" - #include "stream_inc/stream_proxy.h" - #include "stream_inc/stream_project.h" - #include "stream_inc/stream_inject.h" - #include "stream_inc/stream_control.h" - #include "stream_inc/stream_entry.h" - #include "stream_inc/stream_rawpkt.h" -****************************************************************** -20141225 李佳 -1)将ip分片重组类型的包,用Pkttype标识,用于流管理层识别. -2)增加了一些不常见的协议类型处理, 如vlan、pppoe、ppp的非数据传输层协议. -****************************************************************** -20141226 李佳 -1)增加PPP和GRE协议的解析; -****************************************************************** -20141230 李佳 -1)增加addr_type_to_string()函数,用于插件输出协议地址类型字符串; -2)增加get_this_layer_header(),用于插件获取本层头部地址; -3)修改STREAM_CB_FUN_T回调函数的"原始包"参数,改为传输下层IP层的头部, - 真正的全原始包应使用SAPP_STREAM_FUN_T类型回调. -****************************************************************** -20141231 刘庆云 李佳 -1)平台同时支持传原始包和本层包头的接口,增加回调函数类型定义, - 修改callapp.c中stream_register_xxx和stream_process_xxx系列函数. -2)合并dictator2的20141217版本. -****************************************************************** -20150104 李佳 -1)修改stream_base.h, 将pkttype移动至struct layer_addr结构中, - 将routedir扩展为uchar类型; - 新增MESA_dir_reverse()函数, 用于发包时反向routedir. - stream.h增加版本号和MD5验证值. -2)增加MESA_fakepacket_xxx系列函数. -****************************************************************** -20150107 刘庆云 -1)reset重建链接时,重置计数器 -2) 判断syn是否重传的条件 从原来的(thisseq+1 == rcv->first_data_seq) -改为( rcv->first_data_seq-thisseq <=1) -3) 为了防止syn重置的链接syn在第一个链接里面,改为先调用tcp,再调用tcpall -4) 由于3)的修改,对于每个链接重置时rst,需要传递原始包给free_stream的函数 -****************************************************************** -20150112 李佳 -1)修改tcp_deal_data_stream,tcp_save_unorder,deal_tcp_stream等函数的参数, - 增加Iphdr和tcphdr参数,用于传递重组后的IP分片包。 -2)FD补救时增加判断条件,只有tcpdatalen > 0时,才继续调用MESA_kill_tcp, - 以防止攻击或本机发送的RST包又被捕获; -****************************************************************** -20150123 刘庆云 -1) pkttype 增加PKT_TYPE_TCPREORDER,需要每个包来了赋值 -2) proxy增加对地址的虚拟转换 -****************************************************************** -20150126 lqy yw -1) pkttype 增加PKT_TYPE_TCPRESTRAS 增加重传报文的类型 -2) tcp_stream_free重置顺序,先进行tcp,再进行tcpall -3) pkttype 分离成两个变量,pktipflagtype -****************************************************************** -20150129 李佳,刘庆云, 刘洋 -1)sapp增加-v参数,用于识别版本功能, 对外提供的可执行文件要strip, 通过nm命令无法查看. -2)sapp内置libsesame_door,用于限制平台使用范围,保护软件产权; -3)callapp内支持udp_raw接口 -4)插件管理更改;打开解析层插件,符号表为全局可见 -****************************************************************** -20150203 李佳 -1)新增四个地址转换函数: - const char *stream_addr_list_ntop_outward(const struct streaminfo *pstream); - const char *stream_addr_list_ntop_inward(const struct streaminfo *pstream); - const struct streaminfo *stream_addr_list_pton_outward(const char *addr_list_str, int thread_index); - const struct streaminfo *stream_addr_list_pton_inward(const char *addr_list_str, int thread_index); - 修改stream_base.h, 增加以上函数声明. -2)增加类型定义PKT_TYPE_IP_FRAG; - 增加stream_register_ip_frag, stream_register_ipv6_frag入口函数. -****************************************************************** -20150205 李佳 -1)增加基于PPP,GRE协议的RST包构造功能, - 因GRE没有创建流,目前只能单向发送RST. -***************************************************************** -20150210 刘庆云 -1) 修正tcp链接单流变双流时max_unorder未设置的问题 -2) nouse状态看到syn标识重置链接,这样能够看到新流的建立过程; -3) 对于fin状态后的数据在未开tcpall接口时,tcp会新建链接进行处理 - 而开tcpall接口后,这些包都不会被tcp看到 - tcpall接口的引入引起tcp处理包数的变换, - 从正常协议栈的角度,引入tcpall接口后的处理是正常的; - 但是有恶劣的情况是,tcp四元组复用,而又丢了syn的链接不能正常处理 -***************************************************************** -20150225 刘庆云 -1)记录tcp报文的重叠长度internal内增加变量tcpoverlen -2)tcplen>0但是带fin,rst等标志的数据包不建立链接 -3)对于syn后面第一个数据包乱序的情况,置标志位为tcpunorder -4)更新dictator2 到20150215版本 -****************************************************************** -20150226 李佳 -1)修改stream_base.h, 将地址转换函数接口变更为: -int stream_addr_list_ntop(const struct streaminfo *pstream, char *dst, int size); -int stream_addr_list_pton(const char *addr_list_str, void *dst, int size, int thread_index); -****************************************************************** -20150306 李佳 -1)解决隧道模式下, IPv6层无法回调的BUG. -****************************************************************** -20150311 李佳 -1)解决IP分片重组包同时在TCP层是乱序包的BUG, - (之前已解决, 后来在20150126版将pkttype分离后, 没有对pktipflagtype赋值, 此BUG重现). -****************************************************************** -20150312 李佳 -1)修复raw_ip_frag_list模块,v4和v6混乱的BUG. -****************************************************************** -20150316 刘洋 -1)1-plugin.c:1259 add funelem->called_flag =1; -否则如果pending状态没有调用业务层插件,每个data状态都会有pending的标示 -2-pending 增加called_flag的初始化 -3-close增加对调用的判断:如果该插件曾经被调用过或者当前字段是该插件所 - 需要的字段才在close状态调用,否则不调用 -****************************************************************** -20150319 李佳 -1)修改tcp_change_stream_todata()函数, TCP半流结构内存泄露BUG. -2)平台不再使用liblogger.so. -****************************************************************** -20150311,25 刘庆云, 李佳 -1)更新plugin到_20150325版本 -2) 修改了乱序报文中对于cout_ideal的重置过程 -3)0319修改tcp_change_stream_todata()函数, TCP半流结构内存泄露BUG . -4)0311对乱序缓存的数据,增加判断是否有重传重叠,如有则矫正 -5)修改了对于seq的比较时出现的问题改为用after,before函数比较 -6) 去掉了老版本的logger,更新为MESA_handle_logger -7) 修改test_app.so, TCP层插件统计信息错误BUG. -****************************************************************** -20150327 李佳 -1)修改mac_n2p_fun()BUG. -****************************************************************** -20150409 李佳 -1)修改配置参数MaxUdpStreams=0时, UDP插件得到的pdetail为NULL的BUG. -****************************************************************** -20150415 李佳,刘庆云 -合并papp在20150401的BUG修复: -1)修改deal_tcp.c 对乱序包的处理逻辑 - 对于达到最大乱序数目的链接,乱序中又出现乱序的情况,跳出本次乱序处理; - 对于乱序包的cout_ideal重置条件进行,只有当序号大时才从 -****************************************************************** -20150416 李佳 -1)增加cycle_pkt_dump功能, 解决在线流量出了BUG,无法重现问题. - main.conf中新增3个配置项: - [pkt_dump] - pkt_dump_switch=0 //总开关 - pkt_dump_file_max_size=10000 //单位:MB, 每个线程 - pkt_dump_file_root_dir=/dev/shm //pcap存储路径, 推荐/dev/shm, 速度快 -****************************************************************** -20150430 李佳 -1)修改配置文件对连接超时时间无效问题. - LinkTimeout=0, 用于TCP - UdpResetTime=0, 用于UDP -********************************************************************* -20150507 李佳 -1)新增加TCP连接数, 新建连接数,销毁连接数,HASH表冲突数统计。 -********************************************************************* -20150508 李佳 -1)增加UDP连接数统计. -********************************************************************* -20150512 李佳 -1)修复GRE负载长度为0时, Invalid read的BUG. -********************************************************************* -20150526 李佳 -1)修复pkt_dump模块, 因信号中断读写错误的BUG. -********************************************************************* -20150610 李佳 -1)修复流超时淘汰BUG. -********************************************************************* -20150612 刘庆云 -1)修复del_stream_by_time()从链表尾部淘汰BUG. -********************************************************************* -20150615 李佳 -1)修复MAC地址src,dst与流创建的反向不一致问题. -********************************************************************* -20150702 李佳 -1)增加GRE-IPv6协议的解析。 -********************************************************************* -20150703 李佳 -1)main.conf增加配置选项"skip_not_ip_layer", 用于双栈环境无法发送非IP承载的RST包问题。 -********************************************************************* -20150715 李佳 -1)修复丢流BUG,原因: - 在HASH函数比较地址时,只比较了IP忘记了端口,当在一个HASH-SLOT中有多个冲突链时, - 如果凑巧这些四元组的IP都是相同的,那么就会造成后续的新包被误认为是已有流的一部分, - 而不会被识别成一个新流. -2)增加从程序启动以来,处理的所有流数统计信息。 -********************************************************************* -20150902 李佳 -1) 集成iknow, 方便获取更多、更详细的辅助信息; -********************************************************************* -20150908 李佳 -1) 修改pkt_dump模块, 可以设置所有历史包总大小, 防止程序频繁重启造成无限制写硬盘; -********************************************************************* -20150916 李佳 -1)集成MESA_sleep(), 防止在2.6.32内核以上,usleep(1)CPU占用率过高问题. -********************************************************************* -20150922 李佳 -1)修改Iknow回调函数接口定义. -********************************************************************* -20150928 李佳 -1)修改pcap捕包模块获取原始包长BUG, 应该使用caplen而不是Len, - 因为可能没有加-s0选项,造成实际捕获的长度比理论包长小. -********************************************************************* -20150929 李佳 -1)增加topsec捕包库接口, 用于木马设备项目, 不再单独维护一个分支版本. -********************************************************************* -20151014 李佳 -1)增加MESA_sleep到平台,解决usleep()在高内核版本下CPU占用率太高问题. -********************************************************************* -20151027 李佳 -1)修复不能按已有方式识别本机发出的RST包的BUG。 -********************************************************************* -20151030 李佳 -1)修改teredo识别不准确问题; -2)修改sysinfo.h相关宏定义, 某些与start旧版有冲突, 造成sysinfo.log计数不准; -********************************************************************* -20151102 刘庆云,李佳 -1)修改因乱序包触发插件返回DROPPKT,造成平台乱序包链表逐渐增长,致使CPU占用率高的BUG; -********************************************************************* -20151104 李佳 -1)修改TCP、UDP流还原之后,没有更新IP分片状态标志BUG. -********************************************************************* -20151105 李佳 -1)修改pkt_dump模块性能较差问题; -********************************************************************* -20151106 李佳 -1)修改pkt_dump模块, 捕获SIGSEGV信号, 在信号处理函数中调用sync(), 保证触发segment fault的pcap包真正的保存到硬盘; -********************************************************************* -20151109 李佳 -1)修改pkt_dump模块,增加BPF-Filter过滤功能. -********************************************************************* -20151112 李佳 -1)增加新函数tcp_set_single_stream_drop_by_time(), - 设置当前流不再根据RST、FIN等标志结束, 只能等超时、或移至LRU队尾后被free. - 用于某些业务使用第三方的FD补救使用. -********************************************************************* -20151112-2 李佳 -1)增加函数MESA_set_stream_opt(), 用于控制单个链接的属性, - 使用类似setsockopt的方式, 不再增加独立函数. -********************************************************************* -20151118 李佳 -1)去掉捕包模式下对包长度是否超过MTU的检查, 因为在TSO模式下, 本机捕包经常会有单包长度几万字节的情况, - 导致应用层插件莫名其妙收不全数据。 -********************************************************************* -20151125 李佳 -1)解决平台在高版本系统下编译警告和错误; -2)关闭Iknow的DEBUG打印信息; - -********************************************************************* -20151207 李佳 -1)修改流创建结构, 将IP和端口绑定在一个地址集合, 普通IPv4, IPv6协议只需一个streaminfo结构, - TCP层不再通过pfather指针指向IP层地址, - 可节约内存和提高性能; -********************************************************************* -20151209 李佳 -1)增加配置参数: skip_ethernet_layer, - 用于控制是否跳过ethernet层, 不再处理MAC地址信息, 提高运行效率. - -********************************************************************* -20151215 李佳 -1)HASH冲突链表增加LRU机制, 将最近使用最频繁的流放于链表第一个, 提高查找效率; -2)使用LINUX内核HASH时, 一次makehash计算可以得到多个HASH值, - 使用一个HASH用于确定在HASH_SLOT的位置, - 再使用另一个HASH用于快速比较地址是否相等. - -********************************************************************* -20151223 李佳 -1)在乱序包的情况下, 先增加了数据包和字节数, - 导致插件还未拿到当前数据包, 但实际字节数已经增加, 导致计数不准确, - 已修复. -********************************************************************* -************************* 2016 year ********************************* -********************************************************************* -2016-01-19 李佳 -1)修复因将IP-PORT合并之后, inet_addr_list函数BUG。 -********************************************************************* -2016-06-08 李佳 -1)修改在按data建连接时, 调用了TCPALL插件后, 即便插件返回DROP, 仍然会调用TCP插件的逻辑, 导致HMD不生效问题. -********************************************************************* -2016-06-15 李佳 -1)增加丢弃纯ACK包功能, 靠配置文件discard_ack控制; -2)修改FD补救时, 由原来发送3个RST, 减少为1个. -********************************************************************* -2016-06-21 李佳 -1)增加配置项:kill_tcp_remedy, 用于控制是否开启FD补救功能. -********************************************************************* -2016-09-01 李佳 -1)for soq项目, 增加对隧道协议L2TP, PPTP, IPSEC的连接检测与日志记录。 - 新增stream_tunnel.h. -********************************************************************* -2016-09-30 李佳 -1)修复IPv6分片重组线程ID设置错误, 导致在开启dictator后coredump, 而是用普通malloc模式无问题. -********************************************************************* -2016-10-09 李佳 -1)修改stream_inject.h, 增加MESA_kill_tcp_feedback()等带反馈功能的函数接口. -********************************************************************* -2016-10-12 李佳 -1)增加L2TP协议的FD功能. -********************************************************************* -2016-11-10 李佳 -1)针对WY发包特殊需求--某插件不论网络中有无数据包, 都不能阻塞等待, 必须被持续不断调用, - 新增POLLING类型插件入口, 保证无数据包时, 也会调用此接口的插件. -********************************************************************* -2016-11-24 李佳 -1)修改sapp目录结构, 将原来test拆分为运行目录run, 和源码目录entry, 便于部署批量copy. -********************************************************************* -2016-12-01 李佳 -1)增加PPP协议解析CHAP认证的用户名功能. -********************************************************************* -2016-12-05 李佳 -1)修改stream_base.h, 增加layer_addr_ntop(), layer_addr_prefix_ntop(). -********************************************************************* -2016-12-15 李佳 -1)增强IPv4包格式的校验, 增加对包截断等情况的判断; -1)修复pptp HASH插入失败后没有free的BUG. -********************************************************************* -2016-12-20 郑超, 李佳 -1)更新dictator, 修复realloc BUG. -********************************************************************* -2016-12-21 李佳 -1)更新stream_addr_list_ntop, stream_addr_list_pton等函数, 修改地址字符串前缀命名, 更易读. -********************************************************************* -2016-12-22 李佳 -1)修复平台在非X86平台下无法编译问题; -2)修改dictator初始化读取配置文件顺序BUG. -********************************************************************* -2016-12-26 刘洋, 李佳 -1)刘洋修改plungin, 插件加载失败后, 调用dlclose关闭dlopen打开的文件句柄; -********************************************************************* -2016-12-27 李佳 -1)修改pptp解析层调用业务插件时, streaminfo结构体为NULL的BUG; -********************************************************************* -2016-12-29 李佳 -1)修改pptp隧道无法反向inject包的BUG(暂时只支持双向流反向inject, 单向流仍无法支持); - -********************************************************************* -************************* 2017 year ********************************* -********************************************************************* - -********************************************************************* -2017-01-03 李佳 -1)增加L2tp解析层HASH冲突严重问题, 超过阈值后不再处理新流. -2)修改TCP流管理BUG, tcp_reset_stream()将当前流移出lru_list, 在tcp_deal_unorder()函数中, - 可能会再调用tcp_change_stream_tonouse(), 再次调用streamleavlist, 致使plist->head, tail都为NULL. -********************************************************************* -2017-01-05 李佳 -1)修改PPTP, L2TP协议解析层hash算法, 减少冲突率. -********************************************************************* -2017-01-09 李佳 -1)因2016-12-26, 插件加载失败后, 调用dlclose关闭dlopen打开的文件句柄的方案会造成程序崩溃且无法查看函数调用栈, - 所以不再主动dlclose句柄; -2)修改打开ip_frag_list功能后, UDP超时重置时造成内存泄漏的BUG; -3)修改增加MESA_kill_tcp_feedback()函数后, MESA_sendpacket_iplayer()等函数, 在调用packet_io_send_fake_pkt()时, 传递参数错误BUG. -********************************************************************* -2017-01-20 李佳 -1)pcap模式启用dictator后, 读包完退出时free线程不是包处理线程, 造成dictator assert失败. -********************************************************************* -2017-02-10 李佳 -1)layer_addr_ntop()增加OpenVPN协议; -2)修改l2tp, pptp二元组HASH算法,减少HASH冲突; -3)临时增加SAPP_INSECTICIDE宏,用于检查莫名其妙的BUG,尽量早发现问题。 -********************************************************************* -2017-02-11 李佳 -1)增加TCP-RST, UDP发包统计计数; -********************************************************************* -2017-02-16 李佳 -1)修改get_stream_carry_tunnel_type()对于PPTP, L2TP的识别BUG。 -********************************************************************* -2017-02-24 李佳 -1)因DPDK初始化时绑定当前线程到某CPU核心, 导致后续动态创建的所有线程都默认继承这个行为, 全绑定到同一个核心, - 修改packet_io和plug_proc的初始化顺序。 -********************************************************************* -2017-04-07 李佳 -1)增加新的pag_marsio模式, 主要用于使用marsio的pag_get_frame接口,和之前Zhuanyong网卡的pag_get_frame区分。 -********************************************************************* -2017-04-21 李佳 -1)集成327的Ipfile读包模式。 -********************************************************************* -2017-05-11 李佳 -1)main.conf增加配置文件ipentry_priority_over_ipfrag,用于控制IP层和IPFRAG层调用优先级; -2)增加包类型PKT_TYPE_IP_FRAG_LAST,表示同属于一个原始IP包的最后一个IP分片包。 -********************************************************************* -2017-05-15 李佳 -1)支持marsio-4.1原生接口. -********************************************************************* -2017-05-24 李佳 -1)支持将sapp做为一个动态链接库.so, 可挂载到其他平台上的IP_entry, 减少联调TCP流还原及streaminfo各种变量不一致的时间, - 做为插件使用时,默认使用固定目录/home/mesasoft/sapp. -********************************************************************* -2017-06-08 李佳,刘洋 -1)将wangyan保活功能独立做为插件实现, 更新callapp.c与插件管理相关流程,如记录插件包处理延时等。 -********************************************************************* -2017-06-12 李佳 -1)平台修改流淘汰机制, 业务插件可设置独立的超时时间, 如果UDP流一段时间无包到达, 也不会因流表满而遭淘汰。 -********************************************************************* -2017-06-27 李佳 -1)针对GDEV串联模式,修改底层收发包接口; -2)更新stream_base.h, stream_inject.h, stream_rawpkt.h; -3)将GDEV保护功能移出平台,做为独立插件运行; -4)增加检测实际运行环境的stream_inc和当前sapp版本不一致,打印警告功能。 - -********************************************************************* -2017-06-28 李佳 -1)增加检测实际运行环境的stream_inc和当前sapp版本不一致,打印警告功能。 -********************************************************************* -2017-07-10 李佳 -1)marsio模式,则增加从main.conf中获取app_name功能; -2)修改UDP超时淘汰机制,除reset当前流外,还可以淘汰其他超时的流; -********************************************************************* -2017-08-03 李佳 -1)增加TCP单向流推测对端ISN功能; -1)增加TCP单向流推测对端总计接收字节数功能; -********************************************************************* -2017-08-08 李佳 -1)修改tcpdump_mesa, 支持指定捕包线程ID -********************************************************************* -2017-08-24 李佳 -1)修改tcpdump_mesa, 增加捕包采样率,防止在大流量环境下丢包。 -********************************************************************* -2017-09-04 李佳 -1)增加函数sapp_get_platform_opt(), 供插件获取平台内部参数,如包数、字节数等。 -2)marsio4不再支持runtime检测,平台增加runtime.log,记录单包处理延时; -3)合并单向流处理ISN的缺陷, 可以通过C2S方向的SYN,ACK包,推算出S2C的ISN. -********************************************************************* -2017-09-05 李佳 -1)修改tcp获取syn包选项dir方向参数BUG; -********************************************************************* -2017-09-21 李佳,刘洋 -1)增加回调函数platform_register_action_judge, 平台最终的包转发返回值PASS or DROP由外部插件决定. -2)修改插件管理模块,返回值根据业务插件类型, FD or JC决定; -3)修改默认不识别流量转发策略, GDEV模式下为DROP; -********************************************************************* -2017-09-26 李佳 -1)修复2017-05-11修改ip_entry和ip_frag_entry调用优先级,导致IP包会调用ip_frag_entry的BUG. -********************************************************************* - -2017-09-28 李佳 -1)增加按业务号保活功能,WY保活插件只在主应用下设置gdev保活插件的业务号; -********************************************************************* -2017-10-03 李佳 -1)增加解析TCP包头部选项TCP_OPT_MULTI_PATH_TCP, 因选项不定长,且可能超过8字节, - 原有结构不适用,为了向后兼容同时支持新选项, - 新增struct tcp_option_ext结构, - 及函数MESA_get_tcp_pkt_opts_ext(). -********************************************************************* -2017-10-10 李佳 -1)修改在DDP模式下tcpdump_mesa的包捕获位置,可以捕获DDP内封装的原始包。 -********************************************************************* -2017-10-16 李佳 -1)增加判断四元组重用的判断。 -2)增加iknow_switch配置文件, iknow功能可以关闭, 默认开启. -3)增加symbol_conflict_check配置文件, 符号名检查可以关闭, 默认开启. -********************************************************************* -2017-10-19 李佳 -1)增加anti_flood模块, 用于抵御SYN_flood, DNS_flood攻击; -2)修改TCPALL插件, 因乱序的SYN, SYN/ACK包,被误认为是四元组重用, 重置连接而导致被分拆为两个流的BUG. -********************************************************************* -2017-10-26 李佳 -1)Gserial_send系列函数增加发包日志, 便于WY环境下查找问题. -2)增加field_stat输出. -********************************************************************* -2017-10-31 李佳 -1)修复因pcap.h, libpcap.so在纯新的系统上缺失,第一次无法编译的情况; -2)修复PPTP隧道协议,因PPP头部压缩且没有获取PPTP控制连接时,无法解析的问题。 -********************************************************************* -2017-11-09 李佳 -1)Gserial_send系列函数发包按ip, tcp, udp分协议类型统计。 -2)内置pcap.h, 在纯新机器上可以编译通过. -********************************************************************* -2017-11-13 李佳 -1)增加GDEV保活计数获取接口, 便于统计; -********************************************************************* -2017-11-24 李佳 -1)VxLan模式PPP或HDLC封装, MAC地址为驱动随机填充的, 不能用于判定广播、组播等操作. -********************************************************************* -2017-12-08 李佳 -1)修改平台调用TCPALL插件逻辑, 先调用TCPALL, 后调用TCP; -2)对于一个流的首包是RST且SEQ=0的包,平台忽略不处理。 -********************************************************************* -2017-12-20 李佳 -1)l2tp_protocol_plug修复地址解析长度超范围BUG; -2)更新TCP流还原机制, 四元组重用判断与最后一个包的时间间隔, 太短则认为是恶意逃逸, 丢弃. - -********************************************************************* -************************* 2018 year ********************************* -********************************************************************* - -2018-01-19 lijia add, -1-多个tcpdump_mesa同时启动时, 后续的连接会抢占第一个连接的数据流, 但使用第一个连接的过滤条件, - 增加TCP命令连接的确认机制, 如果sapp不回复确认包, tcpdump_mesa不启动捕包. - -2-增加丢包计数, 如果使用-a参数指定perceptive模式, sapp在发送包时, 在源MAC地址上打上序号, - tcpdump_mesa检查序号是否连续, 以确认中间是否有丢包, 丢了几个包. -********************************************************************* -2018-02-28 李佳 -1)修复插重要件不保活时, gdev仍继续保活的BUG; -2)修改vxlan模式下, 丢弃广播、组播包的判断逻辑. -********************************************************************* -2018-03-02 lijia add, -1)因并联模式FD效果不好,增加FD补救向GDEV下发规则功能,依靠串联丢包提高FD率。 -********************************************************************* -2018-03-13 李佳 -1)修复teredo隧道非标准端口无法识别问题. -********************************************************************* -2018-03-23 李佳 -1) 修复GDEV规则下发插件BUG. -********************************************************************* -2018-04-17 刘洋 -1)主从应用都是通过配置文件PLUGINFO获得,该功能由总控添加,不过sapp中需要将原功能注释掉,即plugin.c:733行。 -********************************************************************* -2018-04-25 李佳 -1)修复get_this_layer_header()函数, 在流超时淘汰时的BUG; -********************************************************************* -2018-07-10 李佳 -1)修改private_ip段识别错误BUG; -********************************************************************* -2018-08-01 李佳 -1)针对3x7项目,增加剥离3x7数据包头功能,将内层原始数据包再注入ipv4_entry(); -********************************************************************* -2018-08-03 李佳 -1)修复IP头部检测不支持ESP问题, 导致IPSEC业务被丢弃. -********************************************************************* -2018-09-23 李佳 -1)增加对MAC_IN_MAC回流镜像格式的处理; -2)修复MAC_IN_MAC封装格式下, RST发送BUG. -3)修改判断广播和组播的判断逻辑, vxlan模式下对于vxlan封装的数据包不做判断; -4)支持IPV6发包. -********************************************************************* -2018-10-13 李佳 -1)修改IP包头检测函数, 对协议类型字段的检查, 防止误丢弃某些不常见协议的数据包. -********************************************************************* -2018-10-19 李佳 -1)修改field_stat输出TCP并发连接数BUG. -********************************************************************* -2018-10-24 李佳 -1)增加对MAC_IN_MAC的地址解析, 从中获取GDEV_ID, LINK_ID, LINK_DIR等参数. -********************************************************************* -2018-11-02 李佳 -1)修改mpls_hdr头部定义错误; -2)解析多层嵌套MPLS数据包. -********************************************************************* -2018-11-05 杨威 -1)修改源码, 适配cmake编译. -********************************************************************* -2018-11-08 杨威 -1.更新gprs tunnel协议识别逻辑,使用identify_gtp函数,取代原有的仅识别端口的逻辑 -2.更新packet_io_send_fake_pkt_gdev函数逻辑,正确的计算偏移填写发包内容时的data和datalen -3.更新packet_io_send_fake_pkt,对于注入发包,直接调用packet_io_send_fake_pkt_by_gdev -4.MESA_send_handle新增raw_udp_fd用于从udp负载开始发送注入包 -6.增加Gserial_sendpacket_ipv6_layer()函数, 可以发送已构造好的IPV6数据包. -********************************************************************* -2018-11-09 杨威 -1.整理TODO,按重要程度分级 -2.移除run目录下的log文件 -3.更新GTP处理逻辑,增加对带seq消息的处理并保存在地址中 -********************************************************************* -2018-11-12 杨威,李佳 -1.更新GTP处理逻辑, 增加对端地址(TEID,SEQ等)更新逻辑。 -********************************************************************* -2018-11-16 李佳 -1)支持cmake, 与并联版本部分同步. - -********************************************************************* -**************************** 2019 Year ****************************** -********************************************************************* -2019-05-15 李佳 -1)sapp version 4.0! -2)从新设计配置文件格式; -3)支持命令行参数; -4)其他重大更新待后续版本升级...... -#endif diff --git a/src/readme_UTF8.txt b/src/readme_UTF8.txt deleted file mode 100644 index 3e0f411..0000000 --- a/src/readme_UTF8.txt +++ /dev/null @@ -1,748 +0,0 @@ -锘#if 0 -1.鏈儴鍒嗕唬鐮佷富瑕佷袱涓姛鑳 - 1锛夊畬鎴愬簳灞傛暟鎹寘鐨勮幏鍙栵紝 鏀寔澶氱鏁版嵁鑾峰彇鏂瑰紡pag锛宲pf锛宲fring锛 - 2) 瀹屾垚tcp銆乽dp鐨勬祦杩樺師鍔熻兘 - 3) 瀹屾垚鎻掍欢鎸傝浇鍔熻兘 -********************************************************************* -20130802 鍒樺簡浜 -1)tcp寤虹珛閾炬帴鏃讹紝涓轰簡鎶楁敾鍑伙紝瀵瑰崟渚ф祦蹇呴』鏈夌涓変釜鍖 -2)澧炲姞鎺у埗寮鍏筹紝閫夋嫨寤虹珛閾炬帴鐨勬柟寮 -**************************************************************************** -20130803 鍒樺簡浜 浼樺寲娴佽繕鍘熸ā鍧楃殑澶勭悊 -1) 姣忎釜鍖呭埌鏉ユ椂鎸夌収涓や晶绔彛鍙凤紝寤虹珛涓存椂娴佽〃锛 - 濡傛灉鍑虹幇灏忕鍙d负鏈嶅姟绔椂锛岄氳繃syn鍒ゆ柇鍑哄悗锛岄鍊掑洓鍏冪粍锛 - 姣忎釜娴佽〃杩涜hash鏃朵笉鍦ㄨ繘琛屽垽鏂紝鐩存帴鐢ㄥ洓鍏冪粍锛 -2) 娴佽〃鍔犲叆hash鏃舵寜鐓у洓鍏冪粍澶у皬杩涜鎺掑簭锛屾彃鍏ョ殑浣嶇疆鍦╢indstream鏃舵彁鍓嶇畻濂斤紝鍑忓皯鎻掑叆鏃剁殑璁$畻锛 -3) dealpkt閮ㄥ垎鐨勪唬鐮侀噸鏂版⒊鐞嗭紝鍚庡緱鍑鸿兘澶熺嫭绔嬭繍琛岀殑浠g爜锛屼笉鍦ㄤ緷璧栧灞傜殑 stack锛宻upport -4) 缂栧啓娴嬭瘯閮ㄥ垎鐨勭嫭绔嬫祴璇曞嚱鏁帮紝骞惰繘琛屾祴璇曪紱 -**************************************************************************** -20130805 鍒樺簡浜 -1) 寤虹珛娴佽〃鐨勭鍙g殑鏀逛负鍒ゆ柇涓绘満搴忓垪; -2锛夊弻鍚戞祦鏀跺埌绗笁涓寘鍚庯紝鐩存帴杩涘叆鏁版嵁琛紝璧峰埌淇濇姢鐪熷疄閾炬帴鐨勭洰鏍; -**************************************************************************** -20130813 鍒樺簡浜 -1)tcp娴佽〃鐨勬煡鎵炬敼涓烘姌鍗婃煡鎵 -********************************************************************************************* -20130821 鏉庝匠 -1)閽堝鏌愰」鐩渶姹: 濡傛灉IP鍖呮槸鐢卞涓狪P鍒嗙墖鍖呴噸缁勮屾垚, 搴旂敤灞傛彃浠跺彲浠ヨ幏鍙栨墍鏈夊師濮婭P鍒嗙墖鍖, - 鏂板鍔爎aw_ipfrag_list缁撴瀯, 骞跺湪streaminfo缁撴瀯涓坊鍔犲師濮婭P鍒嗙墖鍒楄〃澶存寚閽. - 淇敼stream.h銆乨ealpkt.c銆乨ealtcp.c銆乨eal_ipv4.c銆乨eal_ipv6.c銆乮p_reassembly.c绛変笌IP鍒嗙墖鐩稿叧浠g爜. -**************************************************************************** -20130822 鍒樺簡浜 -1)澧炲姞tcp鍏ㄥ寘鍥炶皟鎺ュ彛锛屽叏鍖呭洖璋冩椂鍙兘浼氭病鏈塸detail锛 -2)涓轰簡鑳藉鍒ゆ柇姝g‘鏄惁鏈塸detail锛屼箣鍓嶆湇鐢╬detail淇℃伅鏉ュ瓨鍌╯ynseq鐨勬柟寮忎笉鍐嶅彲琛岋紝澧炲姞浜嗗彉閲忕敤浜庝复鏃惰褰晄eq - 鍚屾椂锛屼负浜嗚兘澶熷悓鏃舵敮鎸佷袱绉嶆ā寮忓鍔犱簡pktstate鍜岀敤浜庡嚱鏁颁笂涓嬫枃鐨勫彉閲弍ktallme - pktstate鐨勫彉鎹㈤昏緫濡備笅锛氱涓涓寘涓簆ending锛屽鏋滄湁鍑芥暟闇瑕佸垯璇ヤ负data锛屽鏃犻渶瑕佹敼涓篶lose锛岄摼鎺ユ窐姹版椂涓篶lose -3)褰撴湁鍏ㄥ寘鑾峰彇鍑芥暟鎸傝浇鏃,姝e父鐨刦in锛宺st涓嶄細娣樻卑閾炬帴鍙兘绛夋窐姹 -4)涓轰簡鍦ㄤ笉鍚宼cp鎺ュ彛鎯呭喌涓嬶紝鎸傝浇鍑芥暟鑳藉缁熶竴绠$悊锛屽嚱鏁拌皟鐢ㄩ摼琛ㄥ嚱鏁伴渶瑕佷紶鍏xstat鍜寈xpme锛 -5) streaimindex鏀逛负棰勫厛鍒嗛厤闇瑕佺殑涓暟锛岃繖鏍锋槸涓轰簡闃叉褰撳鐞嗚繃绋嬩腑璋冪敤tcp_free_stream涔嬪悗鍙堣繘琛屼娇鐢ㄥ嚭鐜伴噹鎸囬拡 - 鍙﹀涓绉嶉伩鍏嶇殑鏂规硶鏄病閿欎紶鍏**锛屾帴鍙f瘮杈冮夯鐑︼紝鏆傛湭浣跨敤 - -6锛夊鍔爐akeover妯″紡锛岀洰鍓嶅彧鏀寔娉ㄥ唽涓涓帴绠″嚱鏁帮紱 -7) syn+rst鐨勬姤鏂囦篃寤虹珛閾炬帴 -********************************************************************** -20130826 鍒樺簡浜 -1) mkstreamhash 鐢╢rand鍙備笌hash杩愮畻澶氫簡涓娆℃嫹璐濓紝 骞朵笖澶ч儴鍒嗘儏鍐典负0锛岄犳垚hash鍐茬獊锛屽洜姝ゅ彧鐢ㄥ湴鍧鍙備笌杩愮畻 - -********************************************************************** -20130917,18 鍒樺簡浜 - 1) hash_add_stream 蹇呴』鍦╯treamaddlist鍓嶈繘琛岋紝鍚﹀垯streamaddlist鍐呮窐姹颁竴浜涢摼鎺ュ悗浼氶犳垚 - hash_add_stream鍒╃敤鐨勪箣鍓嶆煡鎵剧殑缁撴灉涓洪敊璇粨鏋 - 2) 姣忔娣樻卑鐨勯摼鎺ユ暟鐩负鎬婚摼鎺ユ暟鐩殑2% - -****************************************************************************************** -20130922 鏉庝匠 -1)澧炲姞NPacket鎹曞寘鏂瑰紡, 缂栬瘧鍙傛暟"CAPTURE_MODE=$(LINK_NP)", 瀵瑰簲閰嶇疆鏂囦欢"capdatamodlel=5" -****************************************************************************************** -20140302 鍒樺簡浜 浠巇ealpkt鍒皃latform 鍚堝苟涔嬪墠鐨勫悇绉嶄慨鏀 -1)dealpkt鐩綍澧炲姞ipv6鏀寔 -2)dealpkt鐩綍鍚堝苟涔嬪墠淇敼鐨則cp_allpkt鎺ュ彛锛岃皟鏁寸瓑 -3)dealpkt鐩綍鍚堝苟涔嬪墠淇敼鐨勪涪鍖呰鏁板垎渚х殑bug -4)dealpkt鐩綍涓璬ealpkt.c dealtcp.c鏈悎鍏108鐩稿叧浠g爜锛 - call_app鏈悎鍏863_control鐨勪唬鐮 -5)鍚堝苟plugin 鏀寔鎻掍欢绠$悊鍔熻兘 - (1)绋嬪簭璋冪敤鎺ュ彛锛歱lugctrl_proc() 锛(鏃犲弬鏁) - (2)绋嬪簭浣滅敤锛 - a銆佽嚜鍔ㄦ壂鎻忚В鏋愬眰銆佷笟鍔″眰銆佸吋瀹规彃浠朵笁涓枃浠跺す涓嬫彃浠(榛樿璺緞鍒嗗埆鏄./plug/protocol,./plug/business,./plug/general锛屽彲閫氳繃./wyqd.conf涓弬鏁版洿鏀规璺緞)锛岃皟鐢ㄥ叾鍒濆鍖栧嚱鏁帮紱 - b銆佸苟灏咺P_ENTRY,TCP_ENTRY,UDP_ENTRY涓変釜鍏ュ彛鎸囬拡鍒嗗埆鎸傝浇鍒板搴斿嚱鏁拌皟鐢ㄩ摼涓婏紱 - c銆佷繚瀛樺叾浠栧叆鍙e嚱鏁版寚閽堬紝瑙f瀽灞傝皟鐢ㄦ椂浣跨敤锛 -****************************************************************************************** -20140322 鍒樺簡浜 涓轰簡鏀寔浠g悊宓屽锛岃繘琛屼簡鑻ュ共淇敼 -1)tcp閮ㄥ垎鍘熸潵璁捐鍙湁褰撹繘鍏ata鐘舵佸悗锛屾墠鍒嗛厤pdetail鐨勭┖闂达紱鐜板湪淇敼涓 - 娴佷竴寤虹珛灏卞垎閰峱detail鐨勭┖闂达紝褰撹繘鍏ata鍚庢墠鍒嗛厤half鐨勭┖闂 -2)閲嶆柊瑙勬暣浜唖tream缁撴瀯浣撶殑瀹氫箟锛 - 鍘熸潵鍜屾祦鐩稿叧鐨勪竴浜涘彉閲忥紝鍏ㄩ儴绉诲叆pdetail锛屽寘鎷琣pme绛夛紱 -3)娴佽〃鐨勭鐞嗭紝鐢ㄦ渶閲屽眰鐨勫湴鍧鍋歨ash锛岀敤澶氬眰鍦板潃閫掑綊杩涜姣旇緝 -4)鍒濇娣诲姞浜嗗vlan鐨勫鐞嗗嚱鏁帮紝寰呭畬鍠 -****************************************************************************************** -20140323 鍒樺簡浜 涓轰簡鏀寔搴旂敤灞備唬鐞嗭紝杩涜淇敼 -1) tcpdetail缁撴瀯浣撳唴澧炲姞proxylist鎸囬拡锛岃褰曚唬鐞嗘儏鍐 -2) proxylist鐨勭敵璇凤紝閲婃斁锛屾湁浠g悊瑙f瀽灞傛帶鍒讹紱 -3) 浠g悊缁撴瀯浣撳唴鑷甫pme,opstate锛岀敤杩欎袱涓彉閲忓洖璋冩墍鏈夌殑鎺ュ彛鍑芥暟 -****************************************************************** -20140406 鏉庝匠 -1)澧炲姞瀵归毀閬撶殑澶勭悊锛岀悊璁轰笂鏀寔鏃犻檺宓屽妯″紡; -2)淇敼stream.h涓瑼DDR_TYPE_IPV4鍦板潃绫诲瀷瀹氫箟锛屼笉鍐嶄唬琛ㄥ熀浜嶪Pv4鍦板潃鐨勫洓鍏冪粍锛 - 鑰屾槸鐪熸鐨処Pv4鍦板潃瀵, 鍥涘厓缁勪娇鐢╯truct stream_tuple4琛ㄧず; -3)缁嗗寲鍒嗗眰缁撴瀯锛孴CP灞備笉鍐嶅瓨鍌ㄥ洓鍏冪粍淇℃伅锛岃屾槸浠呭瓨鍌ㄦ湰灞傜殑绔彛淇℃伅锛 - 璁$畻HASH浠ュ強鍦板潃姣旇緝鏃讹紝鍐嶉氳繃fstream鎵惧埌IP鍦板潃; -4)淇敼璁$畻HASH鍑芥暟銆丠ASH鍐茬獊鍚庣殑姣旇緝鍑芥暟; -5)灏嗘煇椤圭洰鐨勭壒娈婂簲鐢紝濡傛爣绛俱乻tream_id銆佸師濮婭P鍒嗙墖鍖呭墺绂诲苟妯″潡鍖栵紝 - 浣跨敤寮鍏崇伒娲绘帶鍒舵煇涓ā鍧楃殑鍚敤; -6)鎶婂簳灞傛崟鍖呭簱灏佽鎴.so妯″紡锛屽湪涓嶅悓鐨勬崟鍖呮ā寮忛棿鍒囨崲鏃讹紝鍙淇敼閰嶇疆鏂囦欢鍗冲彲锛屾棤闇浠庣紪璇戙 -****************************************************************** -20140422 鏉庝匠 -1)涓轰簡澶勭悊鏁堢巼锛屽噺灏戝唴瀛樺崰鐢紝鍙婃彃浠惰幏鍙栧洓鍏冪粍鐨勬槗鐢ㄦэ紝 - 灏員CP銆乁DP鐨勭鍙e瓨鍌ㄤ簬IP灞傦紝TCP灞傜敤鎸囬拡鎸囧悜IP灞傛鍧楀唴瀛橈紝鍗冲彲浠ョ洿鎺ヨ幏鍙栧洓鍏冪粍淇℃伅銆 -****************************************************************** -20140515 鏉庝匠 -閽堝863-UDP娴佽繕鍘熸祴璇曠‖浠剁幆澧冿紝澧炲姞QNF鎹曞寘鎺ュ彛. -****************************************************************** -20140616 鏉庝匠 -1)澧炲姞project绠$悊妯″潡锛屽湪stream->pproject缁撴瀯涓紝鍙互浠绘剰鎸傝浇澶氫釜搴旂敤淇℃伅; -****************************************************************** -20140619 鏉庝匠 -1)澧炲姞raw_pkt_t缁撴瀯锛屽瓨鍌ㄤ粠鎹曞寘搴撹幏鍙栫殑鍘熷鍖呬俊鎭; -2)鎻掍欢鍏ュ彛鍑芥暟澧炲姞鍘熷鍖呭弬鏁; -3)淇敼IP鍒嗙墖閲嶇粍娴佺▼锛屾敮鎸侀毀閬撳灞傚祵濂楁ā寮 -****************************************************************** -20140721 鏉庝匠 -1)IP鍒嗙墖閲嶇粍HASH鏀寔澶氬眰宓屽妯″紡; -2)灏嗗師IP鍒嗙墖閲嶇粍HASH妯″潡鏀规垚鍩轰簬MESA_htable瀹炵幇; -****************************************************************** -20140901 鏉庝匠 -1)涓茶仈妯″紡涓嬶紝搴旂敤鍙兘浼氳鏀瑰師濮嬪寘锛屽鍔犲鍘熷鍖呮暟鎹牎楠屽姛鑳姐 -****************************************************************** -20140910 鏉庝匠 -1)澧炲姞MESA_inject_pkt()鍙戝寘鎺ュ彛锛岀畝鍖栭犲寘鎿嶄綔锛屽噺灏戜紶鍙傛暟閲. -****************************************************************** -20140922 鏉庝匠 -1)澧炲姞MESA_kill_tcp_synack()鎺ュ彛, 鐢ㄤ簬IP-HMD鐨勬楠楄繛鎺; -****************************************************************** -20141011 鏉庝匠 -1)澧炲姞璇诲彇閰嶇疆鏂囦欢鍙橀噺maxrandval, randkeyval锛岀敤浜庤瘑鍒郴缁熷彂鍑虹殑RST鍖; -2)fd琛ユ晳鐢卞钩鍙板疄鐜, 鎻掍欢鍙互璁や负MESA_kill_tcp()鏄彲闈犵殑锛 -****************************************************************** -20141113 鏉庝匠 -1)淇敼鍒涘缓杩炴帴鏈夊湴鍧缈昏浆鏃讹紝鍥燭CP娴佽〃鏌ユ壘閿欒锛岄犳垚鏃犳硶璇嗗埆鏌愪簺娴佺殑BUG銆 -****************************************************************** -20141115 鏉庝匠 -1)澧炲姞MESA_kill_connection()鍑芥暟锛岄櫎浜嗗彲浠ュ疄鐜癕ESA_kill_tcp()鍘熸湁鍔熻兘澶栵紝 - 杩樺彲浠ュ湪涓茶仈妯″紡涓嬶紝瀵瑰熀浜庢祦鐨勯潪TCP鍗忚鍋歠d(drop packet). -****************************************************************** -20141120 鏉庝匠 -1)澧炲姞pcap璇诲ぇ鍖呮ā寮忚繘搴︽潯鏄剧ず锛岄娴嬪鐞嗘椂闂. -****************************************************************** -20141125 鏉庝匠 -1)淇敼pcap妯″紡涓, 澶氱嚎绋嬪垎娴丅UG锛屽叾浠栨ā寮(pag銆乸fring銆乨pdk绛夌瓑)涓嶅彈褰卞搷銆 -2)鏇存柊plunin妯″潡锛寁ersion:2014-11-24 -****************************************************************** -20141127 鏉庝匠 -1)淇敼鏈澶т贡搴忓寘鏁版渶澶у硷紝鐢255鎵╁睍涓65535, 淇敼浜唖tream.h涓叧浜巑axunorder鐨勫畾涔. -****************************************************************** -20141202 鏉庝匠 -1)淇敼鍦╬cap璇诲寘妯″紡涓嬶紝璇诲寘绾跨▼璋冪敤freeall_stream()鏃╀簬宸ヤ綔绾跨▼瀵艰嚧鐨凚UG; -2)澧炲姞骞冲彴鍜宲acket_io_lib鐗堟湰鍙峰姣斿垽鏂紝濡傛灉涓嶄竴鑷翠細鎵撳嵃璀﹀憡淇℃伅; -3)淇敼娣樻卑UDP娴佹椂锛宲ktstate娌℃湁姝g‘璁剧疆涓篊LOSE鐘舵丅UG; -4)閰嶇疆鏂囦欢澧炲姞"UdpStreamTimeout"锛 鐢ㄤ簬璁剧疆寮鍚疷DP娴佽繕鍘熸椂锛岃秴鏃舵窐姹版椂闂; - 澧炲姞"load_plug_switch", 鐢ㄤ簬鍔ㄦ佸紑鍚槸鍚﹀姞杞芥彃浠; -5)澧炲姞浜唖ysinfo.log缁熻淇℃伅鏄剧ず. -****************************************************************** -20141204 鏉庝匠 -1)淇鍦╬ag妯″紡涓嬭繍琛屾椂锛孖Pv4鍜孖Pv6鍏卞瓨鏃剁殑BUG, - 鍦ㄩ《绾akefile涓鍔"USE_PAG_GET_FRAME", - 鏍规嵁鐜閫夋嫨鏄惁浣跨敤pag_get_frame()鐩存帴鑾峰彇mac鍖. -****************************************************************** -20141205 鏉庝匠 -1)淇IPv6-UDP鏁版嵁鍖, 鍦ㄥ紑鍚疷DP娴佽繕鍘熺殑鎯呭喌涓, 鏃犳硶鎵惧埌瀵瑰簲鐨勬祦, 閫犳垚HASH鍐茬獊閾捐〃鐖嗙偢BUG銆 -****************************************************************** -20141208 鏉庝匠 -1)澧炲姞build_net_layer_gre()鍑芥暟锛屽彲浠ユ瀯閫犲甫GRE鍗忚鐨剅st鍖. -****************************************************************** -20141211 鏉庝匠 -1)淇敼鍥營P鍒嗙墖閲嶇粍鍚庣殑鍖咃紝鑰岃Е鍙戣皟鐢∕ESA_kill_tcp()鐨凚UG; -2)淇敼MESA_kill_tcp()璁$畻鍖呴暱搴UG; -3)鍘熷鍖呯粨鏋剅aw_pkt_t涓鍔燺_magic__, 鐢ㄤ簬鍦╬app鍜宻app骞冲彴涔嬮棿鍖哄垎鍘熷鍖卾oid *鐨勫疄闄呯被鍨. -****************************************************************** -20141217 鏉庝匠 -1)澧炲姞pag妯″紡涓嬶紝浣跨敤pag_get_frame鎺ュ彛鍔熻兘, 鐢ㄩ《灞侻akefile鐨刄SE_PAG_GET_FRAME閫夐」鎺у埗; -2)淇敼娴佽繕鍘熸寜data寤鸿繛鎺ユ椂锛屼互澶х鍙d负婧愮殑瑙勫垯; -3)淇敼浜嗗洜閲嶈浇浜嗙郴缁熸爣鍑嗗簱exit()锛 閫犳垚绋嬪簭閫鍑烘椂鑾悕鍏跺鐨凚UG. -****************************************************************** -20141219 鏉庝匠 -1)涓轰簡鍏煎涔嬪墠鎻掍欢, 淇敼IPv4, IPv6灞傛彃浠跺師濮嬪寘鎸囬拡涓烘湰灞侷P鍖呮寚閽. -****************************************************************** -20141223 鏉庝匠, 鍒樺簡浜 -1锛夊鍔燬APP_PKT_CB_FUN_T鍥炶皟鍑芥暟绫诲瀷锛 - char SAPP_PKT_EXAMPLE(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt); -****************************************************************** -20141224 鏉庝匠 -1锛変慨鏀箂tream.h锛屽皢鍐呴儴鍙橀噺涓庡閮ㄥ彉閲忓垎绂伙紝鏍规嵁鍔熻兘鐨勪笉鍚岋紝灏唖tream.h鍒嗘媶涓: - #include "stream_inc/stream_base.h" - #include "stream_inc/stream_proxy.h" - #include "stream_inc/stream_project.h" - #include "stream_inc/stream_inject.h" - #include "stream_inc/stream_control.h" - #include "stream_inc/stream_entry.h" - #include "stream_inc/stream_rawpkt.h" -****************************************************************** -20141225 鏉庝匠 -1)灏唅p鍒嗙墖閲嶇粍绫诲瀷鐨勫寘锛岀敤Pkttype鏍囪瘑锛岀敤浜庢祦绠$悊灞傝瘑鍒. -2)澧炲姞浜嗕竴浜涗笉甯歌鐨勫崗璁被鍨嬪鐞, 濡倂lan銆乸ppoe銆乸pp鐨勯潪鏁版嵁浼犺緭灞傚崗璁. -****************************************************************** -20141226 鏉庝匠 -1)澧炲姞PPP鍜孏RE鍗忚鐨勮В鏋; -****************************************************************** -20141230 鏉庝匠 -1)澧炲姞addr_type_to_string()鍑芥暟锛岀敤浜庢彃浠惰緭鍑哄崗璁湴鍧绫诲瀷瀛楃涓; -2)澧炲姞get_this_layer_header()锛岀敤浜庢彃浠惰幏鍙栨湰灞傚ご閮ㄥ湴鍧; -3)淇敼STREAM_CB_FUN_T鍥炶皟鍑芥暟鐨"鍘熷鍖"鍙傛暟锛屾敼涓轰紶杈撲笅灞侷P灞傜殑澶撮儴, - 鐪熸鐨勫叏鍘熷鍖呭簲浣跨敤SAPP_STREAM_FUN_T绫诲瀷鍥炶皟. -****************************************************************** -20141231 鍒樺簡浜 鏉庝匠 -1)骞冲彴鍚屾椂鏀寔浼犲師濮嬪寘鍜屾湰灞傚寘澶寸殑鎺ュ彛锛屽鍔犲洖璋冨嚱鏁扮被鍨嬪畾涔夛紝 - 淇敼callapp.c涓璼tream_register_xxx鍜宻tream_process_xxx绯诲垪鍑芥暟. -2)鍚堝苟dictator2鐨20141217鐗堟湰. -****************************************************************** -20150104 鏉庝匠 -1)淇敼stream_base.h, 灏唒kttype绉诲姩鑷硈truct layer_addr缁撴瀯涓, - 灏唕outedir鎵╁睍涓簎char绫诲瀷; - 鏂板MESA_dir_reverse()鍑芥暟, 鐢ㄤ簬鍙戝寘鏃跺弽鍚憆outedir. - stream.h澧炲姞鐗堟湰鍙峰拰MD5楠岃瘉鍊. -2)澧炲姞MESA_fakepacket_xxx绯诲垪鍑芥暟. -****************************************************************** -20150107 鍒樺簡浜 -1)reset閲嶅缓閾炬帴鏃讹紝閲嶇疆璁℃暟鍣 -2) 鍒ゆ柇syn鏄惁閲嶄紶鐨勬潯浠 浠庡師鏉ョ殑(thisseq+1 == rcv->first_data_seq) -鏀逛负( rcv->first_data_seq-thisseq <=1) -3) 涓轰簡闃叉syn閲嶇疆鐨勯摼鎺yn鍦ㄧ涓涓摼鎺ラ噷闈紝鏀逛负鍏堣皟鐢╰cp锛屽啀璋冪敤tcpall -4) 鐢变簬3锛夌殑淇敼锛屽浜庢瘡涓摼鎺ラ噸缃椂rst锛岄渶瑕佷紶閫掑師濮嬪寘缁檉ree_stream鐨勫嚱鏁 -****************************************************************** -20150112 鏉庝匠 -1)淇敼tcp_deal_data_stream,tcp_save_unorder,deal_tcp_stream绛夊嚱鏁扮殑鍙傛暟, - 澧炲姞Iphdr鍜宼cphdr鍙傛暟锛岀敤浜庝紶閫掗噸缁勫悗鐨処P鍒嗙墖鍖呫 -2)FD琛ユ晳鏃跺鍔犲垽鏂潯浠讹紝鍙湁tcpdatalen > 0鏃,鎵嶇户缁皟鐢∕ESA_kill_tcp, - 浠ラ槻姝㈡敾鍑绘垨鏈満鍙戦佺殑RST鍖呭張琚崟鑾; -****************************************************************** -20150123 鍒樺簡浜 -1) pkttype 澧炲姞PKT_TYPE_TCPREORDER锛岄渶瑕佹瘡涓寘鏉ヤ簡璧嬪 -2) proxy澧炲姞瀵瑰湴鍧鐨勮櫄鎷熻浆鎹 -****************************************************************** -20150126 lqy yw -1) pkttype 澧炲姞PKT_TYPE_TCPRESTRAS 澧炲姞閲嶄紶鎶ユ枃鐨勭被鍨 -2) tcp_stream_free閲嶇疆椤哄簭锛屽厛杩涜tcp锛屽啀杩涜tcpall -3) pkttype 鍒嗙鎴愪袱涓彉閲忥紝pktipflagtype -****************************************************************** -20150129 鏉庝匠锛屽垬搴嗕簯, 鍒樻磱 -1)sapp澧炲姞-v鍙傛暟锛岀敤浜庤瘑鍒増鏈姛鑳, 瀵瑰鎻愪緵鐨勫彲鎵ц鏂囦欢瑕乻trip, 閫氳繃nm鍛戒护鏃犳硶鏌ョ湅. -2)sapp鍐呯疆libsesame_door,鐢ㄤ簬闄愬埗骞冲彴浣跨敤鑼冨洿,淇濇姢杞欢浜ф潈; -3)callapp鍐呮敮鎸乽dp_raw鎺ュ彛 -4)鎻掍欢绠$悊鏇存敼锛涙墦寮瑙f瀽灞傛彃浠讹紝绗﹀彿琛ㄤ负鍏ㄥ眬鍙 -****************************************************************** -20150203 鏉庝匠 -1)鏂板鍥涗釜鍦板潃杞崲鍑芥暟: - const char *stream_addr_list_ntop_outward(const struct streaminfo *pstream); - const char *stream_addr_list_ntop_inward(const struct streaminfo *pstream); - const struct streaminfo *stream_addr_list_pton_outward(const char *addr_list_str, int thread_index); - const struct streaminfo *stream_addr_list_pton_inward(const char *addr_list_str, int thread_index); - 淇敼stream_base.h, 澧炲姞浠ヤ笂鍑芥暟澹版槑. -2)澧炲姞绫诲瀷瀹氫箟PKT_TYPE_IP_FRAG; - 澧炲姞stream_register_ip_frag, stream_register_ipv6_frag鍏ュ彛鍑芥暟. -****************************************************************** -20150205 鏉庝匠 -1)澧炲姞鍩轰簬PPP,GRE鍗忚鐨凴ST鍖呮瀯閫犲姛鑳斤紝 - 鍥燝RE娌℃湁鍒涘缓娴侊紝鐩墠鍙兘鍗曞悜鍙戦丷ST. -***************************************************************** -20150210 鍒樺簡浜 -1) 淇tcp閾炬帴鍗曟祦鍙樺弻娴佹椂max_unorder鏈缃殑闂 -2) nouse鐘舵佺湅鍒皊yn鏍囪瘑閲嶇疆閾炬帴锛岃繖鏍疯兘澶熺湅鍒版柊娴佺殑寤虹珛杩囩▼锛 -3) 瀵逛簬fin鐘舵佸悗鐨勬暟鎹湪鏈紑tcpall鎺ュ彛鏃讹紝tcp浼氭柊寤洪摼鎺ヨ繘琛屽鐞 - 鑰屽紑tcpall鎺ュ彛鍚庯紝杩欎簺鍖呴兘涓嶄細琚玹cp鐪嬪埌 - tcpall鎺ュ彛鐨勫紩鍏ュ紩璧穞cp澶勭悊鍖呮暟鐨勫彉鎹紝 - 浠庢甯稿崗璁爤鐨勮搴︼紝寮曞叆tcpall鎺ュ彛鍚庣殑澶勭悊鏄甯哥殑锛 - 浣嗘槸鏈夋伓鍔g殑鎯呭喌鏄紝tcp鍥涘厓缁勫鐢紝鑰屽張涓簡syn鐨勯摼鎺ヤ笉鑳芥甯稿鐞 -***************************************************************** -20150225 鍒樺簡浜 -1)璁板綍tcp鎶ユ枃鐨勯噸鍙犻暱搴nternal鍐呭鍔犲彉閲弔cpoverlen -2)tcplen>0浣嗘槸甯in锛宺st绛夋爣蹇楃殑鏁版嵁鍖呬笉寤虹珛閾炬帴 -3锛夊浜巗yn鍚庨潰绗竴涓暟鎹寘涔卞簭鐨勬儏鍐碉紝缃爣蹇椾綅涓簍cpunorder -4)鏇存柊dictator2 鍒20150215鐗堟湰 -****************************************************************** -20150226 鏉庝匠 -1)淇敼stream_base.h, 灏嗗湴鍧杞崲鍑芥暟鎺ュ彛鍙樻洿涓: -int stream_addr_list_ntop(const struct streaminfo *pstream, char *dst, int size); -int stream_addr_list_pton(const char *addr_list_str, void *dst, int size, int thread_index); -****************************************************************** -20150306 鏉庝匠 -1)瑙e喅闅ч亾妯″紡涓, IPv6灞傛棤娉曞洖璋冪殑BUG. -****************************************************************** -20150311 鏉庝匠 -1)瑙e喅IP鍒嗙墖閲嶇粍鍖呭悓鏃跺湪TCP灞傛槸涔卞簭鍖呯殑BUG, - (涔嬪墠宸茶В鍐, 鍚庢潵鍦20150126鐗堝皢pkttype鍒嗙鍚, 娌℃湁瀵筽ktipflagtype璧嬪, 姝UG閲嶇幇). -****************************************************************** -20150312 鏉庝匠 -1)淇raw_ip_frag_list妯″潡锛寁4鍜寁6娣蜂贡鐨凚UG. -****************************************************************** -20150316 鍒樻磱 -1)1-plugin.c:1259 add funelem->called_flag =1; -鍚﹀垯濡傛灉pending鐘舵佹病鏈夎皟鐢ㄤ笟鍔″眰鎻掍欢锛屾瘡涓猟ata鐘舵侀兘浼氭湁pending鐨勬爣绀 -2-pending 澧炲姞called_flag鐨勫垵濮嬪寲 -3-close澧炲姞瀵硅皟鐢ㄧ殑鍒ゆ柇:濡傛灉璇ユ彃浠舵浘缁忚璋冪敤杩囨垨鑰呭綋鍓嶅瓧娈垫槸璇ユ彃浠舵墍 - 闇瑕佺殑瀛楁鎵嶅湪close鐘舵佽皟鐢紝鍚﹀垯涓嶈皟鐢 -****************************************************************** -20150319 鏉庝匠 -1)淇敼tcp_change_stream_todata()鍑芥暟, TCP鍗婃祦缁撴瀯鍐呭瓨娉勯湶BUG. -2)骞冲彴涓嶅啀浣跨敤liblogger.so. -****************************************************************** -20150311,25 鍒樺簡浜, 鏉庝匠 -1锛夋洿鏂皃lugin鍒癬20150325鐗堟湰 -2) 淇敼浜嗕贡搴忔姤鏂囦腑瀵逛簬cout_ideal鐨勯噸缃繃绋 -3锛0319淇敼tcp_change_stream_todata()鍑芥暟, TCP鍗婃祦缁撴瀯鍐呭瓨娉勯湶BUG . -4锛0311瀵逛贡搴忕紦瀛樼殑鏁版嵁锛屽鍔犲垽鏂槸鍚︽湁閲嶄紶閲嶅彔锛屽鏈夊垯鐭 -5锛変慨鏀逛簡瀵逛簬seq鐨勬瘮杈冩椂鍑虹幇鐨勯棶棰樻敼涓虹敤after锛宐efore鍑芥暟姣旇緝 -6) 鍘绘帀浜嗚佺増鏈殑logger锛屾洿鏂颁负MESA_handle_logger -7) 淇敼test_app.so, TCP灞傛彃浠剁粺璁′俊鎭敊璇疊UG. -****************************************************************** -20150327 鏉庝匠 -1)淇敼mac_n2p_fun()BUG. -****************************************************************** -20150409 鏉庝匠 -1)淇敼閰嶇疆鍙傛暟MaxUdpStreams=0鏃, UDP鎻掍欢寰楀埌鐨刾detail涓篘ULL鐨凚UG. -****************************************************************** -20150415 鏉庝匠锛屽垬搴嗕簯 -鍚堝苟papp鍦20150401鐨凚UG淇: -1)淇敼deal_tcp.c 瀵逛贡搴忓寘鐨勫鐞嗛昏緫 - 瀵逛簬杈惧埌鏈澶т贡搴忔暟鐩殑閾炬帴锛屼贡搴忎腑鍙堝嚭鐜颁贡搴忕殑鎯呭喌锛岃烦鍑烘湰娆′贡搴忓鐞嗭紱 - 瀵逛簬涔卞簭鍖呯殑cout_ideal閲嶇疆鏉′欢杩涜锛屽彧鏈夊綋搴忓彿澶ф椂鎵嶄粠 -****************************************************************** -20150416 鏉庝匠 -1)澧炲姞cycle_pkt_dump鍔熻兘, 瑙e喅鍦ㄧ嚎娴侀噺鍑轰簡BUG锛屾棤娉曢噸鐜伴棶棰. - main.conf涓柊澧3涓厤缃」: - [pkt_dump] - pkt_dump_switch=0 //鎬诲紑鍏 - pkt_dump_file_max_size=10000 //鍗曚綅:MB, 姣忎釜绾跨▼ - pkt_dump_file_root_dir=/dev/shm //pcap瀛樺偍璺緞, 鎺ㄨ崘/dev/shm, 閫熷害蹇 -****************************************************************** -20150430 鏉庝匠 -1)淇敼閰嶇疆鏂囦欢瀵硅繛鎺ヨ秴鏃舵椂闂存棤鏁堥棶棰. - LinkTimeout=0, 鐢ㄤ簬TCP - UdpResetTime=0, 鐢ㄤ簬UDP -********************************************************************* -20150507 鏉庝匠 -1)鏂板鍔燭CP杩炴帴鏁, 鏂板缓杩炴帴鏁,閿姣佽繛鎺ユ暟锛孒ASH琛ㄥ啿绐佹暟缁熻銆 -********************************************************************* -20150508 鏉庝匠 -1)澧炲姞UDP杩炴帴鏁扮粺璁. -********************************************************************* -20150512 鏉庝匠 -1)淇GRE璐熻浇闀垮害涓0鏃, Invalid read鐨凚UG. -********************************************************************* -20150526 鏉庝匠 -1)淇pkt_dump妯″潡, 鍥犱俊鍙蜂腑鏂鍐欓敊璇殑BUG. -********************************************************************* -20150610 鏉庝匠 -1)淇娴佽秴鏃舵窐姹癇UG. -********************************************************************* -20150612 鍒樺簡浜 -1)淇del_stream_by_time()浠庨摼琛ㄥ熬閮ㄦ窐姹癇UG. -********************************************************************* -20150615 鏉庝匠 -1)淇MAC鍦板潃src,dst涓庢祦鍒涘缓鐨勫弽鍚戜笉涓鑷撮棶棰. -********************************************************************* -20150702 鏉庝匠 -1)澧炲姞GRE-IPv6鍗忚鐨勮В鏋愩 -********************************************************************* -20150703 鏉庝匠 -1)main.conf澧炲姞閰嶇疆閫夐」"skip_not_ip_layer", 鐢ㄤ簬鍙屾爤鐜鏃犳硶鍙戦侀潪IP鎵胯浇鐨凴ST鍖呴棶棰樸 -********************************************************************* -20150715 鏉庝匠 -1)淇涓㈡祦BUG锛屽師鍥: - 鍦℉ASH鍑芥暟姣旇緝鍦板潃鏃讹紝鍙瘮杈冧簡IP蹇樿浜嗙鍙o紝褰撳湪涓涓狧ASH-SLOT涓湁澶氫釜鍐茬獊閾炬椂锛 - 濡傛灉鍑戝阀杩欎簺鍥涘厓缁勭殑IP閮芥槸鐩稿悓鐨勶紝閭d箞灏变細閫犳垚鍚庣画鐨勬柊鍖呰璇涓烘槸宸叉湁娴佺殑涓閮ㄥ垎锛 - 鑰屼笉浼氳璇嗗埆鎴愪竴涓柊娴. -2)澧炲姞浠庣▼搴忓惎鍔ㄤ互鏉ワ紝澶勭悊鐨勬墍鏈夋祦鏁扮粺璁′俊鎭 -********************************************************************* -20150902 鏉庝匠 -1) 闆嗘垚iknow, 鏂逛究鑾峰彇鏇村銆佹洿璇︾粏鐨勮緟鍔╀俊鎭; -********************************************************************* -20150908 鏉庝匠 -1) 淇敼pkt_dump妯″潡, 鍙互璁剧疆鎵鏈夊巻鍙插寘鎬诲ぇ灏, 闃叉绋嬪簭棰戠箒閲嶅惎閫犳垚鏃犻檺鍒跺啓纭洏; -********************************************************************* -20150916 鏉庝匠 -1)闆嗘垚MESA_sleep(), 闃叉鍦2.6.32鍐呮牳浠ヤ笂锛寀sleep(1)CPU鍗犵敤鐜囪繃楂橀棶棰. -********************************************************************* -20150922 鏉庝匠 -1)淇敼Iknow鍥炶皟鍑芥暟鎺ュ彛瀹氫箟. -********************************************************************* -20150928 鏉庝匠 -1)淇敼pcap鎹曞寘妯″潡鑾峰彇鍘熷鍖呴暱BUG, 搴旇浣跨敤caplen鑰屼笉鏄疞en, - 鍥犱负鍙兘娌℃湁鍔-s0閫夐」锛岄犳垚瀹為檯鎹曡幏鐨勯暱搴︽瘮鐞嗚鍖呴暱灏. -********************************************************************* -20150929 鏉庝匠 -1)澧炲姞topsec鎹曞寘搴撴帴鍙, 鐢ㄤ簬鏈ㄩ┈璁惧椤圭洰, 涓嶅啀鍗曠嫭缁存姢涓涓垎鏀増鏈. -********************************************************************* -20151014 鏉庝匠 -1)澧炲姞MESA_sleep鍒板钩鍙,瑙e喅usleep()鍦ㄩ珮鍐呮牳鐗堟湰涓婥PU鍗犵敤鐜囧お楂橀棶棰. -********************************************************************* -20151027 鏉庝匠 -1)淇涓嶈兘鎸夊凡鏈夋柟寮忚瘑鍒湰鏈哄彂鍑虹殑RST鍖呯殑BUG銆 -********************************************************************* -20151030 鏉庝匠 -1)淇敼teredo璇嗗埆涓嶅噯纭棶棰; -2)淇敼sysinfo.h鐩稿叧瀹忓畾涔, 鏌愪簺涓巗tart鏃х増鏈夊啿绐, 閫犳垚sysinfo.log璁℃暟涓嶅噯; -********************************************************************* -20151102 鍒樺簡浜戯紝鏉庝匠 -1)淇敼鍥犱贡搴忓寘瑙﹀彂鎻掍欢杩斿洖DROPPKT锛岄犳垚骞冲彴涔卞簭鍖呴摼琛ㄩ愭笎澧為暱锛岃嚧浣緾PU鍗犵敤鐜囬珮鐨凚UG; -********************************************************************* -20151104 鏉庝匠 -1)淇敼TCP銆乁DP娴佽繕鍘熶箣鍚庯紝娌℃湁鏇存柊IP鍒嗙墖鐘舵佹爣蹇桞UG. -********************************************************************* -20151105 鏉庝匠 -1)淇敼pkt_dump妯″潡鎬ц兘杈冨樊闂; -********************************************************************* -20151106 鏉庝匠 -1)淇敼pkt_dump妯″潡, 鎹曡幏SIGSEGV淇″彿, 鍦ㄤ俊鍙峰鐞嗗嚱鏁颁腑璋冪敤sync(), 淇濊瘉瑙﹀彂segment fault鐨刾cap鍖呯湡姝g殑淇濆瓨鍒扮‖鐩; -********************************************************************* -20151109 鏉庝匠 -1)淇敼pkt_dump妯″潡锛屽鍔燘PF-Filter杩囨护鍔熻兘. -********************************************************************* -20151112 鏉庝匠 -1)澧炲姞鏂板嚱鏁皌cp_set_single_stream_drop_by_time(), - 璁剧疆褰撳墠娴佷笉鍐嶆牴鎹甊ST銆丗IN绛夋爣蹇楃粨鏉, 鍙兘绛夎秴鏃躲佹垨绉昏嚦LRU闃熷熬鍚庤free. - 鐢ㄤ簬鏌愪簺涓氬姟浣跨敤绗笁鏂圭殑FD琛ユ晳浣跨敤. -********************************************************************* -20151112-2 鏉庝匠 -1)澧炲姞鍑芥暟MESA_set_stream_opt(), 鐢ㄤ簬鎺у埗鍗曚釜閾炬帴鐨勫睘鎬, - 浣跨敤绫讳技setsockopt鐨勬柟寮, 涓嶅啀澧炲姞鐙珛鍑芥暟. -********************************************************************* -20151118 鏉庝匠 -1)鍘绘帀鎹曞寘妯″紡涓嬪鍖呴暱搴︽槸鍚﹁秴杩嘙TU鐨勬鏌, 鍥犱负鍦═SO妯″紡涓, 鏈満鎹曞寘缁忓父浼氭湁鍗曞寘闀垮害鍑犱竾瀛楄妭鐨勬儏鍐, - 瀵艰嚧搴旂敤灞傛彃浠惰帿鍚嶅叾濡欐敹涓嶅叏鏁版嵁銆 -********************************************************************* -20151125 鏉庝匠 -1)瑙e喅骞冲彴鍦ㄩ珮鐗堟湰绯荤粺涓嬬紪璇戣鍛婂拰閿欒; -2)鍏抽棴Iknow鐨凞EBUG鎵撳嵃淇℃伅; - -********************************************************************* -20151207 鏉庝匠 -1)淇敼娴佸垱寤虹粨鏋, 灏咺P鍜岀鍙g粦瀹氬湪涓涓湴鍧闆嗗悎, 鏅欼Pv4, IPv6鍗忚鍙渶涓涓猻treaminfo缁撴瀯, - TCP灞備笉鍐嶉氳繃pfather鎸囬拡鎸囧悜IP灞傚湴鍧, - 鍙妭绾﹀唴瀛樺拰鎻愰珮鎬ц兘; -********************************************************************* -20151209 鏉庝匠 -1)澧炲姞閰嶇疆鍙傛暟: skip_ethernet_layer, - 鐢ㄤ簬鎺у埗鏄惁璺宠繃ethernet灞, 涓嶅啀澶勭悊MAC鍦板潃淇℃伅, 鎻愰珮杩愯鏁堢巼. - -********************************************************************* -20151215 鏉庝匠 -1)HASH鍐茬獊閾捐〃澧炲姞LRU鏈哄埗, 灏嗘渶杩戜娇鐢ㄦ渶棰戠箒鐨勬祦鏀句簬閾捐〃绗竴涓, 鎻愰珮鏌ユ壘鏁堢巼; -2)浣跨敤LINUX鍐呮牳HASH鏃, 涓娆akehash璁$畻鍙互寰楀埌澶氫釜HASH鍊, - 浣跨敤涓涓狧ASH鐢ㄤ簬纭畾鍦℉ASH_SLOT鐨勪綅缃, - 鍐嶄娇鐢ㄥ彟涓涓狧ASH鐢ㄤ簬蹇熸瘮杈冨湴鍧鏄惁鐩哥瓑. - -********************************************************************* -20151223 鏉庝匠 -1)鍦ㄤ贡搴忓寘鐨勬儏鍐典笅, 鍏堝鍔犱簡鏁版嵁鍖呭拰瀛楄妭鏁, - 瀵艰嚧鎻掍欢杩樻湭鎷垮埌褰撳墠鏁版嵁鍖, 浣嗗疄闄呭瓧鑺傛暟宸茬粡澧炲姞, 瀵艰嚧璁℃暟涓嶅噯纭, - 宸蹭慨澶. -********************************************************************* -************************* 2016 year ********************************* -********************************************************************* -2016-01-19 鏉庝匠 -1)淇鍥犲皢IP-PORT鍚堝苟涔嬪悗, inet_addr_list鍑芥暟BUG銆 -********************************************************************* -2016-06-08 鏉庝匠 -1)淇敼鍦ㄦ寜data寤鸿繛鎺ユ椂, 璋冪敤浜員CPALL鎻掍欢鍚, 鍗充究鎻掍欢杩斿洖DROP, 浠嶇劧浼氳皟鐢═CP鎻掍欢鐨勯昏緫, 瀵艰嚧HMD涓嶇敓鏁堥棶棰. -********************************************************************* -2016-06-15 鏉庝匠 -1)澧炲姞涓㈠純绾疉CK鍖呭姛鑳, 闈犻厤缃枃浠禿iscard_ack鎺у埗; -2)淇敼FD琛ユ晳鏃, 鐢卞師鏉ュ彂閫3涓猂ST, 鍑忓皯涓1涓. -********************************************************************* -2016-06-21 鏉庝匠 -1)澧炲姞閰嶇疆椤:kill_tcp_remedy, 鐢ㄤ簬鎺у埗鏄惁寮鍚疐D琛ユ晳鍔熻兘. -********************************************************************* -2016-09-01 鏉庝匠 -1)for soq椤圭洰, 澧炲姞瀵归毀閬撳崗璁甃2TP, PPTP, IPSEC鐨勮繛鎺ユ娴嬩笌鏃ュ織璁板綍銆 - 鏂板stream_tunnel.h. -********************************************************************* -2016-09-30 鏉庝匠 -1)淇IPv6鍒嗙墖閲嶇粍绾跨▼ID璁剧疆閿欒, 瀵艰嚧鍦ㄥ紑鍚痙ictator鍚巆oredump, 鑰屾槸鐢ㄦ櫘閫歮alloc妯″紡鏃犻棶棰. -********************************************************************* -2016-10-09 鏉庝匠 -1)淇敼stream_inject.h, 澧炲姞MESA_kill_tcp_feedback()绛夊甫鍙嶉鍔熻兘鐨勫嚱鏁版帴鍙. -********************************************************************* -2016-10-12 鏉庝匠 -1)澧炲姞L2TP鍗忚鐨凢D鍔熻兘. -********************************************************************* -2016-11-10 鏉庝匠 -1)閽堝WY鍙戝寘鐗规畩闇姹--鏌愭彃浠朵笉璁虹綉缁滀腑鏈夋棤鏁版嵁鍖, 閮戒笉鑳介樆濉炵瓑寰, 蹇呴』琚寔缁笉鏂皟鐢, - 鏂板POLLING绫诲瀷鎻掍欢鍏ュ彛, 淇濊瘉鏃犳暟鎹寘鏃, 涔熶細璋冪敤姝ゆ帴鍙g殑鎻掍欢. -********************************************************************* -2016-11-24 鏉庝匠 -1)淇敼sapp鐩綍缁撴瀯, 灏嗗師鏉est鎷嗗垎涓鸿繍琛岀洰褰時un, 鍜屾簮鐮佺洰褰昬ntry, 渚夸簬閮ㄧ讲鎵归噺copy. -********************************************************************* -2016-12-01 鏉庝匠 -1)澧炲姞PPP鍗忚瑙f瀽CHAP璁よ瘉鐨勭敤鎴峰悕鍔熻兘. -********************************************************************* -2016-12-05 鏉庝匠 -1)淇敼stream_base.h, 澧炲姞layer_addr_ntop(), layer_addr_prefix_ntop(). -********************************************************************* -2016-12-15 鏉庝匠 -1)澧炲己IPv4鍖呮牸寮忕殑鏍¢獙, 澧炲姞瀵瑰寘鎴柇绛夋儏鍐电殑鍒ゆ柇; -1)淇pptp HASH鎻掑叆澶辫触鍚庢病鏈塮ree鐨凚UG. -********************************************************************* -2016-12-20 閮戣秴, 鏉庝匠 -1)鏇存柊dictator, 淇realloc BUG. -********************************************************************* -2016-12-21 鏉庝匠 -1)鏇存柊stream_addr_list_ntop, stream_addr_list_pton绛夊嚱鏁, 淇敼鍦板潃瀛楃涓插墠缂鍛藉悕, 鏇存槗璇. -********************************************************************* -2016-12-22 鏉庝匠 -1)淇骞冲彴鍦ㄩ潪X86骞冲彴涓嬫棤娉曠紪璇戦棶棰; -2)淇敼dictator鍒濆鍖栬鍙栭厤缃枃浠堕『搴廈UG. -********************************************************************* -2016-12-26 鍒樻磱, 鏉庝匠 -1)鍒樻磱淇敼plungin, 鎻掍欢鍔犺浇澶辫触鍚, 璋冪敤dlclose鍏抽棴dlopen鎵撳紑鐨勬枃浠跺彞鏌; -********************************************************************* -2016-12-27 鏉庝匠 -1)淇敼pptp瑙f瀽灞傝皟鐢ㄤ笟鍔℃彃浠舵椂, streaminfo缁撴瀯浣撲负NULL鐨凚UG; -********************************************************************* -2016-12-29 鏉庝匠 -1)淇敼pptp闅ч亾鏃犳硶鍙嶅悜inject鍖呯殑BUG(鏆傛椂鍙敮鎸佸弻鍚戞祦鍙嶅悜inject, 鍗曞悜娴佷粛鏃犳硶鏀寔); - -********************************************************************* -************************* 2017 year ********************************* -********************************************************************* - -********************************************************************* -2017-01-03 鏉庝匠 -1)澧炲姞L2tp瑙f瀽灞侶ASH鍐茬獊涓ラ噸闂, 瓒呰繃闃堝煎悗涓嶅啀澶勭悊鏂版祦. -2)淇敼TCP娴佺鐞咮UG, tcp_reset_stream()灏嗗綋鍓嶆祦绉诲嚭lru_list, 鍦╰cp_deal_unorder()鍑芥暟涓, - 鍙兘浼氬啀璋冪敤tcp_change_stream_tonouse(), 鍐嶆璋冪敤streamleavlist, 鑷翠娇plist->head, tail閮戒负NULL. -********************************************************************* -2017-01-05 鏉庝匠 -1)淇敼PPTP, L2TP鍗忚瑙f瀽灞俬ash绠楁硶, 鍑忓皯鍐茬獊鐜. -********************************************************************* -2017-01-09 鏉庝匠 -1)鍥2016-12-26, 鎻掍欢鍔犺浇澶辫触鍚, 璋冪敤dlclose鍏抽棴dlopen鎵撳紑鐨勬枃浠跺彞鏌勭殑鏂规浼氶犳垚绋嬪簭宕╂簝涓旀棤娉曟煡鐪嬪嚱鏁拌皟鐢ㄦ爤, - 鎵浠ヤ笉鍐嶄富鍔╠lclose鍙ユ焺; -2)淇敼鎵撳紑ip_frag_list鍔熻兘鍚, UDP瓒呮椂閲嶇疆鏃堕犳垚鍐呭瓨娉勬紡鐨凚UG; -3)淇敼澧炲姞MESA_kill_tcp_feedback()鍑芥暟鍚, MESA_sendpacket_iplayer()绛夊嚱鏁, 鍦ㄨ皟鐢╬acket_io_send_fake_pkt()鏃, 浼犻掑弬鏁伴敊璇疊UG. -********************************************************************* -2017-01-20 鏉庝匠 -1)pcap妯″紡鍚敤dictator鍚, 璇诲寘瀹岄鍑烘椂free绾跨▼涓嶆槸鍖呭鐞嗙嚎绋, 閫犳垚dictator assert澶辫触. -********************************************************************* -2017-02-10 鏉庝匠 -1)layer_addr_ntop()澧炲姞OpenVPN鍗忚; -2)淇敼l2tp, pptp浜屽厓缁凥ASH绠楁硶锛屽噺灏慔ASH鍐茬獊; -3)涓存椂澧炲姞SAPP_INSECTICIDE瀹忥紝鐢ㄤ簬妫鏌ヨ帿鍚嶅叾濡欑殑BUG锛屽敖閲忔棭鍙戠幇闂銆 -********************************************************************* -2017-02-11 鏉庝匠 -1)澧炲姞TCP-RST, UDP鍙戝寘缁熻璁℃暟锛 -********************************************************************* -2017-02-16 鏉庝匠 -1)淇敼get_stream_carry_tunnel_type()瀵逛簬PPTP, L2TP鐨勮瘑鍒獴UG銆 -********************************************************************* -2017-02-24 鏉庝匠 -1)鍥燚PDK鍒濆鍖栨椂缁戝畾褰撳墠绾跨▼鍒版煇CPU鏍稿績, 瀵艰嚧鍚庣画鍔ㄦ佸垱寤虹殑鎵鏈夌嚎绋嬮兘榛樿缁ф壙杩欎釜琛屼负, 鍏ㄧ粦瀹氬埌鍚屼竴涓牳蹇, - 淇敼packet_io鍜宲lug_proc鐨勫垵濮嬪寲椤哄簭銆 -********************************************************************* -2017-04-07 鏉庝匠 -1)澧炲姞鏂扮殑pag_marsio妯″紡, 涓昏鐢ㄤ簬浣跨敤marsio鐨刾ag_get_frame鎺ュ彛锛屽拰涔嬪墠Zhuanyong缃戝崱鐨刾ag_get_frame鍖哄垎銆 -********************************************************************* -2017-04-21 鏉庝匠 -1)闆嗘垚327鐨処pfile璇诲寘妯″紡銆 -********************************************************************* -2017-05-11 鏉庝匠 -1)main.conf澧炲姞閰嶇疆鏂囦欢ipentry_priority_over_ipfrag锛岀敤浜庢帶鍒禝P灞傚拰IPFRAG灞傝皟鐢ㄤ紭鍏堢骇; -2)澧炲姞鍖呯被鍨婸KT_TYPE_IP_FRAG_LAST锛岃〃绀哄悓灞炰簬涓涓師濮婭P鍖呯殑鏈鍚庝竴涓狪P鍒嗙墖鍖呫 -********************************************************************* -2017-05-15 鏉庝匠 -1)鏀寔marsio-4.1鍘熺敓鎺ュ彛. -********************************************************************* -2017-05-24 鏉庝匠 -1)鏀寔灏唖app鍋氫负涓涓姩鎬侀摼鎺ュ簱.so, 鍙寕杞藉埌鍏朵粬骞冲彴涓婄殑IP_entry, 鍑忓皯鑱旇皟TCP娴佽繕鍘熷強streaminfo鍚勭鍙橀噺涓嶄竴鑷寸殑鏃堕棿, - 鍋氫负鎻掍欢浣跨敤鏃讹紝榛樿浣跨敤鍥哄畾鐩綍/home/mesasoft/sapp. -********************************************************************* -2017-06-08 鏉庝匠锛屽垬娲 -1)灏唚angyan淇濇椿鍔熻兘鐙珛鍋氫负鎻掍欢瀹炵幇, 鏇存柊callapp.c涓庢彃浠剁鐞嗙浉鍏虫祦绋嬶紝濡傝褰曟彃浠跺寘澶勭悊寤舵椂绛夈 -********************************************************************* -2017-06-12 鏉庝匠 -1)骞冲彴淇敼娴佹窐姹版満鍒, 涓氬姟鎻掍欢鍙缃嫭绔嬬殑瓒呮椂鏃堕棿, 濡傛灉UDP娴佷竴娈垫椂闂存棤鍖呭埌杈, 涔熶笉浼氬洜娴佽〃婊¤岄伃娣樻卑銆 -********************************************************************* -2017-06-27 鏉庝匠 -1)閽堝GDEV涓茶仈妯″紡锛屼慨鏀瑰簳灞傛敹鍙戝寘鎺ュ彛锛 -2)鏇存柊stream_base.h, stream_inject.h, stream_rawpkt.h; -3)灏咷DEV淇濇姢鍔熻兘绉诲嚭骞冲彴锛屽仛涓虹嫭绔嬫彃浠惰繍琛; -4)澧炲姞妫娴嬪疄闄呰繍琛岀幆澧冪殑stream_inc鍜屽綋鍓峴app鐗堟湰涓嶄竴鑷达紝鎵撳嵃璀﹀憡鍔熻兘銆 - -********************************************************************* -2017-06-28 鏉庝匠 -1)澧炲姞妫娴嬪疄闄呰繍琛岀幆澧冪殑stream_inc鍜屽綋鍓峴app鐗堟湰涓嶄竴鑷达紝鎵撳嵃璀﹀憡鍔熻兘銆 -********************************************************************* -2017-07-10 鏉庝匠 -1)marsio妯″紡锛屽垯澧炲姞浠巑ain.conf涓幏鍙朼pp_name鍔熻兘锛 -2)淇敼UDP瓒呮椂娣樻卑鏈哄埗锛岄櫎reset褰撳墠娴佸锛岃繕鍙互娣樻卑鍏朵粬瓒呮椂鐨勬祦锛 -********************************************************************* -2017-08-03 鏉庝匠 -1)澧炲姞TCP鍗曞悜娴佹帹娴嬪绔疘SN鍔熻兘; -1)澧炲姞TCP鍗曞悜娴佹帹娴嬪绔昏鎺ユ敹瀛楄妭鏁板姛鑳; -********************************************************************* -2017-08-08 鏉庝匠 -1)淇敼tcpdump_mesa, 鏀寔鎸囧畾鎹曞寘绾跨▼ID -********************************************************************* -2017-08-24 鏉庝匠 -1)淇敼tcpdump_mesa, 澧炲姞鎹曞寘閲囨牱鐜囷紝闃叉鍦ㄥぇ娴侀噺鐜涓嬩涪鍖呫 -********************************************************************* -2017-09-04 鏉庝匠 -1)澧炲姞鍑芥暟sapp_get_platform_opt(), 渚涙彃浠惰幏鍙栧钩鍙板唴閮ㄥ弬鏁帮紝濡傚寘鏁般佸瓧鑺傛暟绛夈 -2)marsio4涓嶅啀鏀寔runtime妫娴嬶紝骞冲彴澧炲姞runtime.log锛岃褰曞崟鍖呭鐞嗗欢鏃讹紱 -3)鍚堝苟鍗曞悜娴佸鐞咺SN鐨勭己闄, 鍙互閫氳繃C2S鏂瑰悜鐨凷YN,ACK鍖咃紝鎺ㄧ畻鍑篠2C鐨処SN. -********************************************************************* -2017-09-05 鏉庝匠 -1)淇敼tcp鑾峰彇syn鍖呴夐」dir鏂瑰悜鍙傛暟BUG; -********************************************************************* -2017-09-21 鏉庝匠,鍒樻磱 -1)澧炲姞鍥炶皟鍑芥暟platform_register_action_judge, 骞冲彴鏈缁堢殑鍖呰浆鍙戣繑鍥炲糚ASS or DROP鐢卞閮ㄦ彃浠跺喅瀹. -2)淇敼鎻掍欢绠$悊妯″潡锛岃繑鍥炲兼牴鎹笟鍔℃彃浠剁被鍨, FD or JC鍐冲畾; -3)淇敼榛樿涓嶈瘑鍒祦閲忚浆鍙戠瓥鐣, GDEV妯″紡涓嬩负DROP; -********************************************************************* -2017-09-26 鏉庝匠 -1)淇2017-05-11淇敼ip_entry鍜宨p_frag_entry璋冪敤浼樺厛绾э紝瀵艰嚧IP鍖呬細璋冪敤ip_frag_entry鐨凚UG. -********************************************************************* - -2017-09-28 鏉庝匠 -1)澧炲姞鎸変笟鍔″彿淇濇椿鍔熻兘锛學Y淇濇椿鎻掍欢鍙湪涓诲簲鐢ㄤ笅璁剧疆gdev淇濇椿鎻掍欢鐨勪笟鍔″彿; -********************************************************************* -2017-10-03 鏉庝匠 -1)澧炲姞瑙f瀽TCP鍖呭ご閮ㄩ夐」TCP_OPT_MULTI_PATH_TCP, 鍥犻夐」涓嶅畾闀匡紝涓斿彲鑳借秴杩8瀛楄妭锛 - 鍘熸湁缁撴瀯涓嶉傜敤锛屼负浜嗗悜鍚庡吋瀹瑰悓鏃舵敮鎸佹柊閫夐」锛 - 鏂板struct tcp_option_ext缁撴瀯锛 - 鍙婂嚱鏁癕ESA_get_tcp_pkt_opts_ext(). -********************************************************************* -2017-10-10 鏉庝匠 -1)淇敼鍦―DP妯″紡涓媡cpdump_mesa鐨勫寘鎹曡幏浣嶇疆锛屽彲浠ユ崟鑾稤DP鍐呭皝瑁呯殑鍘熷鍖呫 -********************************************************************* -2017-10-16 鏉庝匠 -1)澧炲姞鍒ゆ柇鍥涘厓缁勯噸鐢ㄧ殑鍒ゆ柇銆 -2)澧炲姞iknow_switch閰嶇疆鏂囦欢, iknow鍔熻兘鍙互鍏抽棴, 榛樿寮鍚. -3)澧炲姞symbol_conflict_check閰嶇疆鏂囦欢, 绗﹀彿鍚嶆鏌ュ彲浠ュ叧闂, 榛樿寮鍚. -********************************************************************* -2017-10-19 鏉庝匠 -1)澧炲姞anti_flood妯″潡, 鐢ㄤ簬鎶靛尽SYN_flood, DNS_flood鏀诲嚮; -2)淇敼TCPALL鎻掍欢, 鍥犱贡搴忕殑SYN, SYN/ACK鍖咃紝琚璁や负鏄洓鍏冪粍閲嶇敤, 閲嶇疆杩炴帴鑰屽鑷磋鍒嗘媶涓轰袱涓祦鐨凚UG. -********************************************************************* -2017-10-26 鏉庝匠 -1)Gserial_send绯诲垪鍑芥暟澧炲姞鍙戝寘鏃ュ織, 渚夸簬WY鐜涓嬫煡鎵鹃棶棰. -2)澧炲姞field_stat杈撳嚭. -********************************************************************* -2017-10-31 鏉庝匠 -1)淇鍥爌cap.h, libpcap.so鍦ㄧ函鏂扮殑绯荤粺涓婄己澶憋紝绗竴娆℃棤娉曠紪璇戠殑鎯呭喌锛 -2)淇PPTP闅ч亾鍗忚锛屽洜PPP澶撮儴鍘嬬缉涓旀病鏈夎幏鍙朠PTP鎺у埗杩炴帴鏃讹紝鏃犳硶瑙f瀽鐨勯棶棰樸 -********************************************************************* -2017-11-09 鏉庝匠 -1)Gserial_send绯诲垪鍑芥暟鍙戝寘鎸塱p, tcp, udp鍒嗗崗璁被鍨嬬粺璁° -2)鍐呯疆pcap.h, 鍦ㄧ函鏂版満鍣ㄤ笂鍙互缂栬瘧閫氳繃. -********************************************************************* -2017-11-13 鏉庝匠 -1)澧炲姞GDEV淇濇椿璁℃暟鑾峰彇鎺ュ彛, 渚夸簬缁熻; -********************************************************************* -2017-11-24 鏉庝匠 -1)VxLan妯″紡PPP鎴朒DLC灏佽, MAC鍦板潃涓洪┍鍔ㄩ殢鏈哄~鍏呯殑, 涓嶈兘鐢ㄤ簬鍒ゅ畾骞挎挱銆佺粍鎾瓑鎿嶄綔. -********************************************************************* -2017-12-08 鏉庝匠 -1)淇敼骞冲彴璋冪敤TCPALL鎻掍欢閫昏緫, 鍏堣皟鐢═CPALL, 鍚庤皟鐢═CP; -2)瀵逛簬涓涓祦鐨勯鍖呮槸RST涓擲EQ=0鐨勫寘锛屽钩鍙板拷鐣ヤ笉澶勭悊銆 -********************************************************************* -2017-12-20 鏉庝匠 -1)l2tp_protocol_plug淇鍦板潃瑙f瀽闀垮害瓒呰寖鍥碆UG; -2)鏇存柊TCP娴佽繕鍘熸満鍒, 鍥涘厓缁勯噸鐢ㄥ垽鏂笌鏈鍚庝竴涓寘鐨勬椂闂撮棿闅, 澶煭鍒欒涓烘槸鎭舵剰閫冮, 涓㈠純. - -********************************************************************* -************************* 2018 year ********************************* -********************************************************************* - -2018-01-19 lijia add, -1-澶氫釜tcpdump_mesa鍚屾椂鍚姩鏃, 鍚庣画鐨勮繛鎺ヤ細鎶㈠崰绗竴涓繛鎺ョ殑鏁版嵁娴, 浣嗕娇鐢ㄧ涓涓繛鎺ョ殑杩囨护鏉′欢, - 澧炲姞TCP鍛戒护杩炴帴鐨勭‘璁ゆ満鍒, 濡傛灉sapp涓嶅洖澶嶇‘璁ゅ寘, tcpdump_mesa涓嶅惎鍔ㄦ崟鍖. - -2-澧炲姞涓㈠寘璁℃暟, 濡傛灉浣跨敤-a鍙傛暟鎸囧畾perceptive妯″紡, sapp鍦ㄥ彂閫佸寘鏃, 鍦ㄦ簮MAC鍦板潃涓婃墦涓婂簭鍙, - tcpdump_mesa妫鏌ュ簭鍙锋槸鍚﹁繛缁, 浠ョ‘璁や腑闂存槸鍚︽湁涓㈠寘, 涓簡鍑犱釜鍖. -********************************************************************* -2018-02-28 鏉庝匠 -1)淇鎻掗噸瑕佷欢涓嶄繚娲绘椂, gdev浠嶇户缁繚娲荤殑BUG; -2)淇敼vxlan妯″紡涓, 涓㈠純骞挎挱銆佺粍鎾寘鐨勫垽鏂昏緫. -********************************************************************* -2018-03-02 lijia add, -1锛夊洜骞惰仈妯″紡FD鏁堟灉涓嶅ソ锛屽鍔燜D琛ユ晳鍚慓DEV涓嬪彂瑙勫垯鍔熻兘锛屼緷闈犱覆鑱斾涪鍖呮彁楂楩D鐜囥 -********************************************************************* -2018-03-13 鏉庝匠 -1)淇teredo闅ч亾闈炴爣鍑嗙鍙f棤娉曡瘑鍒棶棰. -********************************************************************* -2018-03-23 鏉庝匠 -1) 淇GDEV瑙勫垯涓嬪彂鎻掍欢BUG. -********************************************************************* -2018-04-17 鍒樻磱 -1)涓讳粠搴旂敤閮芥槸閫氳繃閰嶇疆鏂囦欢PLUGINFO鑾峰緱锛岃鍔熻兘鐢辨绘帶娣诲姞锛屼笉杩噑app涓渶瑕佸皢鍘熷姛鑳芥敞閲婃帀锛屽嵆plugin.c:733琛屻 -********************************************************************* -2018-04-25 鏉庝匠 -1)淇get_this_layer_header()鍑芥暟, 鍦ㄦ祦瓒呮椂娣樻卑鏃剁殑BUG; -********************************************************************* -2018-07-10 鏉庝匠 -1)淇敼private_ip娈佃瘑鍒敊璇疊UG; -********************************************************************* -2018-08-01 鏉庝匠 -1)閽堝3x7椤圭洰锛屽鍔犲墺绂3x7鏁版嵁鍖呭ご鍔熻兘锛屽皢鍐呭眰鍘熷鏁版嵁鍖呭啀娉ㄥ叆ipv4_entry(); -********************************************************************* -2018-08-03 鏉庝匠 -1)淇IP澶撮儴妫娴嬩笉鏀寔ESP闂, 瀵艰嚧IPSEC涓氬姟琚涪寮. -********************************************************************* -2018-09-23 鏉庝匠 -1)澧炲姞瀵筂AC_IN_MAC鍥炴祦闀滃儚鏍煎紡鐨勫鐞; -2)淇MAC_IN_MAC灏佽鏍煎紡涓, RST鍙戦丅UG. -3)淇敼鍒ゆ柇骞挎挱鍜岀粍鎾殑鍒ゆ柇閫昏緫, vxlan妯″紡涓嬪浜巚xlan灏佽鐨勬暟鎹寘涓嶅仛鍒ゆ柇锛 -4)鏀寔IPV6鍙戝寘. -********************************************************************* -2018-10-13 鏉庝匠 -1)淇敼IP鍖呭ご妫娴嬪嚱鏁, 瀵瑰崗璁被鍨嬪瓧娈电殑妫鏌, 闃叉璇涪寮冩煇浜涗笉甯歌鍗忚鐨勬暟鎹寘. -********************************************************************* -2018-10-19 鏉庝匠 -1)淇敼field_stat杈撳嚭TCP骞跺彂杩炴帴鏁癇UG. -********************************************************************* -2018-10-24 鏉庝匠 -1)澧炲姞瀵筂AC_IN_MAC鐨勫湴鍧瑙f瀽, 浠庝腑鑾峰彇GDEV_ID, LINK_ID, LINK_DIR绛夊弬鏁. -********************************************************************* -2018-11-02 鏉庝匠 -1)淇敼mpls_hdr澶撮儴瀹氫箟閿欒; -2)瑙f瀽澶氬眰宓屽MPLS鏁版嵁鍖. -********************************************************************* -2018-11-05 鏉ㄥ▉ -1)淇敼婧愮爜, 閫傞厤cmake缂栬瘧. -********************************************************************* -2018-11-08 鏉ㄥ▉ -1.鏇存柊gprs tunnel鍗忚璇嗗埆閫昏緫锛屼娇鐢╥dentify_gtp鍑芥暟锛屽彇浠e師鏈夌殑浠呰瘑鍒鍙g殑閫昏緫 -2.鏇存柊packet_io_send_fake_pkt_gdev鍑芥暟閫昏緫锛屾纭殑璁$畻鍋忕Щ濉啓鍙戝寘鍐呭鏃剁殑data鍜宒atalen -3.鏇存柊packet_io_send_fake_pkt锛屽浜庢敞鍏ュ彂鍖咃紝鐩存帴璋冪敤packet_io_send_fake_pkt_by_gdev -4.MESA_send_handle鏂板raw_udp_fd鐢ㄤ簬浠巙dp璐熻浇寮濮嬪彂閫佹敞鍏ュ寘 -6.澧炲姞Gserial_sendpacket_ipv6_layer()鍑芥暟, 鍙互鍙戦佸凡鏋勯犲ソ鐨処PV6鏁版嵁鍖. -********************************************************************* -2018-11-09 鏉ㄥ▉ -1.鏁寸悊TODO锛屾寜閲嶈绋嬪害鍒嗙骇 -2.绉婚櫎run鐩綍涓嬬殑log鏂囦欢 -3.鏇存柊GTP澶勭悊閫昏緫锛屽鍔犲甯eq娑堟伅鐨勫鐞嗗苟淇濆瓨鍦ㄥ湴鍧涓 -********************************************************************* -2018-11-12 鏉ㄥ▉,鏉庝匠 -1.鏇存柊GTP澶勭悊閫昏緫, 澧炲姞瀵圭鍦板潃(TEID,SEQ绛)鏇存柊閫昏緫銆 -********************************************************************* -2018-11-16 鏉庝匠 -1)鏀寔cmake, 涓庡苟鑱旂増鏈儴鍒嗗悓姝. - -********************************************************************* -**************************** 2019 Year ****************************** -********************************************************************* -2019-05-15 鏉庝匠 -1)sapp version 4.0! -2)浠庢柊璁捐閰嶇疆鏂囦欢鏍煎紡; -3)鏀寔鍛戒护琛屽弬鏁; -4)鍏朵粬閲嶅ぇ鏇存柊寰呭悗缁増鏈崌绾...... -#endif diff --git a/src/sapp_dev/sapp_global_val.c b/src/sapp_dev/sapp_global_val.c index 4613f44..7fd3902 100644 --- a/src/sapp_dev/sapp_global_val.c +++ b/src/sapp_dev/sapp_global_val.c @@ -224,9 +224,6 @@ void sapp_gval_init(void) { int tseq; - /* 第一步先判断是否使用dictator,此值影响后续的内存分配 策略,否则后面的sapp_mem_xx系列函数无法运行 */ - tomlc99_wrap_load_int_def(g_cmd_args_main_cfg_file, (char *)"MEM", (char *)"dictator_enable", (int *)&g_sapp_mem_use_dictator, 1); - /* 内存统计的数据自身就是存储在全局变量中, 这是先有鸡还是先有蛋的问题, 此处直接用系统的calloc, 独立计数 */ sapp_global_val = (sapp_global_t *)calloc(1, sizeof(sapp_global_t)); g_sapp_global_mem_used_block++; diff --git a/src/sapp_dev/sapp_init.c b/src/sapp_dev/sapp_init.c index cfc2150..528cb78 100644 --- a/src/sapp_dev/sapp_init.c +++ b/src/sapp_dev/sapp_init.c @@ -25,7 +25,6 @@ extern void sesame_open_door(const char *lock_path, const char *lock_name); /* (0:pag,1:pcap,2:dumpfile,3:pfring,4:DPDK,5:ppf,6:NPacket,7:qnf,8:N95,9:pcap-dumpfile-list, 10:topsec) */ //int cap_mode = 2; //int top_mode = 0; -//extern int G_DICTATOR_SW; extern struct global_stream **G_MESA_GLOBAL_STREAM; //static int __times = 0; //int g_timestamp_record_sw = 0; @@ -75,27 +74,6 @@ static void forbid_call_exit_in_running_state(void) } -/* 2016-09-22 lijia add, dictator在第一次被调用时有初始化代码, 防止多线程重入冲突, 平台先调用一次 */ -static void sapp_dictator_init(void) -{ -#if USE_MEMPOOL - void *tmp; - if(G_DICTATOR_SW){ - tmp = __wrap_malloc(1); - assert(tmp != NULL); - __wrap_free(tmp); - - tmp = malloc(1); - assert(tmp != NULL); - free(tmp); - }else{ - sapp_printf("\033[33m[Warning]dictator is not enable, maybe slow down performance, please check 'sapp.toml -> dictator_enable'.\033[0m\n"); - } -#else - sapp_printf("\033[33m[Warning]sapp is compiled without dictator.\033[0m\n"); -#endif -} - static void sapp_platform_finish_up(void) { /* @@ -139,11 +117,6 @@ int MESA_platform_init(int argc, char *argv[]) ABBR_CURRENT_TIME = time(NULL); ABBR_SAPP_START_TIME = time(NULL); - /* 2016-09-22 lijia add, dictator在第一次被调用时有初始化代码, 防止多线程重入冲突, 平台先调用一次, 先要读取配置文件开关 */ - //MESA_load_profile_int_def("conf/main.conf","Module", "dictator_switch", &G_DICTATOR_SW, 1); - sapp_dictator_init(); - - ipv4_frag_init(g_iThreadNum, 1024 * 512); ipv6_frag_init(g_iThreadNum, 1024 * 256); tcp_set_stream_num(max_tcp_stream_num*3,max_tcp_stream_num,max_tcp_stream_num*2); diff --git a/src/support/CMakeLists.txt b/src/support/CMakeLists.txt index d1fb998..270f71d 100644 --- a/src/support/CMakeLists.txt +++ b/src/support/CMakeLists.txt @@ -5,7 +5,6 @@ add_subdirectory(symbol_check) add_subdirectory(MESA_sleep) add_subdirectory(md5) add_subdirectory(MESA_socket_wrap/src) -add_subdirectory(dictator2/src) add_subdirectory(tomlc99_wrap) add_subdirectory(dpdk_rte_hash) add_subdirectory(cpu_limit) diff --git a/src/support/MESA_sleep/Makefile b/src/support/MESA_sleep/Makefile deleted file mode 100644 index 9315625..0000000 --- a/src/support/MESA_sleep/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -all:demo libMESA_sleep.so libMESA_sleep.a - - - -demo:demo.o libMESA_sleep.so - gcc -g -Wall demo.o -o demo -lpthread ./libMESA_sleep.so -demo.o: demo.c - gcc -g -c demo.c -o demo.o -W - -libMESA_sleep.so:MESA_sleep.o - gcc -o $@ -fPIC -shared $^ -lpthread - -libMESA_sleep.a:MESA_sleep.o - ar -cr $@ $^ - cp $@ ../../lib/ - -#MESA_sleep.o:MESA_sleep.c -MESA_sleep.o:mesa_sleep_nowatchBGT.c - gcc -g -Wall -fPIC -shared -c $^ -o $@ -clean: - rm -f *.o demo libMESA_sleep.so libMESA_sleep.a - diff --git a/src/support/MESA_socket_wrap/Makefile b/src/support/MESA_socket_wrap/Makefile deleted file mode 100644 index 2f9c182..0000000 --- a/src/support/MESA_socket_wrap/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CFLAGS = -O2 -Wall -export CFLAGS - -all: - cd src; $(MAKE) - cd example;$(MAKE) -clean: - cd src; $(MAKE) clean - cd example; $(MAKE) clean diff --git a/src/support/MESA_socket_wrap/example/Makefile b/src/support/MESA_socket_wrap/example/Makefile deleted file mode 100644 index a1279a4..0000000 --- a/src/support/MESA_socket_wrap/example/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -CC=gcc -CCC=gcc - -TARGET=MESA_sock_example multi_thread_example udp_example test_read tcp_example - -all:$(TARGET) - -INC=-I../include -LIBPATH=-L../lib -LIB=-lpthread ../lib/libMESA_socket_wrap.a - -multi_thread_example:multi_thread_example.c - $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB) - -MESA_sock_example:MESA_sock_example.c - $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB) - -tcp_example:tcp_example.c - $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB) - -udp_example:udp_example.c - $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB) - -test_read:test_read.c - $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB) - -clean: - rm -f *.o $(TARGET) diff --git a/src/support/MESA_socket_wrap/src/Makefile b/src/support/MESA_socket_wrap/src/Makefile deleted file mode 100644 index dddf620..0000000 --- a/src/support/MESA_socket_wrap/src/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CC=gcc -g -fPIC -CCC=gcc -g -fPIC - -TARGET=libMESA_socket_wrap.a libMESA_socket_wrap.so -INC=-I../include -LIBPATH=../lib - -OBJS=MESA_socket_wrap.o - -all:$(TARGET) - -.c.o: - $(CC) -c $(CFLAGS) -I. $(INC) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(INC) $< - -libMESA_socket_wrap.a: $(OBJS) - echo making lib ... - (rm -f $@ ;ar -r $@ $^; cp $@ $(LIBPATH); cp $@ ../../../lib/) - -libMESA_socket_wrap.so: $(OBJS) - $(CC) -o $@ $^ -shared - -clean: - rm -f *.o $(TARGET) diff --git a/src/support/dictator2/lib/.gitignore b/src/support/dictator2/lib/.gitignore deleted file mode 100644 index 1c2ee5e..0000000 --- a/src/support/dictator2/lib/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -SI/ -*.log -*.o -*.so -bin/avrule/ -bin/avlog/ diff --git a/src/support/dictator2/readme.txt b/src/support/dictator2/readme.txt deleted file mode 100644 index 247b571..0000000 --- a/src/support/dictator2/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -LDDICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc -Define above variable in Makefile,then use this variable as a ld parameter to enable dictator. -This is enough for shared dynamic library(.so). -Further more,final executable file need to link with libdictator.a or libdictator_debug.a to include dictator binary. \ No newline at end of file diff --git a/src/support/dictator2/src/CMakeLists.txt b/src/support/dictator2/src/CMakeLists.txt deleted file mode 100644 index d5f0315..0000000 --- a/src/support/dictator2/src/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8...3.10) - -include_directories(${MESA_SDK_PREFIX}/include) -include_directories(${MESA_SDK_PREFIX}/include/MESA) -#include_directories(${CMAKE_SOURCE_DIR}/packet_io) -#include_directories(${CMAKE_SOURCE_DIR}/project) -#include_directories(${CMAKE_SOURCE_DIR}/include) -#include_directories(${CMAKE_SOURCE_DIR}/include/support) -#include_directories(${CMAKE_SOURCE_DIR}/dealpkt) - -add_definitions(${MEM_POOL_DEFINITIONS} -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H) -add_library(dictator2 STATIC dictator.cpp dictator_debuger.cpp - D_internal/D_kernel_list.cpp D_internal/list_common.cpp - D_internal/MESA_hash_v2.cpp D_internal/MESA_list_v2.cpp) - -add_library(dictator2_debug STATIC dictator.cpp dictator_debuger.cpp - D_internal/D_kernel_list.cpp D_internal/list_common.cpp - D_internal/MESA_hash_v2.cpp D_internal/MESA_list_v2.cpp) -target_compile_definitions(dictator2_debug PRIVATE "-DDICTATOR_DEBUG") \ No newline at end of file diff --git a/src/support/dictator2/src/D_internal/D_kernel_list.cpp b/src/support/dictator2/src/D_internal/D_kernel_list.cpp deleted file mode 100644 index d1131e8..0000000 --- a/src/support/dictator2/src/D_internal/D_kernel_list.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include "D_kernel_list.h" - -void D_kernel_list_init(struct D_kernel_list_head *head) -{ - assert(head); - head->next = head; - head->prev = head; -} - -void D_kernel_list_destroy(struct D_kernel_list_head *head,\ - void (*my_list_free_cb)(struct D_kernel_list_head *del)) -{ - struct D_kernel_list_head *cur, *next; - - assert(head && my_list_free_cb); - - cur = head->next; - while(head != cur) - { - next = cur->next; - my_list_free_cb(cur); - cur = next; - } -} - -inline static void __D_kernel_list_delete(struct D_kernel_list_head *prev, struct D_kernel_list_head *next) -{ - next->prev = prev; - prev->next = next; -} - -void D_kernel_list_delete(struct D_kernel_list_head *head,struct D_kernel_list_head *del) -{ - __D_kernel_list_delete(del->prev, del->next); -} - -inline static void __D_kernel_list_insert(struct D_kernel_list_head *new_node, - struct D_kernel_list_head *prev, struct D_kernel_list_head *next) -{ - next->prev = new_node; - new_node->next = next; - new_node->prev = prev; - prev->next = new_node; -} - -void D_kernel_list_add_head(struct D_kernel_list_head *head, - struct D_kernel_list_head *new_node) -{ - __D_kernel_list_insert(new_node, head, head->next); -} - -void D_kernel_list_add_tail(struct D_kernel_list_head *head, - struct D_kernel_list_head *new_node) -{ - __D_kernel_list_insert(new_node, head->prev, head); -} - -struct D_kernel_list_head * D_kernel_list_get_head(struct D_kernel_list_head *head) -{ - struct D_kernel_list_head*p=NULL; - if(LIST_IS_EMPTY(head)) - { - return NULL; - } - p=head->next; - D_kernel_list_delete(head, p); - return p; -} -struct D_kernel_list_head * D_kernel_list_get_tail(struct D_kernel_list_head *head) -{ - struct D_kernel_list_head*p=NULL; - if(LIST_IS_EMPTY(head)) - { - return NULL; - } - p=head->prev; - D_kernel_list_delete(head, p); - return p; -} -void D_kernel_list_move_head(struct D_kernel_list_head *head, - struct D_kernel_list_head *node) -{ - D_kernel_list_delete(node->prev, node->next); - __D_kernel_list_insert(node, head, head->next); -} - diff --git a/src/support/dictator2/src/D_internal/D_kernel_list.h b/src/support/dictator2/src/D_internal/D_kernel_list.h deleted file mode 100644 index 6968f03..0000000 --- a/src/support/dictator2/src/D_internal/D_kernel_list.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _D_KERNEL_LIST_ -#define _D_KERNEL_LIST_ - -#include - -struct D_kernel_list_head{ - struct D_kernel_list_head *next, *prev; -}; - -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - -#ifndef container_of -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -#endif - - -#define D_kernel_list_entry(ptr, type, member) container_of(ptr, type, member) - -#define LIST_IS_EMPTY(_head) (((_head)->next == (_head)) ? 1 : 0 ) - -#define D_kernel_list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -void D_kernel_list_init(struct D_kernel_list_head *head); -void D_kernel_list_add_head(struct D_kernel_list_head *head, struct D_kernel_list_head *new_node); -void D_kernel_list_add_tail(struct D_kernel_list_head *head,struct D_kernel_list_head *new_node); -void D_kernel_list_delete(struct D_kernel_list_head *head,struct D_kernel_list_head *del); -void D_kernel_list_move_head(struct D_kernel_list_head *head, struct D_kernel_list_head *node); -void D_kernel_list_destroy(struct D_kernel_list_head *head, void (*my_list_free)(struct D_kernel_list_head *del)); -struct D_kernel_list_head * D_kernel_list_get_head(struct D_kernel_list_head *head); -struct D_kernel_list_head * D_kernel_list_get_tail(struct D_kernel_list_head *head); - -#endif - diff --git a/src/support/dictator2/src/D_internal/MESA_hash_v2.cpp b/src/support/dictator2/src/D_internal/MESA_hash_v2.cpp deleted file mode 100644 index d6b9219..0000000 --- a/src/support/dictator2/src/D_internal/MESA_hash_v2.cpp +++ /dev/null @@ -1,655 +0,0 @@ -#include -#include -#include -#include "MESA_hash_v2.h" -#include "MESA_list_v2.h" -#include "list_common.h" -#include "../dictator.h" - -#if MESA_HASH_DEBUG -static int *hash_slot_list_num; /* 用于记录每个slot挂接链表节点数量 */ -static int max_slot_list_num = 0; /* 每个slot最大冲突数 */ -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -/* - * hash implementation, xh, 2001-07-26 - */ - -/*Developer Notice: - in hash_add function,hash table MALLOC memory for keys and RECORD data pointer, - which means need NOT malloc memory for keys before call hash_add. zhengchao - - 2013-05, LiJia, add thread safe implement. -*/ - - -/* - 尽可能减少锁冲突,每N个Hash-slot共享一个互斥锁, - (HASH_Index % HASH_TABLE_MUTEX_NUM)的值相同的item共享一个mutex. -*/ -#define HASH_TABLE_MUTEX_NUM (256) - - -static HASH_INLINE int D_INTERNAL___MESA_hash_mutex_unlock(MESA_hash_tab_v2_t * table,uint index) -{ - if(table->is_thread_safe){ - return pthread_mutex_unlock(&table->htable_mutex[index%HASH_TABLE_MUTEX_NUM]); - } - return 0; -} - - -static HASH_INLINE int D_INTERNAL___MESA_hash_mutex_lock(MESA_hash_tab_v2_t * table, uint index) -{ - if(table->is_thread_safe){ - return pthread_mutex_lock(&table->htable_mutex[index%HASH_TABLE_MUTEX_NUM]); - } - return 0; -} - -static int D_INTERNAL___MESA_hash_time_list_insert(MESA_hash_tab_v2_t *table, - hash_elem_v2_t *hash_elem, uint index) -{ - int ret = 0; - MESA_queue_head_v2_t *list_head; - - if(table->is_thread_safe){ - list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM]; - }else{ - list_head = &table->hlist_head[0]; - } - - D_INTERNAL_MESA_q_join_tail_v2(list_head, &hash_elem->list_node); - - return ret; -} - -static HASH_INLINE void D_INTERNAL___MESA_hash_time_list_delete(MESA_hash_tab_v2_t *table, - hash_elem_v2_t *hash_elem, uint index) -{ - MESA_queue_head_v2_t *list_head; - - if(table->is_thread_safe){ - list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM]; - }else{ - list_head = &table->hlist_head[0]; - } - D_INTERNAL_MESA_q_leave_list_v2(list_head, &hash_elem->list_node); - - return; -} - -static HASH_INLINE int D_INTERNAL___MESA_hash_time_list_lru(MESA_hash_tab_v2_t *table, - hash_elem_v2_t *hash_elem, uint index) -{ - int ret = 0; - MESA_queue_head_v2_t *list_head; - - if(table->is_thread_safe){ - list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM]; - }else{ - list_head = &table->hlist_head[0]; - } - - D_INTERNAL_MESA_q_move_tail_v2(list_head, &hash_elem->list_node); - - return ret; -} - - -/* - search HASH-table whether has duplicate key. -*/ -static HASH_INLINE hash_elem_v2_t *D_INTERNAL___MESA_hash_key_search(MESA_hash_tab_v2_t * table, - uchar * key, uint size, uint index) -{ - hash_elem_v2_t * ptr; - for(ptr = table->elems[index]; NULL != ptr; ptr = ptr->next) { - if(!table->key_comp(ptr->key, ptr->size, key, size)) - break; - } - - return ptr; -} - -static HASH_INLINE void D_INTERNAL___MESA_hash_list_insert(MESA_hash_tab_v2_t * table, - hash_elem_v2_t * ptr, uint index) -{ - ptr->prev = NULL; - ptr->next = table->elems[index]; - if(NULL != table->elems[index]){ - table->elems[index]->prev = ptr; - } - table->elems[index] = ptr; - - table->elem_count++; -} - -static HASH_INLINE void D_INTERNAL___MESA_hash_list_delete(MESA_hash_tab_v2_t * table, - hash_elem_v2_t * ptr, uint index) -{ - if(NULL != ptr->prev){ - ptr->prev->next = ptr->next; - }else{ - table->elems[index] = ptr->next; - } - - if(NULL != ptr->next){ - ptr->next->prev = ptr->prev; - } - - table->elem_count--; -} - -static HASH_INLINE hash_elem_v2_t *D_INTERNAL___MESA_hash_alloc_resource( - uchar * key, uint size, void * data, uint index - ,IMP_t*p_mempool) -{ - hash_elem_v2_t *ptr = NULL; - if(NULL == (ptr = (hash_elem_v2_t*)block_alloc(sizeof(hash_elem_v2_t),p_mempool))){ - goto err_1; - } - if(NULL == (ptr->key = (unsigned char*)block_alloc(size,p_mempool))) { - goto err_2; - } - memcpy(ptr->key, key, size); - ptr->size = size; - ptr->data = data; /* lijia comment, data指向的内存是调用者申请的 */ - ptr->list_node.nextele = NULL; - ptr->list_node.preele = NULL; - ptr->list_node.quiddity = (void *)ptr; - ptr->op_time = HASH_TIME_NOW(); - ptr->hash_index = index; - return ptr; - -err_2: - block_free(ptr,p_mempool); -err_1: - return NULL; -} - - -static HASH_INLINE void D_INTERNAL___MESA_hash_free_resource(MESA_hash_tab_v2_t * table, - hash_elem_v2_t *ptr, void (* func)(void *)) -{ - IMP_t *p_mempool=table->p_mempool; - if(NULL != func){ - func(ptr->data); - }else if(NULL != table->free){ - table->free(ptr->data); - } - block_free(ptr->key,p_mempool); - block_free(ptr,p_mempool); -} - - -static HASH_INLINE void D_INTERNAL___MESA_hash_del_node(MESA_hash_tab_v2_t * table, - hash_elem_v2_t * ptr, uint index, void (* func)(void *)) -{ - D_INTERNAL___MESA_hash_list_delete(table, ptr, index); - D_INTERNAL___MESA_hash_time_list_delete(table, ptr, index); - D_INTERNAL___MESA_hash_free_resource(table, ptr, func); -} - -/* - kick out a oldest node from HASH-table if elements number exceed threshold, - or the node's operate time expired. -*/ -static void D_INTERNAL___MESA_hash_eliminate(MESA_hash_tab_v2_t *table, uint index) -{ - MESA_list_index_v2_t *list_head, *oldest_node; - hash_elem_v2_t *hash_elem; - int do_eliminate = 0; - if(table->is_thread_safe){ - list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM]; - }else{ - list_head = &table->hlist_head[0]; - } - - oldest_node = D_INTERNAL_MESA_q_read_head_v2(list_head); - if(oldest_node){ - hash_elem = (hash_elem_v2_t *)oldest_node->quiddity; - if((table->max_elem_num != 0) - && (table->elem_count > table->max_elem_num)){ /* too many elements */ - do_eliminate |= 0x01; - }else if((table->expire_time != 0) - &&(hash_elem->op_time + table->expire_time < HASH_TIME_NOW())){ /* time expired */ - do_eliminate |= 0x10; - } - if(do_eliminate != 0){ - if(table->expire){ - table->expire(hash_elem->data); - } - D_INTERNAL___MESA_hash_del_node(table ,hash_elem, hash_elem->hash_index, NULL); - //printf("eliminate a oldest element!\n"); - } - } -} - -/* - * name: D_INTERNAL___default_hash_key2index - * functionality: computes index from key, default key2index implementation - * if previous hash_create() call did not provide such a function; - * params: - * table: with which table are you dealing, we want this param be present - * because we may need size of table to compute the key; - * key: what is the label; - * size: how long is the label; - * returns: - * index in given table for given key, never fails; - */ -#if 0 -static uint D_INTERNAL___default_hash_key2index(MESA_hash_tab_v2_t * table, uchar * key, uint size) -{ - uchar * c; - uint h, g; - - for (c = key, h = 0; c - key < size; c ++) { - h = (h << 2) + c[0]; - if(0 != (g = (h & 0xf0000000))) { - h = h ^ (g >> 24); - h = h ^ g; - } - } - return h % table->size; -} -#else -/* BKDR Hash Function */ -static uint D_INTERNAL___default_hash_key2index(MESA_hash_tab_v2_t * table, uchar *str, uint size) -{ - uint i; - uint seed = 131; // 31 131 1313 13131 131313 etc.. - uint hash = 0; - uint cmp_size=MIN(size,96); - for(i = 0; i < cmp_size; i++){ - if((i&0x7)<3) - hash = hash * seed + (*str++); - else - *str++; - } - - return (hash % table->size); -} -#endif - -/* - * name: D_INTERNAL___default_hash_key_comp - * functionality: compares two key; - * params: - * key1, key2: what are the labels; - * size1, size2: how long are them; - * returns: - * 0, if two keys are identical; (just a simple memcmp() ); - * 1, no. - */ -static int D_INTERNAL___default_hash_key_comp(uchar * key1, uint size1, uchar * key2, uint size2) -{ - if(size1 != size2) return 1; - return memcmp(key1, key2, size1); -} - -/* 检验是否2的N次方 */ -static HASH_INLINE int D_INTERNAL_number_is_2N(uint n) -{ -#if 0 - uint s; - for(s = n; s != 0; ) { - if(0x01 != s && 0x01 == (0x01 & s)) return 0; - s = s >> 1; - } -#else - if(n & (n-1)){ - return 0; - } -#endif - - return 1; -} - -/* - * name: hash_create - * functionality: allocats memory for hash slots, and fill in hash structure; - * param: - * table: caller allocated hash table structure, gets filled in; - * is_thread_safe:1:create thread safe hashtable; 0:create hashtable without thread safe insurance; - * size: how big do you want the table to be, must be 2^N; - * max_elem_num: the maximum elements of the HASH-table,0 means infinite; - * key_comp: hash key compare function, use default function if NULL; - * key2index: hash key->index computing function, use default function if NULL; - * data_free: release resources function, only free attached data pointer if NULL; - * data_expire: if expire_time > 0, call this function when a element expire, can be NULL; - * eliminate_type: the algorithm of elimanate a expired element, 0:FIFO; 1:LRU. - * expire_time: the element expire time in second, 0 means infinite. - * returns: - * 0, success; - * -1, memory failure; - * -2, parameter not acceptable; - */ -int D_INTERNAL_MESA_hash_create_v2(MESA_hash_tab_v2_t * table, uint is_thread_safe, - uint size, uint max_elem_num, - key_comp_t * key_comp, - key2index_t * key2index, - void (* data_free)(void *), - void (* data_expire)(void *), - int eliminate_type, - int expire_time, - IMP_t* p_mempool) -{ - int i=0,j, ret = 0; - - if(D_INTERNAL_number_is_2N(size) == 0){ - return -2; - } - - table->elems = (hash_elem_v2_t**)mmap_alloc(sizeof(hash_elem_v2_t *) * size); - if(NULL == table->elems) - return -1; - memset(table->elems, 0, sizeof(hash_elem_v2_t *) * size); - table->size = size; - if(NULL == key_comp) table->key_comp = D_INTERNAL___default_hash_key_comp; - else table->key_comp = key_comp; - if(NULL == key2index) table->key2index = D_INTERNAL___default_hash_key2index; - else table->key2index = key2index; - table->expire = data_expire; - //if(NULL == data_free) return -1; /* 2013-05-06 modify, can be NULL */ - table->free = data_free; - table->elem_count = 0; - table->max_elem_num = max_elem_num; - //table->threshold_lo = 0; - //table->threshold_hi = size; - table->eliminate_type = eliminate_type; - table->expire_time = expire_time; - table->is_thread_safe = is_thread_safe; - table->p_mempool=p_mempool; - if(table->is_thread_safe){ - table->htable_mutex = (pthread_mutex_t *)mmap_alloc(sizeof(pthread_mutex_t) * HASH_TABLE_MUTEX_NUM); - if(NULL == table->htable_mutex){ - ret = -1; - goto err_1; - } - for(i = 0; i < HASH_TABLE_MUTEX_NUM; i++){ - if(pthread_mutex_init(&table->htable_mutex[i], NULL)!=0){ - ret = -1; - goto err_2; - } - } - table->hlist_head = (MESA_list_index_v2_t *)mmap_alloc(sizeof(MESA_list_index_v2_t) * HASH_TABLE_MUTEX_NUM); - if(NULL == table->hlist_head){ - ret = -1; - goto err_2; - } - for(i=0;ihlist_head[i]); - } - }else{ - table->hlist_head = (MESA_list_index_v2_t *)mmap_alloc(sizeof(MESA_list_index_v2_t)); - if(NULL == table->hlist_head){ - ret = -1; - goto err_2; - } - D_INTERNAL_MESA_list_init_v2(&table->hlist_head[0]); - } - - return 0; - -err_2: - for(j = 0; j < i; j++){ - pthread_mutex_destroy(&table->htable_mutex[j]); - } - mmap_free(table->htable_mutex); -err_1: - mmap_free(table->elems); - return ret; -} - -/* - * frees table->elems and chains attached to each element of it. - * always returns 0. - */ -int D_INTERNAL_MESA_hash_destroy_v2(MESA_hash_tab_v2_t * table, void (* func)(void *)) -{ - int i; - hash_elem_v2_t * cur; - IMP_t* p_mempool=table->p_mempool; - for(i = 0; i < (int)table->size; i ++) { - while(NULL != table->elems[i]) { - cur = table->elems[i]; - if(NULL != func) func(cur->data); - else if(NULL != table->free) table->free(cur->data); - table->elems[i] = (table->elems[i])->next; - block_free(cur->key,p_mempool); - block_free(cur,p_mempool); - } - } - if(table->is_thread_safe){ - for(i=0;ihtable_mutex[i]); - mmap_free(table->htable_mutex); - } - mmap_free(table->hlist_head); - mmap_free(table->elems); - table->elems = NULL; - table->size = 0; - - return 0; -} - -/* - * adds data identified by key to table. - * table->elems always points to the newest added element. - * no two elements should have a same key, although them may have a same index. - * returns: - * -1, if duplicate is found; - * -2, if memory fails; - * 0, success. - */ -int D_INTERNAL_MESA_hash_add_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size, - void * data) -{ - uint index; - hash_elem_v2_t * ptr; - int ret = 0; - IMP_t *p_mempool=table->p_mempool; - index = table->key2index(table, key, size); - - D_INTERNAL___MESA_hash_mutex_lock(table,index); - if(D_INTERNAL___MESA_hash_key_search(table,key,size,index)){ /* already exist */ - ret = -1; - goto err; - } - ptr = D_INTERNAL___MESA_hash_alloc_resource(key, size, data, index,p_mempool); - if(NULL == ptr){ - ret = -2; - goto err; - } - D_INTERNAL___MESA_hash_list_insert(table, ptr, index); - D_INTERNAL___MESA_hash_time_list_insert(table, ptr, index); - - D_INTERNAL___MESA_hash_eliminate(table,index); - - D_INTERNAL___MESA_hash_mutex_unlock(table,index); - -#if MESA_HASH_DEBUG - hash_slot_list_num[index]++; - if(max_slot_list_num < hash_slot_list_num[index]){ - max_slot_list_num = hash_slot_list_num[index]; - printf("Hash table max list num:%d\n", max_slot_list_num); - } -#endif - - return 0; - -err: - D_INTERNAL___MESA_hash_mutex_unlock(table,index); - return ret; -} - - - -/* - * name: hash_del - * functionality: deletes item from table. - * param: - * table: from which table do you want to delete; - * key : what is the label; - * size : how long is the label; - * func : callback function to clean up data attached to hash items, - if this pointer is NULL will call "data_free" in MESA_hash_create(), - * returns: - * 0, success; - * -1, no such thing; - */ -int D_INTERNAL_MESA_hash_del_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size, - void (* func)(void *)) -{ - uint index; - hash_elem_v2_t * ptr; - int ret = 0; - index = table->key2index(table, key, size); - - D_INTERNAL___MESA_hash_mutex_lock(table,index); - ptr = D_INTERNAL___MESA_hash_key_search(table,key,size,index); - if(NULL == ptr){ - ret = -1; - goto err; /* success, maybe? why? */ - } - - D_INTERNAL___MESA_hash_del_node(table ,ptr, index, func); - - //D_INTERNAL___MESA_hash_eliminate(table,index); - - D_INTERNAL___MESA_hash_mutex_unlock(table,index); - - return ret; - -err: - D_INTERNAL___MESA_hash_mutex_unlock(table,index); - return ret; -} - -/* - * name: hash_sel - * functionality: selects item from table; - * param: - * table: from which table do you want to select; - * key: what is the label; - * size: how long is the label; - * - * return: - * not NULL :pointer to attached data; - * NULL :not found(thus be careful if you are attaching NULL data on purpose). - */ -void *D_INTERNAL_MESA_hash_sel_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size) -{ - uint index; - hash_elem_v2_t * ptr; - void *ret; - index = table->key2index(table, key, size); - D_INTERNAL___MESA_hash_mutex_lock(table,index); - D_INTERNAL___MESA_hash_eliminate(table,index); /* 2013-09-12 LiJia modify, 先淘汰再查找,否则会将查到的结果淘汰而又返回给了调用者 */ - ptr = D_INTERNAL___MESA_hash_key_search(table,key,size,index); - if(NULL != ptr){ - ret = ptr->data; - if(HASH_ELIMINATE_ALGO_LRU==table->eliminate_type){ - ptr->op_time = HASH_TIME_NOW(); - D_INTERNAL___MESA_hash_time_list_lru(table, ptr, index); - } - }else{ - ret = NULL; - } - - D_INTERNAL___MESA_hash_mutex_unlock(table,index); - - return ret; -} - -/* - * name: hash_sel - * functionality: selects item from table; - * in param: - * table: from which table do you want to select; - * key : what is the label; - * size : how long is the label; - * cb : call this function when found the attached data; - * arg : the argument of "cb" function. - * out param: - * cb_ret: the return value of the function "cb". - * return: - * not NULL :pointer to attached data; - * NULL :not found(thus be careful if you are attaching NULL data on purpose). - */ -void *D_INTERNAL_MESA_hash_sel_with_cb_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size, - hash_cb_t *cb, void *arg, int *cb_ret) -{ - uint index; - hash_elem_v2_t * ptr; - void *ret; - - index = table->key2index(table, key, size); - D_INTERNAL___MESA_hash_mutex_lock(table,index); - D_INTERNAL___MESA_hash_eliminate(table,index);/* 2013-09-12 LiJia modify, 先淘汰再查找,否则会将查到的结果淘汰而又返回给了调用者 */ - ptr = D_INTERNAL___MESA_hash_key_search(table,key,size,index); - if(NULL != ptr){ - ret = ptr->data; - if(HASH_ELIMINATE_ALGO_LRU == table->eliminate_type){ - ptr->op_time = HASH_TIME_NOW(); - D_INTERNAL___MESA_hash_time_list_lru(table, ptr, index); - } - if(cb){ - *cb_ret = cb(ptr->data, arg); - } - }else{ - ret = NULL; - if(cb){ - *cb_ret = cb(NULL, arg); - } - } - - D_INTERNAL___MESA_hash_mutex_unlock(table,index); - - return ret; -} - -int D_INTERNAL_MESA_hash_iterate_v2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data)) -{ - int i; - hash_elem_v2_t * ptr; - - if(NULL == func){ - return 0; - } - - for(i = 0; i < (int)table->size; i++) { - D_INTERNAL___MESA_hash_mutex_lock(table, i/(table->size/HASH_TABLE_MUTEX_NUM)); - for(ptr = table->elems[i]; NULL != ptr; ptr = ptr->next) - func(ptr->key, ptr->size, ptr->data); - D_INTERNAL___MESA_hash_mutex_unlock(table, i/(table->size/HASH_TABLE_MUTEX_NUM)); - } - - return 0; -} - -int D_INTERNAL_MESA_hash_iterate_v2_2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data, void * u), void * user) -{ - int i; - hash_elem_v2_t * ptr; - - if(NULL == func){ - return 0; - } - for(i = 0; i < (int)table->size; i ++) { - D_INTERNAL___MESA_hash_mutex_lock(table, i/(table->size/HASH_TABLE_MUTEX_NUM)); - for(ptr = table->elems[i]; NULL != ptr; ptr = ptr->next) - func(ptr->key, ptr->size, ptr->data, user); - D_INTERNAL___MESA_hash_mutex_unlock(table, i/(table->size/HASH_TABLE_MUTEX_NUM)); - } - - return 0; -} - diff --git a/src/support/dictator2/src/D_internal/MESA_hash_v2.h b/src/support/dictator2/src/D_internal/MESA_hash_v2.h deleted file mode 100644 index 52d5c19..0000000 --- a/src/support/dictator2/src/D_internal/MESA_hash_v2.h +++ /dev/null @@ -1,262 +0,0 @@ -#ifndef _LIB_HASH_H_INCLUDED_ -#define _LIB_HASH_H_INCLUDED_ - - -/* - * general purpose hash table implementation. - * - * xiang hong - * 2002-07-28 - *History: - *2012-03-23 zhengchao add thread safe option and link expire feature; - */ - - - -#include -#include -#include -#include "MESA_list_v2.h" -#include "list_common.h" -#include "../internal_mp.h" -#define MESA_HASH_DEBUG (0) - -#if MESA_HASH_DEBUG -#define HASH_INLINE -#else -#define HASH_INLINE inline -#endif - - -/* - 此宏定义的作用是取当前时间,可以不是绝对时间,比如一个每隔1秒自增的数, - 为了减少调用time(NULL)函数的次数. - 推荐做法: - 新建一个线程,对某个变量每隔一秒自增一次. -*/ -#if 1 -#define HASH_TIME_NOW() time(NULL) -#else -extern volatile unsigned int G_TIMER; /* 此变量在另一个线程中每隔1秒自增一次 */ -#define HASH_TIME_NOW() (time_t)G_TIMER -#endif - -#ifndef uchar -#define uchar unsigned char -#endif -#ifndef uint -#define uint unsigned int -#endif - -#define HASH_THRESHOLD_MAX 65536 -#define HASH_THRESHOLD_MIN 0 -#define HASH_THRESHOLD_MAX_DELTA 32768 -#define HASH_THRESHOLD_MIN_DELTA 16 - -#define HASH_ELIMINATE_ALGO_FIFO (0) /* by default */ -#define HASH_ELIMINATE_ALGO_LRU (1) - -struct __hash_tab_v2; - -/* - * hash key compare function prototype, see hash_key_comp(). - * return value: - * 0:key1 and key2 are equal; - * other:key1 and key2 not equal. - */ -typedef int key_comp_t(uchar * key1, uint size1, uchar * key2, uint size2); - -/* - * hash key->index computing function prototype, see hash_key2index(). - */ -typedef uint key2index_t(struct __hash_tab_v2 * tab, uchar * key, uint size); - -typedef int hash_cb_t(void *data, void *arg); - -/* - * hash element structure. - * - * key : a copy of key; - * size: size of key; - * hash_index: index which use this key and key2index_t() calculated; - * data: pointer to attached data; - * prev, next: pointer to prev and next item; - */ -typedef struct struct_hash_elem { - uchar *key; - void *data; - uint size; - uint hash_index; - time_t op_time; - struct struct_hash_elem *prev; - struct struct_hash_elem *next; - MESA_list_index_v2_t list_node; -} hash_elem_v2_t; - -/* - * hash structure. - * - * size: number of slots; - * key_comp: pointer to the function that compares 2 keys; - * key2index: pointer to the function that computes index from key; - * expire: pointer to the function that do somthing when data expired; - * free: pointer to the function that cleans up attached data; - * elems: array of slots; - * elem_count: number of items; - * threshold_lo, threshold_hi: low and high threshold; when elem_count reaches - * one of them, an iteration will be launched to clean up expired items; - */ -typedef struct __hash_tab_v2 { - uint size; - uint is_thread_safe; - key_comp_t * key_comp; - key2index_t * key2index; - void (* expire)(void * data); - void (* free)(void * data); - hash_elem_v2_t ** elems; - unsigned int max_elem_num; - volatile uint elem_count; - //uint threshold_lo; - //uint threshold_hi; - int eliminate_type; - int expire_time; - pthread_mutex_t *htable_mutex; - //MESA_queue_head_t *hlist_head; - MESA_list_index_v2_t *hlist_head; - IMP_t* p_mempool; -} MESA_hash_tab_v2_t; - -/* - * name: hash_create - * functionality: allocats memory for hash slots, and fill in hash structure; - * param: - * table: caller allocated hash table structure, gets filled in; - * is_thread_safe:1:create thread safe hashtable; 0:create hashtable without thread safe insurance; - * size: how big do you want the table to be, must be 2^N; - * max_elem_num: the maximum elements of the HASH-table,0 means infinite; - * key_comp: hash key compare function, use default function if NULL; - * key2index: hash key->index computing function, use default function if NULL; - * data_free: release resources function, only free attached data pointer if NULL; - * data_expire: if expire_time > 0, call this function when a element expire, can be NULL; - * eliminate_type: the algorithm of elimanate a expired element, 0:FIFO; 1:LRU. - * expire_time: the element expire time in second, 0 means infinite. - * returns: - * 0, success; - * -1, memory failure; - * -2, parameter not acceptable; - */ -int D_INTERNAL_MESA_hash_create_v2(MESA_hash_tab_v2_t * table, - uint is_thread_safe , - uint size, - uint max_elem_num, - key_comp_t * key_comp, - key2index_t * key2index, - void (* data_free)(void *), - void (* data_expire)(void *), - int eliminate_type, - int expire_time, - IMP_t * mempool); - -/* - * name: hash_destroy - * functionality: cleans up hash structure, frees memory occupied; - * param: - * table: who is the victim; - * func: callback function to clean up data attached to hash items; - * returns: - * always returns 0; - */ -int D_INTERNAL_MESA_hash_destroy_v2(MESA_hash_tab_v2_t * table, void (* func)(void *)); - -/* - * name: hash_add - * functionality: adds item to table, call hash_expire() if elem_count gets - * bigger than threshold_hi, and adjust threshold; - * param: - * table: to which table do you want to add; - * key: what is the label; - * size: how long is the label; - * data: what data do you want to attach; - * returns: - * >0 success,return hash elems' linklist size - * -1, duplicates found and can't add this one; - * -2, memory failure; - */ -int D_INTERNAL_MESA_hash_add_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size, void * data); - -/* - * name: hash_del - * functionality: deletes item from table. - * param: - * table: from which table do you want to delete; - * key : what is the label; - * size : how long is the label; - * func : callback function to clean up data attached to hash items, - if this pointer is NULL will call "data_free" in MESA_hash_create(), - * returns: - * 0, success; - * -1, no such thing; - */ -int D_INTERNAL_MESA_hash_del_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size, - void (* func)(void *)); - -/* - * name: hash_sel - * functionality: selects item from table; - * param: - * table: from which table do you want to select; - * key : what is the label; - * size : how long is the label; - * - * return: - * not NULL :pointer to attached data; - * NULL :not found(thus be careful if you are attaching NULL data on purpose). - */ -void * D_INTERNAL_MESA_hash_sel_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size); - -/* - * name: hash_sel - * functionality: selects item from table; - * in param: - * table: from which table do you want to select; - * key : what is the label; - * size : how long is the label; - * cb : call this function when found the attached data; - * arg : the argument of "cb" function. - * out param: - * cb_ret: the return value of the function "cb". - * return: - * not NULL :pointer to attached data; - * NULL :not found(thus be careful if you are attaching NULL data on purpose). - */ -void *D_INTERNAL_MESA_hash_sel_with_cb_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size, - hash_cb_t *cb, void *arg, int *cb_ret); - -/* - * name: hash_iterate - * functionality: iterates each hash item; - * params: - * table: what table is to be iterated; - * func: what do you want to do to each attached data item; - * returns: - * 0: iterates all items; - * -3: can't get lock in non-block mode; - */ -int D_INTERNAL_MESA_hash_iterate_v2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data)); -int D_INTERNAL_MESA_hash_iterate_v2_2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data, void * u), void * user); - -#if 0 -/* - * name: hash_expire - * functionality: iterates each item and deletes those that are expired; - * params: - * table: what table do you want to check; - * returns: - * always 0; - */ -int MESA_hash_expire(MESA_hash_tab_v2_t * table); -#endif - -#endif /* _LIB_HASH_H_INCLUDED_ */ - - diff --git a/src/support/dictator2/src/D_internal/MESA_list_v2.cpp b/src/support/dictator2/src/D_internal/MESA_list_v2.cpp deleted file mode 100644 index bd5a22d..0000000 --- a/src/support/dictator2/src/D_internal/MESA_list_v2.cpp +++ /dev/null @@ -1,361 +0,0 @@ -#include -#include -#include -#include -#include -#include "MESA_list_v2.h" -#include "list_common.h" - - - -extern void D_INTERNAL_list_count_init(void **list_count); -extern void D_INTERNAL_list_count_inc(void **list_count); -extern void D_INTERNAL_list_count_dec(void **list_count); - -#if MESA_LIST_CHECK != 0 -/*Function:Check the intergrity of the list,to dectect memory mess. -*Input: Queue Head,data check call back function -*Output: return a number below zero,if the queue got a problem,else return 0; -*Author:zhengchao@iie.ac.cn at 20100913 -*/ -#if 0 -static int MESA_q_list_check(const MESA_queue_head_v2_t *qhead_obj,int(*quiddity_check)(const void *)) -{ - MESA_list_index_v2_t *p=NULL, *head=NULL; -// int linked_ele_number=0; - int ret=0; -// return 0; - if(qhead_obj->listcount==0) - { - if(qhead_obj->head!=NULL||qhead_obj->head!=NULL) - { - ret=-1; - } - goto exit; - } - - if(qhead_obj->head==NULL||qhead_obj->tail==NULL) - { - ret=-2; - goto exit; - } - if(qhead_obj->listcount>1){ - if(qhead_obj->head->preele!=NULL||qhead_obj->head->nextele==NULL) - { - ret=-3; - goto exit; - } - if(qhead_obj->tail->preele==NULL||qhead_obj->tail->nextele!=NULL) - { - ret=-4; - goto exit; - } - - head = p = qhead_obj->head; - p = p->nextele; - while(p != head) - { - if(p == NULL) break; - if(p == head){ - ret = -5; /* has a cycle */ - goto exit; - } - p = p->nextele; - } - } - /* - pre=qhead_obj->head; - p=pre->nextele; - while(p!=NULL){ - linked_ele_number++; - - //Is the declared size equal to element linked number; - if(linked_ele_number > qhead_obj->listcount) - { - ret=-5; - goto exit; - } - - //Is element's preele pointer equal to its preele - if(pre!=p->preele) - { - ret=-6; - goto exit; - } - if(quiddity_check!=NULL){ - if(0>quiddity_check(p->quiddity)) - { - ret =-7; - goto exit; - } - } - pre=p; - p=p->nextele; - } - //Is the last element equal to tail - if(pre!=qhead_obj->tail) - { - ret=-8; - goto exit; - } - if(linked_ele_number !=qhead_obj->listcount-1) - { - ret=-9; - goto exit; - } - */ -exit: - if(ret<0) - { - return ret; - } - else - { - return 1; - } - -} -#endif - -#if 2==MESA_LIST_CHECK -/*Simple check,not raversal*/ -static int D_INTERNAL_MESA_q_is_item_in_list_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj){ -// MESA_list_index_v2_t* pre=lindex_obj->preele; -// MESA_list_index_v2_t*next=lindex_obj->nextele; - MESA_list_index_v2_t*p=NULL; - int i, num; - - if(D_INTERNAL_common_list_empty_careful(qhead_obj)){ - return 0; - } - - p = qhead_obj->nextele; - num = D_INTERNAL_MESA_get_list_count_v2(qhead_obj); - i = 0; - while((p != qhead_obj) && (i <= num)) - { - if(p == lindex_obj) - { - return 1; - } - p=p->nextele; - i++; - } - - return 0; - -} -#endif - -/*every MESA_list_index_v2_t leaves list,its pre and next will be set NULL - * In Configuration Transmiiter project, not null element will consider in list, - * pre and next is NULL only if there's one element in list only*/ -static int D_INTERNAL_MESA_q_is_item_in_list_quick_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj) -{ - //empty list - if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){ - return 0; - } - - //have more element - if(lindex_obj->nextele==NULL || lindex_obj->preele==NULL){ - return 0; - } - if(lindex_obj->nextele->preele != lindex_obj){ - return 0; - } - if(lindex_obj->preele->nextele != lindex_obj){ - return 0; - } - - return 1; - -} -#endif - -void D_INTERNAL_list_count_init(void **list_count) -{ - long *p_c = (long *)list_count; - *p_c = 0; -} - -void D_INTERNAL_list_count_inc(void **list_count) -{ - long *p_c = (long *)list_count; - long c = *p_c; - *p_c = c + 1; -} - -void D_INTERNAL_list_count_dec(void **list_count) -{ - long *p_c = (long *)list_count; - long c = *p_c; - *p_c = c - 1; -} - - -/*************************** 外部调用接口 ********************************/ - - -/* - 第一次使用MESA_list模块时,必须调用此初始化模块. -*/ -int D_INTERNAL_MESA_list_init_v2(MESA_queue_head_v2_t *head) -{ - D_INTERNAL_COMMON_LIST_INIT_HEAD((struct common_list_index *)head); - D_INTERNAL_list_count_init(&head->quiddity); - return 0; -} - -/* 做为head使用时, "quiddity"做为一个long型变量,用于存储链表元素数量 */ -long D_INTERNAL_MESA_get_list_count_v2(const MESA_queue_head_v2_t *head) -{ - return (long)head->quiddity; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_next_v2(MESA_queue_head_v2_t *head,MESA_list_index_v2_t *lindex_obj) -{ - return (lindex_obj->nextele == head) ? NULL: lindex_obj->nextele; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_pre_v2(MESA_queue_head_v2_t *head, MESA_list_index_v2_t *lindex_obj) -{ - return (lindex_obj->preele == head) ? NULL: lindex_obj->nextele; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_head_v2(const MESA_queue_head_v2_t *qhead_obj) -{ - if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){ - return NULL; - } - return qhead_obj->nextele; -} - - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_head_v2(MESA_queue_head_v2_t *qhead_obj) -{ - MESA_list_index_v2_t *out; - if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){ - return NULL; - } - out = qhead_obj->nextele; - D_INTERNAL_common_list_del((struct common_list_index *)out); - D_INTERNAL_list_count_dec(&qhead_obj->quiddity); - - return out; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_tail_v2(MESA_queue_head_v2_t *qhead_obj) -{ - MESA_list_index_v2_t *out; - if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){ - return NULL; - } - out = qhead_obj->preele; - D_INTERNAL_common_list_del((struct common_list_index *)out); - D_INTERNAL_list_count_dec(&qhead_obj->quiddity); - - return out; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj) -{ - D_INTERNAL_common_list_add_tail((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj); - D_INTERNAL_list_count_inc(&qhead_obj->quiddity); - - return lindex_obj; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj) -{ - D_INTERNAL_common_list_add((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj); - D_INTERNAL_list_count_inc(&qhead_obj->quiddity); - - return lindex_obj; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_n_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *place_next, MESA_list_index_v2_t *new_obj) -{ - D_INTERNAL_common_list_add((struct common_list_index *)new_obj, (struct common_list_index *)place_next); - D_INTERNAL_list_count_inc(&qhead_obj->quiddity); - return new_obj; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_p_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *new_obj, MESA_list_index_v2_t *place_pre) -{ - D_INTERNAL_common_list_add((struct common_list_index *)new_obj, (struct common_list_index *)place_pre->preele); - D_INTERNAL_list_count_inc(&qhead_obj->quiddity); - return new_obj; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_leave_list_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj) -{ -#if 1==MESA_LIST_CHECK - if(0 == D_INTERNAL_MESA_q_is_item_in_list_quick_v2(qhead_obj, lindex_obj)){ - //return NULL; - assert(0); //critical - } -#elif 2==MESA_LIST_CHECK - if(0 == D_INTERNAL_MESA_q_is_item_in_list_v2(qhead_obj, lindex_obj)){ - //return NULL; - assert(0); //critical - } -#endif - D_INTERNAL_common_list_del((struct common_list_index *)lindex_obj); - D_INTERNAL_list_count_dec(&qhead_obj->quiddity); - - return lindex_obj; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj) -{ -#if 1==MESA_LIST_CHECK - if(0 == D_INTERNAL_MESA_q_is_item_in_list_quick_v2(qhead_obj, lindex_obj)){ - //return NULL; - assert(0); //critical - } -#elif 2==MESA_LIST_CHECK - if(0 == D_INTERNAL_MESA_q_is_item_in_list_v2(qhead_obj, lindex_obj)){ - //return NULL; - assert(0); //critical - } -#endif - D_INTERNAL_common_list_move((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj); - - return lindex_obj; -} - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj) -{ -#if 1==MESA_LIST_CHECK - if(0 == D_INTERNAL_MESA_q_is_item_in_list_quick_v2(qhead_obj,lindex_obj)){ - //return NULL; - assert(0); //critical - } -#elif 2==MESA_LIST_CHECK - if(0 == D_INTERNAL_MESA_q_is_item_in_list_v2(qhead_obj, lindex_obj)){ - //return NULL; - assert(0); //critical - } -#endif - D_INTERNAL_common_list_move_tail((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj); - - return lindex_obj; -} - -void D_INTERNAL_MESA_q_destroy_v2(MESA_queue_head_v2_t *qhead_obj, void (* cb)(MESA_list_index_v2_t *)) -{ - MESA_list_index_v2_t *del; - - while(!D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){ - del = qhead_obj->nextele; - D_INTERNAL_common_list_del((struct common_list_index *)del); - if(del->quiddity && cb){ - cb(del); - } - } - - return; -} - - diff --git a/src/support/dictator2/src/D_internal/MESA_list_v2.h b/src/support/dictator2/src/D_internal/MESA_list_v2.h deleted file mode 100644 index 8dbb098..0000000 --- a/src/support/dictator2/src/D_internal/MESA_list_v2.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _MESA_LIST_V2_H_ -#define _MESA_LIST_V2_H_ - - -#define MESA_LIST_CHECK (1) /* 0:no check; 1:quick check; 2:careful check */ - -typedef struct list_index_v2{ - struct list_index_v2 *nextele; - struct list_index_v2 *preele; - void *quiddity; -}MESA_list_index_v2_t; - -typedef struct list_index_v2 MESA_queue_head_v2_t; - - -/* - 第一次使用MESA_list模块时,必须调用此初始化模块!!! -*/ -int D_INTERNAL_MESA_list_init_v2(MESA_queue_head_v2_t *head); - -long D_INTERNAL_MESA_get_list_count_v2(const MESA_queue_head_v2_t *head); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_head_v2(const MESA_queue_head_v2_t *qhead_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_head_v2(MESA_queue_head_v2_t *qhead_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_tail_v2(MESA_queue_head_v2_t *qhead_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_leave_list_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj); -void D_INTERNAL_MESA_q_destroy_v2(MESA_queue_head_v2_t *qhead_obj, void (* cb)(MESA_list_index_v2_t *)); - -/* insert "new_obj" between "op_place" and "op_place->nextele" */ -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_n_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *op_place, MESA_list_index_v2_t *new_obj); - -/* insert "new_obj" between "op_place->preele" and "op_place" */ -MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_p_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *new_obj, MESA_list_index_v2_t *op_place); - -MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_next_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj); -MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_pre_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj); - -#endif - - diff --git a/src/support/dictator2/src/D_internal/Makefile b/src/support/dictator2/src/D_internal/Makefile deleted file mode 100644 index 4432e91..0000000 --- a/src/support/dictator2/src/D_internal/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -CC=gcc -CCC=g++ -O2 - -CFLAGS=-g -Wall -fPIC -LIBPATH=../ - -OBJS=MESA_hash_v2.o D_kernel_list.o MESA_list_v2.o list_common.o - -.c.o: - $(CC) -c $(CFLAGS) -I. $(H_DIR) $< - -.cpp.o: - $(CCC) -c $(CFLAGS) -I. $(H_DIR) $< - -libMESA_hash_v2.a: $(OBJS) - echo making lib ... - (rm -f $@ ;ar -r $@ $^; cp $(OBJS) $(LIBPATH);) - -clean: - rm -f *.o libMESA_hash_v2.a diff --git a/src/support/dictator2/src/D_internal/list_common.cpp b/src/support/dictator2/src/D_internal/list_common.cpp deleted file mode 100644 index ca6a1b0..0000000 --- a/src/support/dictator2/src/D_internal/list_common.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include -#include "list_common.h" - - -/*************************** 内部实现接口 ********************************/ - -/* - * Simple doubly linked list implementation. - * - * Some of the internal functions ("__xxx") are useful when - * manipulating whole lists rather than single entries, as - * sometimes we already know the next/prev entries and we can - * generate better code by using them directly rather than - * using the generic single-entry routines. - */ - -void D_INTERNAL_COMMON_LIST_INIT_HEAD(struct common_list_index *head) -{ - head->nextele = head; - head->preele = head; -} - - -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void D_INTERNAL___common_list_add(struct common_list_index *new_list, - struct common_list_index *prev, - struct common_list_index *next) -{ - next->preele = new_list; - new_list->nextele = next; - new_list->preele = prev; - prev->nextele = new_list; -} - -/** - * list_add - add a new entry - * @new: new entry to be added - * @head: list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - * lijia comment: list_add()把新节点插在head与head->next之间. - */ -void D_INTERNAL_common_list_add(struct common_list_index *new_list, struct common_list_index *head) -{ - D_INTERNAL___common_list_add(new_list, head, head->nextele); -} - - -/** - * list_add_tail - add a new entry - * @new: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - * lijia comment: list_add_tail()把新节点插在head与head->prev之间. - */ -void D_INTERNAL_common_list_add_tail(struct common_list_index *new_list, struct common_list_index *head) -{ - D_INTERNAL___common_list_add(new_list, head->preele, head); -} - -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void D_INTERNAL___common_list_del(struct common_list_index * prev, struct common_list_index * next) -{ - next->preele = prev; - prev->nextele = next; -} - -static inline void D_INTERNAL___common_list_del_entry(struct common_list_index *entry) -{ - D_INTERNAL___common_list_del(entry->preele, entry->nextele); - entry->nextele = NULL; - entry->preele = NULL; -} - -/** - * list_del - deletes entry from list. - * @entry: the element to delete from the list. - * Note: list_empty() on entry does not return true after this, the entry is - * in an undefined state. - */ - -void D_INTERNAL_common_list_del(struct common_list_index *entry) -{ - D_INTERNAL___common_list_del(entry->preele, entry->nextele); - entry->nextele = NULL; - entry->preele = NULL; -} - - -/** - * list_move - delete from one list and add as another's head - * @list: the entry to move - * @head: the head that will precede our entry - */ -void D_INTERNAL_common_list_move(struct common_list_index *list, struct common_list_index *head) -{ - D_INTERNAL___common_list_del_entry(list); - D_INTERNAL_common_list_add(list, head); -} - -/** - * list_move_tail - delete from one list and add as another's tail - * @list: the entry to move - * @head: the head that will follow our entry - */ -void D_INTERNAL_common_list_move_tail(struct common_list_index *list, struct common_list_index *head) -{ - D_INTERNAL___common_list_del_entry(list); - D_INTERNAL_common_list_add_tail(list, head); -} - -#if 0 -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -static int list_empty(const struct common_list_index *head) -{ - return head->nextele == head; -} -#endif - -/** - * list_empty_careful - tests whether a list is empty and not being modified - * @head: the list to test - * - * Description: - * tests whether a list is empty _and_ checks that no other CPU might be - * in the process of modifying either member (next or prev) - * - * NOTE: using list_empty_careful() without synchronization - * can only be safe if the only activity that can happen - * to the list entry is list_del_init(). Eg. it cannot be used - * if another CPU could re-list_add() it. - */ -int D_INTERNAL_common_list_empty_careful(const struct common_list_index *head) -{ - struct common_list_index *next = head->nextele; - return (next == head) && (next == head->preele); -} - diff --git a/src/support/dictator2/src/D_internal/list_common.h b/src/support/dictator2/src/D_internal/list_common.h deleted file mode 100644 index 6ef3dd0..0000000 --- a/src/support/dictator2/src/D_internal/list_common.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _LIST_COMMON_H_ -#define _LIST_COMMON_H_ - -struct common_list_index{ - struct common_list_index *nextele; - struct common_list_index *preele; -}; - -void D_INTERNAL_COMMON_LIST_INIT_HEAD(struct common_list_index *head); -int D_INTERNAL_common_list_empty_careful(const struct common_list_index *head); -void D_INTERNAL_common_list_add(struct common_list_index *new_list, struct common_list_index *head); -void D_INTERNAL_common_list_add_tail(struct common_list_index *new_list, struct common_list_index *head); -void D_INTERNAL_common_list_del(struct common_list_index *entry); -void D_INTERNAL_common_list_move(struct common_list_index *list, struct common_list_index *head); -void D_INTERNAL_common_list_move_tail(struct common_list_index *list, struct common_list_index *head); - -#endif - diff --git a/src/support/dictator2/src/D_internal/readme.txt b/src/support/dictator2/src/D_internal/readme.txt deleted file mode 100644 index fc87961..0000000 --- a/src/support/dictator2/src/D_internal/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -此文件夹是内部源代码,做为生成.a库,一般不对外发布! -对外提供libMESA_hash_v2.a、MESA_list.h、MESA_hash_v2.h - -MESA_list_v2为增加了线程安全的队列,现仅供自用. \ No newline at end of file diff --git a/src/support/dictator2/src/Makefile b/src/support/dictator2/src/Makefile deleted file mode 100644 index c7c9137..0000000 --- a/src/support/dictator2/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: - cp dictator.h ../../../../include/support/ - make clean&&make -f Makefile_nodebug - #make clean&&make -f Makefile_debug -clean: - rm -f D_internal/*.o - rm *.o -f diff --git a/src/support/dictator2/src/Makefile_debug b/src/support/dictator2/src/Makefile_debug deleted file mode 100644 index e8d7fc6..0000000 --- a/src/support/dictator2/src/Makefile_debug +++ /dev/null @@ -1,43 +0,0 @@ -################################################# -# # -# dictator, version 0.01 # -# # -# Software Division, ICT, 2010.11 # -# # -################################################# - -#CC=gcc -g -CC = g++ - -INCLUDES = -LIBS = -lpthread -ldl -CFLAGS = -g -Wall -fPIC - - -SOURCES = dictator.cpp -OBJECTS = dictator.o dictator_debuger.o -TARGET = EXEditctator -TARGETLIB = libdictator.a - -.PHONY: all dep clean install - -.c.o: - $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $< -DDICTATOR_DEBUG - -.cpp.o: - $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $< -DDICTATOR_DEBUG -all:$(OBJECTS) - cd D_internal/ && $(MAKE) clean && $(MAKE) - ar cqs $(TARGETLIB) *.o - cp $(TARGETLIB) ../lib/ - cp $(TARGETLIB) ../../../lib/ -dictator.o: dictator.cpp dictator.h dictator_core.h - $(CC) -c -o $@ $(CFLAGS) $< -DDICTATOR_DEBUG -dictator_debuger.o: dictator_debuger.cpp dictator.h dictator_core.h - $(CC) -c -o $@ $(CFLAGS) $< -DDICTATOR_DEBUG -# $(CC) $(OBJECTS) -o $(TARGET) $(LIBS) -# ld dictator.o $(LIBS) -clean: - rm -f *.o $(TARGETLIB) - cd D_internal && $(MAKE) clean - diff --git a/src/support/dictator2/src/Makefile_nodebug b/src/support/dictator2/src/Makefile_nodebug deleted file mode 100644 index 8884569..0000000 --- a/src/support/dictator2/src/Makefile_nodebug +++ /dev/null @@ -1,44 +0,0 @@ -################################################# -# # -# dictator, version 0.01 # -# # -# Software Division, ICT, 2010.11 # -# # -################################################# - -#CC=gcc -g -CC = g++ - -INCLUDES = -LIBS = -lpthread -ldl -CFLAGS = -g -Wall -fPIC - - - -SOURCES = dictator.cpp -OBJECTS = dictator.o dictator_debuger.o -TARGET = EXEditctator -TARGETLIB = libdictator.a - -.PHONY: all dep clean install - -.c.o: - $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $< - -.cpp.o: - $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $< -all:$(OBJECTS) - cd D_internal/ && $(MAKE) clean && $(MAKE) - ar cqs $(TARGETLIB) *.o - cp $(TARGETLIB) ../lib/ - cp $(TARGETLIB) ../../../lib/ -dictator.o: dictator.cpp dictator.h dictator_core.h - $(CC) -c -o $@ $(CFLAGS) $< -dictator_debuger.o: dictator_debuger.cpp dictator.h dictator_core.h - $(CC) -c -o $@ $(CFLAGS) $< -# $(CC) $(OBJECTS) -o $(TARGET) $(LIBS) -# ld dictator.o $(LIBS) -clean: - rm -f *.o $(TARGETLIB) - cd D_internal && $(MAKE) clean - diff --git a/src/support/dictator2/src/dictator.cpp b/src/support/dictator2/src/dictator.cpp deleted file mode 100644 index 2de2deb..0000000 --- a/src/support/dictator2/src/dictator.cpp +++ /dev/null @@ -1,866 +0,0 @@ -/* - * Manage program memory,for high perfomance and exclusive application. - * The dictator will hoard memory for program to reduce malloc time cost. - * Version : 2014-12-15 - * Usage:LD_DICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc,add LD_DICTATOR as ld parameter. - * Zheng Chao, zhengchao@iie.ac.cn - * - * History: - * 2010-11-30 first build - * 2010-12-14 to reduce memory waste,change block list from exponential(e.g.64,128,256,512...)to linearity (e.g. 64,128,192,256...) - * 2010-12-16 to resolve productor and consumer problem, thread 1 free thread 2's mem block,add block to thread 2's tail, - * use mutex to protect the block queues tail. - * 2010-12-20 fix core_realloc memcpy read out line. - * 2010-12-29 use gcc buildin atomic operation to proctec chain ele_cnt,use volatile to describe thread stat value - * 2010-12-30 redesigned mem_info_t struct,reduce mem used from 40 to 8;not suport slice; - * 2011-01-05 change block assigned strategy,POWER[]. - * 2011-01-28 use as atomic operation - * 2011-02-14 check block's tid,if from unactivated thread - * 2011-11-21 strict check block size ,whether it suit chain index in free with assert - * 2013-12-26 DICTATOR2 first build. - * 2014-01-17 DICTATOR2 v1.0 released. - * 2014-06-18 fix realloc memcpy over read ptr bug. - * 2014-12-02 use mesa_backtrace(student wangpeng@iie.ac.cn) replace glibc backtrace or libunwind backtrace. - * 2014-12-08 use array replace hash to implement tid2idx and tseq2idx. - * Notes: - * - * block(dictator manged) < chunk (system mmap alloced) - * - */ - -#include -#include -#include -#include -#include //using memset -#include -#include -#include -#include -#include -//#define DPDK_HUGE_PAGE - -#ifdef DPDK_HUGE_PAGE -#include -#endif - -#include "internal_mp.h" -#include "dictator.h" -#include "dictator_core.h" -#include "dummy_hash.h" - - -#ifdef DICTATOR_DEBUG -const char* DICTATOR2_VERSION_20170910_DEBUG="DICTATOR2_VERSION_1_3_20170910_DEBUG"; -#else -const char* DICTATOR2_VERSION_20170910="DICTATOR2_VERSION_1_3_20170910"; -#endif -#define FREE_MEM_HEAD_LEN (sizeof(mem_info_t)) -struct dictator_space_t D_SPACE; -#define D_THREAD_HASH_SIZE 4*1024 -int is_first=0; -const unsigned int LINEAR_1_BOUNDARY=1024; -const unsigned int LINEAR_2_FACTOR=8; - -char boundary_marker[D_MARKER_SIZE]={'d'}; -#define PAGE_SIZE 4096 -#define ELF_MIN_ALIGN PAGE_SIZE -#define ELF_PAGEALIGN(_v) (((_v)+ELF_MIN_ALIGN-1)&~(ELF_MIN_ALIGN-1)) - -static inline pid_t dictator_gettid(void){ - pid_t ret=(pid_t)pthread_self(); - return ret; -} -mem_info_t* fill_empty_block(mem_info_t* block,unsigned int blk_num,unsigned short D_id){ - block->blk_num=blk_num; - block->D_id=D_id; -#ifdef DICTATOR_DEBUG - block->magic=DICTATOR_MAGIC; - block->idx=NULL; -#endif - block->next=NULL; - block->type=0; - return block; -} -inline int D_hash_key_comp(uchar * key1, uint size1, uchar * key2, uint size2) -{ - assert(size1==sizeof(int)&&size2==sizeof(int)); - if(*(int*)key1==*(int*)key2) - { - return 0; - } - else - { - return 1; - } -} -inline unsigned int D_hash_key2index(MESA_hash_tab_v2_t * table, uchar *str, uint size) -{ - assert(size==sizeof(int)); - return (*(unsigned int*)str % table->size); -} -inline static int tid2idx(pthread_t * array,int size,pthread_t tid) -{ - int i=0; - for(i=size-1;i>=0;i--) - { - if(array[i]==tid) - { - return i; - } - } - return -1; -} - -inline static thread_mem_pool_t* locate_mp_by_tseq(int t_seq) -{ - long idx=0; - int ret=0; - pthread_t tid=0; - thread_mem_pool_t* p_mempool=NULL; - idx=D_SPACE.tseq2idx[t_seq]; - if(idx>=0) - { - p_mempool=D_SPACE.thread_mem_info[idx]; - } - if(p_mempool==NULL) - { - tid=pthread_self(); - ret=dummy_htable_read(&(D_SPACE.tid2idx), (long)tid,&idx); - if(ret==1) - { - p_mempool=D_SPACE.thread_mem_info[idx]; - } - if(p_mempool==NULL) - { - atomic_inc(&(D_SPACE.used_mem_pool_counter));//here is not thread safe but __sync_add_and_fetch not support in all OS - idx = atomic_read(&(D_SPACE.used_mem_pool_counter)); - p_mempool=create_mem_pool(idx); - p_mempool->tid=tid; -#ifdef DICTATOR_DEBUG - init_debugger(&(p_mempool->debugger),p_mempool); -#endif - D_SPACE.thread_mem_info[idx]=p_mempool; - dummy_htable_add(&(D_SPACE.tid2idx),tid,idx); - D_SPACE.tseq2idx[t_seq]=idx; - } - p_mempool->t_seq=t_seq; - } -#ifdef DICTATOR_DEBUG - tid=pthread_self(); - assert(p_mempool->t_seq==t_seq); - assert(tid==p_mempool->tid); -#endif - return p_mempool; -} -inline static thread_mem_pool_t* locate_mp_by_tid(pthread_t tid) -{ - thread_mem_pool_t* p_mempool=NULL; - long idx=0; - int ret=0; - ret=dummy_htable_read(&(D_SPACE.tid2idx), tid, &idx); - if(ret==1) - { - p_mempool=D_SPACE.thread_mem_info[idx]; - } - if(p_mempool==NULL) - { - atomic_inc(&(D_SPACE.used_mem_pool_counter)); - idx = atomic_read(&(D_SPACE.used_mem_pool_counter)); - p_mempool=create_mem_pool(idx); - p_mempool->tid=tid; -#ifdef DICTATOR_DEBUG - init_debugger(&(p_mempool->debugger),p_mempool); -#endif - D_SPACE.thread_mem_info[idx]=p_mempool; - dummy_htable_add(&(D_SPACE.tid2idx), tid, idx); - } - return p_mempool; -} -thread_mem_pool_t* init_dictator(pthread_t tid) -{ - unsigned int i=1; - thread_mem_pool_t* p_mempool=NULL; - is_first=1; - D_SPACE.INIT_THREAD_BLOCK_NUM=0; - assert(getpagesize()==PAGE_SIZE); - D_SPACE.POWER[0]=1; - for(i=1;iblock_buffer_container.buffer=(char*)mmap_alloc(DICTATOR_UNIT_SIZE*D_SPACE.INIT_THREAD_BLOCK_NUM); - if(NULL==p->block_buffer_container.buffer){ - fprintf(stderr,"malloc failed in dictator %s : %d\n",__FILE__,__LINE__); - assert(0); - } - p->raw_mem_header[0]=p->block_buffer_container.buffer; - p->rawmem_idx=1; - p->block_buffer_container.available_size=DICTATOR_UNIT_SIZE*D_SPACE.INIT_THREAD_BLOCK_NUM; - p->D_id=D_id; - p->t_seq=-1; - p->tid=0; - - //assigned a suitable block for each chain - for(i=0;iblock_buffer_container.buffer); - fill_empty_block(target_block,assigned_blk_num ,D_id); - p->block_buffer_container.buffer+=assigned_blk_num*DICTATOR_UNIT_SIZE; - p->block_buffer_container.available_size-=assigned_blk_num*DICTATOR_UNIT_SIZE; - - //restore this block - p->block_chain[i].head=target_block; - p->block_chain[i].tail=p->block_chain[i].head; - atomic_set(&(p->block_chain[i].ele_cnt),1); - pthread_mutex_init(&(p->block_chain[i].mutex_tail_lock), NULL); - } - return p; - -} - - - - -mem_info_t* get_chunk(unsigned short D_id,unsigned int blk_num){ - mem_info_t* block=NULL; - size_t assigned_size=blk_num*DICTATOR_UNIT_SIZE; - int is_dpdk_hugepage=0; -#ifdef DPDK_HUGE_PAGE - if(marsio_is_hugepage_available()==1) - { - block=(mem_info_t*)marsio_hugepage_malloc(assigned_size, D_SPACE.thread_mem_info[D_id]->t_seq); - is_dpdk_hugepage=1; - } - else - { - block=(mem_info_t*)mmap(NULL,assigned_size,PROT_WRITE|PROT_READ,MAP_ANONYMOUS|MAP_PRIVATE,-1,0); - } -#else - block=(mem_info_t*)mmap(NULL,assigned_size,PROT_WRITE|PROT_READ,MAP_ANONYMOUS|MAP_PRIVATE,-1,0); -#endif - - - if(-1==(long)block) - { - fprintf(stderr,"mmap/hugepage failed: %s ,at dictator %s : %d\n",strerror(errno),__FILE__,__LINE__); - _exit(-1); - } - fill_empty_block(block,blk_num,D_id); - block->type=is_dpdk_hugepage; - if(block->type==0) - { - assert((unsigned long)block%PAGE_SIZE==0); - } - return block; -} -void* mmap_alloc(size_t size) -{ - mem_info_t*p=NULL; - unsigned int block_num=0; - unsigned long assigned_size=0; - block_num=calc_block_num(size+USED_MEM_HEAD_LEN); - assigned_size=ELF_PAGEALIGN((unsigned long)block_num*(unsigned long)DICTATOR_UNIT_SIZE); - block_num=assigned_size/DICTATOR_UNIT_SIZE; - p=get_chunk(0, block_num); - return D_MEM(p); -} -void mmap_free(void*p) -{ - mem_info_t* block=D_HEADER(p); - size_t len=block->blk_num*DICTATOR_UNIT_SIZE; - int ret=0; -#ifdef DPDK_HUGE_PAGE - if(block->type==1) - { - marsio_hugepage_free(block); - } - else - { - ret=munmap(block,len); - } -#else - ret=munmap(block,len); -#endif - if(ret!=0) - { - fprintf(stderr,"munmap failed: %s ,at dictator %s : %d\n",strerror(errno),__FILE__,__LINE__); - } - assert(ret==0); - return; -} -void* block_alloc(size_t size,IMP_t *imp) -{ - mem_info_t* p=NULL; - thread_mem_pool_t *p_mempool=(thread_mem_pool_t *)imp; - unsigned int block_num=calc_block_num(size+USED_MEM_HEAD_LEN); - assert(!IS_CHUNK(block_num)); - p=get_block(p_mempool,block_num); -#ifdef DICTATOR_DEBUG - atomic_add(&(p_mempool->debugger.selfcost_mem),p->blk_num*DICTATOR_UNIT_SIZE); - atomic_sub(&(p_mempool->debugger.cached_mem), p->blk_num*DICTATOR_UNIT_SIZE); -#endif - return D_MEM(p); -} -void block_free(void*p,IMP_t* imp) -{ - mem_info_t *block=D_HEADER(p); - thread_mem_pool_t *p_mempool=(thread_mem_pool_t *)imp; -#ifdef DICTATOR_DEBUG - atomic_sub(&(p_mempool->debugger.selfcost_mem),block->blk_num*DICTATOR_UNIT_SIZE); - atomic_add(&(p_mempool->debugger.cached_mem), block->blk_num*DICTATOR_UNIT_SIZE); -#endif - restore_block(p_mempool, block); - //restore_other_block(p_mempool, block); - - return; -} - -// own block add to chain head -inline void add_block_to_chain_head(thread_mem_pool_t* thread_info,int chain_idx,mem_info_t* block) -{ - block->next=thread_info->block_chain[chain_idx].head; - thread_info->block_chain[chain_idx].head=block; - atomic_inc(&(thread_info->block_chain[chain_idx].ele_cnt)); -} -inline void join_block_to_chain_tail(thread_mem_pool_t* thread_info,int chain_idx,mem_info_t* block) -{ - thread_info->block_chain[chain_idx].tail->next=block; - block->next=NULL; - thread_info->block_chain[chain_idx].tail=block; - atomic_inc(&(thread_info->block_chain[chain_idx].ele_cnt)); -} -inline void restore_block(thread_mem_pool_t* thread_info,mem_info_t *block) -{ - unsigned int chain_idx=0; - chain_idx=select_chain(block->blk_num); - assert(block->blk_num==D_SPACE.POWER[chain_idx]); - add_block_to_chain_head(thread_info, chain_idx, block); - return; -} -inline void restore_other_block(thread_mem_pool_t* thread_info,mem_info_t *block) -{ - unsigned int chain_idx=0; - chain_idx=select_chain(block->blk_num); - assert(block->blk_num==D_SPACE.POWER[chain_idx]); - pthread_mutex_lock(&(thread_info->block_chain[chain_idx].mutex_tail_lock)); - join_block_to_chain_tail(thread_info, chain_idx, block); - pthread_mutex_unlock(&(thread_info->block_chain[chain_idx].mutex_tail_lock)); - - return; -} -inline mem_info_t *get_block_from_chain(thread_mem_pool_t* thread_info,int chain_idx) -{ - mem_info_t *target=NULL; -#ifdef DICTATOR_DEBUG - assert(thread_info->block_chain[chain_idx].head!=thread_info->block_chain[chain_idx].tail); - assert(atomic_read(&(thread_info->block_chain[chain_idx].ele_cnt))>1); -#endif - target=thread_info->block_chain[chain_idx].head; - thread_info->block_chain[chain_idx].head=target->next; - atomic_dec(&(thread_info->block_chain[chain_idx].ele_cnt)); - return target; -} -inline mem_info_t *get_block(thread_mem_pool_t *thread_info,unsigned int block_num) -{ - - mem_info_t* target_block=NULL,*tmp; - unsigned int assigned_chain=0; - unsigned int assigned_size=0; - assigned_chain=select_chain(block_num); - assigned_size=D_SPACE.POWER[assigned_chain]*DICTATOR_UNIT_SIZE; - int i=0; - assert(assigned_size!=0); - //block chain is available - if(thread_info->block_chain[assigned_chain].head!=thread_info->block_chain[assigned_chain].tail&& - atomic_read(&(thread_info->block_chain[assigned_chain].ele_cnt))>1) - { - target_block=get_block_from_chain(thread_info,assigned_chain); - } - else - { - //block buffer is not enough for this request - if(thread_info->block_buffer_container.available_sizeblock_buffer_container.available_size%DICTATOR_UNIT_SIZE==0); - if(thread_info->block_buffer_container.available_size>0) - { - for(i=0;thread_info->block_buffer_container.available_size>0;i++) - { - tmp=(mem_info_t *)(thread_info->block_buffer_container.buffer); - thread_info->block_buffer_container.available_size-=DICTATOR_UNIT_SIZE; - thread_info->block_buffer_container.buffer+=DICTATOR_UNIT_SIZE; - fill_empty_block(tmp, 1, thread_info->D_id); - restore_block(thread_info,tmp); - } - } - //malloc a new buffer - thread_info->block_buffer_container.buffer=(char *)mmap_alloc(D_SPACE.INIT_THREAD_BLOCK_NUM*DICTATOR_UNIT_SIZE); - if(NULL==thread_info->block_buffer_container.buffer) - { - fprintf(stderr,"malloc failed in dictator %s : %d\n",__FILE__,__LINE__); - return NULL; - } - thread_info->block_buffer_container.available_size=D_SPACE.INIT_THREAD_BLOCK_NUM*DICTATOR_UNIT_SIZE; - thread_info->raw_mem_header[thread_info->rawmem_idx]=thread_info->block_buffer_container.buffer; - thread_info->rawmem_idx++; -#ifdef DICTATOR_DEBUG - atomic_add(&(thread_info->debugger.cached_mem),D_SPACE.INIT_THREAD_BLOCK_NUM*DICTATOR_UNIT_SIZE); -#endif - } - //cut a block from buffer - target_block=(mem_info_t*)(thread_info->block_buffer_container.buffer); - fill_empty_block(target_block, D_SPACE.POWER[assigned_chain],thread_info->D_id); - thread_info->block_buffer_container.buffer+=assigned_size; - thread_info->block_buffer_container.available_size-=assigned_size; - } - return target_block; - - -} - -void *core_alloc(thread_mem_pool_t *p_mempool,size_t size) -{ - unsigned int block_num=0; - unsigned long assigned_size=0; - mem_info_t *target_mem=NULL; - if(0==size) - { - return NULL; - } - block_num=calc_block_num(size+USED_MEM_HEAD_LEN); - if(block_num>D_SPACE.POWER[MAX_CHAIN_NUM_SUPPORT-1]) - { - assigned_size=ELF_PAGEALIGN((unsigned long)block_num*(unsigned long)DICTATOR_UNIT_SIZE); - block_num=assigned_size/DICTATOR_UNIT_SIZE; - //malloc with mmap - target_mem=get_chunk(p_mempool->D_id, block_num); - } - else - { - target_mem=get_block(p_mempool,block_num); - } -#ifdef DICTATOR_DEBUG - backtrace_info_t *caller_bt; - struct dbg_index_t* dbg_idx=NULL; - assigned_size=target_mem->blk_num*DICTATOR_UNIT_SIZE; - dbg_idx=get_dbg_index(&(p_mempool->debugger)); - target_mem->idx=dbg_idx; - dbg_idx->mem_info=(void*)target_mem; - - - //use by thread self and debug thread's threadsafe callback, no need to protect with mutex; - caller_bt=backtrace_ref_inc(&((p_mempool->debugger.malloc_backtrace_hash)),size,p_mempool); - - - target_mem->idx->p_backtrace=caller_bt; - target_mem->idx->used_size=size; - target_mem->idx->assigned_size=assigned_size; - - pthread_mutex_lock(&(p_mempool->debugger.mutex_malloced_in_reach_list)); - D_kernel_list_add_tail(&(p_mempool->debugger.malloced_in_reach_list),&(target_mem->idx->malloced_in_reach_hook)); - pthread_mutex_unlock(&(p_mempool->debugger.mutex_malloced_in_reach_list)); - - int boundary_len=assigned_size-size-USED_MEM_HEAD_LEN; - memset(D_MEM(target_mem)+target_mem->idx->used_size,'d',boundary_len); - atomic_add(&(p_mempool->debugger.app_mem),size); - atomic_add(&(p_mempool->debugger.assigned_mem),assigned_size); - atomic_inc(&(p_mempool->debugger.inuse_num)); - atomic_inc(&(p_mempool->debugger.malloc_cnt)); - if(IS_CHUNK(target_mem->blk_num)) - { - //no need do free_backtrace_hash ,index for double free check; - } - else - { - atomic_sub(&(p_mempool->debugger.cached_mem), target_mem->blk_num*DICTATOR_UNIT_SIZE); - } -#endif - return D_MEM(target_mem); -} -void core_free(unsigned short caller_Did,void *p) -{ - mem_info_t *block=D_HEADER(p); - thread_mem_pool_t* p_mempool=D_SPACE.thread_mem_info[block->D_id]; -#ifdef DICTATOR_DEBUG - thread_mem_pool_t* caller_mp=D_SPACE.thread_mem_info[caller_Did]; - backtrace_info_t *caller_bt; - assert(block->magic==DICTATOR_MAGIC); - const char* user_boundary=(char*)block+block->idx->used_size+USED_MEM_HEAD_LEN; - int boundary_len=0; - unsigned int assigned_size=block->blk_num*DICTATOR_UNIT_SIZE; - assert(block->idx->assigned_size==assigned_size); - if(!IS_CHUNK(block->blk_num))//not a chunk - { - atomic_add(&(p_mempool->debugger.cached_mem),assigned_size); - } - pthread_mutex_lock(&(p_mempool->debugger.mutex_malloced_in_reach_list)); - D_kernel_list_delete(&(p_mempool->debugger.malloced_in_reach_list),&(block->idx->malloced_in_reach_hook)); - pthread_mutex_unlock(&(p_mempool->debugger.mutex_malloced_in_reach_list)); - - atomic_sub(&(p_mempool->debugger.app_mem),block->idx->used_size); - atomic_sub(&(p_mempool->debugger.assigned_mem),assigned_size); - atomic_dec(&(block->idx->p_backtrace->ref_cnt)); - atomic_sub(&(block->idx->p_backtrace->ref_bytes),block->idx->used_size); - atomic_dec(&(p_mempool->debugger.inuse_num)); - atomic_inc(&(p_mempool->debugger.free_cnt)); - caller_bt=backtrace_ref_inc(&(caller_mp->debugger.free_backtrace_hash),assigned_size,caller_mp); - block->idx->p_backtrace=caller_bt; - - boundary_len=MIN(assigned_size-block->idx->used_size-USED_MEM_HEAD_LEN,D_MARKER_SIZE); - assert(0==memcmp(user_boundary,boundary_marker,boundary_len)); - restore_dbg_index(&(p_mempool->debugger), block->idx); - block->idx=NULL; -#endif - if(IS_CHUNK(block->blk_num)) - { - //a chunk - mmap_free(D_MEM(block)); - } - else - { - if(block->D_id==caller_Did) - { - restore_block(p_mempool, block); - - } - else - { - restore_other_block(p_mempool, block); - } - } - -} -void *core_realloc(unsigned short caller_Did,void *ptr, size_t size) -{ - mem_info_t *block=D_HEADER(ptr); - mem_info_t *new_block=NULL; - void* new_mem=NULL; - size_t old_size=0; -#ifdef DICTATOR_DEBUG - size_t new_size=0; - thread_mem_pool_t* orginal_mempool=D_SPACE.thread_mem_info[block->D_id]; - struct dbg_index_t* tmp_idx=NULL; - assert(block->magic==DICTATOR_MAGIC); -#endif - old_size=(block->blk_num*DICTATOR_UNIT_SIZE)-USED_MEM_HEAD_LEN; - - if(IS_CHUNK(block->blk_num)) - { -#ifdef DICTATOR_DEBUG - size_t orginal_size=0; - orginal_size=block->blk_num*DICTATOR_UNIT_SIZE; - atomic_sub(&(block->idx->p_backtrace->ref_bytes),block->idx->used_size); - pthread_mutex_lock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list)); - D_kernel_list_delete(&(orginal_mempool->debugger.malloced_in_reach_list),&(block->idx->malloced_in_reach_hook)); - pthread_mutex_unlock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list)); - atomic_sub(&(orginal_mempool->debugger.app_mem),block->idx->used_size); - atomic_sub(&(orginal_mempool->debugger.assigned_mem),orginal_size); - tmp_idx=block->idx; -#endif - if(old_size>=size) - { - new_block=block; - } - else - { - new_block=D_HEADER(mmap_alloc(size)); - memcpy(D_MEM(new_block),D_MEM(block),old_size); - mmap_free(D_MEM(block)); - } - new_mem=D_MEM(new_block); -#ifdef DICTATOR_DEBUG - new_size=new_block->blk_num*DICTATOR_UNIT_SIZE; - new_block->idx=tmp_idx; - new_block->idx->used_size=size; - new_block->idx->assigned_size=new_size; - new_block->idx->mem_info=new_block; - atomic_add(&(new_block->idx->p_backtrace->ref_bytes),size); - if(atomic_read(&(new_block->idx->p_backtrace->maxsize))<(signed long)size) - { - atomic_set(&(new_block->idx->p_backtrace->maxsize),(signed long)size); - } - pthread_mutex_lock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list)); - D_kernel_list_add_tail(&(orginal_mempool->debugger.malloced_in_reach_list),&(new_block->idx->malloced_in_reach_hook)); - pthread_mutex_unlock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list)); - - memset((char*)new_mem+size,'d',new_size-size-USED_MEM_HEAD_LEN); - atomic_add(&(orginal_mempool->debugger.app_mem),size); - atomic_add(&(orginal_mempool->debugger.assigned_mem),new_size); -#endif - block=NULL; - } - else - { - if(old_size>=size) - { - new_mem=ptr; -#ifdef DICTATOR_DEBUG - atomic_sub(&(orginal_mempool->debugger.app_mem),block->idx->used_size-size); - atomic_sub(&(block->idx->p_backtrace->ref_bytes),block->idx->used_size-size); - block->idx->used_size=size; -#endif - } - else - { - new_mem=core_alloc(D_SPACE.thread_mem_info[caller_Did],size); - new_block=D_HEADER(new_mem); - memcpy((char*)new_mem, - (char*)ptr, - old_size); - core_free(caller_Did,ptr); - } - } - return new_mem; -} - -void *__wrap_malloc(size_t size) -{ - thread_mem_pool_t* p_mempool=NULL; - pthread_t tid=pthread_self(); - if(is_first==0) - { - p_mempool=init_dictator(tid); - } - else - { - p_mempool=locate_mp_by_tid(tid); - } - return core_alloc(p_mempool,size); - -} - -//If ptr is NULL, no operation is performed. -void __wrap_free(void *p) -{ - thread_mem_pool_t* p_mempool=NULL; - if(p==NULL) - return; - pthread_t tid=pthread_self(); - p_mempool=locate_mp_by_tid(tid); - core_free(p_mempool->D_id,p); - return; -} - -#if 0// close by lijia -void* operator new(size_t size) -{ - if(size==0) - { - size=1; - } - return __wrap_malloc(size); -} -void* operator new(size_t size,const std::nothrow_t ¬hrow_const) -{ - if(size==0) - { - size=1; - } - return __wrap_malloc(size); -} -void operator delete(void*p) -{ - __wrap_free(p); -} -#endif - -//The contents will be unchanged to the minimum of the old and new sizes; -//If ptr is NULL, the call is equivalent to malloc(size); if size is equal to zero, the call is equivalent to free(ptr). -//Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc(). -void *__wrap_realloc(void *ptr, size_t size) -{ - pthread_t tid=pthread_self(); - thread_mem_pool_t* p_mempool=NULL; - if(is_first==0) - { - p_mempool=init_dictator(tid); - } - else - { - p_mempool=locate_mp_by_tid(tid); - } - if(size==0&&ptr!=NULL) - { - core_free(p_mempool->D_id,ptr); - return NULL; - } - if(ptr==NULL) - { - return core_alloc(p_mempool,size); - } - return core_realloc(p_mempool->D_id,ptr,size); -} -/* Maybe conflict with DPDK -void *malloc(size_t size) -{ - return __wrap_malloc(size); -} -void *realloc(void *ptr, size_t size) -{ - return __wrap_realloc(ptr, size); -} -void *calloc(size_t nmemb, size_t size) -{ - return __wrap_calloc(nmemb, size); -} -void free(void *p) -{ - return __wrap_free(p); -}*/ -void *__wrap_calloc(size_t nmemb, size_t size) -{ - thread_mem_pool_t* p_mempool=NULL; - void* p=NULL; - pthread_t tid=pthread_self(); - if(is_first==0) - { - p_mempool=init_dictator(tid); - } - else - { - p_mempool=locate_mp_by_tid(tid); - } - p=core_alloc(p_mempool,nmemb*size); - if(p!=NULL) - { - memset(p,0,nmemb*size); - } - return p; -} -void *__dictator_malloc(int t_seq,size_t size) -{ - thread_mem_pool_t* p_mempool=NULL; - pthread_t tid=0; - if(is_first==0) - { - tid=pthread_self(); - p_mempool=init_dictator(tid); - } - else - { - p_mempool=locate_mp_by_tseq(t_seq); - } - return core_alloc(p_mempool,size); -} -void __dictator_free(int t_seq,void*p) -{ - unsigned short this_D_id=0; - if(p==NULL) - { - return; - } - thread_mem_pool_t* p_mempool=NULL; - p_mempool=locate_mp_by_tseq(t_seq); - this_D_id=p_mempool->D_id; - core_free(this_D_id,p); - return; -} -void *__dictator_realloc(int t_seq,void*ptr,size_t size) -{ - thread_mem_pool_t* p_mempool=NULL; - pthread_t tid=0; - if(is_first==0) - { - tid=pthread_self(); - p_mempool=init_dictator(tid); - } - else - { - p_mempool=locate_mp_by_tseq(t_seq); - } - if(size==0&&ptr!=NULL){ - core_free(p_mempool->D_id,ptr); - return NULL; - } - if(ptr==NULL) - { - return core_alloc(p_mempool,size); - } - return core_realloc(p_mempool->D_id,ptr,size); -} -void *__dictator_calloc(int t_seq,size_t nmemb, size_t size) -{ - thread_mem_pool_t* p_mempool=NULL; - pthread_t tid=0; - if(is_first==0) - { - tid=pthread_self(); - p_mempool=init_dictator(tid); - } - else - { - p_mempool=locate_mp_by_tseq(t_seq); - } - return core_alloc(p_mempool,nmemb*size); -} - diff --git a/src/support/dictator2/src/dictator.h b/src/support/dictator2/src/dictator.h deleted file mode 100644 index 5a95132..0000000 --- a/src/support/dictator2/src/dictator.h +++ /dev/null @@ -1,30 +0,0 @@ -/* DICATATOR Memory Manager -* Version 20141115 -* zhengchao@iie.ac.cn -*/ -#ifndef _DICTATOR2_H_ -#define _DICTATOR2_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -void *__wrap_malloc(size_t size); -void __wrap_free(void *p); -void *__wrap_realloc(void *ptr, size_t size); -void *__wrap_calloc(size_t nmemb, size_t size); - -void *__dictator_malloc(int t_seq,size_t size); -void __dictator_free(int t_seq,void*p); -void *__dictator_realloc(int t_seq,void *ptr, size_t size); -void *__dictator_calloc(int t_seq,size_t nmemb, size_t size); - -void *malloc(size_t size); -void *calloc(size_t nmemb, size_t size); -void free(void *p); - -#ifdef __cplusplus -} -#endif// end extern "C" - -#endif diff --git a/src/support/dictator2/src/dictator_core.h b/src/support/dictator2/src/dictator_core.h deleted file mode 100644 index be11cdc..0000000 --- a/src/support/dictator2/src/dictator_core.h +++ /dev/null @@ -1,191 +0,0 @@ -#ifndef _DICTATOR2_CORE_H_ -#define _DICTATOR2_CORE_H_ - -#include -#include "internal_mp.h" -#include "dummy_hash.h" - -#define DICTATOR2_VERSION "v1.3" -#if(__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__ >= 410) -#define atomic_inc(x) __sync_add_and_fetch((x),1) -#define atomic_dec(x) __sync_sub_and_fetch((x),1) -#define atomic_add(x,y) __sync_add_and_fetch((x),(y)) -#define atomic_sub(x,y) __sync_sub_and_fetch((x),(y)) -typedef long atomic_t; -#define ATOMIC_INIT(i) { (i) } -#define atomic_read(x) __sync_add_and_fetch((x),0) -#define atomic_set(x,y) __sync_lock_test_and_set((x),y) -#else -typedef long atomic_t; -#define atomic_inc(x) ((*(x))++) -#define atomic_dec(x) ((*(x))--) -#define atomic_add(x,y) ((*(x))+=(y)) -#define atomic_sub(x,y) ((*(x))-=(y)) -#define ATOMIC_INIT(i) { (i) } -#define atomic_read(x) (*(x)) -#define atomic_set(x,y) ((*(x))=(y)) -#endif -#include "D_internal/D_kernel_list.h" -#include "D_internal/MESA_hash_v2.h" - -const unsigned int MAX_CHAIN_NUM_SUPPORT=128*3; -const unsigned int MAX_TRHEAD_NUM_SUPPORT=1024; -const unsigned int MAX_THREAD_RAWMEM_CNT=1024*4; -const unsigned int DICTATOR_UNIT_SIZE=32; -const unsigned int BATCH_DBG_IDX_NUM=MAX_CHAIN_NUM_SUPPORT*256; - - -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -const unsigned int DICTATOR_MAGIC=0x5210; -#define MAX_BACKTRACE_DEPTH 32 -#define MALLOC_SELF_DEPTH 3 -#define FREE_SEFL_DEPTH 3 - -#define D_MARKER_SIZE 1024 -enum CHUNK_STATE -{ - CHUNK_STATE_MALLOC=0, - CHUNK_STATE_FREE, - CHUNK_STATE_VIGRIN, - CHUNK_STATE_REALLOC -}; -struct backtrace_info_t -{ - atomic_t ref_cnt; - atomic_t ref_bytes; - atomic_t maxsize; - void** bt_array; - size_t array_size; - IMP_t* p_mempool; -}; -struct dbg_index_t -{ - unsigned int used_size; - unsigned int assigned_size; - struct D_kernel_list_head malloced_in_reach_hook; - struct backtrace_info_t* p_backtrace; - void* mem_info; -}; -typedef struct mem_info{ - -#ifdef DICTATOR_DEBUG - unsigned short magic; - unsigned short D_id; - unsigned int blk_num:31; - unsigned short type:1; // 0:mmap, 1:DPDK_HUGEPAGE - struct dbg_index_t* idx; -#else - unsigned int blk_num; - unsigned short D_id; - unsigned short type; // 0:mmap, 1:DPDK_HUGEPAGE -#endif - - struct mem_info *next;//used only if free -} mem_info_t; -//__attribute__((packed)) -typedef struct buffer_container{ - size_t available_size; - char *buffer; -}buffer_container_t; - -typedef struct mem_queue{ - mem_info_t * head; - mem_info_t * tail; - atomic_t ele_cnt; - pthread_mutex_t mutex_tail_lock; -}mem_queue_t; - -typedef struct _thread_mem_debugger -{ - atomic_t cached_mem;//dictator managed mem,less than total mem - atomic_t app_mem; //application applied mem size,inlucding not managed mem,less than total_mem - atomic_t assigned_mem;//dictator assigned to application - atomic_t inuse_num; - atomic_t malloc_cnt; - atomic_t free_cnt; - atomic_t selfcost_mem;//used by dictator itself - MESA_hash_tab_v2_t malloc_backtrace_hash; - MESA_hash_tab_v2_t free_backtrace_hash; - pthread_mutex_t mutex_malloced_in_reach_list; - struct D_kernel_list_head malloced_in_reach_list; - - atomic_t pool_unit_cnt; - struct D_kernel_list_head index_pool; - pthread_mutex_t mutex_pool_tail; - unsigned int rawmem_idx; - void* raw_mem_header[MAX_THREAD_RAWMEM_CNT]; -}thread_mem_debugger_t; - -typedef struct thread_mem_pool{ - unsigned short D_id; - pthread_t tid; - int t_seq; - int rawmem_idx; - mem_queue_t block_chain[MAX_CHAIN_NUM_SUPPORT]; - buffer_container_t block_buffer_container; - void* raw_mem_header[MAX_THREAD_RAWMEM_CNT]; -#ifdef DICTATOR_DEBUG - thread_mem_debugger_t debugger; -#endif -}thread_mem_pool_t; - -struct dictator_space_t -{ - unsigned int POWER[MAX_CHAIN_NUM_SUPPORT]; - unsigned int INIT_THREAD_BLOCK_NUM; - - struct dummy_htable_t tid2idx; - int tseq2idx[MAX_TRHEAD_NUM_SUPPORT]; - - thread_mem_pool_t *thread_mem_info[MAX_TRHEAD_NUM_SUPPORT]; - atomic_t used_mem_pool_counter; - int page_size; -}; - -inline mem_info_t *get_block(thread_mem_pool_t *thread_info,unsigned int block_num); -inline void restore_block(thread_mem_pool_t* thread_info,mem_info_t *block); - -unsigned int calc_block_num(size_t alloc_size); -inline mem_info_t* fill_empty_block(mem_info_t* block,unsigned int blk_num,unsigned short D_id); - -thread_mem_pool_t *create_mem_pool(unsigned short D_id); -backtrace_info_t* create_bt_info(void** bt_array,int size); -backtrace_info_t* backtrace_ref_inc(MESA_hash_tab_v2_t* hash,size_t inc_size,thread_mem_pool_t *p_mempool); -struct dbg_index_t* get_dbg_index(thread_mem_debugger_t* debugger); -void restore_dbg_index(thread_mem_debugger_t* debugger,struct dbg_index_t*idx); -thread_mem_pool_t *create_mem_pool(unsigned short D_id); -void init_debugger(thread_mem_debugger_t* debugger,thread_mem_pool_t* p_mp); - -void * dictator_debug_thread(void* param); -void D_check_mem(int sd,int is_scheduled); -#define USED_MEM_HEAD_LEN (sizeof(mem_info_t)-sizeof(struct mem_info *)) -#define D_HEADER(ptr) ((mem_info_t *)((char*)(ptr)-USED_MEM_HEAD_LEN)) -#define D_MEM(ptr) ((char*)(ptr)+USED_MEM_HEAD_LEN) -#define IS_CHUNK(x) ((x)>(D_SPACE.POWER[MAX_CHAIN_NUM_SUPPORT-1])) - -inline unsigned int calc_block_num(size_t alloc_size){ - unsigned int block_num=0; - if(alloc_size%DICTATOR_UNIT_SIZE==0) - { - block_num = alloc_size/DICTATOR_UNIT_SIZE; -#ifdef DICTATOR_DEBUG - block_num++; -#endif - } - else - { - block_num = (alloc_size/DICTATOR_UNIT_SIZE)+1; - } - return block_num; -} - - -#endif - diff --git a/src/support/dictator2/src/dictator_debuger.cpp b/src/support/dictator2/src/dictator_debuger.cpp deleted file mode 100644 index db8b621..0000000 --- a/src/support/dictator2/src/dictator_debuger.cpp +++ /dev/null @@ -1,816 +0,0 @@ -#include -#include -#include -#include -#include //using memset -#include -#include -#include -//#include //backtrace -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include - -#include "dictator.h" -#include "dictator_core.h" -#ifdef DICTATOR_DEBUG -extern struct dictator_space_t D_SPACE; -thread_mem_pool_t* DEBUGGER_MP=NULL; -extern char boundary_marker[D_MARKER_SIZE]; - -#define D_CMD_HELP 0 -#define D_CMD_STAT 1 -#define D_CMD_LIST_MALLOC 2 -#define D_CMD_CHECK 3 -#define D_CMD_LIST_LARGE_M 4 -const char* support_cmd_full[]={"help","stat memory","list malloc","check memory","list large","\0"}; -const char support_cmd_short[]={'h','s','l','c','m','\0'}; -const char* cmd_introduce[]={"Print this text", - "Statistic memory usage", - "List 'max_num' and 'minmum_bytes' malloc backtrace,list all as default", - "Check 'times' and 'interval us' to find if any memroy corrupt,check 1 time and 100*1000 us as default", - "List 'max_num' and 'minmum_bytes' of SINGLE malloc backtrace which size is larger than 'minmum_bytes',list 65535(64KB) as default", - "\0"}; - -backtrace_info_t* create_bt_info(void** bt_array,int size,thread_mem_pool_t *p_mempool) -{ - backtrace_info_t*caller_bt=NULL; - unsigned int memsize=sizeof(backtrace_info_t)+sizeof(void**)*size; - caller_bt=(backtrace_info_t*)block_alloc(memsize,(IMP_t*)p_mempool); - atomic_set(&(caller_bt->ref_cnt),0); - atomic_set(&(caller_bt->ref_bytes),0); - atomic_set(&(caller_bt->maxsize),0); - caller_bt->bt_array=(void**)((char*)caller_bt+sizeof(backtrace_info_t)); - memcpy(caller_bt->bt_array,bt_array,sizeof(void**)*size); - caller_bt->array_size=size; - caller_bt->p_mempool=(IMP_t*)p_mempool; - return caller_bt; -} -void destroy_bt_info(void* bt_info) -{ - backtrace_info_t*caller_bt=(backtrace_info_t*)bt_info; - block_free(caller_bt,caller_bt->p_mempool); - return; -} -void init_debugger(thread_mem_debugger_t* debugger,thread_mem_pool_t* p_mp) -{ - unsigned int i=0; - int ret=0; - struct dbg_index_t* idx_pool_buff=NULL; - - D_kernel_list_init(&(debugger->malloced_in_reach_list)); - pthread_mutex_init(&(debugger->mutex_malloced_in_reach_list),NULL); - pthread_mutex_init(&(debugger->mutex_pool_tail),NULL); - atomic_set(&(debugger->app_mem),0); - atomic_set(&(debugger->assigned_mem),0); - atomic_set(&(debugger->inuse_num),0); - atomic_set(&(debugger->malloc_cnt),0); - atomic_set(&(debugger->free_cnt),0); - atomic_set(&(debugger->selfcost_mem),sizeof(thread_mem_pool_t)); - debugger->cached_mem=DICTATOR_UNIT_SIZE*D_SPACE.INIT_THREAD_BLOCK_NUM; - - - idx_pool_buff=(struct dbg_index_t*)mmap_alloc(D_SPACE.INIT_THREAD_BLOCK_NUM*sizeof(struct dbg_index_t)); - atomic_add(&(debugger->selfcost_mem),D_SPACE.INIT_THREAD_BLOCK_NUM*sizeof(struct dbg_index_t)); - - debugger->raw_mem_header[0]=idx_pool_buff; - debugger->rawmem_idx=1; - D_kernel_list_init(&(debugger->index_pool)); - for(i=0;iindex_pool), &(idx_pool_buff[i].malloced_in_reach_hook)); - } - atomic_set(&(debugger->pool_unit_cnt),D_SPACE.INIT_THREAD_BLOCK_NUM); - ret=D_INTERNAL_MESA_hash_create_v2(&(debugger->malloc_backtrace_hash), - 1,//thread safe - 1024*32, - 0,//unlimited max element num - NULL, - NULL, - destroy_bt_info, - NULL, - 0, - 0,//never expire - (IMP_t*)p_mp); - assert(ret==0); - ret=D_INTERNAL_MESA_hash_create_v2(&(debugger->free_backtrace_hash), - 1,//thread safe - 1024*32, - 0,//unlimited max element num - NULL, - NULL, - destroy_bt_info, - NULL, - 0, - 0,//never expire - (IMP_t*)p_mp); - assert(ret==0); - return; -} -void destroy_thread_mem_debugger(thread_mem_debugger_t* debugger) -{ - unsigned int i=0; - D_INTERNAL_MESA_hash_destroy_v2(&(debugger->malloc_backtrace_hash),NULL); - D_INTERNAL_MESA_hash_destroy_v2(&(debugger->free_backtrace_hash),NULL); - for(i=0;irawmem_idx;i++) - { - mmap_free(debugger->raw_mem_header[i]); - debugger->raw_mem_header[i]=NULL; - } - pthread_mutex_destroy(&(debugger->mutex_malloced_in_reach_list)); - pthread_mutex_destroy(&(debugger->mutex_pool_tail)); - return; -} -struct dbg_index_t* get_dbg_index(thread_mem_debugger_t* debugger) -{ - struct dbg_index_t* p; - struct D_kernel_list_head* elem=NULL; - struct dbg_index_t* idx_pool_buff=NULL; - unsigned int i=0; - if(atomic_read(&(debugger->pool_unit_cnt))<2) - { - idx_pool_buff=(struct dbg_index_t*)mmap_alloc(BATCH_DBG_IDX_NUM*sizeof(struct dbg_index_t)); - atomic_add(&(debugger->selfcost_mem),BATCH_DBG_IDX_NUM*sizeof(struct dbg_index_t)); - assert(debugger->rawmem_idxraw_mem_header[debugger->rawmem_idx]=idx_pool_buff; - debugger->rawmem_idx++; - for(i=0;iindex_pool), &(idx_pool_buff[i].malloced_in_reach_hook)); - } - atomic_add(&(debugger->pool_unit_cnt),BATCH_DBG_IDX_NUM); - } - elem=D_kernel_list_get_head(&(debugger->index_pool)); - p=container_of(elem,struct dbg_index_t,malloced_in_reach_hook); - atomic_dec(&(debugger->pool_unit_cnt)); - p->used_size=0; - p->p_backtrace=NULL; - p->mem_info=0; - return p; -} -void restore_dbg_index(thread_mem_debugger_t* debugger,struct dbg_index_t*idx) -{ - pthread_mutex_lock(&(debugger->mutex_pool_tail)); - D_kernel_list_add_tail(&(debugger->index_pool),&(idx->malloced_in_reach_hook)); - atomic_inc(&(debugger->pool_unit_cnt)); - pthread_mutex_unlock(&(debugger->mutex_pool_tail)); - return; -} -struct sort_data_t -{ - long val; - void* data; -}; -static int sort_data_pos=0; - -void quick_sort(struct sort_data_t *a,int i,int j) -{ - - int m,n; - struct sort_data_t temp; - int k; - m=i; - n=j; - k=a[(i+j)/2].val; /*选取的参照*/ - do { - while(a[m].valk&&n>i) - n--; /* 从右到左找比k小的元素*/ - if(m<=n) - { /*若找到且满足条件,则交换*/ - temp=a[m]; - a[m]=a[n]; - a[n]=temp; - m++; - n--; - } - - }while(m<=n); - - if(mi) - quick_sort(a,i,n); - -} -void show_help(int sd) -{ - int i=0; - char buff[4096]={0}; - unsigned int printed=0; - printed+=snprintf(buff,sizeof(buff)-printed,"Command Usage:\n"); - while(strlen(support_cmd_full[i])>1&&printeddebugger.app_mem)); - cached_mem+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.cached_mem)); - assigned_mem+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.assigned_mem)); - num_malloced_places+=D_SPACE.thread_mem_info[i]->debugger.malloc_backtrace_hash.elem_count; - num_freed_places+=D_SPACE.thread_mem_info[i]->debugger.free_backtrace_hash.elem_count; - inuse_num+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.inuse_num)); - malloc_cnt+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.malloc_cnt)); - free_cnt+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.free_cnt)); - selfcost_mem+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.selfcost_mem)); - } - printed+=snprintf(buff+printed,sizeof(buff)-printed,"pool num:%d inuse %llu block\n",i,inuse_num); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"malloced %llu times in %llu context(s)\n",malloc_cnt,num_malloced_places); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"freed %llu times in %llu context(s)\n",free_cnt,num_freed_places); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"app used:%llu bytes/%lluMB\n",app_mem,app_mem/(1024*1024)); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"assigned:%llu bytes/%lluMB\n",assigned_mem,assigned_mem/(1024*1024)); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"cached :%llu bytes/%lluMB\n",cached_mem,cached_mem/(1024*1024)); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"selfcost:%llu bytes/%lluMB\n",selfcost_mem,selfcost_mem/(1024*1024)); - write(sd,buff,printed); -} - -/* -int unw_backtrace(void **bt_array,int number) -{ - unw_cursor_t cursor; - unw_context_t uc; - unw_word_t ip; - - unw_getcontext(&uc); - unw_init_local(&cursor, &uc); - int ret_cnt=0; - while (unw_step(&cursor) > 0) { - unw_get_reg(&cursor, UNW_REG_IP, &ip); - if(ret_cnt0)//make exception for unw_backtrace - { - return ret_cnt-1; - } - else - { - return 0; - } -} -*/ -#define STACKCALL __attribute__((regparm(1),noinline)) -void ** STACKCALL getEBP(void){ - void **ebp=NULL; - __asm__ __volatile__("mov %%rbp, %0;\n\t" - :"=m"(ebp) /* 输出 */ - : /* 输入 */ - :"memory"); /* 不受影响的寄存器 */ - return (void **)(*ebp); -} -int mesa_backtrace(void **buffer,int size){ - - int frame=0; - void ** ebp; - void **ret=NULL; - unsigned long long func_frame_distance=0; - if(buffer!=NULL && size >0) - { - ebp=getEBP(); - func_frame_distance=(unsigned long long)(*ebp) - (unsigned long long)ebp; - while(ebp&& frame0)) - { - ret=ebp+1; - buffer[frame++]=*ret; - ebp=(void**)(*ebp); - func_frame_distance=(unsigned long long)(*ebp) - (unsigned long long)ebp; - } - } - return frame; -} - - -backtrace_info_t* backtrace_ref_inc(MESA_hash_tab_v2_t* hash,size_t inc_size,thread_mem_pool_t *p_mempool) -{ - void *bt_array[MAX_BACKTRACE_DEPTH]; - void** except_self_bt_array; - size_t bt_depth,except_self_bt_depths; - bt_depth = mesa_backtrace(bt_array, MAX_BACKTRACE_DEPTH); -// bt_depth = backtrace(bt_array, MAX_BACKTRACE_DEPTH); -// bt_depth = unw_backtrace(bt_array, MAX_BACKTRACE_DEPTH); - backtrace_info_t *caller_bt; - if(bt_depth<=MALLOC_SELF_DEPTH) - { - bt_depth=MALLOC_SELF_DEPTH+1; - memset(bt_array,0,sizeof(bt_array)); - } - except_self_bt_array=bt_array+MALLOC_SELF_DEPTH; - except_self_bt_depths=bt_depth-MALLOC_SELF_DEPTH; - caller_bt=(backtrace_info_t *)D_INTERNAL_MESA_hash_sel_v2(hash, - (uchar*)(except_self_bt_array), - sizeof(void*)*(except_self_bt_depths)); - if(caller_bt==NULL) - { - caller_bt=create_bt_info(except_self_bt_array, except_self_bt_depths,p_mempool); - D_INTERNAL_MESA_hash_add_v2(hash, - (uchar*)except_self_bt_array, - sizeof(void*)*except_self_bt_depths, - caller_bt); - } - atomic_inc(&(caller_bt->ref_cnt)); - atomic_add(&(caller_bt->ref_bytes),inc_size); - if(atomic_read(&(caller_bt->maxsize))<(signed long)inc_size) - { - atomic_set(&(caller_bt->maxsize),(signed long)inc_size); - } - return caller_bt; -} -void merge_mp_hash(uchar * key, uint size, void * data, void * u) -{ - MESA_hash_tab_v2_t* target_hash=(MESA_hash_tab_v2_t*)u; - backtrace_info_t* tmp_bt_info=(backtrace_info_t*)data; - if(0==atomic_read(&(tmp_bt_info->ref_bytes))) - { - return; - } - backtrace_info_t* target_bt_info=(backtrace_info_t *)D_INTERNAL_MESA_hash_sel_v2(target_hash, - (uchar*)key, - size); - if(target_bt_info==NULL) - { - target_bt_info=create_bt_info(tmp_bt_info->bt_array, tmp_bt_info->array_size,DEBUGGER_MP); - - D_INTERNAL_MESA_hash_add_v2(target_hash, - key, - size, - target_bt_info); - } - atomic_add(&(target_bt_info->ref_bytes),atomic_read(&(tmp_bt_info->ref_bytes))); - atomic_add(&(target_bt_info->ref_cnt),atomic_read(&(tmp_bt_info->ref_cnt))); - if(atomic_read(&(target_bt_info->maxsize))maxsize))) - { - atomic_set(&(target_bt_info->maxsize),atomic_read(&(tmp_bt_info->maxsize))); - } - return; -} -void dump2array_by_refbytes(uchar * key, uint size, void * data, void * u) -{ - - backtrace_info_t* bt_info=(backtrace_info_t*)data; - struct sort_data_t* sort_array=(struct sort_data_t*)u; - sort_array[sort_data_pos].val=atomic_read(&(bt_info->ref_bytes)); - sort_array[sort_data_pos].data=data; - sort_data_pos++; - return; -} -void dump2array_by_maxsize(uchar * key, uint size, void * data, void * u) -{ - - backtrace_info_t* bt_info=(backtrace_info_t*)data; - struct sort_data_t* sort_array=(struct sort_data_t*)u; - sort_array[sort_data_pos].val=atomic_read(&(bt_info->maxsize)); - sort_array[sort_data_pos].data=data; - sort_data_pos++; - return; -} -int exec_shell(const char*cmd ,char* buff,int buff_size) -{ - FILE* fp = popen(cmd, "r"); - if(fp==NULL) - { - return -1; - } - memset(buff,0,buff_size); - fgets(buff,buff_size,fp); - pclose(fp); - return strlen(buff); -} -int get_backtrace_string(void* bt,char* buff,int buff_size) -{ - char cmd[128] = {0}; - char property[256]={0}; - char not_care1[128]={0},not_care2[128]={0},not_care3[128]={0}; - char library_path[256]={0}; - char exe_path[256]={0},function_name[256]={0}; - char maps_line[1024]={0}; - void* offset_start,*offset_end; - int maps_column_num=0; - FILE* fd_maps=NULL; - fd_maps=fopen("/proc/self/maps","r"); - unsigned long exe_symbol_offset=0; - const char* unknow_position="??:0\n"; - if(fd_maps==NULL) - { - return -1; - } - while(NULL!=fgets(maps_line,sizeof(maps_line),fd_maps)) - { - maps_column_num=sscanf(maps_line,"%p-%p\t%s\t%s\t%s\t%s\t%s" - ,&offset_start - ,&offset_end - ,property - ,not_care1 - ,not_care2 - ,not_care3 - ,library_path); - if(maps_column_num==7&&bt>=offset_start&&bt<=offset_end) - { - break; - } - - } - fclose(fd_maps); - memset(exe_path,0,sizeof(exe_path)); - readlink("/proc/self/exe", exe_path, sizeof(exe_path)); - if(exe_path[strlen(exe_path)-1]=='\n') - { - exe_path[strlen(exe_path)-1]='\0'; - } - if(0==strcmp(exe_path,library_path)) - { - exe_symbol_offset=(unsigned long)bt; - } - else - { - exe_symbol_offset=(char*)bt-(char*)offset_start; - } - snprintf(cmd,sizeof(cmd),"addr2line -C -e %s 0x%lx",library_path,exe_symbol_offset); - exec_shell(cmd, buff, buff_size); - if(0==strcmp(buff,unknow_position)) - { - snprintf(cmd,sizeof(cmd),"addr2line -Cif -e %s 0x%lx",library_path,exe_symbol_offset); - exec_shell(cmd, function_name, sizeof(function_name)); - function_name[strlen(function_name)-1]='\0'; - snprintf(buff,buff_size,"%s(%s+0x%lx)\n",library_path,function_name,exe_symbol_offset); - } - return 0; -} - -int merge_malloc_bt(MESA_hash_tab_v2_t *merged_hash) -{ - int ret=0,i=0; - MESA_hash_tab_v2_t* mp_malloc_hash; - int to_sort_size=0; - ret=D_INTERNAL_MESA_hash_create_v2(merged_hash, - 1,//thread safe - 1024*32, - 0,//unlimited max element num - NULL, - NULL, - destroy_bt_info, - NULL, - 0, - 0,//never expire - (IMP_t*)DEBUGGER_MP); - assert(ret==0); - for(i=0;i<=atomic_read(&(D_SPACE.used_mem_pool_counter));i++) - { - if(D_SPACE.thread_mem_info[i]==NULL) - { - continue; - } - mp_malloc_hash=&(D_SPACE.thread_mem_info[i]->debugger.malloc_backtrace_hash); - D_INTERNAL_MESA_hash_iterate_v2_2(mp_malloc_hash, merge_mp_hash,merged_hash); - } - - to_sort_size=merged_hash->elem_count; - return to_sort_size; -} - - -void list_malloc_bt(int sd,const char*args,int CMD) -{ - int i=0,printed=0,list_cnt=0; - unsigned int j=0; - backtrace_info_t* bt_info=NULL; - long ref_bytes=0,ref_cnt=0; - struct sort_data_t* sort_array=NULL; - int to_sort_size=0; - char buff[4096]={0},bt_string[1024]={0}; - pid_t pid=getpid(); - int max_list_num=-1,min_list_size=-1; - MESA_hash_tab_v2_t merged_hash; - sscanf(args,"%d %d",&max_list_num,&min_list_size); - if(CMD!=D_CMD_LIST_LARGE_M&&CMD!=D_CMD_LIST_MALLOC) - { - assert(0); - } - to_sort_size=merge_malloc_bt(&merged_hash); - sort_array=(struct sort_data_t*)mmap_alloc(to_sort_size*sizeof(struct sort_data_t)); - - if(CMD==D_CMD_LIST_LARGE_M) - { - D_INTERNAL_MESA_hash_iterate_v2_2(&merged_hash, dump2array_by_maxsize,sort_array); - - } - else if(CMD==D_CMD_LIST_MALLOC) - { - D_INTERNAL_MESA_hash_iterate_v2_2(&merged_hash, dump2array_by_refbytes,sort_array); - } - sort_data_pos=0; - quick_sort(sort_array, 0,to_sort_size-1); - for(i=to_sort_size-1;i>=0;i--) - { - printed=0; - memset(buff,0,sizeof(buff)); - bt_info=(backtrace_info_t*)(sort_array[i].data); - if(list_cnt>=max_list_num&&max_list_num>0) - { - break; - } - if(CMD==D_CMD_LIST_LARGE_M) - { - if(atomic_read(&(bt_info->maxsize))0) - { - break; - } - } - else if(CMD==D_CMD_LIST_MALLOC) - { - if(atomic_read(&(bt_info->ref_bytes))0) - { - break; - } - } - - ref_bytes=atomic_read(&(bt_info->ref_bytes)); - ref_cnt=atomic_read(&(bt_info->ref_cnt)); - printed+=snprintf(buff+printed,sizeof(buff)-printed, - "=%u=\t malloc %ld bytes(%ldMB) and %ld times in contexts (MAX %ld bytes,AVG %ld bytes)\n", - pid, - ref_bytes, - ref_bytes/(1024*1024), - ref_cnt, - atomic_read(&(bt_info->maxsize)), - ref_bytes/ref_cnt); - for(j=0;jarray_size;j++) - { - memset(bt_string,0,sizeof(bt_string)); - get_backtrace_string(bt_info->bt_array[j],bt_string,sizeof(bt_string)); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"=%u=\tby %s",pid,bt_string); - } - printed+=snprintf(buff+printed,sizeof(buff)-printed,"\n"); - write(sd,buff,printed); - list_cnt++; - } - D_INTERNAL_MESA_hash_destroy_v2(&merged_hash,NULL); - mmap_free(sort_array); -} -int d_chk_one_mem(struct dbg_index_t* idx,char* err_string,int size) -{ - int printed=0,invalid_write_size=0,i=0; - unsigned int assigned_size=0; - const char* user_boundary=NULL; - mem_info_t* block=(mem_info_t*)(idx->mem_info); - int boundary_len=0,is_corrupt=0; - if(block->magic!=DICTATOR_MAGIC) - { - printed+=snprintf(err_string+printed,size-printed,"Magic Error|"); - is_corrupt=1; - } - assigned_size=block->blk_num*DICTATOR_UNIT_SIZE; - if(assigned_sizeused_size+USED_MEM_HEAD_LEN) - { - printed+=snprintf(err_string+printed,size-printed,"Corrupt mem head usd(%lu)>assigned(%u)|" - ,idx->used_size+USED_MEM_HEAD_LEN - ,assigned_size); - is_corrupt=1; - } - user_boundary=(char*)block+USED_MEM_HEAD_LEN+idx->used_size; - boundary_len=MIN(assigned_size-idx->used_size-USED_MEM_HEAD_LEN,D_MARKER_SIZE); - if(0!=memcmp(user_boundary,boundary_marker,boundary_len)) - { - for(i=0;idebugger.mutex_malloced_in_reach_list)); - to_check_list=&(D_SPACE.thread_mem_info[i]->debugger.malloced_in_reach_list); - to_check_elem=to_check_list->next; - while(to_check_elem!=to_check_list) - { - printed=0; - to_chk_idx=container_of(to_check_elem,struct dbg_index_t, malloced_in_reach_hook); - chked_blk_sum++; - chked_bytes_sum+=to_chk_idx->used_size; - is_corrupt=d_chk_one_mem(to_chk_idx, err_string,sizeof(err_string)); - if(is_corrupt==1) - { - block=(mem_info_t*)to_chk_idx->mem_info; - corrupt_sum++; - printed=snprintf(buff+printed,sizeof(buff)-printed,"Mem %p size %d(%s) D_id %u %s in context\n", - (char*)block+USED_MEM_HEAD_LEN, - to_chk_idx->used_size, - block->blk_num?"block":"chunk", - block->D_id, - err_string); - - for(j=0;jp_backtrace->array_size;j++) - { - memset(bt_string,0,sizeof(bt_string)); - get_backtrace_string(to_chk_idx->p_backtrace->bt_array[j],bt_string,sizeof(bt_string)); - printed+=snprintf(buff+printed,sizeof(buff)-printed,"=%u=\tby %s",pid,bt_string); - } - - write(sd,buff,printed); - } - to_check_elem=to_check_elem->next; - } - pthread_mutex_unlock(&(D_SPACE.thread_mem_info[i]->debugger.mutex_malloced_in_reach_list)); - - } - printed=0; - printed+=snprintf(buff+printed,sizeof(buff)-printed,"Corrutp Sumary:\n\tChecked %d threads.\n\tChecked %lu block,%lu bytes(%luMB).\n\t%lu block(s) Corrupt.\n", - i, - chked_blk_sum, - chked_bytes_sum, - chked_bytes_sum/(1024*1024), - corrupt_sum); - if(!is_scheduled) - { - write(sd,buff,printed); - } - return; - -} -int dictator_parse_cmd(const char* cmd,const char**args) -{ - int i=0,ret=0; - while(strlen(support_cmd_full[i])>1) - { - ret=strncasecmp(cmd,support_cmd_full[i],strlen(support_cmd_full[i])); - if(ret==0) - { - *args=cmd+strlen(support_cmd_full[i])+1; - break; - } - else if((cmd[0]==support_cmd_short[i])&&(cmd[1]=='\n'||cmd[1]==' ')) - { - *args=cmd+2; - break; - } - i++; - } - return i; -} -void * dictator_debug_thread(void* param) -{ - pid_t app_pid=0; - char listen_path[64]; - char cmd_buff[1024],debug_cmd[1024]; - app_pid=getpid(); - char banner[1024]={0}; - const char* unknown_cmd="UNKNOWN CMD.\n"; - const char* shell="dictator2>"; - const char* schedule_checking="Schedule Checking"; - snprintf(listen_path,sizeof(listen_path),"/tmp/dictator_%u",app_pid); - snprintf(banner,sizeof(banner),"WELCOME TO DICTATOR2(%s) DEBUG CONSOLE.\n", - DICTATOR2_VERSION); - DEBUGGER_MP=create_mem_pool(-1); - struct sockaddr_un address; - int sock, conn,cmd_id=0; - int check_times=-1,check_interval_us=1000*100; - int i=0,ret=-1; - size_t addrLength; - const char *args=NULL; - - if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) - { - fprintf(stderr,"DICTATOR2 INIT FAILED!\n"); - } - - unlink(listen_path); - - address.sun_family = AF_UNIX; - strcpy(address.sun_path,listen_path); - - addrLength = sizeof(address.sun_family) + strlen(address.sun_path); - - if (bind(sock, (struct sockaddr *) &address, addrLength)) - { - fprintf(stderr,"DICTATOR2 bind %s FAILED!\n",listen_path); - } - if (listen(sock, 1)) - { - fprintf(stderr,"DICTATOR2 listen %s FAILED!\n",listen_path); - } - fprintf(stderr,"Using DICTATOR2 memory debugger (%s)\n",listen_path); - while ((conn = accept(sock, (struct sockaddr *) &address,(socklen_t*)&addrLength)) >= 0) - { - write(conn,banner,strlen(banner)); - memset(debug_cmd,0,sizeof(debug_cmd)); - write(conn,shell,strlen(shell)); - while(read(conn,cmd_buff,sizeof(cmd_buff))>0) - { - if(cmd_buff[0]!='\n') - { - memcpy(debug_cmd,cmd_buff,sizeof(debug_cmd)); - cmd_id=dictator_parse_cmd(debug_cmd,&args); - } - check_times=-1; - check_interval_us=1000*100; - switch(cmd_id) - { - case D_CMD_HELP: - show_help(conn); - break; - case D_CMD_STAT: - stat_memory(conn); - break; - case D_CMD_LIST_MALLOC: - case D_CMD_LIST_LARGE_M: - list_malloc_bt(conn,args,cmd_id); - break; - case D_CMD_CHECK: - sscanf(args,"%d %d",&check_times,&check_interval_us); - if(check_times>0) - { - write(conn,schedule_checking,strlen(schedule_checking)); - for(i=0;i//using memset -#define DUMMY_HASH_SIZE 2048 -#define DUMMY_COLLISION_SIZE 2048 -struct dummy_pair_t -{ - long key; - long value; -}; -struct dummy_htable_t -{ - struct dummy_pair_t array[DUMMY_HASH_SIZE+DUMMY_COLLISION_SIZE]; - long collision_cnt; -}; -inline void dummy_htable_init(struct dummy_htable_t* table) -{ - memset(table,0,sizeof(struct dummy_htable_t)); - return; -} -inline long dummy_htable_read(struct dummy_htable_t* table,long key,long *value) -{ - int i=0; - int idx=key%DUMMY_HASH_SIZE; - if(table->array[idx].key==key) - { - *value=table->array[idx].value; - return 1; - } - else if(table->array[idx].key==0) - { - return 0; - } - else - { - for(i=DUMMY_HASH_SIZE;icollision_cnt;i++) - { - if(table->array[i].key==key) - { - *value=table->array[i].value; - return 1; - } - } - return 0; - } -} -inline int dummy_htable_add(struct dummy_htable_t* table,long key,long value) -{ - int idx=key%DUMMY_HASH_SIZE; - long previous_key=0,previous_value=0; - assert(key!=0); - previous_key=__sync_lock_test_and_set(&(table->array[idx].key),key); - if(previous_key==0) - { - return 0; - } - previous_value=table->array[idx].value; - table->array[idx].value=value; - - assert(table->collision_cntcollision_cnt),1); - previous_key=__sync_fetch_and_add(&(table->array[idx].key),previous_key); - table->array[idx].value=previous_value; - assert(previous_key==0); - return idx; -} -#endif diff --git a/src/support/dictator2/src/internal_mp.h b/src/support/dictator2/src/internal_mp.h deleted file mode 100644 index 40796cd..0000000 --- a/src/support/dictator2/src/internal_mp.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __INTERNAL_MEM_POOL_H_INCLUDE_ -#define __INTERNAL_MEM_POOL_H_INCLUDE_ -typedef struct -{ -}IMP_t; -void* mmap_alloc(size_t size); -void mmap_free(void*p); -void* block_alloc(size_t size,IMP_t *imp); -void block_free(void*p,IMP_t* imp); -#endif //end of __INTERNAL_MEM_POOL_H_INCLUDE_ - diff --git a/src/support/dictator2/src/mr_hugepage.h b/src/support/dictator2/src/mr_hugepage.h deleted file mode 100644 index d853e86..0000000 --- a/src/support/dictator2/src/mr_hugepage.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/* 鐢宠澶ч〉鍐呭瓨鍑芥暟 - * @note: 涓嶈鍦ㄦ暟鎹潰棰戠箒浣跨敤锛侊紒 - */ -int marsio_is_hugepage_available(void); -void * marsio_hugepage_malloc(size_t size, int seq); -void * marsio_hugepage_calloc(size_t num, size_t size, int seq); -void * marsio_hugepage_realloc(void * ptr, size_t size); - -/* 閲婃斁澶ч〉鍐呭瓨鍑芥暟 */ -void marsio_hugepage_free(void * mem); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/src/support/dictator2/test/Makefile b/src/support/dictator2/test/Makefile deleted file mode 100644 index 682b906..0000000 --- a/src/support/dictator2/test/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: - g++ -o test -g -Wall test.cpp ../lib/libdictator_debug.a -lpthread -clean: - rm test -f diff --git a/src/support/dictator2/test/test.cpp b/src/support/dictator2/test/test.cpp deleted file mode 100644 index 504dcb0..0000000 --- a/src/support/dictator2/test/test.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include -#include -#include -#include -#include -#if 0 // for EAL check, Delete code temporary -#define TEST_CNT (8) -#define TEST_THREAD (4) -struct test_case_t -{ - void *mem; - unsigned int size; -}; -unsigned int g_used_mem_size=0; - -void mem_test(void*) -{ - struct test_case_t test_array[TEST_CNT]; - int i=0; - for(i=1;i