增加传输common_direction 的cmsg 给tfe

This commit is contained in:
fumingwei
2020-12-04 17:21:50 +08:00
parent 8b13689219
commit 13e663f7f9
3 changed files with 43 additions and 0 deletions

View File

@@ -79,6 +79,8 @@ enum tfe_cmsg_tlv_type
//fqdn cat id
TFE_CMSG_FQDN_CAT_ID_NUM, // uint32_t
TFE_CMSG_FQDN_CAT_ID_VAL, // string max size 8 * sizeof(uint32_t)
//cmsg common_direction
TFE_CMSG_COMMON_DIRECTION,
//cmsg tlv max
KNI_CMSG_TLV_NR_MAX,
};

View File

@@ -251,5 +251,7 @@ void tfe_cmsg_enum_to_string()
tfe_cmsg_tlv_type_to_string[TFE_CMSG_FQDN_CAT_ID_NUM] = "TFE_CMSG_FQDN_CAT_ID_NUM";
tfe_cmsg_tlv_type_to_string[TFE_CMSG_FQDN_CAT_ID_VAL] = "TFE_CMSG_FQDN_CAT_ID_VAL";
tfe_cmsg_tlv_type_to_string[TFE_CMSG_COMMON_DIRECTION] = "TFE_CMSG_COMMON_DIRECTION";
}

View File

@@ -413,6 +413,39 @@ static int session_attribute_cmsg_set(struct kni_cmsg *cmsg, struct pme_info *pm
}
static unsigned int get_stream_common_direction(struct streaminfo *stream)
{
int i_or_e=0;
unsigned int direction=0;
i_or_e=MESA_dir_link_to_human(stream->routedir);
switch(stream->curdir)
{
case DIR_C2S:
if(i_or_e=='E' || i_or_e=='e')
{
direction='E';
}
else
{
direction='I';
}
break;
case DIR_S2C:
if(i_or_e=='E' || i_or_e=='e')
{
direction='I';
}
else
{
direction='E';
}
break;
default:
break;
}
return direction;
}
static unsigned char* kni_cmsg_serialize_header_new(struct pme_info *pmeinfo, struct streaminfo *stream, struct pkt_info *pktinfo, uint16_t *len){
void *logger = g_kni_handle->local_logger;
uint16_t bufflen = 0, serialize_len = 0;
@@ -440,6 +473,7 @@ static unsigned char* kni_cmsg_serialize_header_new(struct pme_info *pmeinfo, st
char src_mac[6] = {0};
char dst_mac[6] = {0};
int policy_id;
unsigned int stream_common_direction;
switch(pmeinfo->protocol)
{
@@ -528,6 +562,11 @@ static unsigned char* kni_cmsg_serialize_header_new(struct pme_info *pmeinfo, st
goto error_out;
}
//common direction
stream_common_direction = get_stream_common_direction(stream);
ret = wrapped_kni_cmsg_set(cmsg, TFE_CMSG_COMMON_DIRECTION, (const unsigned char*)&stream_common_direction, sizeof(stream_common_direction), pmeinfo);
if(ret < 0) goto error_out;
//src mac
ret = get_rawpkt_opt_from_streaminfo(stream, RAW_PKT_GET_ORIGINAL_LOWEST_ETH_SMAC, src_mac);
if(ret < 0){