summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijia <[email protected]>2021-01-13 17:17:33 +0800
committerlijia <[email protected]>2021-01-13 17:17:33 +0800
commit9eaec095c5c7de7e1e6acc48de2aff99b2a26ae4 (patch)
tree1b6e34358d4955f7eabeee314a939068c3edfa00
parentd051c6da0cdd76b9efafd65ac44b1e121c3ff0e3 (diff)
修改各层协议计数,支持矩阵式输出显示.v4.2.23
-rw-r--r--include/private/sapp_global_val.h2
-rw-r--r--include/private/sapp_pkt_stat.h2
-rw-r--r--src/dealpkt/deal_arp.c4
-rw-r--r--src/dealpkt/deal_ethernet.c39
-rw-r--r--src/dealpkt/deal_gprs_tunnel.c4
-rw-r--r--src/dealpkt/deal_gre.c6
-rw-r--r--src/dealpkt/deal_ipv4.c10
-rw-r--r--src/dealpkt/deal_ipv6.c4
-rw-r--r--src/dealpkt/deal_l2tp.c4
-rw-r--r--src/dealpkt/deal_mpls.c3
-rw-r--r--src/dealpkt/deal_pppoe.c5
-rw-r--r--src/dealpkt/deal_pptp.c4
-rw-r--r--src/dealpkt/deal_tcp.c3
-rw-r--r--src/dealpkt/deal_udp.c7
-rw-r--r--src/dealpkt/deal_vlan.c4
-rw-r--r--src/dealpkt/deal_vxlan.c5
-rw-r--r--src/dealpkt/stream_manage.c4
-rw-r--r--src/packet_io/packet_io.c4
-rw-r--r--src/packet_io/packet_io_status.cpp62
19 files changed, 153 insertions, 23 deletions
diff --git a/include/private/sapp_global_val.h b/include/private/sapp_global_val.h
index ea0483c..436bbd4 100644
--- a/include/private/sapp_global_val.h
+++ b/include/private/sapp_global_val.h
@@ -319,6 +319,8 @@ typedef struct{
typedef struct{
unsigned long long count[SAPP_STAT_NUM_MAX]; /* ������, �����, �½�������, ������������ */
unsigned long long length[SAPP_STAT_NUM_MAX]; /* ������, �����ݰ����ֽ��� */
+ unsigned long long count_per_layer[__ADDR_TYPE_MAX][SAPP_SUPPORT_LAYER_NUM_MAX];
+ unsigned long long length_per_layer[__ADDR_TYPE_MAX][SAPP_SUPPORT_LAYER_NUM_MAX];
}sapp_gval_mthread_sys_stat_t;
diff --git a/include/private/sapp_pkt_stat.h b/include/private/sapp_pkt_stat.h
index 8487a9c..5e95873 100644
--- a/include/private/sapp_pkt_stat.h
+++ b/include/private/sapp_pkt_stat.h
@@ -16,7 +16,7 @@ typedef enum __sapp_sys_stat_type{
SAPP_STAT_RCV_LINE,
/************* receive packet ****************/
- SAPP_STAT_RCV_RAW, /* �յ�����ʵԭʼ������, ethernet����mac-in-mac, vpls��ԭ��Ҳ���ܻ��ظ����� */
+ SAPP_STAT_RCV_RAW, /* �յ�����ʵԭʼ������, ��һ������ethernet, ethernet����mac-in-mac, vpls��ԭ��Ҳ���ܻ��ظ����� */
SAPP_STAT_RCV_ETHERNET,
SAPP_STAT_RCV_IPV4, /* ������SAPP_STAT_RCV_IPV4_FRAG */
diff --git a/src/dealpkt/deal_arp.c b/src/dealpkt/deal_arp.c
index e8908dd..f7e5836 100644
--- a/src/dealpkt/deal_arp.c
+++ b/src/dealpkt/deal_arp.c
@@ -9,7 +9,11 @@ extern "C" {
int thread_num, unsigned char dir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr)
{
const struct mesa_arp_hdr *aph = (struct mesa_arp_hdr *)this_layer_hdr;
+ sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
+ local_sys_stat->count_per_layer[ADDR_TYPE_ARP][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_ARP][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
+
if((ntohs(aph->ar_op) == ARPOP_REPLY) && (ETH_P_IP == ntohs(aph->ar_pro))){
stream_process_arp(NULL, (struct mesa_arp_hdr *)this_layer_hdr, thread_num, dir, raw_pkt);
}
diff --git a/src/dealpkt/deal_ethernet.c b/src/dealpkt/deal_ethernet.c
index 24d79ba..53a2fe0 100644
--- a/src/dealpkt/deal_ethernet.c
+++ b/src/dealpkt/deal_ethernet.c
@@ -56,6 +56,15 @@ int eth_entry(struct streaminfo_private *fstream_pr, const void *this_layer_hdr,
struct streaminfo *pstream;
sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
int this_layer_len = raw_pkt->raw_pkt_len - ((char *)this_layer_hdr - (char *)raw_pkt->raw_pkt_data);
+ int this_layer_is_overlay = 0;
+
+ if(NULL == fstream_pr){
+ local_sys_stat->count_per_layer[ADDR_TYPE_MAC][0]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_MAC][0] += this_layer_len;
+ }else{
+ local_sys_stat->count_per_layer[ADDR_TYPE_MAC][fstream_pr->layer_index + 1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_MAC][fstream_pr->layer_index + 1] += this_layer_len;
+ }
if(NET_CONN_SERIAL_GDEV == g_topology_mode){
if(unlikely(sapp_identify_broad_multicast_pkt(this_layer_hdr, raw_pkt) != 0)){
@@ -101,18 +110,6 @@ int eth_entry(struct streaminfo_private *fstream_pr, const void *this_layer_hdr,
pstream->curdir = DIR_S2C;
}
- if(g_overlay_layer_set[ADDR_TYPE_MAC][pstream_pr->layer_index] == 0){ /* ��overlay����ۼ���ز���� */
- local_sys_stat->count[SAPP_STAT_RCV_ETHERNET]++;
- local_sys_stat->length[SAPP_STAT_RCV_ETHERNET] += (unsigned long long)this_layer_len;
- if(dir == sapp_global_val->config.packet_io.inbound_route_dir){
- local_sys_stat->count[SAPP_STAT_ETH_INBOUND]++;
- local_sys_stat->length[SAPP_STAT_ETH_INBOUND] += (unsigned long long)this_layer_len;
- }else{
- local_sys_stat->count[SAPP_STAT_ETH_OUTBOUND]++;
- local_sys_stat->length[SAPP_STAT_ETH_OUTBOUND] += (unsigned long long)this_layer_len;
- }
- }
-
if(NULL == fstream_pr){
pstream_pr->layer_index = 0; /* first layer, index start from 0 */
}else{
@@ -137,9 +134,21 @@ int eth_entry(struct streaminfo_private *fstream_pr, const void *this_layer_hdr,
((raw_pkt_t *)raw_pkt)->raw_pkt_len = raw_pkt->__lib_raw_pkt_len - sizeof(struct mesa_ethernet_hdr);
}
}
-
- if((g_overlay_layer_set[ADDR_TYPE_MAC][pstream_pr->layer_index] == 0) /* �����overlay���򲻴���mpls�ղ� */
- && (should_create_empty_mpls_layer_for_symmetric(pstream, eth_type) != 0)){
+
+ this_layer_is_overlay = sapp_is_overlay_layer(pstream_pr, raw_pkt);
+ if(0 == this_layer_is_overlay){ /* ��overlay����ۼ���ز���� */
+ local_sys_stat->count[SAPP_STAT_RCV_ETHERNET]++;
+ local_sys_stat->length[SAPP_STAT_RCV_ETHERNET] += (unsigned long long)this_layer_len;
+ if(dir == sapp_global_val->config.packet_io.inbound_route_dir){
+ local_sys_stat->count[SAPP_STAT_ETH_INBOUND]++;
+ local_sys_stat->length[SAPP_STAT_ETH_INBOUND] += (unsigned long long)this_layer_len;
+ }else{
+ local_sys_stat->count[SAPP_STAT_ETH_OUTBOUND]++;
+ local_sys_stat->length[SAPP_STAT_ETH_OUTBOUND] += (unsigned long long)this_layer_len;
+ }
+ }
+
+ if(should_create_empty_mpls_layer_for_symmetric(pstream, eth_type) != 0){
((raw_pkt_t *)raw_pkt)->offset_to_raw_pkt_hdr = next_layer_offset;
ret = mpls_empty_entry(pstream_pr, (const void *)next_layer_data, thread_num, dir, raw_pkt, next_layer_offset);
return ret;
diff --git a/src/dealpkt/deal_gprs_tunnel.c b/src/dealpkt/deal_gprs_tunnel.c
index 031699f..78f5d87 100644
--- a/src/dealpkt/deal_gprs_tunnel.c
+++ b/src/dealpkt/deal_gprs_tunnel.c
@@ -34,6 +34,10 @@ int gtp_entry(struct streaminfo_private *pfstream_pr,void *this_layer_data,int t
unsigned int cur_seq = 0, seq_offset = 0;
sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
+ local_sys_stat->count_per_layer[ADDR_TYPE_GPRS_TUNNEL][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_GPRS_TUNNEL][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
+
+
//���ͬһ�ỰGTP����Դ�˿ڱ仯�������ǿ�ƽ�ջ�ϵ�streaminfo�У���ַȫ������Ϊ0
pfstream_pr->stream_public.addr.tuple4_v4->source = 0;
pfstream_pr->stream_public.addr.tuple4_v4->dest = 0;
diff --git a/src/dealpkt/deal_gre.c b/src/dealpkt/deal_gre.c
index b1bed6f..ece9aa9 100644
--- a/src/dealpkt/deal_gre.c
+++ b/src/dealpkt/deal_gre.c
@@ -224,7 +224,11 @@ int gre_entry(struct streaminfo_private *pfstream_pr,const void *this_layer_data
int gre_hdr_len = 0; /* GRE��ַ��ʵ�ʳ���, �ɱ� */
char *next_layer_hdr;
int next_layer_offset;
-
+ sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
+
+ local_sys_stat->count_per_layer[ADDR_TYPE_GRE][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_GRE][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
+
memset(ptmp,0,sizeof(struct streamindex));
//set_gre_id(&addr, (unsigned short *)this_layer_data);
gre_hdr_len = set_gre_hdr(&gre_addr, this_layer_data);
diff --git a/src/dealpkt/deal_ipv4.c b/src/dealpkt/deal_ipv4.c
index 893b53c..7487ab0 100644
--- a/src/dealpkt/deal_ipv4.c
+++ b/src/dealpkt/deal_ipv4.c
@@ -594,11 +594,16 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da
sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
/* ע��, �˴���ȡ��ǰ�㳤����ipͷ���ֶμ���ó�, ������this_layer_data- raw_pkt->raw_pkt_data, ��ΪijЩ����64�ֽڵ�С���������triler, �������߼��㲻һ�� */
int this_layer_len = ntohs(a_packet->ip_len);
+ int this_layer_is_overlay = 0;
#if DEBUG
//timestamp_record(TS_LEVEL_IP_ENTRY, raw_pkt, thread_num);
#endif
+ local_sys_stat->count_per_layer[__ADDR_TYPE_IP_PAIR_V4][pfstream_pr->layer_index + 1]++;
+ local_sys_stat->length_per_layer[__ADDR_TYPE_IP_PAIR_V4][pfstream_pr->layer_index + 1] += this_layer_len;
+
+
/* NOTE, ע��, �м�:
���߻�����������Ī�������IPv4��, ͷ���ֶβ��Ϸ�,
�����ƽ̨coredump, ��������ѭ��, һ��Ҫ��ͷ���Ϸ��Լ��!!
@@ -677,7 +682,8 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da
pstream->threadnum=thread_num;
/* 2020-12-23 lijia add, ��mrtunnatģʽ, �����overlay��, ��������ͨ��� */
- if(sapp_is_overlay_layer(pstream_pr, raw_pkt) != 0){
+ this_layer_is_overlay = sapp_is_overlay_layer(pstream_pr, raw_pkt);
+ if(this_layer_is_overlay != 0){
ret = stream_process_overlay_ipv4(pstream, (const struct ip *)this_layer_data, thread_num, routedir, raw_pkt);
if(DROP == ret){
return DROP;
@@ -724,7 +730,7 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da
local_sys_stat->count[SAPP_STAT_RCV_IPV4_FRAG]++;
local_sys_stat->length[SAPP_STAT_RCV_IPV4_FRAG] += this_layer_len;
}else{
- if(g_overlay_layer_set[__ADDR_TYPE_IP_PAIR_V4][pstream_pr->layer_index] == 0){ /* ��overlay����ۼ���ز���� */
+ if(0 == this_layer_is_overlay){ /* ��overlay����ۼ���ز���� */
local_sys_stat->count[SAPP_STAT_RCV_IPV4]++;
local_sys_stat->length[SAPP_STAT_RCV_IPV4] += this_layer_len;
if (routedir == sapp_global_val->config.packet_io.inbound_route_dir)
diff --git a/src/dealpkt/deal_ipv6.c b/src/dealpkt/deal_ipv6.c
index e9ed505..b2f925c 100644
--- a/src/dealpkt/deal_ipv6.c
+++ b/src/dealpkt/deal_ipv6.c
@@ -777,6 +777,10 @@ int ipv6_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_hd
static unsigned int ipv6_frag_reassemble_num = 0;
#endif
+ local_sys_stat->count_per_layer[__ADDR_TYPE_IP_PAIR_V6][pfstream_pr->layer_index + 1]++;
+ local_sys_stat->length_per_layer[__ADDR_TYPE_IP_PAIR_V6][pfstream_pr->layer_index + 1] += payload_len+sizeof(struct mesa_ip6_hdr);
+
+
if(unlikely(0 == g_ipv6_decapsulation_enabled)){
sapp_runtime_log(20, "recv a IPv6 packet, but IPv6 decapsulation is not enable!\n");
return PASS;
diff --git a/src/dealpkt/deal_l2tp.c b/src/dealpkt/deal_l2tp.c
index 027b083..8433362 100644
--- a/src/dealpkt/deal_l2tp.c
+++ b/src/dealpkt/deal_l2tp.c
@@ -281,6 +281,10 @@ int l2tpv2_entry(struct streaminfo_private *pfstream_pr,const void *this_layer_d
const struct mesa_ppp_hdr *ppp_net_addr;
int next_layer_offset;
struct l2tp_info_pri *l2tp_pri;
+ sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
+
+ local_sys_stat->count_per_layer[ADDR_TYPE_L2TP][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_L2TP][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
/* ֮ǰ�Ѿ�ͨ��Э��ʶ����guess_if_l2tpv2()ʶ���, ������l2tpv2_entry()�ﲻ���ٴ��ж� */
pl2tphdrv2 = (const struct l2tp_hdr_v2 *)((char *)this_layer_data + sizeof(struct mesa_udp_hdr));
diff --git a/src/dealpkt/deal_mpls.c b/src/dealpkt/deal_mpls.c
index fc3d13f..bdadac8 100644
--- a/src/dealpkt/deal_mpls.c
+++ b/src/dealpkt/deal_mpls.c
@@ -111,6 +111,9 @@ int mpls_uc_entry(struct streaminfo_private *pfstream_pr,const void *this_layer_
int inject_to_eth_flag = 0;
sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
+ local_sys_stat->count_per_layer[ADDR_TYPE_MPLS][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_MPLS][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
+
if(set_mpls_addr(&addr, (unsigned char *)this_layer_data) < 0){
local_sys_stat->count[SAPP_STAT_RCV_UNKNOWN]++;
local_sys_stat->length[SAPP_STAT_RCV_UNKNOWN]+= raw_pkt->raw_pkt_len;
diff --git a/src/dealpkt/deal_pppoe.c b/src/dealpkt/deal_pppoe.c
index 14f36d7..c46b836 100644
--- a/src/dealpkt/deal_pppoe.c
+++ b/src/dealpkt/deal_pppoe.c
@@ -25,7 +25,7 @@ int pppoe_session_entry(struct streaminfo_private *pfstream_pr,const void *this_
return PASS;
#endif
int ret = PASS;
- sapp_gval_mthread_sys_stat_t *local_sys_stat;
+ sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
struct streamindex tmp_index;
struct streamindex *ptmp=&tmp_index;
@@ -36,6 +36,9 @@ int pppoe_session_entry(struct streaminfo_private *pfstream_pr,const void *this_
char *up_layer_data = (char *)this_layer_hdr+PPPOE_HDR_LEN;
int next_layer_offset = offset_to_raw_pkt_hdr + PPPOE_HDR_LEN;
+ local_sys_stat->count_per_layer[ADDR_TYPE_PPPOE_SES][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_PPPOE_SES][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
+
if(0 == G_SKIP_NOT_IP_LAYER){
memset(ptmp,0,sizeof(struct streamindex));
set_pppoe_addr(&addr, (struct mesa_pppoe_session_hdr *)this_layer_hdr);
diff --git a/src/dealpkt/deal_pptp.c b/src/dealpkt/deal_pptp.c
index 17923f7..0746dd3 100644
--- a/src/dealpkt/deal_pptp.c
+++ b/src/dealpkt/deal_pptp.c
@@ -257,6 +257,10 @@ int pptp_entry(struct streamindex *pindex, const void *this_layer_data,int threa
int next_layer_offset;
unsigned short ppp_next_layer_pro;
int ppp_hdr_len;
+ sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
+
+ local_sys_stat->count_per_layer[ADDR_TYPE_PPTP][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_PPTP][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
/* ����PPTP���ַ���� */
pstream->addr.addrtype = ADDR_TYPE_PPTP;
diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c
index b3a8def..7fac8ad 100644
--- a/src/dealpkt/deal_tcp.c
+++ b/src/dealpkt/deal_tcp.c
@@ -2824,6 +2824,9 @@ static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struc
pstream->type=STREAM_TYPE_TCP;
pstream->routedir=routedir;
pstream->threadnum=thread_num;
+
+ local_sys_stat->count_per_layer[ADDR_TYPE_TCP][pstream_pr->layer_index]++; /* tcp��ip����һ�� */
+ local_sys_stat->length_per_layer[ADDR_TYPE_TCP][pstream_pr->layer_index] += tcpdatalen + this_tcphdr->th_off*4; /* tcp��ip����һ�� */
//return deal_tcp_stream(ptmp,this_tcphdr,tcpdatalen,raw_packet,raw_len);
return deal_tcp_stream(pfindex,this_iphdr, this_tcphdr,tcpdatalen, raw_packet, offset_to_raw_pkt_hdr);
diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c
index ac5f80f..00266ce 100644
--- a/src/dealpkt/deal_udp.c
+++ b/src/dealpkt/deal_udp.c
@@ -447,6 +447,10 @@ int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr * this_
udph = (struct mesa_udp_hdr *) ((char*)this_iphdr +hlen );
ulen = ntohs (udph->uh_ulen);
+
+ local_sys_stat->count_per_layer[ADDR_TYPE_UDP][pstream_pr->layer_index]++; /* udp��ip����һ�� */
+ local_sys_stat->length_per_layer[ADDR_TYPE_UDP][pstream_pr->layer_index] += ulen; /* udp��ip����һ�� */
+
/* 2015-12-29 lijia modify, ijЩUDP��û�и�������, û������, ֱ�Ӷ��� */
if(unlikely(iplen - hlen < ulen || ulen <= (int)sizeof (struct mesa_udp_hdr))){
return PASS;
@@ -628,6 +632,9 @@ int dealipv6udppkt(struct streamindex *pindex,const struct mesa_ip6_hdr *a_packe
iplen = ntohs (a_packet->ip6_payload_len);
ulen = ntohs (udph->uh_ulen);
+
+ local_sys_stat->count_per_layer[ADDR_TYPE_UDP][pstream_pr->layer_index]++; /* udp��ip����һ�� */
+ local_sys_stat->length_per_layer[ADDR_TYPE_UDP][pstream_pr->layer_index] += ulen; /* udp��ip����һ�� */
if(unlikely(iplen < ulen || ulen <= (int)sizeof (struct mesa_udp_hdr))){
return PASS;
diff --git a/src/dealpkt/deal_vlan.c b/src/dealpkt/deal_vlan.c
index c071e76..3dc12ad 100644
--- a/src/dealpkt/deal_vlan.c
+++ b/src/dealpkt/deal_vlan.c
@@ -54,6 +54,10 @@ int IEEE_8021_entry(struct streaminfo_private *pfstream_pr,const void *this_laye
int vlan_layer_len;
const struct mesa_vlan_hdr *vhdr;
+ local_sys_stat->count_per_layer[ADDR_TYPE_VLAN][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_VLAN][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
+
+
if(likely(0 == G_SKIP_NOT_IP_LAYER)){
memset(ptmp,0,sizeof(struct streamindex));
vlan_layer_len = set_vlan_addr(&addr, (unsigned char *)this_layer_data);
diff --git a/src/dealpkt/deal_vxlan.c b/src/dealpkt/deal_vxlan.c
index 3859db5..6ef56b6 100644
--- a/src/dealpkt/deal_vxlan.c
+++ b/src/dealpkt/deal_vxlan.c
@@ -32,13 +32,16 @@ int vxlan_entry(struct streaminfo_private *pfstream_pr,const void *this_layer_hd
struct streaminfo_private *pstream_pr = &ptmp->stream;
struct streaminfo *pstream = &pstream_pr->stream_public;
struct layer_addr_vxlan addr;
+ sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
+
+ local_sys_stat->count_per_layer[ADDR_TYPE_VXLAN][pfstream_pr->layer_index+1]++;
+ local_sys_stat->length_per_layer[ADDR_TYPE_VXLAN][pfstream_pr->layer_index+1] += raw_pkt->raw_pkt_len - offset_to_raw_pkt_hdr;
memset(ptmp,0,sizeof(struct streamindex));
next_layer_data = (const unsigned char *)this_layer_hdr + sizeof(inline_vxlan_hdr_t);
next_layer_offset = offset_to_raw_pkt_hdr + sizeof(inline_vxlan_hdr_t);
-
set_vxlan_addr(this_layer_hdr, &addr);
pstream->addr.paddr=&addr;
diff --git a/src/dealpkt/stream_manage.c b/src/dealpkt/stream_manage.c
index 42e20b7..00861b9 100644
--- a/src/dealpkt/stream_manage.c
+++ b/src/dealpkt/stream_manage.c
@@ -2961,7 +2961,7 @@ int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_
}
if((rawpkt->vlan_flipping_couple[0] && rawpkt->vlan_flipping_couple[1]) != 0){
- /* vlan flipping��ADC�Լ켰Alot�豸���е�һ��ģʽ, ������overlay�� */
+ /* vlan flipping��ADC�Լ켰A�����豸���е�һ��ģʽ, ������overlay�� */
return 0;
}
@@ -2970,7 +2970,7 @@ int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_
return 1;
}
- /* Ŀǰ��ʱֻ��vxlanһ��overlayģʽ,�����ϵĶ�����overlay */
+ /* TODO, Ŀǰ��ʱֻ��vxlanһ��overlayģʽ,���������ϵĶ�����overlay */
return 0;
}
diff --git a/src/packet_io/packet_io.c b/src/packet_io/packet_io.c
index 707971e..9056f34 100644
--- a/src/packet_io/packet_io.c
+++ b/src/packet_io/packet_io.c
@@ -594,10 +594,14 @@ static int mesa_default_pkt_cb(const raw_pkt_t *p_raw_pkt, unsigned char dir, in
if(DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin){
ret = packet_io_hook_input((raw_pkt_t *)p_raw_pkt, dir, thread_num);
if(ret < 0){
+ cycle_pkt_dump_by_classify(thread_num, p_raw_pkt, PKT_CLASSIFY_DROP);
return DROP;
}
}
+ local_sys_stat->count[SAPP_STAT_RCV_RAW]++;
+ local_sys_stat->length[SAPP_STAT_RCV_RAW] += ((unsigned long long)p_raw_pkt->raw_pkt_len - p_raw_pkt->overlay_layer_bytes);
+
if (p_raw_pkt->route_dir == sapp_global_val->config.packet_io.inbound_route_dir)
{
local_sys_stat->count[SAPP_STAT_RAW_INBOUND]++;
diff --git a/src/packet_io/packet_io_status.cpp b/src/packet_io/packet_io_status.cpp
index 81321fe..9e8c858 100644
--- a/src/packet_io/packet_io_status.cpp
+++ b/src/packet_io/packet_io_status.cpp
@@ -176,6 +176,66 @@ static void field_stat2_update_metrics(void)
}
+static void sysinfo_output_per_layer_stat(FILE *fp)
+{
+ int i, j, k, layer_num;
+ int layer_type;
+ sapp_gval_mthread_t **mstat = sapp_global_val->mthread_volatile;
+ unsigned long long stat_sum;
+ unsigned long long sum_count_per_layer[__ADDR_TYPE_MAX][SAPP_SUPPORT_LAYER_NUM_MAX] = {0};
+ unsigned long long sum_length_per_layer[__ADDR_TYPE_MAX][SAPP_SUPPORT_LAYER_NUM_MAX] = {0};
+ char layer_length_human_str[SAPP_SUPPORT_LAYER_NUM_MAX][STATS_STR_LEN];
+
+ for(i=0;i<g_packet_io_thread_num;i++){
+ for(j = 0; j < __ADDR_TYPE_MAX; j++){
+ for(k = 0; k < SAPP_SUPPORT_LAYER_NUM_MAX; k++){
+ sum_count_per_layer[j][k] += mstat[i]->sys_stat.count_per_layer[j][k];
+ sum_length_per_layer[j][k] += mstat[i]->sys_stat.length_per_layer[j][k];
+ }
+ }
+ }
+
+ fprintf(fp,"******************************************************************************************************************\n");
+ fprintf(fp,"*************** protocol count statistics matrix ****************\n");
+ fprintf(fp,"%-10s %12s %12s %12s %12s %12s %12s %12s %12s\n","PROTO", "Layer0", "Layer1","Layer2", "Layer3","Layer4","Layer5","Layer6","Layer7");
+
+
+ for(layer_type = 1; layer_type < (int)__ADDR_TYPE_MAX; layer_type++){
+ stat_sum = 0;
+ for(layer_num = 0; layer_num < SAPP_SUPPORT_LAYER_NUM_MAX; layer_num++){
+ stat_sum += sum_count_per_layer[layer_type][layer_num];
+ }
+ if(0 == stat_sum){
+ continue; /* ����ȫ��0�IJ�Ͳ���ʾ�� */
+ }
+
+ fprintf(fp,"%-10s %12llu %12llu %12llu %12llu %12llu %12llu %12llu %12llu\n", addr_type_abbreviation_ntop((enum addr_type_t)layer_type),
+ sum_count_per_layer[layer_type][0], sum_count_per_layer[layer_type][1], sum_count_per_layer[layer_type][2], sum_count_per_layer[layer_type][3],
+ sum_count_per_layer[layer_type][4], sum_count_per_layer[layer_type][5], sum_count_per_layer[layer_type][6], sum_count_per_layer[layer_type][7]);
+ }
+
+ fprintf(fp,"\n************** protocol length statistics matrix ****************\n");
+ fprintf(fp,"%-10s %12s %12s %12s %12s %12s %12s %12s %12s\n","PROTO", "Layer0", "Layer1","Layer2", "Layer3","Layer4","Layer5","Layer6","Layer7");
+ for(layer_type = 1; layer_type < (int)__ADDR_TYPE_MAX; layer_type++){
+ stat_sum = 0;
+ for(layer_num = 0; layer_num < SAPP_SUPPORT_LAYER_NUM_MAX; layer_num++){
+ stat_sum += sum_length_per_layer[layer_type][layer_num];
+ byte_convert_human(sum_length_per_layer[layer_type][layer_num], 1, 8, layer_length_human_str[layer_num]);
+ }
+ if(0 == stat_sum){
+ continue; /* ����ȫ��0�IJ�Ͳ���ʾ�� */
+ }
+
+ fprintf(fp,"%-10s %12s %12s %12s %12s %12s %12s %12s %12s\n", addr_type_abbreviation_ntop((enum addr_type_t)layer_type),
+ layer_length_human_str[0], layer_length_human_str[1], layer_length_human_str[2], layer_length_human_str[3],
+ layer_length_human_str[4], layer_length_human_str[5], layer_length_human_str[6], layer_length_human_str[7]);
+ }
+
+ fprintf(fp,"******************************************************************************************************************\n\n");
+
+ return;
+}
+
void sysinfo_output(void)
{
int i, j;
@@ -286,6 +346,8 @@ void sysinfo_output(void)
mstat[i]->sys_stat.count[SAPP_STAT_UDP_STREAM_RESET],
sapp_global_mthread[i].udp_stream_special_timeout_num);
}
+
+ sysinfo_output_per_layer_stat(fp);
fprintf(fp,"*****************************************************************\n\n");
fprintf(fp,"################# \033[41m%s\033[0m --- is same as above! #########\n", "sysinfo humanly");