summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLu Qiuwen <[email protected]>2022-06-24 12:00:50 -0400
committerLu Qiuwen <[email protected]>2022-06-24 12:20:39 -0400
commite38dda5e172b2698e92ed02981e1253ac62af697 (patch)
tree1bc209b630d5108da7dcc89e1926b4765769b872
parentaba1984874c044bc74f1eb1395d645cebb73cb0d (diff)
适配DPDK-21.11。
-rw-r--r--service/src/flow_manage.c24
-rw-r--r--tools/mrctl/mrctl.c31
2 files changed, 55 insertions, 0 deletions
diff --git a/service/src/flow_manage.c b/service/src/flow_manage.c
index f5f1890..57f7230 100644
--- a/service/src/flow_manage.c
+++ b/service/src/flow_manage.c
@@ -6,6 +6,7 @@
#include <cJSON.h>
#include <sc_common.h>
#include <sc_flow.h>
+#include <rte_version.h>
/* Json Parse Err */
#define MR_FLOW_CREAT_SUCCESS "Flow Create Success"
@@ -398,7 +399,11 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg
send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_ERR,CTRLMSG_TOPIC_FLOW_CREATE);
return RT_ERR;
}
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ if(string_to_mac(cj_ether_item_smac->valuestring,&ether_item->ether_hdr.src_addr) == RT_ERR)
+#else
if(string_to_mac(cj_ether_item_smac->valuestring,&ether_item->ether_hdr.s_addr) == RT_ERR)
+#endif
{
send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE);
return RT_ERR;
@@ -414,7 +419,12 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg
send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_ERR,CTRLMSG_TOPIC_FLOW_CREATE);
return RT_ERR;
}
+
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ if(string_to_mac(cj_ether_item_dmac->valuestring,&ether_item->ether_hdr.dst_addr) == RT_ERR)
+#else
if(string_to_mac(cj_ether_item_dmac->valuestring,&ether_item->ether_hdr.d_addr) == RT_ERR)
+#endif
{
send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE);
return RT_ERR;
@@ -1209,12 +1219,20 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand
/* 2.1.1.2 Fill Ether Spec For Smac */
if (ether_item->arg_flag & MR_RULE_FLOW_ETHER_ARG_SMAC_ENABLE)
{
+#if RTE_VERSION_NUM(21,11,0,0) <= RTE_VERSION
+ rte_ether_addr_copy(&ether_item->ether_hdr.src_addr, &eth_spec.src);
+#else
rte_ether_addr_copy(&ether_item->ether_hdr.s_addr, &eth_spec.src);
+#endif
}
/* 2.1.1.3 Fill Ether Spec For Dmac */
if (ether_item->arg_flag & MR_RULE_FLOW_ETHER_ARG_DMAC_ENABLE)
{
+#if RTE_VERSION_NUM(21,11,0,0) <= RTE_VERSION
+ rte_ether_addr_copy(&ether_item->ether_hdr.dst_addr, &eth_spec.dst);
+#else
rte_ether_addr_copy(&ether_item->ether_hdr.d_addr, &eth_spec.dst);
+#endif
}
/* 2.1.1.4 Fill Ether Spec For Type */
if (ether_item->arg_flag & MR_RULE_FLOW_ETHER_ARG_TYPE_ENABLE)
@@ -1444,7 +1462,10 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand
/* 3.1.1.1 Fill Count Action Conf For Shared */
if (action_counter->arg_flag & MR_RULE_FLOW_COUNT_ARG_SHARED_ENABLE)
{
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+#else
counter_conf.shared = action_counter->shared;
+#endif
}
/* 3.1.1.2 Fill Count Action Conf For Id */
if (action_counter->arg_flag & MR_RULE_FLOW_COUNT_ARG_ID_ENABLE)
@@ -1616,7 +1637,10 @@ int mr_generate_flow_get_count(struct sc_main * sc,struct ctrlmsg_handler * ct_h
cJSON * cjson_count_end = cJSON_CreateObject();
static const struct rte_flow_action_count query_counter = {
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+#else
.shared = 0,
+#endif
};
static const struct rte_flow_action actions[] = {
diff --git a/tools/mrctl/mrctl.c b/tools/mrctl/mrctl.c
index 25c2878..83fcde6 100644
--- a/tools/mrctl/mrctl.c
+++ b/tools/mrctl/mrctl.c
@@ -12,6 +12,7 @@
#include <MESA_prof_load.h>
#include <rte_flow.h>
#include <sc_flow.h>
+#include <rte_version.h>
#define GLOBAL_CONF_FILE_PATH "/opt/tsg/mrzcpd/etc/mrglobal.conf"
#define MR_CLI_ARG_LIST "hcsdg:iep:"
@@ -1138,14 +1139,25 @@ int send_create_request_msg(struct mrctl_instance * instance, struct mrctl_flow_
if (ether_item->arg_flag & MR_RULE_FLOW_ETHER_ARG_SMAC_ENABLE)
{
char mac_addr[MR_RULE_MAC_ADDR_LEN];
+
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.src_addr);
+#else
ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.s_addr);
+#endif
cJSON_AddStringToObject(cjson_ether_item, MR_CJSON_KEY_ETHER_SMAC, mac_addr);
}
if (ether_item->arg_flag & MR_RULE_FLOW_ETHER_ARG_DMAC_ENABLE)
{
char mac_addr[MR_RULE_MAC_ADDR_LEN];
+
+#if RTE_VERSION_NUM(21,11,0,0) <= RTE_VERSION
+ ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.dst_addr);
+#else
ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.d_addr);
+#endif
+
cJSON_AddStringToObject(cjson_ether_item, MR_CJSON_KEY_ETHER_DMAC, mac_addr);
}
@@ -1588,10 +1600,20 @@ int main(int argc, char * argv[])
}
case MR_CLI_ITEM_ETHER_SMAC:
{
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ if(string_to_mac(optarg,&ether_item->ether_hdr.src_addr) == RT_SUCCESS)
+#else
if(string_to_mac(optarg,&ether_item->ether_hdr.s_addr) == RT_SUCCESS)
+#endif
+
{
ether_item->arg_flag |= MR_RULE_FLOW_ETHER_ARG_SMAC_ENABLE;
+
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.src_addr);
+#else
ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.s_addr);
+#endif
}
else
{
@@ -1603,10 +1625,19 @@ int main(int argc, char * argv[])
}
case MR_CLI_ITEM_ETHER_DMAC:
{
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ if(string_to_mac(optarg,&ether_item->ether_hdr.dst_addr) == RT_SUCCESS)
+#else
if(string_to_mac(optarg,&ether_item->ether_hdr.d_addr) == RT_SUCCESS)
+#endif
+
{
ether_item->arg_flag |= MR_RULE_FLOW_ETHER_ARG_DMAC_ENABLE;
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.dst_addr);
+#else
ether_format_addr(mac_addr, sizeof(mac_addr), &ether_item->ether_hdr.d_addr);
+#endif
}
else
{