summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile2
-rw-r--r--bin/etc/sapp.toml14
-rw-r--r--build/.gitignore10
-rw-r--r--include/private/sapp_global_val.h3
-rw-r--r--include/private/sapp_pkt_stat.h4
-rw-r--r--include/private/stream_internal.h4
-rw-r--r--include/public/stream_inc/stream_control.h16
-rw-r--r--src/config/config_parse.cpp2
-rw-r--r--src/dealpkt/deal_arp.c2
-rw-r--r--src/dealpkt/deal_ethernet.c9
-rw-r--r--src/dealpkt/deal_tcp.c7
-rw-r--r--src/dealpkt/deal_udp.c5
-rw-r--r--src/dealpkt/plug_support.c124
-rw-r--r--src/inner_plug/sapp_assistant.cpp50
-rw-r--r--src/packet_io/packet_io.c13
-rw-r--r--src/packet_io/packet_io_marsio.c1
-rw-r--r--src/packet_io/packet_io_pcap.c1
-rw-r--r--src/packet_io/packet_io_status.cpp9
-rw-r--r--src/plugin/src/plugin.c35
-rw-r--r--test/Makefile2
-rw-r--r--test/test_app_sapp.c34
-rw-r--r--version.txt12
23 files changed, 316 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index de2e042..7f636cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,5 +11,5 @@ bin/log/
bin/sapp
cmake-build-debug
.vscode
-build/
+./build/
diff --git a/Makefile b/Makefile
index 5ab6198..833b4f7 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ _MODE_DPDK_VXLAN=dpdk_vxlan
_MODE_PAG_MARSIO=pag_marsio
_MODE_IPFILE=ipfile
_MODE_CHK=0
-iomode=pcap
+iomode=marsio
_OPT0=0
_OPT1=1
diff --git a/bin/etc/sapp.toml b/bin/etc/sapp.toml
index 1a761fd..e7454d7 100644
--- a/bin/etc/sapp.toml
+++ b/bin/etc/sapp.toml
@@ -9,11 +9,17 @@
instance_name = "sapp_v4.0"
[CPU]
-worker_threads=1
+worker_threads=2
### note, bind_mask, if you do not want to bind thread to special CPU core, keep it empty as []
-bind_mask=[1]
+bind_mask=[]
[PACKET_IO]
+### note, used to represent inbound or outbound direction value,
+### because it comes from other device, so it needs to be specified manually,
+### if inbound_route_dir=1, then outbound_route_dir=0, vice versa,
+### in other words, outbound_route_dir = 1 ^ inbound_route_dir;
+inbound_route_dir=1
+
### note, BSD_packet_filter, if you do not want to set any filter rule, keep it empty as ""
BSD_packet_filter=""
@@ -21,7 +27,9 @@ BSD_packet_filter=""
[packet_io.depolyment]
mode=mirror
-### note, interface.type options: [pag,pcap,marsio]
+### note, interface.type options: [pag, pcap, marsio]
+### receive from internal interface, route dir is 0,
+### receive from external interface, route dir is 1.
[packet_io.internal.interface]
type=pcap
name="lo"
diff --git a/build/.gitignore b/build/.gitignore
index cddf60e..4d7810d 100644
--- a/build/.gitignore
+++ b/build/.gitignore
@@ -1,9 +1,3 @@
-SI/
-*.log
-*.o
-*.so
-*.si4project/
-*.a
-*.o
-*.d
+*.*
+*
diff --git a/include/private/sapp_global_val.h b/include/private/sapp_global_val.h
index 46c8899..ee64e2d 100644
--- a/include/private/sapp_global_val.h
+++ b/include/private/sapp_global_val.h
@@ -159,6 +159,7 @@ typedef struct{
char pcap_dumpfile_name[NAME_MAX];
int polling_enabled;
int polling_priority; /* call sapp_recv_pkt every call polling_entry times, ���ö��ٴ�polling�����һ��recv pkt, 1��ʾ�������ȼ���ͬ */
+ int inbound_route_dir; /* ��ʾ�뾳, I2C�����ֵ��0����1 */
}sapp_config_packet_io_t;
typedef struct{
@@ -219,7 +220,7 @@ typedef struct{
typedef struct{
sapp_gval_mthread_sys_stat_t sys_stat;
unsigned short stream_seq_per_thread;
- char __padding[28];
+ char __padding[12];
}sapp_gval_mthread_t; /* for multi-thread, must 64byte alignment */
diff --git a/include/private/sapp_pkt_stat.h b/include/private/sapp_pkt_stat.h
index f9e3f3c..a7feda7 100644
--- a/include/private/sapp_pkt_stat.h
+++ b/include/private/sapp_pkt_stat.h
@@ -21,7 +21,9 @@ typedef enum __sapp_sys_stat_type{
/************* send packet *******************/
- SAPP_STAT_ETH_EGRESS, /* ����ģʽ�µĻ�������, �����Ϻ�SAPP_STAT_RCV_ETHERNET���, �����в������DROPPKT */
+
+ SAPP_STAT_ETH_INBOUND, /* ����ģʽ��, �ǵ�ǰ������I/O����, ��������ڵ�ǰ�豸��������λ��, ���뾳�������� */
+ SAPP_STAT_ETH_OUTBOUND, /* ����ģʽ��, �ǵ�ǰ������I/O����, ��������ڵ�ǰ�豸��������λ��, ���뾳�������� */
SAPP_STAT_SND_ETHERNET, /* ����������͵�����, ������������������ */
SAPP_STAT_SND_IPV4,
diff --git a/include/private/stream_internal.h b/include/private/stream_internal.h
index 09acc80..fceb2d5 100644
--- a/include/private/stream_internal.h
+++ b/include/private/stream_internal.h
@@ -69,6 +69,7 @@ typedef struct {
const void *raw_pkt_data; /* ���ϲ�Ӧ�ÿ���ԭʼ��ͷָ��, �п���������Ethernet��, ����low_layer_type�ж�Э������ */
struct timeval raw_pkt_ts; /* ԭʼ������ʱ���, ���ȫΪ0��֧�ִ˹���(��pagģʽ) */
const void *io_lib_pkt_reference; /* ���õײ�I/O���ԭʼ�������ṹ, ����:����marsio��˵, ���ײ��mbuf�ṹ */
+ int route_dir;
}raw_pkt_t;
@@ -132,7 +133,8 @@ struct streaminfo_private
/* ---8 bytes-- */
UCHAR layer_dir:2; /* ������Ч, ��ǰ��ĵ�ַ�Ƿ��Ĭ�Ϲ���"��˿��ǿͻ���"��ͬ */
- UCHAR stream_dir:2; /* ��������������Ч, ���Ĵ洢�ĵ�ַ�Ƿ��Ĭ�Ϲ���"��˿��ǿͻ���"��ͬ */
+ UCHAR stream_dir:1; /* ��������������Ч, ���Ĵ洢�ĵ�ַ�Ƿ��Ĭ�Ϲ���"��˿��ǿͻ���"��ͬ */
+ UCHAR stream_c2s_route_dir:1; /* c2s����İ�, ��Ӧ����·route dir����, ���ڻ�ȡinbound, outbound���� */
UCHAR addr_use_as_hash:1; /* �����addr�Ƿ���ΪHASH����ͱȽϵIJ���, ��:MAC��ַ��������� */
UCHAR addr_skip_for_layer_cmp:1;/*�����addr�Ƿ���Ϊ��ַ�ȽϵIJ㼶���磺MPLS��ַ����Ϊ�������㣬ֱ����������ֵĬ��Ϊ0������Ҫ�Ƚ�*/
UCHAR need_update_opposite_addr:1;/*�����addr�Ƿ��ڶԲ�����ʱ���£��磺MPLS��ǩ�ǶԳ�ʱ��Ҫ��S2C���һ������¼�����ǩ,��ֵĬ��Ϊ0��������Ҫ����*/
diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h
index d039d74..5f6b4c4 100644
--- a/include/public/stream_inc/stream_control.h
+++ b/include/public/stream_inc/stream_control.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#define STREAM_CONTROL_H_VERSION (20191218)
+#define STREAM_CONTROL_H_VERSION (20191226)
#define TCP_CTEAT_LINK_BYSYN 0x01 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
#define TCP_CTEAT_LINK_BYDATA 0x02 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
@@ -34,6 +34,10 @@ enum MESA_stream_opt{
MSO_GLOBAL_STREAM_ID, /* opt_val type must be unsigned long long, is value-result argument, IN: device_id, value range[0, 4095]; OUT:global stream id */
MSO_DROP_STREAM, /* opt_val type must be int, value only be [0,1]; similar to DROPPKT, but effective scope is stream. */
MSO_TCP_RST_REMEDY, /* opt_val type must be int, value only be [0,1]; if not set this, default is disable. */
+ MSO_TOTAL_INBOUND_PKT, /* opt_val type must be unsigned long long */
+ MSO_TOTAL_INBOUND_BYTE, /* opt_val type must be unsigned long long */
+ MSO_TOTAL_OUTBOUND_PKT, /* opt_val type must be unsigned long long */
+ MSO_TOTAL_OUTBOUND_BYTE,/* opt_val type must be unsigned long long */
__MSO_MAX,
};
@@ -64,11 +68,15 @@ enum sapp_platform_opt{
SPO_FIELD_STAT_HANDLE, /* field stat output handle, opt_val type must be void * */
SPO_INDEPENDENT_THREAD_ID, /* plug independent thread which is created by pthread_create(), opt_val type must be int */
SPO_DEPLOYMENT_MODE_STR, /* opt_val type is char[], optional value is:["mirror", "inline", "transparent"] */
- SPO_TOTAL_EGRESS_PKT, /* total egress packet number, effective in inline or transparent mode, opt_val type must be unsigned long long */
- SPO_TOTAL_EGRESS_BYTE, /* total egress packet byte, effective in inline or transparent mode, opt_val type must be unsigned long long */
+ //SPO_TOTAL_EGRESS_PKT, /* total egress packet number, effective in inline or transparent mode, opt_val type must be unsigned long long */
+ //SPO_TOTAL_EGRESS_BYTE, /* total egress packet byte, effective in inline or transparent mode, opt_val type must be unsigned long long */
SPO_TCP_STREAM_NEW, /* total created tcp streams from start, opt_val type must be unsigned long long */
SPO_TCP_STREAM_CLOSE, /* total closed tcp streams from start, opt_val type must be unsigned long long */
- SPO_TCP_STREAM_LIVE, /* realtime established tcp streams, opt_val type must be unsigned long long */
+ SPO_TCP_STREAM_ESTAB, /* realtime established tcp streams, opt_val type must be unsigned long long */
+ SPO_TOTAL_INBOUND_PKT, /* total inbound packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_INBOUND_BYTE, /* total inbound packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_OUTBOUND_PKT, /* total outbound packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_OUTBOUND_BYTE, /* total outbound packet bytes, opt_val type must be unsigned long long */
};
diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp
index fdcff12..a396ca6 100644
--- a/src/config/config_parse.cpp
+++ b/src/config/config_parse.cpp
@@ -578,6 +578,8 @@ int sapp_parse_config(void)
if(str_tmp[0] != '\0'){
pconfig->packet_io.input_bpf_filter = strdup(str_tmp);
}
+ tomlc99_wrap_load_int_def(default_config_file, (char *)"PACKET_IO", (char *)"inbound_route_dir", &pconfig->packet_io.inbound_route_dir, 0);
+
tomlc99_wrap_load_string_def(default_config_file, (char *)"packet_io.depolyment", (char *)"mode", pconfig->packet_io.depolyment_mode_str, NAME_MAX, "mirror");
tomlc99_wrap_load_string_def(default_config_file, (char *)"packet_io.internal.interface", (char *)"type", pconfig->packet_io.internal.interface.type_str, NAME_MAX, "pcap");
tomlc99_wrap_load_string_def(default_config_file, (char *)"packet_io.internal.interface", (char *)"name", pconfig->packet_io.internal.interface.name, NAME_MAX, "lo");
diff --git a/src/dealpkt/deal_arp.c b/src/dealpkt/deal_arp.c
index 3c08ef1..1c0c767 100644
--- a/src/dealpkt/deal_arp.c
+++ b/src/dealpkt/deal_arp.c
@@ -8,6 +8,8 @@ extern "C" {
int arp_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_hdr,
int thread_num, unsigned char dir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr)
{
+
+
/* ˫��������ģʽ������ת��ARP, ��������ͨѶ�޷�������ȡ�Է�MAC */
if(NET_CONN_SERIAL_2CARD == g_topology_mode){
return PASS;
diff --git a/src/dealpkt/deal_ethernet.c b/src/dealpkt/deal_ethernet.c
index 73c1906..f967526 100644
--- a/src/dealpkt/deal_ethernet.c
+++ b/src/dealpkt/deal_ethernet.c
@@ -82,7 +82,14 @@ int eth_entry(struct streaminfo_private *fstream_pr, const void *this_layer_hdr,
//g_SysInputInfo[thread_num][PKT_ETHERNET]++;
//g_SysInputInfo[thread_num][PKT_ETHERNET_LEN] += (unsigned long long)raw_pkt->raw_pkt_len;
local_sys_stat->count[SAPP_STAT_RCV_ETHERNET]++;
- local_sys_stat->length[SAPP_STAT_RCV_ETHERNET] += (unsigned long long)raw_pkt->raw_pkt_len;;
+ local_sys_stat->length[SAPP_STAT_RCV_ETHERNET] += (unsigned long long)raw_pkt->raw_pkt_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)raw_pkt->raw_pkt_len;
+ }else{
+ local_sys_stat->count[SAPP_STAT_ETH_OUTBOUND]++;
+ local_sys_stat->length[SAPP_STAT_ETH_OUTBOUND] += (unsigned long long)raw_pkt->raw_pkt_len;
+ }
}else{
pstream_pr = NULL; /* ʹ�ϲ����Э���pfatherΪNULL */
next_layer_offset = 0;
diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c
index 163ed0f..a8398f0 100644
--- a/src/dealpkt/deal_tcp.c
+++ b/src/dealpkt/deal_tcp.c
@@ -718,6 +718,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex,
pdetail_pr->iserverseq=ntohl (this_tcphdr->th_ack);
//pdetail->clientpkt++; //adjust by lqy 20140515 ֻ���½�ʱ����
pdetail_pr->S2C_first_ack_seq = pdetail_pr->iserverseq;
+ pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir ^ 1;
}
else if(createdir==DIR_C2S)
{
@@ -725,6 +726,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex,
pdetail_pr->iserverseq=ntohl (this_tcphdr->th_seq)+1;
//pdetail->serverpkt++; //adjust by lqy 20140515 ֻ���½�ʱ����
pdetail_pr->C2S_first_ack_seq = ntohl (this_tcphdr->th_ack);
+ pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir;
}
pdetail->lastmtime=g_CurrentTime;
pdetail_pr->link_state=STREAM_LINK_JUST_EST;
@@ -1006,6 +1008,11 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex,
pdetail_pr->auto_remedy_flag = sapp_global_val->config.stream.tcp.inject.auto_remedy;
+ if(createdir==DIR_C2S){
+ pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir;
+ }else{
+ pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir ^ 1;
+ }
return pindex_tcp;
}
diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c
index 8f2e6bb..d8398ef 100644
--- a/src/dealpkt/deal_udp.c
+++ b/src/dealpkt/deal_udp.c
@@ -208,6 +208,11 @@ static struct streamindex *udp_add_new_stream(struct streamindex *pindex,
}
save_polling_inject_context(pstream_udp_pr, raw_pkt);
+ if(createdir==DIR_C2S){
+ pstream_udp_pr->stream_c2s_route_dir = raw_pkt->route_dir;
+ }else{
+ pstream_udp_pr->stream_c2s_route_dir = raw_pkt->route_dir ^ 1;
+ }
return pindex_udp;
}
diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c
index d23da9b..6c42218 100644
--- a/src/dealpkt/plug_support.c
+++ b/src/dealpkt/plug_support.c
@@ -397,6 +397,80 @@ int get_thread_count(void)
}
+/*
+ ctype:
+ 'c':count;
+ 'l':length;
+*/
+static inline unsigned long long __get_stream_opt_traffic(int cltype, int iotype, struct streaminfo_private *pstream_pr)
+{
+ unsigned long long tval;
+ struct streaminfo *pstream = &pstream_pr->stream_public;
+
+ if('c' == cltype){ /* count */
+ if('i' == iotype){ /* inbound */
+ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->serverpktnum;
+ }else{
+ tval = pstream->pudpdetail->serverpktnum;
+ }
+ }else{
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->clientpktnum;
+ }else{
+ tval = pstream->pudpdetail->clientpktnum;
+ }
+ }
+ }else{ /* outbound */
+ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->clientpktnum;
+ }else{
+ tval = pstream->pudpdetail->clientpktnum;
+ }
+ }else{
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->serverpktnum;
+ }else{
+ tval = pstream->pudpdetail->serverpktnum;
+ }
+ }
+ }
+ }else{/* length */
+ if('i' == iotype){ /* inbound */
+ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->serverbytes;
+ }else{
+ tval = pstream->pudpdetail->serverbytes;
+ }
+ }else{
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->clientbytes;
+ }else{
+ tval = pstream->pudpdetail->clientbytes;
+ }
+ }
+ }else{ /* outbound */
+ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->clientbytes;
+ }else{
+ tval = pstream->pudpdetail->clientbytes;
+ }
+ }else{
+ if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){
+ tval = pstream->ptcpdetail->serverbytes;
+ }else{
+ tval = pstream->pudpdetail->serverbytes;
+ }
+ }
+ }
+ }
+
+ return tval;
+}
int MESA_set_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt opt, void *opt_val, int opt_val_len)
{
int ret = -1;
@@ -517,6 +591,7 @@ int MESA_set_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
pdetail_pr->auto_remedy_flag = (remedy_flag != 0 ? 1:0);
ret = 0;
}
+ break;
default:
sapp_runtime_log(RLOG_LV_INFO, "MESA_set_stream_opt() error: unsupport MESA_stream_opt type!\n");
@@ -889,7 +964,54 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
ret = 0;
}
break;
-
+
+ case MSO_TOTAL_INBOUND_PKT:
+ {
+ if((STREAM_TYPE_TCP != pstream->type) && (STREAM_TYPE_UDP != pstream->type)){
+ sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_PKT error: stream type is not tcp or udp!\n");
+ ret = -1;
+ break;
+ }
+ unsigned long long *inbound_pkt = (unsigned long long *)opt_val;
+ *inbound_pkt = __get_stream_opt_traffic('c', 'i', (struct streaminfo_private *)pstream);
+ }
+ break;
+
+ case MSO_TOTAL_OUTBOUND_PKT:
+ {
+ if((STREAM_TYPE_TCP != pstream->type) && (STREAM_TYPE_UDP != pstream->type)){
+ sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_OUTBOUND_PKT error: stream type is not tcp or udp!\n");
+ ret = -1;
+ break;
+ }
+ unsigned long long *outbound_pkt = (unsigned long long *)opt_val;
+ *outbound_pkt = __get_stream_opt_traffic('c', 'o', (struct streaminfo_private *)pstream);
+ }
+ break;
+
+ case MSO_TOTAL_INBOUND_BYTE:
+ {
+ if((STREAM_TYPE_TCP != pstream->type) && (STREAM_TYPE_UDP != pstream->type)){
+ sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_BYTE error: stream type is not tcp or udp!\n");
+ ret = -1;
+ break;
+ }
+ unsigned long long *inbound_byte = (unsigned long long *)opt_val;
+ *inbound_byte = __get_stream_opt_traffic('l', 'i', (struct streaminfo_private *)pstream);
+ }
+ break;
+
+ case MSO_TOTAL_OUTBOUND_BYTE:
+ {
+ if((STREAM_TYPE_TCP != pstream->type) && (STREAM_TYPE_UDP != pstream->type)){
+ sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_OUTBOUND_BYTE error: stream type is not tcp or udp!\n");
+ ret = -1;
+ break;
+ }
+ unsigned long long *outbound_byte = (unsigned long long *)opt_val;
+ *outbound_byte = __get_stream_opt_traffic('l', 'o', (struct streaminfo_private *)pstream);
+ }
+ break;
default:
sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() error:unsupport MESA_stream_opt type:%d!\n", opt);
ret = -1;
diff --git a/src/inner_plug/sapp_assistant.cpp b/src/inner_plug/sapp_assistant.cpp
index 88d4dcb..b51493e 100644
--- a/src/inner_plug/sapp_assistant.cpp
+++ b/src/inner_plug/sapp_assistant.cpp
@@ -107,7 +107,7 @@ int sapp_identify_broad_multicast_pkt(const void *this_layer_data, const raw_pkt
'c':count;
'l':length;
*/
-static unsigned long long __get_platform_opt_traffic(int ctype, sapp_sys_stat_type_t index)
+static inline unsigned long long __get_platform_opt_traffic(int ctype, sapp_sys_stat_type_t index)
{
int i;
unsigned long long tmp_long = 0;
@@ -158,27 +158,53 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va
}
break;
- case SPO_TOTAL_EGRESS_PKT:
+ case SPO_TOTAL_INBOUND_PKT:
{
if(*opt_val_len != sizeof(long long)){
ret = -1;
sapp_runtime_log(RLOG_LV_DEBUG, "sapp_get_platform_opt() error:opt_val_len:%d is invalid!\n", *opt_val_len);
break;
}
- unsigned long long *tot_byte = (unsigned long long *)opt_val;
- *tot_byte = *tot_byte = __get_platform_opt_traffic('c', SAPP_STAT_ETH_EGRESS);;
+ unsigned long long *inbound_pkt = (unsigned long long *)opt_val;
+ *inbound_pkt = __get_platform_opt_traffic('c', SAPP_STAT_ETH_INBOUND);
}
break;
- case SPO_TOTAL_EGRESS_BYTE:
+ case SPO_TOTAL_INBOUND_BYTE:
{
if(*opt_val_len != sizeof(long long)){
ret = -1;
sapp_runtime_log(RLOG_LV_DEBUG, "sapp_get_platform_opt() error:opt_val_len:%d is invalid!\n", *opt_val_len);
break;
}
- unsigned long long *tot_byte = (unsigned long long *)opt_val;
- *tot_byte = *tot_byte = __get_platform_opt_traffic('l', SAPP_STAT_ETH_EGRESS);;
+ unsigned long long *inbound_byte = (unsigned long long *)opt_val;
+ *inbound_byte = __get_platform_opt_traffic('l', SAPP_STAT_ETH_INBOUND);
+
+ }
+ break;
+
+ case SPO_TOTAL_OUTBOUND_PKT:
+ {
+ if(*opt_val_len != sizeof(long long)){
+ ret = -1;
+ sapp_runtime_log(RLOG_LV_DEBUG, "sapp_get_platform_opt() error:opt_val_len:%d is invalid!\n", *opt_val_len);
+ break;
+ }
+ unsigned long long *outbound_pkt = (unsigned long long *)opt_val;
+ *outbound_pkt = __get_platform_opt_traffic('c', SAPP_STAT_ETH_OUTBOUND);
+ }
+ break;
+
+ case SPO_TOTAL_OUTBOUND_BYTE:
+ {
+ if(*opt_val_len != sizeof(long long)){
+ ret = -1;
+ sapp_runtime_log(RLOG_LV_DEBUG, "sapp_get_platform_opt() error:opt_val_len:%d is invalid!\n", *opt_val_len);
+ break;
+ }
+ unsigned long long *outbound_byte = (unsigned long long *)opt_val;
+ *outbound_byte = __get_platform_opt_traffic('l', SAPP_STAT_ETH_OUTBOUND);
+
}
break;
@@ -194,7 +220,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va
}
break;
- case SPO_TCP_STREAM_LIVE:
+ case SPO_TCP_STREAM_ESTAB:
{
if(*opt_val_len != sizeof(long long)){
ret = -1;
@@ -636,6 +662,14 @@ static int sapp_fs2_init(void)
pfs_para->fs_id_count_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Pkt");
pfs_para->fs_id_length_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Bit");
+ if((DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin)
+ || (DEPOLYMENT_MODE_TRANSPARENT == sapp_global_val->config.packet_io.depolyment_mode_bin)){
+ pfs_para->fs_id_count_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Inbound");
+ pfs_para->fs_id_length_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Inbound");
+ pfs_para->fs_id_count_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Outbound");
+ 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_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");
diff --git a/src/packet_io/packet_io.c b/src/packet_io/packet_io.c
index 53268db..fc66d5a 100644
--- a/src/packet_io/packet_io.c
+++ b/src/packet_io/packet_io.c
@@ -100,6 +100,7 @@ extern void pptp_per_thread_exit(int thread_seq);
extern void __timestamp_print_max_tuple4(const raw_pkt_t *raw_pkt, long timedelay, int tid);
extern int packet_io_device_alias_init(void);
extern void sapp_fs2_set_latency(int thead_seq, long long time_cost);
+extern void plugctrl_destroy_all_plug(void);
static const unsigned char phony_feedback_eth_hdr_ip4[ETHERNET_HDR_LEN] =
{0x50, 0x48, 0x4F, 0x4E, 0x59, 0x5F, 0x4D, 0x41, 0x43, 0x41, 0x44, 0x44, 0x08, 0x00}; /* PHONY_MACADD + ipv4 */
@@ -643,10 +644,7 @@ static int mesa_default_pkt_cb(const raw_pkt_t *p_raw_pkt, unsigned char dir, in
ret = g_platform_action_cb_fun(sapp_global_val->config.packet_io.depolyment_mode_bin, ret);
}
- if((PASS == ret) && (g_topology_mode & __NET_CONN_SERIAL)){
- sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_ETH_EGRESS]++;
- sapp_global_val->mthread_volatile[thread_num]->sys_stat.length[SAPP_STAT_ETH_EGRESS]+= p_raw_pkt->raw_pkt_len;
- }
+
return ret;
}
@@ -660,6 +658,8 @@ void packet_io_exit(void)
sleep(1);
sched_yield();
sleep(1);
+
+ plugctrl_destroy_all_plug();
exit(1);
@@ -1086,10 +1086,7 @@ int packet_io_send_fake_pkt(MESA_send_handle *send_handle,int datalen,int send_t
thread_num);
}
- if(ret >= 0){
- sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_ETH_EGRESS]++;
- sapp_global_val->mthread_volatile[thread_num]->sys_stat.length[SAPP_STAT_ETH_EGRESS] += datalen;
- }
+
return ret;
}
diff --git a/src/packet_io/packet_io_marsio.c b/src/packet_io/packet_io_marsio.c
index 27f3309..a09aca1 100644
--- a/src/packet_io/packet_io_marsio.c
+++ b/src/packet_io/packet_io_marsio.c
@@ -475,6 +475,7 @@ static inline int marsio4_pkt_hand(int tid, marsio_buff_t *rx_buff, raw_pkt_t *r
raw_pkt->__lib_raw_pkt_len = marsio_buff_datalen(rx_buff);
raw_pkt->raw_pkt_len = raw_pkt->__lib_raw_pkt_len;
raw_pkt->io_lib_pkt_reference = rx_buff;
+ raw_pkt->route_dir = mr_ctrlzone->route_dir;
ret = (*g_marsio4_work_fun)((const raw_pkt_t *)raw_pkt, mr_ctrlzone->route_dir, tid);
diff --git a/src/packet_io/packet_io_pcap.c b/src/packet_io/packet_io_pcap.c
index 2c92083..24ab773 100644
--- a/src/packet_io/packet_io_pcap.c
+++ b/src/packet_io/packet_io_pcap.c
@@ -1070,6 +1070,7 @@ retry:
pkt_queue_node.route_dir = *((unsigned char *)user);
pkt_queue_node.raw_pkt.hd_hash = 0; /* 2016-05-05 lijia add, pcapģʽ��֧��Ӳ��HASH */
pkt_queue_node.raw_pkt.io_lib_pkt_reference = pkt_queue_node.raw_pkt.__lib_raw_pkt_data; /* ����dpdkģʽ, ���˱�����ֵ */
+ pkt_queue_node.raw_pkt.route_dir = *((unsigned char *)user);
pkt_queue_node.op_flag = PCAP_OP_FLAG_PKT;
#if DEBUG
diff --git a/src/packet_io/packet_io_status.cpp b/src/packet_io/packet_io_status.cpp
index 3afab4c..d3932e5 100644
--- a/src/packet_io/packet_io_status.cpp
+++ b/src/packet_io/packet_io_status.cpp
@@ -120,6 +120,15 @@ static void field_stat2_update_metrics(void)
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 */
+
+ if((DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin)
+ || (DEPOLYMENT_MODE_TRANSPARENT == sapp_global_val->config.packet_io.depolyment_mode_bin)){
+ sapp_fs2_update_count(SAPP_STAT_ETH_INBOUND, cur_count[SAPP_STAT_ETH_INBOUND]);
+ sapp_fs2_update_length(SAPP_STAT_ETH_INBOUND, 8 *( cur_length[SAPP_STAT_ETH_INBOUND])); /* to bps, bit per second */
+
+ sapp_fs2_update_count(SAPP_STAT_ETH_OUTBOUND, cur_count[SAPP_STAT_ETH_OUTBOUND]);
+ sapp_fs2_update_length(SAPP_STAT_ETH_OUTBOUND, 8 *( cur_length[SAPP_STAT_ETH_OUTBOUND])); /* to bps, bit per second */
+ }
sapp_fs2_update_count(SAPP_STAT_RCV_IPV4, cur_count[SAPP_STAT_RCV_IPV4]);
sapp_fs2_update_length(SAPP_STAT_RCV_IPV4, 8 *(cur_length[SAPP_STAT_RCV_IPV4]));
diff --git a/src/plugin/src/plugin.c b/src/plugin/src/plugin.c
index c987c1b..77e2e16 100644
--- a/src/plugin/src/plugin.c
+++ b/src/plugin/src/plugin.c
@@ -1919,3 +1919,38 @@ char PROT_PROCESS(stSessionInfo* session_info, void **pme, int thread_seq,struct
}
+extern stBusinessPlugInfo* g_platform_plug_info;
+extern stBusinessPlugInfo* g_business_plug_info;
+extern stProtocolPlugInfo* g_protocol_plug_info;
+
+void plugctrl_destroy_all_plug(void)
+{
+ stBusinessPlugInfo *plug_info;
+ stProtocolPlugInfo *pro_plug_info;
+
+ plug_info = g_platform_plug_info;
+ while(plug_info){
+ if(plug_info->fun_destroy){
+ plug_info->fun_destroy();
+ }
+ plug_info = plug_info->next;
+ }
+
+ pro_plug_info = g_protocol_plug_info;
+ while(pro_plug_info){
+ if(pro_plug_info->fun_destroy){
+ pro_plug_info->fun_destroy();
+ }
+ pro_plug_info = pro_plug_info->next;
+ }
+
+ plug_info = g_business_plug_info;
+ while(plug_info){
+ if(plug_info->fun_destroy){
+ plug_info->fun_destroy();
+ }
+ plug_info = plug_info->next;
+ }
+}
+
+
diff --git a/test/Makefile b/test/Makefile
index cdd2f95..5f8b757 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -11,7 +11,7 @@ BIN_PATH = ../bin/
TARGET = test_app_sapp.so
#TARGET += wangyan_gdev_measurement.so
#TARGET += test_anti_flood_hijack
-TARGET += sapp_so_run
+#TARGET += sapp_so_run
INCS =
diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c
index 4b6f7d4..00cfc7f 100644
--- a/test/test_app_sapp.c
+++ b/test/test_app_sapp.c
@@ -354,6 +354,40 @@ char test_sapp_get_platform_opt(struct streaminfo *pstream, void **pme, int thr
return APP_STATE_GIVEME;
}
+
+char test_get_stream_in_out_bound(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet)
+{
+ int ret;
+ unsigned long long inound_stat[2];
+ unsigned long long outound_stat[2];
+ int opt_len;
+
+
+
+ if(pstream->opstate== OP_STATE_CLOSE){
+ opt_len = sizeof(long long);
+ ret = MESA_get_stream_opt(pstream, MSO_TOTAL_INBOUND_PKT, &inound_stat[0], &opt_len);
+ assert(ret >= 0);
+
+ opt_len = sizeof(long long);
+ ret = MESA_get_stream_opt(pstream, MSO_TOTAL_INBOUND_BYTE, &inound_stat[1], &opt_len);
+ assert(ret >= 0);
+
+ opt_len = sizeof(long long);
+ ret = MESA_get_stream_opt(pstream, MSO_TOTAL_OUTBOUND_PKT, &outound_stat[0], &opt_len);
+ assert(ret >= 0);
+
+ opt_len = sizeof(long long);
+ ret = MESA_get_stream_opt(pstream, MSO_TOTAL_OUTBOUND_BYTE, &outound_stat[1], &opt_len);
+ assert(ret >= 0);
+
+ printf("stream: %s, inbound: %llu, %llu, outbound: %llu, %llu\n", printaddr(&pstream->addr, thread_seq),
+ inound_stat[0], inound_stat[1], outound_stat[0], outound_stat[1]);
+ }
+
+ return APP_STATE_GIVEME;
+}
+
int test_sapp_get_device_opt(const char *device)
{
int ret;
diff --git a/version.txt b/version.txt
index 02ec16a..13bb84d 100644
--- a/version.txt
+++ b/version.txt
@@ -3,16 +3,16 @@
VCS_TYPE="git"
VCS_BASENAME="v4.0"
VCS_UUID="efa070923d8398b49f41acda82b839d11eb75230"
-VCS_NUM="144"
-VCS_DATE="2019-12-18T11:25:47+0800"
-VCS_BRANCH="feature-v4.0-get-traffic"
+VCS_NUM="147"
+VCS_DATE="2019-12-31T11:38:03+0800"
+VCS_BRANCH="feature_inbound_outbound"
VCS_TAG="v4.0.7"
-VCS_TICK="0"
+VCS_TICK="3"
VCS_EXTRA=""
VCS_ACTION_STAMP=""
-VCS_FULL_HASH="422766471efa716d82f8d50f6041bb5944cd1d1a"
-VCS_SHORT_HASH="4227664"
+VCS_FULL_HASH="06731c3bb2818b398884990af62ab05a401d1f78"
+VCS_SHORT_HASH="06731c3"
VCS_WC_MODIFIED="1"