解密流量转发时若获取不到 dst mac,则使用默认的 dst mac 进行填充

This commit is contained in:
luwenpeng
2020-11-10 11:52:53 +06:00
parent f59db0ae85
commit 6e80fc6329

View File

@@ -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;