From 897ff3fd6248c7eb3f72e25c92a0e5cb8c872197 Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Wed, 4 Nov 2020 16:26:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=AF=86=E6=B5=81=E9=87=8F=E8=BD=AC?= =?UTF-8?q?=E5=8F=91=E6=97=B6=E8=8B=A5=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=20src=20mac=EF=BC=8C=E5=88=99=E4=BD=BF=E7=94=A8=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84=20src=20mac=20=E8=BF=9B=E8=A1=8C=E5=A1=AB?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/business/traffic-mirror/src/entry.cpp | 9 ++++++--- 1 file 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,