diff options
| author | lijia <[email protected]> | 2021-11-23 17:06:46 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2021-11-23 17:06:46 +0800 |
| commit | c9193fe2e5e9bad00174d6d72b693b279c030793 (patch) | |
| tree | d0426f0a6a37443f4d59fe5ab56a5f164f65b7e2 | |
| parent | bb08abbde07e2c5d322f5040ec67b42c992d176e (diff) | |
TSG-8651, 修复gdev_keepalive_set_opt()停止与Inline设备保活无效的BUG.v4.2.68
| -rw-r--r-- | src/inner_plug/g_device_plug.cpp | 11 | ||||
| -rw-r--r-- | test/test_app_sapp.c | 51 |
2 files changed, 54 insertions, 8 deletions
diff --git a/src/inner_plug/g_device_plug.cpp b/src/inner_plug/g_device_plug.cpp index 2c7290b..430d1d0 100644 --- a/src/inner_plug/g_device_plug.cpp +++ b/src/inner_plug/g_device_plug.cpp @@ -94,10 +94,10 @@ typedef struct _gdev_keepalive_status_per_thread gdev_keepalive_status_per_threa static gdev_keepalive_status_per_thread_t GDEV_KEEPALIVE_STAT[MAX_THREAD_NUM]; static void *gdev_keepalive_fs2_handle; -static int g_dev_keepalive_flag = 1; /* ȫ�ֱ����־, ���в���������������Ҫ������������ */ +static volatile int g_dev_keepalive_flag = 1; /* ȫ�ֱ����־, ���в���������������Ҫ������������ */ -static struct gdev_keepalive_service_ctrl g_dev_keepalive_service_ctrl_array[MAX_VXLAN_SERVICE_NUM];/* ����ij��ҵ����Ƿ� */ +static volatile struct gdev_keepalive_service_ctrl g_dev_keepalive_service_ctrl_array[MAX_VXLAN_SERVICE_NUM];/* ����ij��ҵ����Ƿ� */ //extern int g_packet_io_thread_num; //extern time_t g_CurrentTime; @@ -938,7 +938,8 @@ char gdev_keepalive_udp_entry(const struct streaminfo *a_udp, void **pme, int t a_udp_pr = (const struct streaminfo_private *)a_udp; kp_ret = gdev_keepalive_plug(a_udp_pr->raw_pkt, a_udp->threadnum, a_udp->routedir, GDEV_KEEPALIVE_TYPE_BFD); if(kp_ret < 0){ - entry_ret = APP_STATE_GIVEME; /* ������, socket�ȴ����ܷ���APP_STATE_DROPME, ����DROP ME����Ҳ�ò������������ */ + /* ������, socket�ȴ����ܷ���APP_STATE_DROPME, ����DROP ME����Ҳ�ò������������, ���Dz������ͨ��gdev_keepalive_set_opt()�رձ����, ����Ҫ����DROPPKT, ���ܰ��������ע */ + entry_ret = APP_STATE_GIVEME | APP_STATE_DROPPKT; }else{ entry_ret = APP_STATE_GIVEME | APP_STATE_DROPPKT; /* �����, ������ǰ�� */ } @@ -970,7 +971,7 @@ char gdev_keepalive_ip_entry(const struct streaminfo *pstream,unsigned char rout pstream_pr = (const struct streaminfo_private *)pstream; kp_ret = gdev_keepalive_plug(pstream_pr->raw_pkt, thread_seq, pstream->routedir, GDEV_KEEPALIVE_TYPE_ICMP); if(kp_ret < 0){ - entry_ret = APP_STATE_DROPME; + entry_ret = APP_STATE_DROPME | APP_STATE_DROPPKT; }else{ entry_ret = APP_STATE_GIVEME | APP_STATE_DROPPKT; /* �����, ������ǰ�� */ } @@ -1060,7 +1061,7 @@ void gdev_keepalive_plug_destroy(void) } memset(GDEV_KEEPALIVE_STAT, 0, sizeof(GDEV_KEEPALIVE_STAT)); - memset(g_dev_keepalive_service_ctrl_array, 0, sizeof(g_dev_keepalive_service_ctrl_array)); + memset((void *)g_dev_keepalive_service_ctrl_array, 0, sizeof(g_dev_keepalive_service_ctrl_array)); g_dev_keepalive_flag = 1; g_dev_keepalive_default_action = 1; } diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c index 8a30403..e0df65f 100644 --- a/test/test_app_sapp.c +++ b/test/test_app_sapp.c @@ -1,6 +1,7 @@ #include "stream.h" #include "sapp_api.h" #include "sapp_private_api.h" +#include "gdev_keepalive.h" #ifdef __cplusplus extern "C" { @@ -685,20 +686,20 @@ char ipv4_pkt_detail_entry(struct streaminfo *pstream,unsigned char routedir, in if(IPPROTO_TCP == ihdr4->ip_p){ thdr = (struct mesa_tcp_hdr *)((char *)ihdr4 + ihdr4->ip_hl * 4); - printf("IP pkt: %s:%u --> %s:%u, ipid:%u, proto:%d, routedir:%d\n", + printf("tid:%d, IP pkt: %s:%u --> %s:%u, ipid:%u, proto:%d, routedir:%d\n", thread_seq, ip_src_str, ntohs(thdr->th_sport), ip_dst_str, ntohs(thdr->th_dport), ntohs(ihdr4->ip_id), ihdr4->ip_p, routedir); }else if(IPPROTO_UDP == ihdr4->ip_p){ uhdr = (struct mesa_udp_hdr *)((char *)ihdr4 + ihdr4->ip_hl * 4); - printf("IP pkt: %s:%u --> %s:%u, ipid:%u, proto:%d,routedir:%d\n", + printf("tid:%d, IP pkt: %s:%u --> %s:%u, ipid:%u, proto:%d,routedir:%d\n", thread_seq, ip_src_str, ntohs(uhdr->uh_sport), ip_dst_str, ntohs(uhdr->uh_dport), ntohs(ihdr4->ip_id), ihdr4->ip_p, routedir); }else{ - printf("IP pkt: %s --> %s, ipid:%u, proto:%d, routedir:%d\n", + printf("tid:%d, IP pkt: %s --> %s, ipid:%u, proto:%d, routedir:%d\n", thread_seq, ip_src_str, ip_dst_str, ntohs(ihdr4->ip_id), ihdr4->ip_p, routedir); } @@ -3340,6 +3341,50 @@ char IPv6_RAW_ENTRY(const struct streaminfo *pstream, const void *this_hdr, cons #endif +static volatile int _g_enable_keepalive; +static void *gdev_keepalive_control_thread(void *arg) +{ + SAPP_TLV_T option; + int ret; + + while(1){ + if((time(NULL) % 10) <= 5){ + _g_enable_keepalive = 0; + printf("gdev_keepalive_set_opt() disable keepalive.....\n"); + }else{ + _g_enable_keepalive = 1; + printf("gdev_keepalive_set_opt() enable keepalive.....\n"); + } + + option.type = GDEV_KEEPALIVE_OPT_GLOBAL_SWITCH; + option.length = sizeof(int); + option.int_value = _g_enable_keepalive; + + ret = gdev_keepalive_set_opt(&option); + if(ret < 0){ + printf("gdev_keepalive_set_opt() -> GDEV_KEEPALIVE_OPT_GLOBAL_SWITCH error!\n"); + } + + sleep(1); + } + return NULL; +} + +char gdev_keepalive_control_entry(struct streaminfo *pstream,unsigned char routedir, int thread_seq,void *a_packet) +{ + + static volatile int __thread_created = 0; + + if(0 == __thread_created){ + pthread_t pid; + pthread_create(&pid, NULL, gdev_keepalive_control_thread, NULL); + __thread_created = 1; + } + + return APP_STATE_GIVEME; +} + + char arp_plug_entry(const struct streaminfo *pstream,unsigned char routedir,int thread_seq, const void *arp_hdr) { const struct mesa_arp_hdr *aph = (struct mesa_arp_hdr *)arp_hdr; |
