summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2020-11-10 11:52:53 +0600
committerluwenpeng <[email protected]>2020-11-10 11:57:15 +0600
commit6e80fc6329ae6fc5224290a0150a4411017759b6 (patch)
treea1248f0e2d5293c07140ad9797b1f6e922ae9c41
parentf59db0ae8579256fba21170e217e45c1ff6886c0 (diff)
解密流量转发时若获取不到 dst mac,则使用默认的 dst mac 进行填充v4.3.19-202011
-rw-r--r--plugin/business/traffic-mirror/src/entry.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/plugin/business/traffic-mirror/src/entry.cpp b/plugin/business/traffic-mirror/src/entry.cpp
index 73f81ff..90e1d50 100644
--- a/plugin/business/traffic-mirror/src/entry.cpp
+++ b/plugin/business/traffic-mirror/src/entry.cpp
@@ -554,8 +554,8 @@ errout:
}
const static ether_addr zero_mac = {0};
-const static unsigned char default_mac[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
-
+const static unsigned char default_src_mac[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
+const static unsigned char default_dst_mac[6] = {0x06, 0x05, 0x04, 0x03, 0x02, 0x01};
int traffic_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id,
enum tfe_conn_dir dir, void ** pme)
{
@@ -623,17 +623,17 @@ int traffic_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thr
if (ret < 0 || memcmp(&c_ether_addr, &zero_mac, sizeof(c_ether_addr)) == 0)
{
- TFE_LOG_ERROR(instance->logger, "failed at source mac address, user default src mac.");
- memcpy(&c_ether_addr, &default_mac, sizeof(c_ether_addr));
+ TFE_LOG_ERROR(instance->logger, "failed at source mac address, user default src mac: {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}");
+ memcpy(&c_ether_addr, &default_src_mac, sizeof(c_ether_addr));
}
ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_DST_MAC, (unsigned char *) &s_ether_addr,
sizeof(s_ether_addr), &opt_out_size);
- if (ret < 0)
+ if (ret < 0 || memcmp(&s_ether_addr, &zero_mac, sizeof(s_ether_addr)) == 0)
{
- TFE_LOG_ERROR(instance->logger, "failed at dest mac address, detach the stream.");
- goto detach;
+ TFE_LOG_ERROR(instance->logger, "failed at dest mac address, user default dest mac: {0x06, 0x05, 0x04, 0x03, 0x02, 0x01}");
+ memcpy(&s_ether_addr, &default_dst_mac, sizeof(s_ether_addr));
}
target_id = random() % profile_ex_data->nr_targets;