summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfumingwei <[email protected]>2020-12-04 17:21:50 +0800
committerfumingwei <[email protected]>2020-12-04 17:21:50 +0800
commit13e663f7f944257d15e53bb49929b0ff399a781b (patch)
treeaa9ad3815255b7040e0adf9be732049ba301d873
parent8b136892190adc813835fbcf360fd55c0c9308a4 (diff)
增加传输common_direction 的cmsg 给tfev20.12.01
-rw-r--r--common/include/kni_cmsg.h2
-rw-r--r--common/src/kni_cmsg.cpp2
-rw-r--r--entry/src/kni_entry.cpp39
3 files changed, 43 insertions, 0 deletions
diff --git a/common/include/kni_cmsg.h b/common/include/kni_cmsg.h
index 954fb36..0e79b93 100644
--- a/common/include/kni_cmsg.h
+++ b/common/include/kni_cmsg.h
@@ -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,
};
diff --git a/common/src/kni_cmsg.cpp b/common/src/kni_cmsg.cpp
index 3424f6d..3631745 100644
--- a/common/src/kni_cmsg.cpp
+++ b/common/src/kni_cmsg.cpp
@@ -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";
+
}
diff --git a/entry/src/kni_entry.cpp b/entry/src/kni_entry.cpp
index 9a90d91..7757357 100644
--- a/entry/src/kni_entry.cpp
+++ b/entry/src/kni_entry.cpp
@@ -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){