修复一些已知的bug

* 修复keepalive_replay_htable add失败的问题
* 修改clock_gettime的参数为CLOCK_REALTIME
* 修改kni.conf中keepalive_replay_htable的超时时间为0(不超时)
This commit is contained in:
崔一鸣
2019-06-10 19:55:38 +08:00
parent 88c91689a0
commit fe088bce61
2 changed files with 48 additions and 15 deletions

View File

@@ -203,7 +203,7 @@ static struct pme_info* pme_info_new(const struct streaminfo *stream, int thread
uuid_generate_random(uu);
uuid_unparse(uu, pmeinfo->stream_traceid);
pmeinfo->addr = layer_addr_dup(&(stream->addr));
clock_gettime(CLOCK_MONOTONIC, &(pmeinfo->start_time));
clock_gettime(CLOCK_REALTIME, &(pmeinfo->start_time));
char stream_addr[KNI_SYMBOL_MAX] = "";
//init pme_lock
int ret = pthread_mutex_init(&(pmeinfo->lock), NULL);
@@ -371,19 +371,51 @@ static void judge_pme_destroy(struct pme_info *pmeinfo, int caller){
}
//only intercetp stream need del htable
if(pmeinfo->action == KNI_ACTION_INTERCEPT){
//del traceid2pme htable
int key_size = strnlen(pmeinfo->stream_traceid, sizeof(pmeinfo->stream_traceid));
ret = MESA_htable_del(g_kni_handle->traceid2pme_htable, (const unsigned char *)pmeinfo->stream_traceid,
key_size, NULL);
if(ret < 0){
KNI_LOG_ERROR(logger, "MESA_htable: failed at del, table is %s, key is %s, key_size is %d, ret is %d",
KNI_LOG_ERROR(logger, "MESA_htable: Failed at del, table is %s, key is %s, key_size is %d, ret is %d",
"traceid2pme_htable", pmeinfo->stream_traceid, key_size, ret);
FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_DEL_FAIL], 0, FS_OP_ADD, 1);
}
else{
KNI_LOG_DEBUG(logger, "MESA_htable: succeed at del, table is %s, key is %s, key_size is %d",
KNI_LOG_DEBUG(logger, "MESA_htable: Succeed at del, table is %s, key is %s, key_size is %d",
"traceid2pme_htable", pmeinfo->stream_traceid, key_size);
FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_DEL_SUCC], 0, FS_OP_ADD, 1);
}
//del keepalive_replay_htable
char stream_addr[KNI_SYMBOL_MAX] = "";
kni_stream_addr_trans((const layer_addr*)(pmeinfo->addr), stream_addr, sizeof(stream_addr));
//c2s
struct stream_tuple4_v4 *c2s_key = pmeinfo->addr->tuple4_v4;
key_size = sizeof(*c2s_key);
ret = MESA_htable_del(g_kni_handle->keepalive_replay_htable, (const unsigned char*)c2s_key, key_size, NULL);
if(ret < 0){
KNI_LOG_ERROR(logger, "MESA_htable: Failed at del, table is %s, stream addr is %s, dir is c2s, ret is %d",
"keepalive_replay_htable", stream_addr, ret);
}
else{
KNI_LOG_DEBUG(logger, "MESA_htable: Succeed at del, table is %s, stream addr is %s, dir is c2s",
"keepalive_replay_htable", stream_addr);
}
//s2c
struct stream_tuple4_v4 s2c_key;
key_size = sizeof(s2c_key);
s2c_key.saddr = c2s_key->daddr;
s2c_key.daddr = c2s_key->saddr;
s2c_key.source = c2s_key->dest;
s2c_key.dest = c2s_key->source;
ret = MESA_htable_del(g_kni_handle->keepalive_replay_htable, (const unsigned char*)&s2c_key, key_size, NULL);
if(ret < 0){
KNI_LOG_ERROR(logger, "MESA_htable: Failed at del, table is %s, stream addr is %s, dir is s2c, ret is %d",
"keepalive_replay_htable", stream_addr, ret);
}
else{
KNI_LOG_DEBUG(logger, "MESA_htable: Succeed at del, table is %s, stream addr is %s, dir is s2c",
"keepalive_replay_htable", stream_addr);
}
}
//free pme
pme_info_destroy(pmeinfo);
@@ -719,12 +751,12 @@ static char data_opstate(const struct streaminfo *stream, struct pme_info *pmein
ret = MESA_htable_add(g_kni_handle->traceid2pme_htable, (const unsigned char *)(pmeinfo->stream_traceid),
key_size, (const void*)pmeinfo);
if(ret < 0){
KNI_LOG_ERROR(logger, "MESA_htable: failed at MESA_htable_add,"
"table is traceid2pme_htable, key is %s", pmeinfo->stream_traceid);
KNI_LOG_ERROR(logger, "MESA_htable: Failed at add,"
"table is traceid2pme_htable, key is %s, ret is %d", pmeinfo->stream_traceid, ret);
FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_ADD_FAIL], 0, FS_OP_ADD, 1);
}
else{
KNI_LOG_DEBUG(logger, "MESA_htable: succeed at MESA_htable_add,"
KNI_LOG_DEBUG(logger, "MESA_htable: Succeed at add,"
"table is traceid2pme_htable, key is %s", pmeinfo->stream_traceid);
FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_ADD_SUCC], 0, FS_OP_ADD, 1);
}
@@ -738,12 +770,12 @@ static char data_opstate(const struct streaminfo *stream, struct pme_info *pmein
ret = MESA_htable_add(g_kni_handle->keepalive_replay_htable, (const unsigned char *)c2s_key,
key_size, (const void*)c2s_value);
if(ret < 0){
KNI_LOG_ERROR(logger, "MESA_htable: failed at MESA_htable_add,"
"table is keepalive_replay_htable, dir is c2s, stream is %s", stream_addr);
KNI_LOG_ERROR(logger, "MESA_htable: Failed at add,"
"table is keepalive_replay_htable, dir is c2s, stream is %s, ret is %d", stream_addr, ret);
//FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_ADD_FAIL], 0, FS_OP_ADD, 1);
}
else{
KNI_LOG_DEBUG(logger, "MESA_htable: succeed at MESA_htable_add,"
KNI_LOG_DEBUG(logger, "MESA_htable: Succeed at add,"
"table is keepalive_replay_htable, dir is c2s, stream is %s", stream_addr);
//FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_ADD_SUCC], 0, FS_OP_ADD, 1);
}
@@ -757,12 +789,12 @@ static char data_opstate(const struct streaminfo *stream, struct pme_info *pmein
ret = MESA_htable_add(g_kni_handle->keepalive_replay_htable, (const unsigned char *)(&s2c_key),
key_size, (const void*)s2c_value);
if(ret < 0){
KNI_LOG_ERROR(logger, "MESA_htable: failed at MESA_htable_add,"
"table is keepalive_replay_htable, dir is s2c, stream is %s", stream_addr);
KNI_LOG_ERROR(logger, "MESA_htable: Failed at add,"
"table is keepalive_replay_htable, dir is s2c, stream is %s, ret is %d", stream_addr, ret);
//FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_ADD_FAIL], 0, FS_OP_ADD, 1);
}
else{
KNI_LOG_DEBUG(logger, "MESA_htable: succeed at MESA_htable_add,"
KNI_LOG_DEBUG(logger, "MESA_htable: Succeed at add,"
"table is keepalive_replay_htable, dir is s2c, stream is %s", stream_addr);
//FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_ID2PME_ADD_SUCC], 0, FS_OP_ADD, 1);
}
@@ -790,7 +822,7 @@ static char data_opstate(const struct streaminfo *stream, struct pme_info *pmein
static char close_opstate(const struct streaminfo *stream, struct pme_info *pmeinfo, struct pkt_info *pktinfo, int thread_seq){
//close: a_packet = null, do not sendto tfe
clock_gettime(CLOCK_MONOTONIC, &(pmeinfo->end_time));
clock_gettime(CLOCK_REALTIME, &(pmeinfo->end_time));
void *logger = g_kni_handle->local_logger;
pmeinfo->server_bytes=stream->ptcpdetail->serverbytes;
pmeinfo->client_bytes=stream->ptcpdetail->clientbytes;
@@ -1130,7 +1162,7 @@ static long traceid2pme_htable_search_cb(void *data, const uchar *key, uint size
wrapped_kni_cmsg_get(pmeinfo, cmsg, TFE_CMSG_SSL_PINNING_STATE, sizeof(pmeinfo->pinningst), logger);
wrapped_kni_cmsg_get(pmeinfo, cmsg, TFE_CMSG_SSL_CERT_VERIFY, sizeof(pmeinfo->ssl_cert_verify), logger);
wrapped_kni_cmsg_get(pmeinfo, cmsg, TFE_CMSG_SSL_ERROR, sizeof(pmeinfo->ssl_error), logger);
clock_gettime(CLOCK_MONOTONIC, &(pmeinfo->end_time));
clock_gettime(CLOCK_REALTIME, &(pmeinfo->end_time));
KNI_LOG_INFO(logger, "recv cmsg from tfe, stream traceid is %s", pmeinfo->stream_traceid);
judge_pme_destroy(pmeinfo, CALLER_TFE);
}