diff options
| -rw-r--r-- | include/private/sapp_pkt_stat.h | 2 | ||||
| -rw-r--r-- | src/common/net_common.c | 8 | ||||
| -rw-r--r-- | src/config/config_parse.cpp | 29 | ||||
| -rw-r--r-- | src/dealpkt/deal_vxlan.c | 12 | ||||
| -rw-r--r-- | src/dealpkt/duplicate_pkt_distinguish.c | 6 | ||||
| -rw-r--r-- | src/inner_plug/sapp_assistant.cpp | 11 | ||||
| -rw-r--r-- | src/packet_io/packet_io.c | 6 | ||||
| -rw-r--r-- | src/packet_io/packet_io_status.cpp | 5 | ||||
| -rw-r--r-- | src/packet_io/sendpacket.c | 59 | ||||
| -rw-r--r-- | src/sapp_dev/sapp_global_val.c | 1 | ||||
| -rw-r--r-- | src/sapp_dev/sapp_plug.c | 5 | ||||
| -rw-r--r-- | test/test_app_sapp.c | 6 |
12 files changed, 105 insertions, 45 deletions
diff --git a/include/private/sapp_pkt_stat.h b/include/private/sapp_pkt_stat.h index 66c2631..8fe523c 100644 --- a/include/private/sapp_pkt_stat.h +++ b/include/private/sapp_pkt_stat.h @@ -31,6 +31,8 @@ typedef enum __sapp_sys_stat_type{ SAPP_STAT_RCV_DUP_TCP, /* �ظ����� */ SAPP_STAT_RCV_DUP_UDP, /* �ظ����� */ + SAPP_STAT_DUP_IDENTIFY_ERR, /* �ظ�����ʶ��key���Ӵ��� */ + SAPP_STAT_RCV_UNKNOWN, /************* send packet *******************/ diff --git a/src/common/net_common.c b/src/common/net_common.c index 7d41fb1..22f6306 100644 --- a/src/common/net_common.c +++ b/src/common/net_common.c @@ -1123,7 +1123,7 @@ UINT16 net_layer_to_ethernet_protocol(int addr_type) case ADDR_TYPE_TCP: case ADDR_TYPE_UDP: - sapp_runtime_log(RLOG_LV_FATAL, "net_layer_to_ethernet_protocol(): Ethernet can't carry addr type:%d directly!\n", addr_type); + sapp_runtime_log(RLOG_LV_INFO, "net_layer_to_ethernet_protocol(): Ethernet can't carry addr type:%d directly!\n", addr_type); //assert(0); ether_type = -1; break; @@ -1142,7 +1142,7 @@ UINT16 net_layer_to_ethernet_protocol(int addr_type) default: /* to do, unknown type */ - sapp_runtime_log(RLOG_LV_FATAL, "net_layer_to_ethernet_protocol(): unknown ethernet carry addr type:%d!\n", addr_type); + sapp_runtime_log(RLOG_LV_INFO, "net_layer_to_ethernet_protocol(): unknown ethernet carry addr type:%d!\n", addr_type); ether_type = -1; break; } @@ -1182,7 +1182,7 @@ UINT16 net_layer_to_ethernet_protocol_by_stream(const struct streaminfo *pstream case ADDR_TYPE_TCP: case ADDR_TYPE_UDP: - sapp_runtime_log(RLOG_LV_FATAL, "net_layer_to_ethernet_protocol_by_stream(): Ethernet can't carry addr type:%d directly!\n", addr_type); + sapp_runtime_log(RLOG_LV_INFO, "net_layer_to_ethernet_protocol_by_stream(): Ethernet can't carry addr type:%d directly!\n", addr_type); //assert(0); ether_type = -1; break; @@ -1201,7 +1201,7 @@ UINT16 net_layer_to_ethernet_protocol_by_stream(const struct streaminfo *pstream default: /* to do, unknown type */ - sapp_runtime_log(RLOG_LV_FATAL, "net_layer_to_ethernet_protocol_by_stream(): unknown ethernet carry addr type:%d!\n", addr_type); + sapp_runtime_log(RLOG_LV_INFO, "net_layer_to_ethernet_protocol_by_stream(): unknown ethernet carry addr type:%d!\n", addr_type); ether_type = -1; break; } diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp index cd82efc..e90b7ff 100644 --- a/src/config/config_parse.cpp +++ b/src/config/config_parse.cpp @@ -1053,7 +1053,14 @@ static int parse_well_known_port_config(void) sapp_memmove_for_blank_table(line_buf, sizeof(line_buf)); del_last_rn(line_buf, sizeof(line_buf)); - if('[' == line_buf[0]){ /* һ���������ʼ */ + if('[' == line_buf[0]){ /* [] һ���������ʼ */ + if(port_array != NULL){ + /* ��һ������ս��� */ + update_well_known_port_array(last_section_proto, port_array, port_array_num); + port_array = NULL; + port_array_num = 0; + } + if(strncasecmp("[TCP]", line_buf, strlen("TCP")) == 0){ last_section_proto = IPPROTO_TCP; }else if(strncasecmp("[UDP]", line_buf, strlen("UDP")) == 0){ @@ -1062,14 +1069,6 @@ static int parse_well_known_port_config(void) sapp_log(RLOG_LV_FATAL, ~0, ~0, "[Error]parse cfg_file:%s error, onlye support TCP or UDP", ABBR_WELL_KNOWN_PORT_CONF_FILE); return -1; } - - if(port_array != NULL){ - /* ��һ������ս��� */ - update_well_known_port_array(last_section_proto, port_array, port_array_num); - port_array = 0; - port_array_num = 0; - } - continue; } @@ -1090,6 +1089,18 @@ static int parse_well_known_port_config(void) port_array_num = 0; } + if(sapp_global_val->config.stream.tcp.well_known_ports_array){ + for(i = 0; i < sapp_global_val->config.stream.tcp.well_known_ports_array_num; i++){ + sapp_runtime_log(RLOG_LV_INFO, "these TCP ports are considered as server: %u", sapp_global_val->config.stream.tcp.well_known_ports_array[i]); + } + } + + if(sapp_global_val->config.stream.udp.well_known_ports_array){ + for(i = 0; i < sapp_global_val->config.stream.udp.well_known_ports_array_num; i++){ + sapp_runtime_log(RLOG_LV_INFO, "these UDP ports are considered as server: %u", sapp_global_val->config.stream.udp.well_known_ports_array[i]); + } + } + fclose(fp); return 0; diff --git a/src/dealpkt/deal_vxlan.c b/src/dealpkt/deal_vxlan.c index d6c1a6a..7ab8ddf 100644 --- a/src/dealpkt/deal_vxlan.c +++ b/src/dealpkt/deal_vxlan.c @@ -99,7 +99,9 @@ int vxlan_entry(struct streaminfo_private *pfstream_pr,const void *this_layer_hd if(ETH_P_IP == ntohs(addr_pr.inner_hdlc.protocol)){ ret = ipv4_entry(pstream_pr,next_layer_data,thread_num,routedir,raw_pkt, next_layer_offset); }else{ - sapp_runtime_log(RLOG_LV_FATAL, "vxlan etnry: unsupport HDLC protocol:0x%x\n", addr_pr.inner_hdlc.protocol); + local_sys_stat->count[SAPP_STAT_RCV_UNKNOWN]++; + local_sys_stat->length[SAPP_STAT_RCV_UNKNOWN]+=raw_pkt->raw_pkt_len; + sapp_runtime_log(RLOG_LV_INFO, "vxlan etnry: unsupport HDLC protocol:0x%x\n", addr_pr.inner_hdlc.protocol); ret = PASS; } } @@ -112,14 +114,18 @@ int vxlan_entry(struct streaminfo_private *pfstream_pr,const void *this_layer_hd }else if(PPP_PROTOCOL_IPv6 == ntohs(addr_pr.inner_ppp.protocol)){ ret = ipv6_entry(pstream_pr,next_layer_data,thread_num,routedir,raw_pkt, next_layer_offset); }else{ - sapp_runtime_log(RLOG_LV_FATAL, "vxlan etnry: unsupport PPP protocol:0x%x\n", addr_pr.inner_ppp.protocol); + local_sys_stat->count[SAPP_STAT_RCV_UNKNOWN]++; + local_sys_stat->length[SAPP_STAT_RCV_UNKNOWN]+=raw_pkt->raw_pkt_len; + sapp_runtime_log(RLOG_LV_INFO, "vxlan etnry: unsupport PPP protocol:0x%x\n", addr_pr.inner_ppp.protocol); ret = PASS; } } break; default: - sapp_runtime_log(RLOG_LV_FATAL, "vxlan etnry: unsupport link type:%d\n", addr_pr.addr_public.link_type); + local_sys_stat->count[SAPP_STAT_RCV_UNKNOWN]++; + local_sys_stat->length[SAPP_STAT_RCV_UNKNOWN]+=raw_pkt->raw_pkt_len; + sapp_runtime_log(RLOG_LV_INFO, "vxlan etnry: unsupport link type:%d\n", addr_pr.addr_public.link_type); ret = PASS; break; } diff --git a/src/dealpkt/duplicate_pkt_distinguish.c b/src/dealpkt/duplicate_pkt_distinguish.c index f91efba..8c9c058 100644 --- a/src/dealpkt/duplicate_pkt_distinguish.c +++ b/src/dealpkt/duplicate_pkt_distinguish.c @@ -59,7 +59,8 @@ int sapp_dup_pkt_mark_v4(int tid, const sapp_dup_pkt_key_v4_t *key) ret = expiry_dablooms_add(sapp_global_val->mthread_volatile[tid]->dup_pkt_distinguish_handle, (char *)key, sizeof(sapp_dup_pkt_key_v4_t)); if(ret < 0){ - sapp_runtime_log(RLOG_LV_FATAL, "sapp dup distinguish ipv4 pkt add bloom key error, %s", dup_pkt_key_ntop_v4(key,ntop_buf,sizeof(ntop_buf))); + sapp_global_val->mthread_volatile[tid]->sys_stat.count[SAPP_STAT_DUP_IDENTIFY_ERR]++; + sapp_runtime_log(RLOG_LV_INFO, "sapp dup distinguish ipv4 pkt add bloom key error, %s", dup_pkt_key_ntop_v4(key,ntop_buf,sizeof(ntop_buf))); }else{ sapp_runtime_log(RLOG_LV_DEBUG, "sapp dup distinguish ipv4 pkt add bloom key succ, %s", dup_pkt_key_ntop_v4(key,ntop_buf,sizeof(ntop_buf))); } @@ -74,7 +75,8 @@ int sapp_dup_pkt_mark_v6(int tid, const sapp_dup_pkt_key_v6_t *key) ret = expiry_dablooms_add(sapp_global_val->mthread_volatile[tid]->dup_pkt_distinguish_handle, (char *)key, sizeof(sapp_dup_pkt_key_v6_t)); if(ret < 0){ - sapp_runtime_log(RLOG_LV_FATAL, "sapp dup distinguish ipv6 pkt add bloom key error, %s", dup_pkt_key_ntop_v6(key,ntop_buf,sizeof(ntop_buf))); + sapp_global_val->mthread_volatile[tid]->sys_stat.count[SAPP_STAT_DUP_IDENTIFY_ERR]++; + sapp_runtime_log(RLOG_LV_INFO, "sapp dup distinguish ipv6 pkt add bloom key error, %s", dup_pkt_key_ntop_v6(key,ntop_buf,sizeof(ntop_buf))); }else{ sapp_runtime_log(RLOG_LV_DEBUG, "sapp dup distinguish ipv6 pkt add bloom key succ, %s", dup_pkt_key_ntop_v6(key,ntop_buf,sizeof(ntop_buf))); } diff --git a/src/inner_plug/sapp_assistant.cpp b/src/inner_plug/sapp_assistant.cpp index c55f87d..373bf5c 100644 --- a/src/inner_plug/sapp_assistant.cpp +++ b/src/inner_plug/sapp_assistant.cpp @@ -1198,6 +1198,12 @@ static int sapp_fs2_init(void) pfs_para->fs_id_length_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Outbound"); } + pfs_para->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Pkt"); + pfs_para->fs_id_length_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Bit"); + + pfs_para->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"); + pfs_para->fs_id_count_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Pkt"); pfs_para->fs_id_length_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Bit"); @@ -1211,6 +1217,8 @@ static int sapp_fs2_init(void) pfs_para->fs_id_length_array[SAPP_STAT_TCP_LOST_PKT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_Bit"); pfs_para->fs_id_count_array[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_STM"); + pfs_para->fs_id_count_array[SAPP_STAT_DUP_IDENTIFY_ERR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Key_Err"); /* dup�ظ���ʶ������key������� */ + pfs_para->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byT"); pfs_para->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byK"); @@ -1221,9 +1229,6 @@ static int sapp_fs2_init(void) pfs_para->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byT"); pfs_para->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byK"); - - pfs_para->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Pkt"); - pfs_para->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Bit"); pfs_para->fs_id_count_array[SAPP_STAT_TCP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_New"); pfs_para->fs_id_count_array[SAPP_STAT_TCP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_Del"); diff --git a/src/packet_io/packet_io.c b/src/packet_io/packet_io.c index da0642d..c061adf 100644 --- a/src/packet_io/packet_io.c +++ b/src/packet_io/packet_io.c @@ -911,7 +911,7 @@ retry: goto retry; /* ���ź��жϵ�IO������Ҫ���� */ }else{ local_sys_stat->count[SAPP_STAT_SND_ERROR]++; - sapp_runtime_log(RLOG_LV_FATAL, "packet_io_send_by_sys_routev4(): sendto error, %s\n", strerror(errno)); + sapp_runtime_log(RLOG_LV_INFO, "packet_io_send_by_sys_routev4(): sendto error, %s\n", strerror(errno)); return ret; } } @@ -946,7 +946,7 @@ static int packet_io_send_by_sys_routev6(MESA_send_handle *send_handle,int datal if(0 == g_ipv6_send_packet_enabled){ //printf("IPv6 module is not support! Please check 'sapp.toml->ipv6_send_packet_enabled'.\n"); - sapp_runtime_log(RLOG_LV_FATAL, "IPv6 module is not support! Please check 'sapp.toml->ipv6_send_packet_enabled'.\n" ); + sapp_runtime_log(RLOG_LV_INFO, "IPv6 module is not support! Please check 'sapp.toml->ipv6_send_packet_enabled'.\n" ); return -1; } @@ -979,7 +979,7 @@ retry: goto retry; /* ���ź��жϵ�IO������Ҫ���� */ }else{ local_sys_stat->count[SAPP_STAT_SND_ERROR]++; - sapp_runtime_log(RLOG_LV_FATAL,"packet_io_send_by_sys_routev6() sendto error, %s\n", strerror(errno)); + sapp_runtime_log(RLOG_LV_INFO,"packet_io_send_by_sys_routev6() sendto error, %s\n", strerror(errno)); return ret; } } diff --git a/src/packet_io/packet_io_status.cpp b/src/packet_io/packet_io_status.cpp index 81c8f51..e757a6f 100644 --- a/src/packet_io/packet_io_status.cpp +++ b/src/packet_io/packet_io_status.cpp @@ -91,6 +91,10 @@ static void field_stat2_update_metrics(void) sapp_fs2_update_count(SAPP_STAT_RCV_LINE, cur_count[SAPP_STAT_RCV_LINE]); sapp_fs2_update_length(SAPP_STAT_RCV_LINE, 8 *( cur_length[SAPP_STAT_RCV_LINE])); /* to bps, bit per second */ + + sapp_fs2_update_count(SAPP_STAT_SND_ERROR, cur_count[SAPP_STAT_SND_ERROR]); + sapp_fs2_update_length(SAPP_STAT_SND_ERROR, 8 *( cur_length[SAPP_STAT_SND_ERROR])); /* to bps, bit per second */ + sapp_fs2_update_count(SAPP_STAT_RCV_ETHERNET, cur_count[SAPP_STAT_RCV_ETHERNET]); sapp_fs2_update_length(SAPP_STAT_RCV_ETHERNET, 8 *( cur_length[SAPP_STAT_RCV_ETHERNET])); /* to bps, bit per second */ @@ -115,6 +119,7 @@ static void field_stat2_update_metrics(void) sapp_fs2_update_count(SAPP_STAT_RCV_DUP_TCP, cur_count[SAPP_STAT_RCV_DUP_TCP]); sapp_fs2_update_length(SAPP_STAT_RCV_DUP_TCP, 8 *(cur_length[SAPP_STAT_RCV_DUP_TCP])); + sapp_fs2_update_count(SAPP_STAT_DUP_IDENTIFY_ERR, cur_count[SAPP_STAT_DUP_IDENTIFY_ERR]); sapp_fs2_update_length(SAPP_STAT_TCP_LOST_PKT, 8 *(cur_length[SAPP_STAT_TCP_LOST_PKT])); sapp_fs2_update_count(SAPP_STAT_TCP_LOST_PKT_STREAM_NUM, cur_count[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM]); diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c index 37b7233..1bf39cc 100644 --- a/src/packet_io/sendpacket.c +++ b/src/packet_io/sendpacket.c @@ -918,7 +918,8 @@ static int calc_gtp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_st if(raw_net_gtp_hdr->flags & (GTP_HDR_FLAG_SEQ_NUM | GTP_HDR_FLAG_N_PDU | GTP_HDR_FLAG_NEXT_EXT_HDR)) { if(0 == sapp_global_val->config.protocol_feature.skip_gtp_S_PN_E_field_for_inject){ - sapp_runtime_log(RLOG_LV_FATAL, "calc_gtp_hdr_len error, inject GTP pkt not support SEQ or N-PDU or Extension header, you should set 'skip_gtp_S_PN_E_field_for_inject' to avoid this!"); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "calc_gtp_hdr_len error, inject GTP pkt not support SEQ or N-PDU or Extension header, you should set 'skip_gtp_S_PN_E_field_for_inject' to avoid this!"); return -1; } } @@ -927,12 +928,14 @@ static int calc_gtp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_st /* ���GTP�����˷ǶԳƱ��, ���뱣֤��ǰע�뷽��֮ǰ���������ݰ� */ if(send_stream_dir == DIR_C2S){ if(0 == p_gtp_layer_addr->teid_c2s){ - sapp_runtime_log(RLOG_LV_FATAL, "inject dir:%d packet error, GTP addr is asymmetric, but stream dir is:%d", send_stream_dir, stream_pr->stream_public.dir); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "inject dir:%d packet error, GTP addr is asymmetric, but stream dir is:%d", send_stream_dir, stream_pr->stream_public.dir); return -1; } }else{ if(0 == p_gtp_layer_addr->teid_s2c){ - sapp_runtime_log(RLOG_LV_FATAL, "inject dir:%d packet error, GTP addr is asymmetric, but stream dir is:%d", send_stream_dir, stream_pr->stream_public.dir); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "inject dir:%d packet error, GTP addr is asymmetric, but stream dir is:%d", send_stream_dir, stream_pr->stream_public.dir); return -1; } } @@ -1239,6 +1242,7 @@ static int build_net_layer_ethernet(const struct streaminfo *top_stream, struct } }else{ if((top_stream->dir & send_stream_dir) == 0){ + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; sapp_runtime_log(RLOG_LV_FATAL, "build_net_layer_ethernet() error! ethernet[%d] asymmetric_addr_layer is enabled, but has not recv this dir packet!\n", stream_pr->layer_index); return -1; } @@ -1540,7 +1544,8 @@ static int build_net_layer_vlan(struct streaminfo_private *stream_pr, int carry_ build_net_multilayer_vlan(in_stream_addr->s2c_addr_array, in_stream_addr->s2c_layer_num, (struct mesa_vlan_detail_hdr *)buf); ///memcpy(buf, in_stream_addr->s2c_addr_array, layer_len); }else{ - sapp_runtime_log(RLOG_LV_FATAL, "build_net_layer_vlan() error, no c2s vlan addr, but asymmetric_addr_layer is set!\n"); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "build_net_layer_vlan() error, no c2s vlan addr, but asymmetric_addr_layer is set!\n"); return -1; } } @@ -1556,7 +1561,8 @@ static int build_net_layer_vlan(struct streaminfo_private *stream_pr, int carry_ //memcpy(buf, in_stream_addr->c2s_addr_array, layer_len); build_net_multilayer_vlan(in_stream_addr->c2s_addr_array, in_stream_addr->c2s_layer_num, (struct mesa_vlan_detail_hdr *)buf); }else{ - sapp_runtime_log(RLOG_LV_FATAL, "build_net_layer_vlan() error, no s2c vlan addr, but asymmetric_addr_layer is set!\n"); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "build_net_layer_vlan() error, no s2c vlan addr, but asymmetric_addr_layer is set!\n"); return -1; } } @@ -1778,7 +1784,8 @@ static int build_net_layer_mpls(struct streaminfo_private *stream_pr, int carry_ layer_len += sizeof(int); } }else{ - sapp_runtime_log(RLOG_LV_FATAL, "build_net_layer_mpls() error, no c2s mpls addr, but asymmetric_addr_layer is set!\n"); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "build_net_layer_mpls() error, no c2s mpls addr, but asymmetric_addr_layer is set!\n"); return -1; } } @@ -1802,7 +1809,8 @@ static int build_net_layer_mpls(struct streaminfo_private *stream_pr, int carry_ layer_len += sizeof(int); } }else{ - sapp_runtime_log(RLOG_LV_FATAL, "build_net_layer_mpls() error, no s2c mpls addr, but asymmetric_addr_layer is set!\n"); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "build_net_layer_mpls() error, no s2c mpls addr, but asymmetric_addr_layer is set!\n"); return -1; } } @@ -1828,7 +1836,8 @@ static int build_net_layer_gtp(struct streaminfo_private *stream_pr, int carry_l if(DIR_C2S == send_stream_dir){ if(0 == p_gtp_layer_addr->teid_c2s){ if(g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_GPRS_TUNNEL][stream_pr->layer_index] != 0){ - sapp_runtime_log(RLOG_LV_FATAL, "build_net_layer_gtp() error, no c2s gtp addr, but asymmetric_addr_layer is set!\n"); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "build_net_layer_gtp() error, no c2s gtp addr, but asymmetric_addr_layer is set!\n"); return -1; }else{ this_pkt_teid = p_gtp_layer_addr->teid_s2c; @@ -1839,7 +1848,8 @@ static int build_net_layer_gtp(struct streaminfo_private *stream_pr, int carry_l }else{ if(0 == p_gtp_layer_addr->teid_s2c){ if(g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_GPRS_TUNNEL][stream_pr->layer_index] != 0){ - sapp_runtime_log(RLOG_LV_FATAL, "build_net_layer_gtp() error, no s2c gtp addr, but asymmetric_addr_layer is set!\n"); + sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "build_net_layer_gtp() error, no s2c gtp addr, but asymmetric_addr_layer is set!\n"); return -1; }else{ this_pkt_teid = p_gtp_layer_addr->teid_c2s; @@ -2445,13 +2455,15 @@ static int __do_kill_tcp(struct streaminfo *stream, const void *ext_raw_pkt, int /* ��MPLS�ǶԳ�����, calc_reserved_hdr_len()��Ҫ�ֲ�ͬ�������, �뵱ǰ��ͬ�� */ reserved_hdr_len = calc_reserved_hdr_len(stream, &low_net_layer_type, stream_pr->stream_public.curdir); if((reserved_hdr_len < 0) || (-1 == low_net_layer_type)){ + sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++; sapp_runtime_log(RLOG_LV_INFO, "__do_kill_tcp() calc_reserved_hdr_len error !"); ret = -1; goto fun_exit; } low_net_layer_type = get_eth_carry_layer_type(stream, stream_pr->stream_public.curdir); if(low_net_layer_type < 0){ - sapp_runtime_log(RLOG_LV_FATAL, "__do_kill_tcp(): can't get ethernet carry layer type"); + sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "__do_kill_tcp(): can't get ethernet carry layer type"); ret = -1; goto fun_exit; } @@ -2461,7 +2473,7 @@ static int __do_kill_tcp(struct streaminfo *stream, const void *ext_raw_pkt, int send_handle->send_buf = packet_io_get_sendbuf(SEND_TYPE_LINK_INJECT, thread_num); - sapp_runtime_log(10, "before build_net_layer_pkt(), buf addr:%p, streamdir:%d, total layer len:%d", send_handle->send_buf, stream->curdir, reserved_hdr_len); + sapp_runtime_log(RLOG_LV_DEBUG, "before build_net_layer_pkt(), buf addr:%p, streamdir:%d, total layer len:%d", send_handle->send_buf, stream->curdir, reserved_hdr_len); send_len = build_net_layer_pkt(stream, stream, stream_pr, ADDR_TYPE_TCP, 0, send_handle->send_buf + reserved_hdr_len, 0, raw_pkt, stream->curdir); if(send_len > 0){ /* �Ĵ����ж���, ����ʧ�ܲ��˳�, �������Է�������� */ @@ -2483,6 +2495,7 @@ static int __do_kill_tcp(struct streaminfo *stream, const void *ext_raw_pkt, int stream_pr->stream_public.curdir, stream_pr->stream_public.routedir, send_len); }else{ + sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++; sapp_runtime_log(RLOG_LV_INFO, "do_kill_tcp()-->build_net_layer_pkt() error, send streamdir:%d, routedir:%d, send_len=%d\n", stream_pr->stream_public.curdir ^ DIR_DOUBLE, stream_pr->stream_public.routedir, send_len); @@ -3300,7 +3313,8 @@ int __sapp_inject_pkt(struct streaminfo *raw_stream, enum sapp_inject_opt sio, /* ��ı���ijЩ�ص�������ԭʼ������ΪIP��ͷ, ���Բ���Ҫ�������ԭʼ��, ��Ϣ���洢��˽�����ṹ���� */ raw_pkt = update_raw_pkt(raw_stream_pr, snd_routedir, &snd_routedir_reverse); if(NULL == raw_pkt){ - sapp_runtime_log(RLOG_LV_FATAL, "sapp_inject_pkt() error, not found raw_pkt!"); + sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "__sapp_inject_pkt() error, not found raw_pkt!"); return -1; } @@ -3318,18 +3332,20 @@ int __sapp_inject_pkt(struct streaminfo *raw_stream, enum sapp_inject_opt sio, reserved_hdr_len = calc_reserved_hdr_len(inject_stream, &low_net_layer_type, send_stream_dir); if(reserved_hdr_len < 0){ - sapp_runtime_log(RLOG_LV_FATAL, "calc_reserved_hdr_len() error"); + sapp_runtime_log(RLOG_LV_FATAL, "__sapp_inject_pkt()->calc_reserved_hdr_len() error"); return -1; } low_net_layer_type = get_eth_carry_layer_type(raw_stream, send_stream_dir); if(low_net_layer_type < 0){ - sapp_runtime_log(RLOG_LV_FATAL, "sapp_inject_pkt(): can't get ethernet carry layer type"); + sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "__sapp_inject_pkt(): can't get ethernet carry layer type"); return -1; } if(payload_len + reserved_hdr_len > MTU_MAX){ - sapp_runtime_log(RLOG_LV_FATAL, "MESA_inject_pkt() error! payload_len too long:%d.\n", + sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++; + sapp_runtime_log(RLOG_LV_INFO, "__sapp_inject_pkt() error! payload_len too long:%d.\n", payload_len + reserved_hdr_len); return -1; } @@ -3504,7 +3520,7 @@ int MESA_sendpacket_ethlayer(int thread_num,const char *data, int data_len, unsi if(data_len > MTU_MAX) { - sapp_runtime_log(30, "MESA_sendpacket_ethlayer(): data length:%d is more than MTU:%d\n", data_len, MTU_MAX); + sapp_runtime_log(RLOG_LV_INFO, "MESA_sendpacket_ethlayer(): data length:%d is more than MTU:%d\n", data_len, MTU_MAX); sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++; return -1; } @@ -4205,7 +4221,8 @@ static int __MESA_sendpacket_iplayer_options(int thread_index,const char *data, inner_ret = ptr_marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index); if(inner_ret < 0){ - sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n"); + sapp_runtime_log(RLOG_LV_INFO, "call marsio_buff_malloc_global() failed!\n"); + sapp_global_val->mthread_volatile[thread_index]->sys_stat.count[SAPP_STAT_SND_ERROR]++; return -1; } @@ -4299,7 +4316,7 @@ int MESA_fakepacket_send_ipv4_options(const struct streaminfo *stream, uint8_t p inner_ret = ptr_marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index); if(inner_ret < 0){ - sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n"); + sapp_runtime_log(RLOG_LV_INFO, "MESA_fakepacket_send_ipv4_options-> marsio_buff_malloc_global() failed!\n"); sapp_global_val->mthread_volatile[thread_index]->sys_stat.count[SAPP_STAT_SND_ERROR]++; return -1; } @@ -4455,7 +4472,7 @@ int MESA_fakepacket_send_tcp_options(const struct streaminfo *stream, inner_ret = ptr_marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index); if(inner_ret < 0){ sapp_global_val->mthread_volatile[thread_index]->sys_stat.count[SAPP_STAT_SND_ERROR]++; - sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n"); + sapp_runtime_log(RLOG_LV_INFO, "MESA_fakepacket_send_tcp_options()-> marsio_buff_malloc_global() failed!\n"); return -1; } @@ -4541,7 +4558,7 @@ int MESA_fakepacket_send_ipv6_tcp_options(const struct streaminfo *stream, inner_ret = ptr_marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index); if(inner_ret < 0){ - sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n"); + sapp_runtime_log(RLOG_LV_INFO, "MESA_fakepacket_send_ipv6_tcp_options-> marsio_buff_malloc_global() failed!\n"); sapp_global_val->mthread_volatile[thread_index]->sys_stat.count[SAPP_STAT_SND_ERROR]++; return -1; } @@ -4705,7 +4722,7 @@ int MESA_fakepacket_send_ipv6_udp_options(const struct streaminfo *stream, inner_ret = ptr_marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index); if(inner_ret < 0){ - sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n"); + sapp_runtime_log(RLOG_LV_INFO, "MESA_fakepacket_send_ipv6_udp_options-> marsio_buff_malloc_global() failed!\n"); sapp_global_val->mthread_volatile[thread_index]->sys_stat.count[SAPP_STAT_SND_ERROR]++; return -1; } diff --git a/src/sapp_dev/sapp_global_val.c b/src/sapp_dev/sapp_global_val.c index 4a23ec4..8cda235 100644 --- a/src/sapp_dev/sapp_global_val.c +++ b/src/sapp_dev/sapp_global_val.c @@ -333,6 +333,7 @@ void sapp_gval_destroy(void) memset((void *)sapp_global_val, 0xFE, sizeof(sapp_global_t)); free(sapp_global_val); + sapp_global_val = NULL; } diff --git a/src/sapp_dev/sapp_plug.c b/src/sapp_dev/sapp_plug.c index 87a577d..9b1e84c 100644 --- a/src/sapp_dev/sapp_plug.c +++ b/src/sapp_dev/sapp_plug.c @@ -213,6 +213,11 @@ void libsapp_destroy_env(void) MESA_ATOMIC_SET(g_destory_env_done, 1); } + if(NULL == sapp_global_val){ + /* �����Ѿ����ù�libsapp_destroy_env(), ����libsapp_setup_env()ʧ���� */ + return; + } + if(CAP_MODEL_PCAP_DUMPFILE == g_packet_io_cap_mode){ exit_process = 1; } diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c index a9f40f0..647b3c7 100644 --- a/test/test_app_sapp.c +++ b/test/test_app_sapp.c @@ -3206,6 +3206,12 @@ char KEEP_STREAM(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_p return APP_STATE_GIVEME; } +char DROP_STREAM_PKT(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet) +{ + return APP_STATE_DROPPKT; +} + + char TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet) { //test_project_add(a_tcp,pme,thread_seq,a_packet); |
