完成发送给tfe部分修改

This commit is contained in:
崔一鸣
2019-08-19 17:23:15 +08:00
parent 47eacf2c3a
commit 020782a71a
2 changed files with 100 additions and 9 deletions

View File

@@ -43,6 +43,12 @@ enum stream_error{
STREAM_ERROR_SENDTO_TFE_FAIL = -11,
};
enum sendto_tfe_mode{
SENDTO_TFE_MODE_TAP = 0,
SENDTO_TFE_MODE_NORMAL = 1,
};
SENDTO_TFE_MODE_TAP
struct http_project{
int host_len;
char host[KNI_DOMAIN_MAX];
@@ -141,6 +147,8 @@ struct thread_tfe_cmsg_receiver_args{
struct kni_handle{
int http_project_id;
struct kni_marsio_handle *marsio_handle;
struct kni_tap_handle *tap_handle;
enum sendto_tfe_mode _sendto_tfe_mode;
struct kni_maat_handle *maat_handle;
struct kni_send_logger *send_logger;
MESA_htable_handle traceid2pme_htable;
@@ -668,8 +676,9 @@ static char* add_cmsg_to_packet(struct pme_info *pmeinfo, struct pkt_info *pktin
return new_pkt;
}
static int send_to_tfe_normal_mode(struct kni_marsio_handle *handle, char *raw_data, uint16_t raw_len, int thread_seq, int tfe_id, addr_type_t addr_type){
static int send_to_tfe_normal_mode(char *raw_data, uint16_t raw_len, int thread_seq, int tfe_id, addr_type_t addr_type){
void *logger = g_kni_handle->local_logger;
struct kni_marsio_handle *handle = g_kni_handle->marsio_handle;
marsio_buff_t *tx_buffs[BURST_MAX];
int index = -1;
for(int i = 0; i < handle->tfe_enabled_node_count; i++){
@@ -712,13 +721,19 @@ static int send_to_tfe_normal_mode(struct kni_marsio_handle *handle, char *raw_d
return 0;
}
static int send_to_tfe(struct tap_mode_handle *handle, char *raw_data, uint16_t raw_len){
int ret;
ret = tap_mode_write()
static int send_to_tfe_tap_mode(char *raw_data, uint16_t raw_len){
struct kni_tap_handle *handle = g_kni_handle->tap_handle;
int ret = kni_tap_write(handle, raw_data, raw_len);
if(ret < 0){
return -1;
}
return 0;
}
static int send_to_tfe(struct kni_marsio_handle *marsio_handle, struct tap_mode_handle *tap_handle, char *raw_data,
uint16_t raw_len, int thread_seq, int tfe_id, addr_type_t addr_type, int mode){
static int send_to_tfe(char *raw_data, uint16_t raw_len, int thread_seq, int tfe_id, addr_type_t addr_type){
struct kni_marsio_handle *marsio_handle = g_kni_handle->marsio_handle;
struct kni_tap_handle *tap_handle = g_kni_handle->tap_handle;
int mode = g_kni_handle->_sendto_tfe_mode;
int ret;
if(mode == SENDTO_TFE_MODE_TAP){
ret = send_to_tfe_tap_mode(tap_handle, raw_data, raw_len);
@@ -873,7 +888,7 @@ static int first_data_intercept(const struct streaminfo *stream, struct pme_info
//action = KNI_ACTION_INTERCEPT, sendto tfe
int len = 0;
char *buff = add_cmsg_to_packet(pmeinfo, pktinfo, &len);
ret = send_to_tfe(g_kni_handle->marsio_handle, g_kni_handle->tap_mode_handle, buff, len, thread_seq, pmeinfo->tfe_id, pmeinfo->addr_type);
ret = send_to_tfe(buff, len, thread_seq, pmeinfo->tfe_id, pmeinfo->addr_type);
if(ret < 0){
KNI_LOG_ERROR(logger, "Failed at send first packet to tfe%d, stream traceid is %s", pmeinfo->tfe_id, pmeinfo->stream_traceid);
FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_SENDTO_TFE_FAIL], 0, FS_OP_ADD, 1);
@@ -920,7 +935,7 @@ static char data_opstate(const struct streaminfo *stream, struct pme_info *pmein
ipv4_hdr = (struct iphdr*)a_packet;
len = ntohs(ipv4_hdr->tot_len);
}
ret = send_to_tfe(g_kni_handle->marsio_handle, g_kni_handle->tap_mode_handle, (char*)a_packet, len, thread_seq, pmeinfo->tfe_id, pmeinfo->addr_type);
ret = send_to_tfe((char*)a_packet, len, thread_seq, pmeinfo->tfe_id, pmeinfo->addr_type);
if(ret < 0){
KNI_LOG_ERROR(logger, "Failed at send continue packet to tfe%d, stream traceid is %s", pmeinfo->tfe_id, pmeinfo->stream_traceid);
FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_SENDTO_TFE_FAIL], 0, FS_OP_ADD, 1);
@@ -1292,7 +1307,7 @@ static long keepalive_replay_search_cb(void *data, const uchar *key, uint size,
replay_packet_iphdr->saddr, replay_packet_iphdr->daddr);
}
//send to tfe: thread_seq = g_iThreadNum
int ret = send_to_tfe(marsio_handle, g_kni_handle->tap_mode_handle, replay_packet, tot_len, g_iThreadNum + thread_seq, tfe_id, args->addr_type);
int ret = send_to_tfe(replay_packet, tot_len, g_iThreadNum + thread_seq, tfe_id);
if(ret < 0){
KNI_LOG_ERROR(logger, "Failed at send keepalive replay packet to tfe");
FS_operate(g_kni_fs_handle->handle, g_kni_fs_handle->fields[KNI_FIELD_SENDTO_TFE_FAIL], 0, FS_OP_ADD, 1);
@@ -1885,6 +1900,8 @@ extern "C" int kni_init(){
goto error_out;
}
g_kni_handle->tap_handle = kni_tap_init()
//init maat
g_kni_handle->maat_handle = kni_maat_init(profile, local_logger);
if(g_kni_handle->maat_handle == NULL){