diff options
| author | 杨威 <[email protected]> | 2023-01-11 18:07:11 +0800 |
|---|---|---|
| committer | 杨威 <[email protected]> | 2023-01-11 20:27:58 +0800 |
| commit | 660247773e03be49b107dbe8c58197bc14549edf (patch) | |
| tree | b3b7a081002c3d54e584de34c9893707ca301186 | |
| parent | 8393d32ba6aeec6ff5a1a3143cb3fde2b88a10a4 (diff) | |
🌈 style(packet_io): reduce lint warning
| -rw-r--r-- | src/common/linux_kernel_jhash.c | 5 | ||||
| -rw-r--r-- | src/dealpkt/callapp.c | 5 | ||||
| -rw-r--r-- | src/dealpkt/deal_ipv4.c | 10 | ||||
| -rw-r--r-- | src/dealpkt/deal_ipv6.c | 5 | ||||
| -rw-r--r-- | src/dealpkt/deal_udp.c | 14 | ||||
| -rw-r--r-- | src/dealpkt/stream_manage.c | 4 | ||||
| -rw-r--r-- | src/inner_plug/g_device_plug.cpp | 158 | ||||
| -rw-r--r-- | src/inner_plug/sapp_assistant.cpp | 30 | ||||
| -rw-r--r-- | src/packet_io/packet_io.c | 17 | ||||
| -rw-r--r-- | src/packet_io/packet_io_marsio.c | 140 | ||||
| -rw-r--r-- | src/packet_io/packet_io_status.cpp | 12 | ||||
| -rw-r--r-- | src/packet_io/sendpacket.c | 101 |
12 files changed, 138 insertions, 363 deletions
diff --git a/src/common/linux_kernel_jhash.c b/src/common/linux_kernel_jhash.c index 39c0500..3ca884e 100644 --- a/src/common/linux_kernel_jhash.c +++ b/src/common/linux_kernel_jhash.c @@ -180,7 +180,10 @@ u32 sapp_jhash_4words(u32 a, u32 b, u32 c, u32 initval, u32 *out_val) __jhash_final(a, b, c);
- *out_val = b;
+ if(out_val != NULL)
+ {
+ *out_val = b;
+ }
return c;
}
diff --git a/src/dealpkt/callapp.c b/src/dealpkt/callapp.c index b113634..ec850a5 100644 --- a/src/dealpkt/callapp.c +++ b/src/dealpkt/callapp.c @@ -1,14 +1,13 @@ #include "sapp_api.h"
#include "sapp_private_api.h"
#include "sapp_declaration.h"
-
#include "stream_register.h"
+#include "plugin_serial.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-#include "plugin_serial.h"
-//20170525 liuy add for wy serical
#define CALL_FUN_TYPE_RAW 1
#define CALL_FUN_TYPE_NORAW 2
diff --git a/src/dealpkt/deal_ipv4.c b/src/dealpkt/deal_ipv4.c index 7a23991..65f2c7b 100644 --- a/src/dealpkt/deal_ipv4.c +++ b/src/dealpkt/deal_ipv4.c @@ -884,23 +884,15 @@ int ipv4_frag_init(int thread_count, uint32 hash_size) {
g_ipv4_frag_manage[i].thread_num = i;
-#if USE_MESA_STREAM_HASH
g_ipv4_frag_manage[i].frag_hash_table = ipv4_frag_htable_create();
if(NULL == g_ipv4_frag_manage[i].frag_hash_table){
printf("ipv4_frag_init(): MESA_htable_create fail!\n");
sapp_runtime_log(RLOG_LV_FATAL, "ipv4_frag_init(): MESA_htable_create fail!");
goto err;
}
-#else
- g_ipv4_frag_manage[i].hash_table_size = hash_size;
- g_ipv4_frag_manage[i].frag_hash_table = (struct frag_ipq **)SAPP_GLOBAL_ALLOC(sizeof(void *) * hash_size);
- memset(g_ipv4_frag_manage[i].frag_hash_table, 0, sizeof(void *) * hash_size);
- g_ipv4_frag_manage[i].hash_index = ipv4_frag_hash_index;
- g_ipv4_frag_manage[i].hash_cmp = ipv4_frag_hash_cmp;
-#endif
+
}
- //FRAG_IP4_RANDOM = (unsigned int)time(NULL) ^ 0xABCD9876;
FRAG_IP4_RANDOM = 0xABCD9876;
return 0;
diff --git a/src/dealpkt/deal_ipv6.c b/src/dealpkt/deal_ipv6.c index efa5cfe..b93d526 100644 --- a/src/dealpkt/deal_ipv6.c +++ b/src/dealpkt/deal_ipv6.c @@ -744,7 +744,10 @@ static void set_ipv6_stream(struct streaminfo_private *pfstream_pr, struct strea pstream->routedir=routedir;
pstream->threadnum=thread_num;
- pstream_pr->layer_index = pfstream_pr->layer_index + 1;
+ if(pfstream_pr != NULL)
+ {
+ pstream_pr->layer_index = pfstream_pr->layer_index + 1;
+ }
}
diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c index eb47d5e..7b24aeb 100644 --- a/src/dealpkt/deal_udp.c +++ b/src/dealpkt/deal_udp.c @@ -20,6 +20,13 @@ int copy_ipport_union_addr(struct streaminfo *pstream_heap, struct streaminfo *p extern int guess_if_teredo(const struct streaminfo *pstream, struct mesa_udp_hdr *udphdr); extern int g_overlay_layer_set[__ADDR_TYPE_MAX][SAPP_SUPPORT_LAYER_NUM_MAX]; + +extern int vxlan_entry(struct streaminfo_private *pfstream_pr,const void *this_layer_hdr,int thread_num, + unsigned char routedir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr); +extern int stream_process_overlay_udp(struct streaminfo *a_udp, const void *this_iphdr, const void *transport_hdr, + const raw_pkt_t * raw_pkt,void **apme,unsigned char *popstate); +extern int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_pkt_t *rawpkt); + int G_UDP_FLOW_STAT_PROJECT_ID = -1; int G_UDP_TEREDO_IDENTIFY_PROJECT_ID = -1; @@ -467,6 +474,8 @@ static int dealipv4udppkt_dup_check(int tid, struct streaminfo_private *pstream_ return is_dup_pkt; } + + int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr * this_iphdr, int thread_num,unsigned char routedir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr) { @@ -684,7 +693,7 @@ int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr * this_ } - if(pdetail_pr->offload_stream_flag==SMART_OFFLOAD_FLAG_UDP + if(pdetail_pr!=NULL&&pdetail_pr->offload_stream_flag==SMART_OFFLOAD_FLAG_UDP && pstream_pr->stream_carry_up_layer_tunnel_type==STREAM_TUNNLE_NON && DROP!=ret && (g_CurrentTime > pdetail_pr->offload_stream_timestamp_s)) @@ -918,7 +927,8 @@ int dealipv6udppkt(struct streamindex *pindex,const struct mesa_ip6_hdr *a_packe udp_cleardata(pstream); } - if(pdetail_pr->offload_stream_flag==SMART_OFFLOAD_FLAG_UDP + if(pdetail_pr!=NULL + &&pdetail_pr->offload_stream_flag==SMART_OFFLOAD_FLAG_UDP && pstream_pr->stream_carry_up_layer_tunnel_type==STREAM_TUNNLE_NON && DROP!=ret && (g_CurrentTime > pdetail_pr->offload_stream_timestamp_s)) diff --git a/src/dealpkt/stream_manage.c b/src/dealpkt/stream_manage.c index 34fda10..775e9e3 100644 --- a/src/dealpkt/stream_manage.c +++ b/src/dealpkt/stream_manage.c @@ -2797,7 +2797,7 @@ int find_streaminfo_by_addrv4(int thread_index, const struct stream_tuple4_v4 *t const struct global_stream *this_thread_stream = G_MESA_GLOBAL_STREAM[thread_index]; struct streamindex **phashstream=NULL; struct streamindex *stream_hash_head = NULL; - unsigned int hash_index, hash_max, no_use_slave_hash; + unsigned int hash_index, hash_max; int ret, match_layer_dir; /* �������Ԫ�����˿���ΪԴ�Ĺ���һ�� */ int tot_found_stream_num = 0; @@ -2854,7 +2854,7 @@ int find_streaminfo_by_addrv4(int thread_index, const struct stream_tuple4_v4 *t match_layer_dir = 0; } } - hash_index = sapp_jhash_4words(a,b,c,d, &no_use_slave_hash) % hash_max; + hash_index = sapp_jhash_4words(a,b,c,d, NULL) % hash_max; #else extern unsigned int tuple4_v4_make_crc_hash(const struct stream_tuple4_v4 *tuple4_v4); hash_index = tuple4_v4_make_crc_hash(tuplev4) % hash_max; diff --git a/src/inner_plug/g_device_plug.cpp b/src/inner_plug/g_device_plug.cpp index 78b6007..fa307fe 100644 --- a/src/inner_plug/g_device_plug.cpp +++ b/src/inner_plug/g_device_plug.cpp @@ -221,28 +221,6 @@ static int gdev_keepalive_bfd_plug(const raw_pkt_t *raw_pkt, int thread_id, unsi int service_id = 0; int action; -#if 0 /* ��ΪUDP���, ��gdev_bfd_pkt_identify�Ѿ��жϹ�, �����ٴ��ж� */ - if(ntohs(eth_hdr->ether_type) != ETHERTYPE_IP){ - return -1; - } - - if(ip_hdr->ip_p != IPPROTO_UDP){ - return -1; - } - - if(ntohs(udp_hdr->uh_dport) != BFD_DEFAULT_PORT){ - return -1; - } - - if(memcmp(&ip_hdr->ip_dst.s_addr, &sendto_gdev_card_ip, sizeof(int)) != 0){ - return -1; - } - - if(payload_len != (int)sizeof(bfd_header_t)){ - return -1; - } -#endif - service_id = vxlan_sport_map_to_service_id(ntohs(udp_hdr->uh_sport)); action = gdev_kp_action_judge(service_id); @@ -272,31 +250,30 @@ static int gdev_keepalive_bfd_plug(const raw_pkt_t *raw_pkt, int thread_id, unsi sendpacket_build_ethernet(raw_eth_hdr->ether_shost, raw_eth_hdr->ether_dhost, ETH_P_IP, NULL, 0, send_buf); sendpacket_build_udp_dual_stack(ntohs(udp_hdr->uh_sport), /* BFDЭ�鲻����Դ��Ŀ�Ķ˿� */ - ntohs(udp_hdr->uh_dport), - (char *)bfd_send_hdr, - payload_len, - payload_len, - send_buf + SENDPACKET_ETH_H + SENDPACKET_IP_H); - - sendpacket_build_ipv4(SENDPACKET_UDP_H + payload_len, - 0, - ntohs(ip_hdr->ip_id), - ntohs(ip_hdr->ip_off), - ip_hdr->ip_ttl, - IPPROTO_UDP, - ip_hdr->ip_dst.s_addr, - ip_hdr->ip_src.s_addr, /* ����Դ��Ŀ��IP��ַ */ - NULL, 0, - send_buf + SENDPACKET_ETH_H); - - sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, - IPPROTO_IP, - SENDPACKET_IP_H); - - sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, - IPPROTO_UDP, - payload_len + SENDPACKET_UDP_H); - + ntohs(udp_hdr->uh_dport), + (char *)bfd_send_hdr, + payload_len, + payload_len, + send_buf + SENDPACKET_ETH_H + SENDPACKET_IP_H); + + sendpacket_build_ipv4(SENDPACKET_UDP_H + payload_len, + 0, + ntohs(ip_hdr->ip_id), + ntohs(ip_hdr->ip_off), + ip_hdr->ip_ttl, + IPPROTO_UDP, + ip_hdr->ip_dst.s_addr, + ip_hdr->ip_src.s_addr, /* ����Դ��Ŀ��IP��ַ */ + NULL, 0, + send_buf + SENDPACKET_ETH_H); + + sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, + IPPROTO_IP, + SENDPACKET_IP_H); + + sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, + IPPROTO_UDP, + payload_len + SENDPACKET_UDP_H); return SENDPACKET_IP_H + SENDPACKET_UDP_H+sizeof(bfd_header_t) + sizeof(struct mesa_ethernet_hdr); } @@ -317,31 +294,30 @@ static int gdev_keepalive_icmp_plug(const raw_pkt_t *raw_pkt, int thread_id, uns sendpacket_build_ethernet(raw_eth_hdr->ether_shost, raw_eth_hdr->ether_dhost, ETH_P_IP, NULL, 0, send_buf); - sendpacket_build_icmpv4_echo(ICMP_ECHOREPLY, 0, 0, - ntohs(icmp_hdr->icd_id), - ntohs(icmp_hdr->icd_seq), - icmp_payload, - icmp_payload_len, - send_buf + SENDPACKET_ETH_H + SENDPACKET_IP_H); - - sendpacket_build_ipv4(icmp_payload_len + sizeof(struct mesa_icmp_echo_hdr), - 0, 0x1234, 0, 64, IPPROTO_ICMP, - ip_hdr->ip_dst.s_addr, - ip_hdr->ip_src.s_addr, - NULL, 0, - send_buf + SENDPACKET_ETH_H); - memcpy(send_buf + SENDPACKET_ETH_H+SENDPACKET_IP_H+sizeof(struct mesa_icmp_echo_hdr), - icmp_payload, - icmp_payload_len); - - - sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, - IPPROTO_IP, - SENDPACKET_IP_H); - - sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, - IPPROTO_ICMP, - icmp_payload_len + sizeof(struct mesa_icmp_echo_hdr)); + sendpacket_build_icmpv4_echo(ICMP_ECHOREPLY, 0, 0, + ntohs(icmp_hdr->icd_id), + ntohs(icmp_hdr->icd_seq), + icmp_payload, + icmp_payload_len, + send_buf + SENDPACKET_ETH_H + SENDPACKET_IP_H); + + sendpacket_build_ipv4(icmp_payload_len + sizeof(struct mesa_icmp_echo_hdr), + 0, 0x1234, 0, 64, IPPROTO_ICMP, + ip_hdr->ip_dst.s_addr, + ip_hdr->ip_src.s_addr, + NULL, 0, + send_buf + SENDPACKET_ETH_H); + memcpy(send_buf + SENDPACKET_ETH_H + SENDPACKET_IP_H + sizeof(struct mesa_icmp_echo_hdr), + icmp_payload, + icmp_payload_len); + + sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, + IPPROTO_IP, + SENDPACKET_IP_H); + + sendpacket_do_checksum(send_buf + SENDPACKET_ETH_H, + IPPROTO_ICMP, + icmp_payload_len + sizeof(struct mesa_icmp_echo_hdr)); return ntohs(ip_hdr->ip_len) + sizeof(struct mesa_ethernet_hdr); } @@ -384,41 +360,11 @@ static int gdev_keepalive_plug(const raw_pkt_t *raw_pkt, int thread_id, unsigned return -1; } -#if 0 - snd_eth_hdr = (struct mesa_ethernet_hdr *)snd_handle->send_buf; - memcpy(snd_eth_hdr->ether_shost, raw_eth_hdr->ether_dhost, ETHER_ADDR_LEN); - memcpy(snd_eth_hdr->ether_dhost, raw_eth_hdr->ether_shost, ETHER_ADDR_LEN); - snd_eth_hdr->ether_type = ntohs(ETHERTYPE_IP); - - ///MESA_sendpacket_ethlayer(thread_id, (char *)snd_handle->send_buf, send_len + 14, 0); - - marsio_buff_t *send_mbuf[1]; - char *real_buf; - - ret = ptr_marsio_buff_malloc_global(gdev_plug_extern_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_id); - if(ret < 0){ - goto err; - } - /* �˴�ʹ��append������mtod, append�ڲ�ʵ�ʰ�����set datalen�IJ��� */ - real_buf = ptr_marsio_buff_append(send_mbuf[0], send_len + 14); - if(NULL == real_buf){ - ptr_marsio_buff_free(gdev_plug_extern_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_id); - goto err; - } - - memcpy(real_buf, snd_handle->send_buf, send_len + 14); /* send_lenû����mac��ַ */ - - ret = marsio_send_burst_with_options_for_tcpdumpmesa((struct mr_sendpath *)g_packet_device_alias[0].dl_io_param, - thread_id, send_mbuf, 1, MARSIO_SEND_OPT_FAST); - /* mbuf ��������Զ��ͷ� */ -#else ret = packet_io_send(snd_handle, send_len, SEND_TYPE_LINK_INJECT, __ADDR_TYPE_IP_PAIR_V4, dir, thread_id, (char *)KILL_TCP_PHONY_POINTER, (int *)KILL_TCP_PHONY_POINTER, raw_pkt); -#endif - packet_io_free_sendbuf(SEND_TYPE_LINK_INJECT, thread_id); return ret; @@ -492,7 +438,6 @@ static void gdev_keepalive_update_local_log(void) char cur_time_str[64]; char tmp_ip_str[INET6_ADDRSTRLEN]; const char *tmp_keealive_type; - time_t last_op_time; const gdev_keepalive_status_per_thread_t *this_thread_stat; const gdev_keepalive_status_per_dev_t *this_dev_stat; @@ -554,7 +499,7 @@ static void gdev_keepalive_update_fs2(void) { const gdev_keepalive_status_per_thread_t *this_thread_stat; const gdev_keepalive_status_per_dev_t *this_dev_stat; - int dev_index, thread_seq, service_index; + int dev_index, thread_seq; int platform_thread_num; platform_thread_num = get_thread_count(); @@ -852,13 +797,13 @@ int gdev_keepalive_set_opt(const SAPP_TLV_T *tlv_value) if(last_log_time < g_CurrentTime){ last_log_time = g_CurrentTime; MESA_handle_runtime_log(gdev_kp_log_handle, 20, "[gdev_keepalive]", "set gdev-keepalive error! service:%d, action:%d", - actual_val->service_num, actual_val->keepalive_switch); + actual_val->service_num, actual_val->keepalive_switch); } }else{ if(last_log_time < g_CurrentTime){ last_log_time = g_CurrentTime; MESA_handle_runtime_log(gdev_kp_log_handle, 10, "[gdev_keepalive]", "set gdev-keepalive, service:%d, action:%d", - actual_val->service_num, actual_val->keepalive_switch); + actual_val->service_num, actual_val->keepalive_switch); } } } @@ -1025,7 +970,6 @@ int gdev_keepalive_plug_init(void) inet_pton(AF_INET, tmp_ip_buf, &sendto_gdev_card_ip); MESA_load_profile_int_def((char *)ABBR_INLINE_DEV_CONF_FILE, (char *)"Module", (char *)"default_keepalive_action", &g_dev_keepalive_default_action, 1); - ///MESA_load_profile_int_def((char *)ABBR_INLINE_DEV_CONF_FILE, (char *)"Module", (char *)"gdev_status_switch", &GDEV_KEEPALIVE_LOG_SWITCH, 1); for(i = 0; i < MAX_VXLAN_SERVICE_NUM; i++){ diff --git a/src/inner_plug/sapp_assistant.cpp b/src/inner_plug/sapp_assistant.cpp index 8cddd49..856c238 100644 --- a/src/inner_plug/sapp_assistant.cpp +++ b/src/inner_plug/sapp_assistant.cpp @@ -130,8 +130,7 @@ static inline unsigned long long __get_platform_opt_traffic(int ctype, sapp_sys_ /* 2017-09-04 lijia add, for ��������, �����ȡƽ̨�ڲ����� */ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_val_len) { - int i, ret = 0; - unsigned long long tmp_long; + int ret = 0; if((NULL == opt_val) || (NULL == opt_val_len) || (*opt_val_len <= 0)){ return -1; @@ -158,7 +157,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_RCV_ETHERNET);; + *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_RCV_ETHERNET);; } break; @@ -318,7 +317,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_IPV4_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_IPV4_OUTBOUND); ; } break; @@ -331,7 +330,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_IPV4_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_IPV4_OUTBOUND); ; } break; @@ -369,7 +368,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_IPV6_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_IPV6_OUTBOUND); ; } break; @@ -382,7 +381,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_IPV6_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_IPV6_OUTBOUND); ; } break; @@ -420,7 +419,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_TCP_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_TCP_OUTBOUND); ; } break; @@ -433,7 +432,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_TCP_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_TCP_OUTBOUND); ; } break; @@ -473,7 +472,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_UDP_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_UDP_OUTBOUND); ; } break; @@ -487,7 +486,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va break; } unsigned long long *tot_byte = (unsigned long long *)opt_val; - *tot_byte = *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_UDP_OUTBOUND); + *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_UDP_OUTBOUND); ; } break; @@ -541,7 +540,6 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va } time_t cur_time = g_CurrentTime; struct tm date_loc; - int ret; localtime_r(&cur_time, &date_loc); ret = snprintf((char *)opt_val, *opt_val_len, "%04d-%02d-%02d %02d:%02d:%02d", @@ -1117,9 +1115,6 @@ static int fs2_tcp_unorder_historgram_init(void *fs2_handle) /************************ C++ compiler **************************************/ static int sapp_fs2_init(void) { - char cfg_ip_str[32]; - char fs_name[1024]; - int cfg_port; int fs2_opt; int cycle; int send_historgram = 0; @@ -1311,10 +1306,7 @@ static int sapp_fs2_init(void) 1, //���ٵ���Сֵ 1000000, //���ٵ����ֵ 2); //���ȣ���С�����λ����Χ1~4 - if (send_historgram == 0) - { - FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &pfs_para->fs_latency_id_array[i], sizeof(int)); - } + FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &pfs_para->fs_latency_id_array[i], sizeof(int)); } if (fs2_plug_entry_historgram_init(fs2_handle) < 0) diff --git a/src/packet_io/packet_io.c b/src/packet_io/packet_io.c index fe807ed..cd9285f 100644 --- a/src/packet_io/packet_io.c +++ b/src/packet_io/packet_io.c @@ -2,6 +2,9 @@ #include "sapp_private_api.h" #include "sapp_declaration.h" #include "support/MESA_feedback.h" + +#include "breakpad_mini.h" + /* 2015-04-15 ƽ̨ʵʱ������������ݰ�, ��sizeָ����С, �������100MB, @@ -578,7 +581,7 @@ static int packet_io_strip_L2E_hdr(raw_pkt_t *p_raw_pkt, unsigned char dir, int extern void sapp_fs2_set_latency(int thead_seq, long long time_cost); extern char (*g_platform_action_cb_fun)(int net_conn_mode, char plug_action); - +extern void sapp_fs2_fuzzy_latency_update_per_thread(int thead_seq, long long time_cost); static int mesa_default_pkt_cb(const raw_pkt_t *p_raw_pkt, unsigned char dir, int thread_num) { @@ -1010,7 +1013,7 @@ retry: static int packet_io_get_sendroute_mac(char dev_id, char link_id, unsigned char *out_mac_addr) { char *p_mac_addr = (char *)&g_send_gateway_mac_table[dev_id][link_id][0]; - if(G_SND_ROUTE_INFO_NUM <= 0 || strlen(p_mac_addr) <= 0){ + if(G_SND_ROUTE_INFO_NUM <= 0 || strlen(p_mac_addr) == 0){ return -1; }else{ if(MESA_mac_pton(p_mac_addr, ':', (char *)out_mac_addr) < 0){ @@ -1049,7 +1052,7 @@ static int packet_io_send_by_manual_conf(MESA_send_handle *send_handle,int datal unsigned char send_route_mac[MAC_ADDR_LEN] = ""; unsigned char *p_dst_mac; - if(sapp_global_val->config.packet_io.inject_pkt_mode == SEND_PKT_MODE_STACK_2_LAYER_MUTI_ROUTE ) + if (sapp_global_val->config.packet_io.inject_pkt_mode == SEND_PKT_MODE_STACK_2_LAYER_MUTI_ROUTE) { ret = packet_io_get_sendroute_mac(mim_mem_hdr.dev_id, mim_mem_hdr.link_id, send_route_mac); if(ret < 0){ @@ -1062,7 +1065,7 @@ static int packet_io_send_by_manual_conf(MESA_send_handle *send_handle,int datal { p_dst_mac = (unsigned char *)sapp_global_val->config.packet_io.inject_mode_single_gateway_dst_mac; } - sendpacket_build_ethernet(p_dst_mac, sapp_global_val->config.packet_io.inject_mode_single_gateway_src_mac, ether_type, NULL, 0, send_handle->send_buf); + sendpacket_build_ethernet(p_dst_mac, (unsigned char *)sapp_global_val->config.packet_io.inject_mode_single_gateway_src_mac, ether_type, NULL, 0, send_handle->send_buf); send_again: @@ -1220,7 +1223,7 @@ int parse_send_gdev_ip_conf(const char *profile_path) //del_last_rn(conf_buf, 1024); - ret = sscanf(conf_buf, "%d\t%s", &dev_id, ip_addr); + ret = sscanf(conf_buf, "%d\t%31s", &dev_id, ip_addr); if(ret != 2 || dev_id >= 64 || strlen(ip_addr) >= 32) { @@ -1262,7 +1265,7 @@ int parse_send_route_conf(const char *profile_path) //del_last_rn(conf_buf, 1024); - ret = sscanf(conf_buf, "%d\t%d\t%s", &dev_id, &link_id, mac_addr); + ret = sscanf(conf_buf, "%d\t%d\t%17s", &dev_id, &link_id, mac_addr); if(ret != 3 || dev_id >= 64 || link_id >= 16 || strlen(mac_addr) >= 18) { @@ -1403,6 +1406,8 @@ void sapp_breakpad_destroy(void) breakpad_destroy(sapp_global_val->individual_fixed.breakpad); } +extern void sapp_log_handle_destroy(void); + void packet_io_exit(void) { int i; diff --git a/src/packet_io/packet_io_marsio.c b/src/packet_io/packet_io_marsio.c index 1eb84c5..4aab1a5 100644 --- a/src/packet_io/packet_io_marsio.c +++ b/src/packet_io/packet_io_marsio.c @@ -162,16 +162,7 @@ int marsio_dl_io_set_capdev_parallel(const char *cap_dev) } /* marsioģʽ֧�ֶ�����, ���ŷָ�ģʽ */ -#if 0 - MESA_load_profile_string_def((char *)"conf/main.conf", (char *)"Module", (char *)"pcapdevice", cfg_name_from_conf, 1024, ""); - if('\0' == cfg_name_from_pag_conf[0]){ - printf("\033[1;31;40m[Error]Can't get pcap device from ./conf/main.conf!\033[0m\n"); - return -1; - } -#else strncpy(cfg_name_from_conf, sapp_global_val->config.packet_io.internal.interface.name, sizeof(cfg_name_from_conf)); -#endif - tmp_cap_dev_name = cfg_name_from_conf; while((single_device = strtok_r(tmp_cap_dev_name, delim, &save_ptr)) != NULL){ @@ -235,7 +226,7 @@ int marsio_dl_io_set_capture_filter(const char *filter_rule) memset(&g_marsio_bpf_counter, 0, sizeof(g_marsio_bpf_counter)); g_marsio_have_bpf=0; - if(strlen(filter_rule) <= 0)return -1; + if(strlen(filter_rule) == 0)return -1; int i,j; int pcap_link_type = DLT_EN10MB; @@ -291,40 +282,14 @@ unsigned char *marsio_dl_io_get_sendbuf(void *phandle, int thread_seq) { marsio4_io_handle *mr4_handle = (marsio4_io_handle *)phandle; - - -#if 0 - int ret; - /* NOTE - ����������marsio�ڴ�, ʵ����ʱ�洢��mr4_handle->send_mbuf, - Ȼ��mbuf->data��ʵ�ʵ�����, - ����ģʽ����Ҫ�������һ�η��ͱ��뱣֤malloc��free�ɶ�ʹ��! - */ - ret = marsio_buff_malloc_global(sapp_marsio4_instance, mr4_handle->send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_seq); - if(ret < 0){ - return NULL; - } - g_SysInputInfo[thread_index][PKT_MARSIO_MALLOC]++; - data_buf = (unsigned char *)marsio_buff_mtod(mr4_handle->send_mbuf[0]); -#else - /* ����ʱ, ��Ҫmbuf�ṹ, ���˺����ӿ���ֱ�ӷ���mbuf, ���ǵ���marsio_buff_mtod()֮�����ʵ���ݻ�����, ��ʱʹ��malloc */ - mr4_handle->send_mbuf_mtod_ptr = malloc(SENDPACKET_PACKET_SIZE); -#endif return (unsigned char *)mr4_handle->send_mbuf_mtod_ptr; } void marsio_dl_io_free_sendbuf(void *phandle, int thread_seq) { marsio4_io_handle *mr4_handle = (marsio4_io_handle *)phandle; - -#if 0 /* marsio �ײ㷢������Զ�free, ����Ҫ��ʽfree */ - marsio4_io_handle *mr4_handle = (marsio4_io_handle *)phandle; - - marsio_buff_free(sapp_marsio4_instance, mr4_handle->send_mbuf, 1, -1, thread_seq); -#else free(mr4_handle->send_mbuf_mtod_ptr); -#endif return; } @@ -337,13 +302,9 @@ static void marsio_pkt_dump(int thread_seq, const marsio_buff_t *send_mbuf, enum return; } - //to_tcpdump_mesa.magic_num = RAW_PKT_MAGIC_NUM; to_tcpdump_mesa.low_layer_type = ADDR_TYPE_MAC; to_tcpdump_mesa.raw_pkt_data = ptr_marsio_buff_mtod((marsio_buff_t *)send_mbuf); to_tcpdump_mesa.raw_pkt_len = ptr_marsio_buff_buflen((marsio_buff_t *)send_mbuf); - //to_tcpdump_mesa.__lib_raw_pkt_data = to_tcpdump_mesa.raw_pkt_data; - //to_tcpdump_mesa.__lib_raw_pkt_len = to_tcpdump_mesa.raw_pkt_len; - cycle_pkt_dump_by_classify(thread_seq, &to_tcpdump_mesa, PKT_CLASSIFY_INJECT); } @@ -390,16 +351,9 @@ int marsio_dl_io_raw_pkt_send(void *phandle, unsigned char *data,int datalen, vo ret = ptr_marsio_send_burst_with_options((struct mr_sendpath *)arg, thread_seq, send_mbuf, 1, send_option); if(ret < 0){ - //����ʧ��marsio�Զ�free - //ptr_marsio_buff_free(sapp_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_seq); return -1; } - marsio_pkt_dump(thread_seq, send_mbuf[0], PKT_CLASSIFY_INJECT); - - /* ���ͽӿ��Զ�free */ - //marsio_buff_free(sapp_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_seq); - return datalen; } @@ -407,11 +361,7 @@ int marsio_dl_io_low_level_send(void *phandle, UINT8 *data,int datalen, int eth_carry_layer_addr_type, int dir,int thread_num,const raw_pkt_t *raw_pkt) { int ret; - struct mesa_ethernet_hdr *ehdr = (struct mesa_ethernet_hdr *)data; - - ///ehdr->ether_type = ntohs(ETHERTYPE_IP);/* �ײ���Ϊethernet */ - //��˫������ģʽ(transparent)��, ����dirѡ��up or down device����. if(NET_CONN_SERIAL_2CARD == g_marsio4_topology_mode){ assert((dir >= 0) && (dir <= 1)); @@ -429,12 +379,11 @@ int marsio_dl_io_smart_offload(int device_index, unsigned char *pkt_ptr, int pkt if(ptr_marsio_buff_malloc_smartoffload!=NULL && ptr_marsio_send_burst_with_options!=NULL) { /* for all vxlan pkts, create an offload request */ - marsio_buff_t * offload_request_buf = ptr_marsio_buff_malloc_smartoffload(g_mr4_dev_up_handle_set[device_index], pkt_ptr, pkt_len); + marsio_buff_t * offload_request_buf = ptr_marsio_buff_malloc_smartoffload(g_mr4_dev_up_handle_set[device_index], (const char *)pkt_ptr, pkt_len); if(offload_request_buf==NULL) { return 0; } - /* inject the offload request */ ptr_marsio_send_burst_with_options(g_mr4_sendpath_up_set[device_index], thread_num, &offload_request_buf, 1, MARSIO_SEND_OPT_CTRL); return 1; @@ -486,7 +435,6 @@ void * marsio_dl_io_device_alias(unsigned int target_id, char *device_args) /* ʹ������ַ��Ƚ�, ��ֹ"eth12", "eth1"�Ƚϵ���ȵ�BUG */ if(strncasecmp(device_args, g_mr4_up_device_name[i], MAX(len1, len2)) == 0){ return (void *)g_mr4_sendpath_up_set[i]; - break; } } @@ -496,7 +444,6 @@ void * marsio_dl_io_device_alias(unsigned int target_id, char *device_args) /* ʹ������ַ��Ƚ�, ��ֹ"eth12", "eth1"�Ƚϵ���ȵ�BUG */ if(strncasecmp(device_args, g_mr4_down_device_name[i], MAX(len1, len2)) == 0){ return (void *)g_mr4_sendpath_down_set[i]; - break; } } } @@ -510,7 +457,6 @@ void * marsio_dl_io_device_alias(unsigned int target_id, char *device_args) /* ʹ������ַ��Ƚ�, ��ֹ"eth12", "eth1"�Ƚϵ���ȵ�BUG */ if(strncasecmp(device_args, tmp_vdevice_name[i], MAX(len1, len2)) == 0){ return (void *)tmp_vdevice_sendpath[i]; - break; } } /* û�ҵ�, ���豸, ���洢���;�� */ @@ -530,10 +476,8 @@ void * marsio_dl_io_device_alias(unsigned int target_id, char *device_args) printf("\033[41m[Error]Can't open device '%s'!\033[0m\n", device_args); return NULL; } - t_sendpath = ptr_marsio_sendpath_create_by_vdev(t_vdev); tmp_vdevice_sendpath[tmp_vdevice_num] = t_sendpath; - tmp_vdevice_num++; /* �����¼����� */ return t_sendpath; @@ -562,17 +506,6 @@ static inline int calc_integer_bit_num(unsigned long long num) return bit_num; } - - -#if 0 -static int marsio4_pkt_forward_for_2card_mode(int tid, struct mr_sendpath * sendpath, marsio_buff_t * mbufs[], int nr_mbufs) -{ - //TODO, pcap1->pcap2, pcap2->pcap1 - abort(); - return 0; -} -#endif - static int marsio4_pkt_forward_for_gdev_mode(int tid, struct mr_sendpath * sendpath, marsio_buff_t * mbuf) { char tmp_mac[6]; @@ -594,8 +527,6 @@ static int marsio4_pkt_forward(int tid, struct mr_sendpath * sendpath, marsio_bu ctrl_zone = (struct mr_tunnat_ctrlzone *)ptr_marsio_buff_ctrlzone(mbufs, 0); /* ������ȡ, ���������������, vxlan��������װģʽ����ʹ��, Ҫ��ÿ��mbuf�жϵײ��װģʽ */ - - //if(ctrl_zone->__encap_len > 0){ /* 2018-06-01, marsio vxlan mode, ��vxlan��װ�İ����ܻ�ע */ if((ctrl_zone->action & TUNNAT_CZ_ACTION_FORWARD) || (0 != sapp_global_val->config.packet_io.packet_io_tunnel.l2_l3_tunnel_support)){ /* 20201010 lijia modify, ����overlay��mrtunnat��ģʽ��, ctrl_zone�ǿ�, Ĭ�϶���ע */ @@ -611,13 +542,6 @@ static int marsio4_pkt_forward(int tid, struct mr_sendpath * sendpath, marsio_bu { ret = -1; } - -#if 0 /* 2018-06-01 close, marsio�ò�������ͨ����ģʽ */ - else{ /* standard ethernet */ - ret = marsio4_pkt_forward_for_gdev_mode(tid, sendpath, mbufs); - } -#endif - return ret; } @@ -667,31 +591,12 @@ static inline int marsio4_pkt_hand(int tid, marsio_buff_t *rx_buff, raw_pkt_t *r return ret; } -#if 0 -/* - �ж�gdevģʽ��, �ײ����ݰ�����, - ethernteģʽ��, �ǿ�smac��ַ�����һ��bit; - vxlanģʽ��, ȡvxlan_hdr->dir��λ; -*/ -static unsigned char gdev_route_dir(const marsio_buff_t * rx_buff) -{ - struct mr_tunnat_ctrlzone *mr_ctrlzone = (struct mr_tunnat_ctrlzone *)marsio_buff_ctrlzone(rx_buff, 0); - - - return mr_ctrlzone->route_dir; -} -#endif - static int marsio4_process_packet(int tid, raw_pkt_t *raw_pkt) { int i,j,k, pkt_num = 0; marsio_buff_t * rx_buff[MARSIO_BURST_PKT_MAX]; /* ����豸֮���Ǵ��л�ȡ, ̫�������ܵ�, ̫���������ʱ�� */ int rcv_res, hand_res; -#if TIME_DELAY_MONITOR - struct timespec curtime; - unsigned long long driver, recv_from_driver; -#endif if((__NET_CONN_PARALLEL & g_marsio4_topology_mode) != 0){ for(i = 0; i < g_mr4_device_num; i++){ rcv_res = ptr_marsio_recv_burst(g_mr4_dev_up_handle_set[i], tid, rx_buff, marsio4_burst_process_pkt_num); @@ -715,29 +620,18 @@ static int marsio4_process_packet(int tid, raw_pkt_t *raw_pkt) rcv_res = ptr_marsio_recv_burst(g_mr4_dev_up_handle_set[i], tid, rx_buff, 16); if(rcv_res > 0){ for(j = 0; j < rcv_res; j++){ -#if TIME_DELAY_MONITOR - driver = marsio_buff_get_timestamp(rx_buff[j]); - clock_gettime(CLOCK_MONOTONIC, &curtime); - recv_from_driver = curtime.tv_nsec ; - if(recv_from_driver > driver){ // cross second - timestamp_region_update_driver(tid, recv_from_driver - driver); - } -#endif raw_pkt->device_index = i; hand_res = marsio4_pkt_hand(tid, rx_buff[j], raw_pkt, DIR_ROUTE_UP); /* ��marsio4_pkt_hand()����dir */ if((g_marsio4_topology_mode & __NET_CONN_SERIAL) && (PASS == hand_res)){ /* NOTE: MARSIO����ģʽ������, �����������հ�, ��Ҫͨ������������ע��, */ -#if 1 int ret = marsio4_pkt_forward(tid, g_mr4_sendpath_up_set[i], rx_buff[j]); if(ret < 0) { ptr_marsio_buff_free(sapp_marsio4_instance, &rx_buff[j], 1, MARSIO_SOCKET_ID_ANY, tid); } -#else - MESA_sendpacket_ethlayer(tid, marsio_buff_mtod(rx_buff[j]), marsio_buff_buflen(rx_buff[j]), 0); -#endif + }else{ /* ����ģʽ��ֻ�ܵ���free, �п���batch�յ�N������, ij������Ҫ��ע, ij��������Ҫ */ ptr_marsio_buff_free(sapp_marsio4_instance, &rx_buff[j], 1, MARSIO_SOCKET_ID_ANY, tid); @@ -804,14 +698,6 @@ static inline void marsio4_sleep(int tot_call_times, int rcv_pkt_times) if((work_percent < 90.0) && (marsio4_sleep_time_table[(int)work_percent] > 0)){ sapp_usleep(marsio4_sleep_time_table[(int)work_percent]); } - -/* - static float max_work_percent = 0.0; - if(work_percent > max_work_percent){ - max_work_percent = work_percent; - printf("max_work_percent = %f\n", max_work_percent); - } -*/ } /* ������ģʽ��, marsio�����л���, ���°�����ʱ��Ҫ����ˢ�¶����е����� */ @@ -904,7 +790,6 @@ static void *marsio4_worker(void *arg) polling_work_times = 0; } } - return NULL; } @@ -1094,7 +979,6 @@ static int marsio_dl_get_function_entry(void) return 0; } - int marsio_send_burst_with_options_for_tcpdumpmesa(struct mr_sendpath * sendpath, queue_id_t sid, marsio_buff_t * mbufs[], int nr_mbufs, uint16_t options) { @@ -1144,7 +1028,6 @@ int marsio_set_vlan_id_to_mbuff(void *pkt_reference, unsigned int vlan_id_host_o int marsio_dl_io_init(int argc, char *argv[]) { int i, ret; - char bind_mask_string[128]; char app_name[32]; int max_send_queue_num; @@ -1174,21 +1057,6 @@ int marsio_dl_io_init(int argc, char *argv[]) g_mario4_io_handle = (marsio4_io_handle *)SAPP_GLOBAL_ALLOC(sizeof(marsio4_io_handle) * g_marsio4_work_thread_num); ptr_marsio_option_set(sapp_marsio4_instance, MARSIO_OPT_THREAD_NUM, &g_marsio4_work_thread_num, sizeof(int)); -#if 0 - if(marsio4_thread_bind_mask != 0){ - ret = ptr_marsio_option_set(sapp_marsio4_instance, MARSIO_OPT_THREAD_MASK, &marsio4_thread_bind_mask, sizeof(long)); - if(ret < 0){ - printf("\033[1;31;40m[Error] marsio set CPU-MASK '%lx' failed!\033[0m\n", marsio4_thread_bind_mask); - } - } -#elif 0 - if(sapp_global_val->config.cpu.bind_mask != 0){ - ret = ptr_marsio_option_set(sapp_marsio4_instance, MARSIO_OPT_THREAD_MASK, &sapp_global_val->config.cpu.bind_mask, sizeof(long)); - if(ret < 0){ - printf("\033[1;31;40m[Error] marsio set CPU-MASK '%lx' failed!\033[0m\n", sapp_global_val->config.cpu.bind_mask); - } - } -#else if(sapp_global_val->config.cpu.bind_mask_array_num > 0){ cpu_set_t cpu_mask; CPU_ZERO(&cpu_mask); @@ -1203,7 +1071,6 @@ int marsio_dl_io_init(int argc, char *argv[]) return -1; } } -#endif ptr_marsio_init(sapp_marsio4_instance, sapp_global_val->config.system.instance_name); @@ -1241,7 +1108,6 @@ int marsio_dl_io_init(int argc, char *argv[]) return 0; } - void marsio_dl_io_run(void) { int i = 0, ret; diff --git a/src/packet_io/packet_io_status.cpp b/src/packet_io/packet_io_status.cpp index b9ce1f3..9913c6e 100644 --- a/src/packet_io/packet_io_status.cpp +++ b/src/packet_io/packet_io_status.cpp @@ -300,8 +300,8 @@ void sysinfo_output(void) fprintf(fp,"\n*********************** %s *********************\n", time_string); fprintf(fp,"*********************** \033[41m%s\033[0m *************************\n", "sysinfo exactly"); fprintf(fp,"%-12s %12s %12s %12s %12s\n","Layer", "total_pkt", "total_len","pps", "Bps"); - fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_work", 0,0,(cur_count[SAPP_POLLING_WORK]-history_count[SAPP_POLLING_WORK]),0); - fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_idle", 0,0,(cur_count[SAPP_POLLING_IDLE]-history_count[SAPP_POLLING_IDLE]),0); + fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_work", (unsigned long long)0, (unsigned long long)0,(cur_count[SAPP_POLLING_WORK]-history_count[SAPP_POLLING_WORK]),(unsigned long long)0); + fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_idle", (unsigned long long)0,(unsigned long long)0,(cur_count[SAPP_POLLING_IDLE]-history_count[SAPP_POLLING_IDLE]),(unsigned long long)0); fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Line", cur_count[SAPP_STAT_RCV_LINE],cur_length[SAPP_STAT_RCV_LINE],(cur_count[SAPP_STAT_RCV_LINE]-history_count[SAPP_STAT_RCV_LINE]),(cur_length[SAPP_STAT_RCV_LINE]-history_length[SAPP_STAT_RCV_LINE])); @@ -350,7 +350,7 @@ void sysinfo_output(void) for(i = 0; i < g_packet_io_thread_num; i++){ fprintf(fp, "%3d %6ld %3d %8llu %9llu %10llu %10llu %10llu %10llu %9llu %13llu %13d\n", i, - sapp_global_val->individual_fixed.thread_tid[i], + (long)sapp_global_val->individual_fixed.thread_tid[i], sapp_global_val->individual_fixed.cpu_bind_core_id_per_thread[i], mstat[i]->sys_stat.count[SAPP_STAT_TCP_STREAM_SYN], mstat[i]->sys_stat.count[SAPP_STAT_TCP_STREAM_DATA], @@ -371,7 +371,7 @@ void sysinfo_output(void) for(i = 0; i < g_packet_io_thread_num; i++){ fprintf(fp, "%3d %6ld %3d %8llu %9llu %10llu %10llu %10llu %10llu %9llu %13llu %13d\n", i, - sapp_global_val->individual_fixed.thread_tid[i], + (long)sapp_global_val->individual_fixed.thread_tid[i], sapp_global_val->individual_fixed.cpu_bind_core_id_per_thread[i], mstat[i]->sys_stat.count[SAPP_STAT_UDP_STREAM_ONE], mstat[i]->sys_stat.count[SAPP_STAT_UDP_STREAM_TWO], @@ -389,8 +389,8 @@ void sysinfo_output(void) fprintf(fp,"*****************************************************************\n\n"); fprintf(fp,"################# \033[41m%s\033[0m --- is same as above! #########\n", "sysinfo humanly"); fprintf(fp,"%-12s %12s %12s %12s %12s\n", "Layer", "total_pkt", "total_len","pps", "bps"); - fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_work", 0,0,(cur_count[SAPP_POLLING_WORK]-history_count[SAPP_POLLING_WORK]),0); - fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_idle", 0,0,(cur_count[SAPP_POLLING_IDLE]-history_count[SAPP_POLLING_IDLE]),0); + fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_work", (unsigned long long)0,(unsigned long long)0,(cur_count[SAPP_POLLING_WORK]-history_count[SAPP_POLLING_WORK]),(unsigned long long)0); + fprintf(fp,"%-12s %12llu %12llu %12llu %12llu\n", "Polling_idle", (unsigned long long)0,(unsigned long long)0,(cur_count[SAPP_POLLING_IDLE]-history_count[SAPP_POLLING_IDLE]),(unsigned long long)0); fprintf(fp,"%-12s %12llu %12s %12llu %12s\n","Line",cur_count[SAPP_STAT_RCV_LINE],byte_convert_human(cur_length[SAPP_STAT_RCV_LINE],1 ,1,s1),(cur_count[SAPP_STAT_RCV_LINE]-history_count[SAPP_STAT_RCV_LINE]),byte_convert_human((cur_length[SAPP_STAT_RCV_LINE]-history_length[SAPP_STAT_RCV_LINE]),1,8,s2)); diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c index 076d716..77bc886 100644 --- a/src/packet_io/sendpacket.c +++ b/src/packet_io/sendpacket.c @@ -947,6 +947,7 @@ static int calc_gtp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_st return hdr_len; } +extern int calc_l2tp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_stream_dir); /* 1-�������а�ͷ�ij���, ����Ԥ���ռ�. ���㵽��ײ�Э��, �����MACҲ����MACͷ�ռ�; 2-�ݹ�����л�ȡEthernet����ص�Э������. @@ -1096,9 +1097,7 @@ static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type, return -1; } -#if 0 /* 2014-10-24 lijia modify, pag, ppf�Ȳ�����ʽ��IPv4��ʼ */ - if(stream->pfather && (ADDR_TYPE_MAC == stream->pfather->addr.addrtype)){ -#else + if(CAP_LEVEL_MAC == g_packet_io_cap_level) { if(stream_pr->pfather_pr && ((ADDR_TYPE_MAC_IN_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype) || (ADDR_TYPE_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype))){ @@ -1119,10 +1118,7 @@ static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type, } } } -#endif - -done: pfather_hdr_len = calc_reserved_hdr_len((struct streaminfo *)stream_pr->pfather_pr, net_layer_type, send_stream_dir); if(pfather_hdr_len < 0){ return -1; @@ -1826,8 +1822,6 @@ static int build_net_layer_gtp(struct streaminfo_private *stream_pr, int carry_l const struct gtp_hdr *raw_hdr; struct gtp_hdr *gtp_send_hdr; int gtp_net_layer_len = sizeof(struct gtp_hdr); - void *gtp_hash_key; - int gtp_hash_key_len; const struct layer_addr_gtp *p_gtp_layer_addr = stream_pr->stream_public.addr.gtp; unsigned int this_pkt_teid; @@ -2125,7 +2119,7 @@ void sendpkt_dup_pkt_mark_stream(const struct streaminfo *top_stream, const char } } - +extern int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_pkt_t *rawpkt); /* buf: ִ��Ӧ�ò㸺�ص�ַ, skip hdr. reverse: ��Ӧ�ò�ĽǶ�����dir, ��ʾ�뵱ǰraw_pkt�����, �����Ƿ�һ��, �����з����Եĵ�ַ, �跴�����. @@ -2191,7 +2185,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct */ if((sapp_global_val->config.packet_io.dup_pkt_para.dup_pkt_distinguish_all_inject != 0) && (sapp_is_overlay_layer(stream_pr, raw_pkt) == 0)){ - sendpkt_dup_pkt_mark(top_stream, ADDR_TYPE_IPV4, (char *)buf, buf+sizeof(struct mesa_ip4_hdr)); + sendpkt_dup_pkt_mark(top_stream, ADDR_TYPE_IPV4, (char *)buf, (const char *)buf+sizeof(struct mesa_ip4_hdr)); } } break; @@ -2221,7 +2215,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct /* �ظ�����ʶ��, �ӵ���������Ϊ���������, ���ܻ��ж��, �Ҳ����پ���jump_layer��ת���ڲ�udp/tcp���� */ if(sapp_global_val->config.packet_io.dup_pkt_para.dup_pkt_distinguish_all_inject != 0){ - sendpkt_dup_pkt_mark(top_stream, ADDR_TYPE_IPV6, (char *)buf, buf+sizeof(struct mesa_ip6_hdr)); + sendpkt_dup_pkt_mark(top_stream, ADDR_TYPE_IPV6, (char *)buf, (const char*)buf+sizeof(struct mesa_ip6_hdr)); } break; @@ -2347,7 +2341,6 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct } carry_layer_type = ADDR_TYPE_GPRS_TUNNEL; - ///sapp_runtime_log(10, "build_net_layer_pkt()-->ADDR_TYPE_GPRS_TUNNEL, buf start addr:%p, this_layer_len:%d", buf, this_layer_len); break; case ADDR_TYPE_PPPOE_SES: @@ -2423,24 +2416,6 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct this_layer_len = gre_layer_len + ppp_hdr_len; } break; -#if 0 - case ADDR_TYPE_MAC_IN_MAC: - { - buf -= sizeof(struct mesa_ethernet_hdr); - - build_net_layer_ethernet(stream_pr, ETHERTYPE_PANGU_MAC_IN_MAC, carry_layer_len, buf, reverse, raw_pkt); - - /* �˴����Բ�����mac��ַ, ����֪packet_io_send_fake_pkt�����ײ�����, MAC����MAC_IN_MAC */ - - /* ����ģʽ��, ��MAC����, ����ֱ�ӿ�ϵͳsendto����, ����MAC��ַ����buildϵ�к���������, ��dl_io����� */ - this_layer_len = sizeof(struct mesa_ethernet_hdr); - carry_layer_type = ETHERTYPE_PANGU_MAC_IN_MAC; - - sapp_runtime_log(10, "build_net_layer_pkt()-->ADDR_TYPE_MAC_IN_MAC, buf start addr:%p, this_layer_len:%d", buf, this_layer_len); - } - break; -#endif - case ADDR_TYPE_VXLAN: { const struct layer_addr_vxlan_private *vxaddr_pr = (struct layer_addr_vxlan_private *)stream_pr->stream_public.addr.paddr; @@ -2461,7 +2436,6 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct break; } -done: return build_net_layer_pkt(top_stream, carry_layer_stream, (struct streaminfo_private *)stream_pr->pfather_pr,carry_layer_type, this_layer_len+carry_layer_len, buf, reverse, raw_pkt, send_stream_dir); @@ -2987,7 +2961,7 @@ use_rand_value: int __MESA_rst_tcp(struct streaminfo *stream, unsigned char rst_th_flags, int rst_pkt_num, unsigned char snd_rst_dir, unsigned short signature_seed1, unsigned short signature_seed2) { - int i, ret = -1, reserved_hdr_len, send_len = 0; + int i, ret = -1, send_len = 0; const raw_pkt_t *raw_pkt; int threadnum = stream->threadnum; struct streaminfo_private *stream_pr; @@ -3319,39 +3293,31 @@ static int get_eth_carry_layer_type(struct streaminfo *stream, UCHAR send_stream int ret = -1; struct streaminfo_private *stream_pr = (struct streaminfo_private *)stream; - while(stream_pr && stream_pr->pfather_pr){ -#if 0 //ʹ�ö�̬�����ǶԳ�Э���, �˴������ٶ����ж��� - if(skip_asymmetric_presence_layer(stream, send_stream_dir)){ - stream_pr = stream_pr->pfather_pr; - continue; - } -#endif - if(CAP_LEVEL_MAC == g_packet_io_cap_level) { - if(stream_pr->pfather_pr - && ((ADDR_TYPE_MAC_IN_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype) || (ADDR_TYPE_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype))){ - /* ��¼MAC��֮�ϵ�Э���ַ����, �������Ethernet->type�ֶ�, ����MAC-in-MAC��inner_eth, ��¼�ϲ�Э������ */ - ret = (int)stream->addr.addrtype; - } - }else{ - /* to do: - ����������Զ�������ethernet��, ����������vlan�Ȳ���һ�Ҫ������ô��? - */ - if(NULL == stream_pr->pfather_pr){ - if(g_packet_io_cap_level == stream->addr.addrtype){ - ret = (int)stream->addr.addrtype; - } - if((CAP_LEVEL_IPV4 == g_packet_io_cap_level) - && (ADDR_TYPE_IPV4 == stream->addr.addrtype)){ - ret = CAP_LEVEL_IPV4; - } - } - } - - stream_pr = stream_pr->pfather_pr; - stream = &stream_pr->stream_public; - } + while (stream_pr && stream_pr->pfather_pr) + { + if (CAP_LEVEL_MAC == g_packet_io_cap_level) + { + if (stream_pr->pfather_pr && + ((ADDR_TYPE_MAC_IN_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype) || + (ADDR_TYPE_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype))) + { + /* ��¼MAC��֮�ϵ�Э���ַ����, �������Ethernet->type�ֶ�, ����MAC-in-MAC��inner_eth, ��¼�ϲ�Э������ + */ + ret = (int)stream->addr.addrtype; + } + } + else + { + /* to do: + ����������Զ�������ethernet��, ����������vlan�Ȳ���һ�Ҫ������ô��? + */ + } - return ret; + stream_pr = stream_pr->pfather_pr; + stream = &stream_pr->stream_public; + } + + return ret; } int __sapp_inject_pkt(struct streaminfo *raw_stream, enum sapp_inject_opt sio, @@ -3568,7 +3534,7 @@ static int send_handle_init(int tot_thread_num) } if(pcfg_io->inject_mode_single_gateway_device[0] != '\0'){ - ret = g_send_handle[i].raw_eth_fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL)); + g_send_handle[i].raw_eth_fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL)); if(g_send_handle[i].raw_eth_fd < 0){ sapp_log(30, ~0, ~0, "create socket raw eth error, %s\n", strerror(errno)); return -1; @@ -4875,7 +4841,6 @@ int MESA_fakepacket_send_ipv6_udp_options(const struct streaminfo *stream, int sapp_forward_current_pkt(const struct streaminfo *stream, unsigned int target_id) { int ret; -#if IOMODE_MARSIO marsio_buff_t *raw_mbuf, *new_clone_buf; const struct streaminfo_private *stream_pr = (const struct streaminfo_private *)stream; @@ -4916,10 +4881,6 @@ int sapp_forward_current_pkt(const struct streaminfo *stream, unsigned int targe ret = ptr_marsio_send_burst((struct mr_sendpath *)g_packet_device_alias[target_id].dl_io_param, stream->threadnum, &new_clone_buf, 1); -#else - sapp_runtime_log(30, "sapp_forward_current_pkt() not support in non-marsio mode, TODO!\n"); - return -1;/* ����ģʽtodo */ -#endif return ret; } |
