设计tap模式接口
This commit is contained in:
@@ -667,8 +667,8 @@ static char* add_cmsg_to_packet(struct pme_info *pmeinfo, struct pkt_info *pktin
|
||||
*len = offset;
|
||||
return new_pkt;
|
||||
}
|
||||
|
||||
static int send_to_tfe(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(struct kni_marsio_handle *handle, 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;
|
||||
marsio_buff_t *tx_buffs[BURST_MAX];
|
||||
int index = -1;
|
||||
@@ -712,6 +712,23 @@ static int send_to_tfe(struct kni_marsio_handle *handle, char *raw_data, uint16_
|
||||
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(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){
|
||||
int ret;
|
||||
if(mode == SENDTO_TFE_MODE_TAP){
|
||||
ret = send_to_tfe_tap_mode(tap_handle, raw_data, raw_len);
|
||||
}
|
||||
else{
|
||||
ret = send_to_tfe_normal_mode(marsio_handle, raw_data, raw_len, thread_seq, tfe_id, addr_type);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int wrapped_kni_header_parse(const void *a_packet, struct pme_info *pmeinfo, struct pkt_info *pktinfo){
|
||||
void *logger = g_kni_handle->local_logger;
|
||||
if(pmeinfo->addr_type == ADDR_TYPE_IPV6){
|
||||
@@ -856,7 +873,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, buff, len, thread_seq, pmeinfo->tfe_id, pmeinfo->addr_type);
|
||||
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);
|
||||
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);
|
||||
@@ -903,7 +920,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, (char*)a_packet, len, thread_seq, pmeinfo->tfe_id, pmeinfo->addr_type);
|
||||
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);
|
||||
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);
|
||||
@@ -1275,7 +1292,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, replay_packet, tot_len, g_iThreadNum + thread_seq, tfe_id, args->addr_type);
|
||||
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);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user