不再数据处理线程将数据write到tun中,而是拷贝到队列中,由单独线程处理。本版本目前在性能测试过程中用于调试对比,目前不加入主版本中
This commit is contained in:
40
kni_entry.c
40
kni_entry.c
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
int g_kni_version_VERSION_20181122_htable_add;
|
||||
int g_kni_version_VERSION_20181123_test;
|
||||
|
||||
struct kni_var_comm g_kni_comminfo;
|
||||
struct kni_var_struct g_kni_structinfo;
|
||||
@@ -548,7 +548,8 @@ char kni_pending_opstate(const struct streaminfo* pstream,struct kni_pme_info* p
|
||||
ret=kni_first_tcpdata(pstream,a_packet,pmeinfo,data,datalen);
|
||||
if((pmeinfo->protocol==KNI_FLAG_HTTP) ||(pmeinfo->protocol==KNI_FLAG_SSL))
|
||||
{
|
||||
ret=tun_write_data(g_kni_comminfo.fd_tun[thread_seq],(char*)ipv4_hdr,iplen,(struct streaminfo*)pstream,thread_seq);
|
||||
kni_add_lqueue(ADDR_TYPE_IPV4,thread_seq,(char*)ipv4_hdr,iplen);
|
||||
// ret=tun_write_data(g_kni_comminfo.fd_tun[thread_seq],(char*)ipv4_hdr,iplen,(struct streaminfo*)pstream,thread_seq);
|
||||
}
|
||||
}
|
||||
#ifndef KNI_DEBUG_TCPREPAIR
|
||||
@@ -632,7 +633,8 @@ char kni_data_opstate(const struct streaminfo* pstream,struct kni_pme_info* pmei
|
||||
|
||||
if((pmeinfo->action == KNI_ACTION_MONITOR) && ((pmeinfo->protocol==KNI_FLAG_HTTP)||(pmeinfo->protocol==KNI_FLAG_SSL)))
|
||||
{
|
||||
ret=tun_write_data(g_kni_comminfo.fd_tun[thread_seq],(char*)a_packet,iplen,(struct streaminfo*)pstream,thread_seq);
|
||||
kni_add_lqueue(ADDR_TYPE_IPV4,thread_seq,(char*)a_packet,iplen);
|
||||
// ret=tun_write_data(g_kni_comminfo.fd_tun[thread_seq],(char*)a_packet,iplen,(struct streaminfo*)pstream,thread_seq);
|
||||
}
|
||||
else if(pmeinfo->action == KNI_ACTION_RATELIMIT)
|
||||
{
|
||||
@@ -1279,6 +1281,31 @@ int init_kni_sendpkt()
|
||||
}
|
||||
|
||||
|
||||
int kni_init_lqueue()
|
||||
{
|
||||
int i=0;
|
||||
|
||||
g_kni_structinfo.lqueue_send_fds=MESA_lqueue_create(KNI_THREAD_SAFE,KNI_LQUEUE_MAXNUM);
|
||||
if(g_kni_structinfo.lqueue_send_fds==NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_FATAL,KNI_MODULE_INIT,"MESA_lqueue_create() error for lqueue_send_fds,action:%s",KNI_ACTION_EXIT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i=0;i<g_iThreadNum;i++)
|
||||
{
|
||||
g_kni_structinfo.lqueue_write_tun[i] = MESA_lqueue_create(0,KNI_LQUEUE_MAXNUM);
|
||||
if(g_kni_structinfo.lqueue_write_tun[i] == NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_FATAL,KNI_MODULE_INIT,"MESA_lqueue_create() error for lqueue_write_tun,thread_num:%d,action:%s",i,KNI_ACTION_EXIT);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
extern "C" char kni_init()
|
||||
{
|
||||
int ret=0;
|
||||
@@ -1320,12 +1347,13 @@ extern "C" char kni_init()
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_kni_structinfo.lqueue_for_domain=MESA_lqueue_create(KNI_THREAD_SAFE,KNI_LQUEUE_MAXNUM);
|
||||
if(g_kni_structinfo.lqueue_for_domain==NULL)
|
||||
|
||||
ret = kni_init_lqueue();
|
||||
if(ret<0)
|
||||
{
|
||||
printf("MESA_lqueue_create() error!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ret = init_kni_tun();
|
||||
|
||||
Reference in New Issue
Block a user