diff options
| author | luwenpeng <[email protected]> | 2020-11-04 16:26:50 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2020-11-04 16:37:24 +0800 |
| commit | 897ff3fd6248c7eb3f72e25c92a0e5cb8c872197 (patch) | |
| tree | c40531e8d7287ad9830dbe7f6efb935761e097eb | |
| parent | b1c3ba754a3857ef6babaddde1a7a2d46afd5423 (diff) | |
解密流量转发时若获取不到 src mac,则使用默认的 src mac 进行填充v4.3.17-202011
| -rw-r--r-- | plugin/business/traffic-mirror/src/entry.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/plugin/business/traffic-mirror/src/entry.cpp b/plugin/business/traffic-mirror/src/entry.cpp index 97306b6..73f81ff 100644 --- a/plugin/business/traffic-mirror/src/entry.cpp +++ b/plugin/business/traffic-mirror/src/entry.cpp @@ -553,6 +553,9 @@ errout: return -1; } +const static ether_addr zero_mac = {0}; +const static unsigned char default_mac[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; + int traffic_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, void ** pme) { @@ -618,10 +621,10 @@ int traffic_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thr ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_MAC, (unsigned char *) &c_ether_addr, sizeof(c_ether_addr), &opt_out_size); - if (ret < 0) + if (ret < 0 || memcmp(&c_ether_addr, &zero_mac, sizeof(c_ether_addr)) == 0) { - TFE_LOG_ERROR(instance->logger, "failed at source mac address, detach the stream."); - goto detach; + TFE_LOG_ERROR(instance->logger, "failed at source mac address, user default src mac."); + memcpy(&c_ether_addr, &default_mac, sizeof(c_ether_addr)); } ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_DST_MAC, (unsigned char *) &s_ether_addr, |
