修正pcap模式下解密流量转发发包缓冲区未初始化的问题
This commit is contained in:
@@ -54,7 +54,7 @@ struct profile_table_ex_data
|
||||
struct traffic_mirror_ethdev_pcap
|
||||
{
|
||||
pcap_t * pcap_device_handle;
|
||||
char * sendbuf[TFE_THREAD_MAX];
|
||||
char sendbuf[TFE_THREAD_MAX][ETHER_MAX_LEN];
|
||||
};
|
||||
|
||||
struct traffic_mirror_ethdev_mr4
|
||||
@@ -78,10 +78,6 @@ struct traffic_mirror_ethdev
|
||||
unsigned int en_offload_vlan;
|
||||
unsigned int en_offload_ip_cksum;
|
||||
unsigned int en_offload_tcp_cksum;
|
||||
|
||||
/* PRIVATE, FOR PCAP */
|
||||
pcap_t * pcap_device_handle;
|
||||
|
||||
char local_ether_addr[6];
|
||||
|
||||
enum traffic_mirror_ethdev_type type;
|
||||
|
||||
@@ -465,6 +465,15 @@ int traffic_mirror_init(struct tfe_proxy * proxy)
|
||||
const char * profile = "./conf/pangu/pangu_pxy.conf";
|
||||
const char * section = "maat";
|
||||
|
||||
unsigned int is_enable = 1;
|
||||
MESA_load_profile_uint_def(profile, "traffic_mirror", "enable", &is_enable, 1);
|
||||
|
||||
if (!is_enable)
|
||||
{
|
||||
TFE_LOG_INFO(instance->logger, "traffic_mirror is disabled.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* INIT DECRYPT MIRROR INSTANCE */
|
||||
instance->logger = tfe_proxy_get_error_logger();
|
||||
instance->nr_threads = tfe_proxy_get_work_thread_count();
|
||||
|
||||
@@ -101,7 +101,7 @@ static int pcap_ethdev_send_finish(struct traffic_mirror_ethdev * ethdev, unsign
|
||||
assert(detail_pcap != NULL && detail_pcap->sendbuf[tid] != NULL);
|
||||
|
||||
char * sendbuf = detail_pcap->sendbuf[tid];
|
||||
return pcap_sendpacket(ethdev->pcap_device_handle, (const u_char *)sendbuf, pktlen);
|
||||
return pcap_sendpacket(detail_pcap->pcap_device_handle, (const u_char *)sendbuf, pktlen);
|
||||
}
|
||||
|
||||
static void pcap_ethdev_send_abort(struct traffic_mirror_ethdev * ethdev, unsigned int tid)
|
||||
@@ -111,7 +111,7 @@ static void pcap_ethdev_send_abort(struct traffic_mirror_ethdev * ethdev, unsign
|
||||
|
||||
static void pcap_ethdev_destroy(struct traffic_mirror_ethdev * ethdev)
|
||||
{
|
||||
pcap_close(ethdev->pcap_device_handle);
|
||||
pcap_close(ethdev->detail_pcap->pcap_device_handle);
|
||||
return free(ethdev);
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ struct traffic_mirror_ethdev * traffic_mirror_ethdev_pcap_create(const char * st
|
||||
ethdev->en_offload_tcp_cksum = 0;
|
||||
ethdev->en_offload_vlan = 0;
|
||||
|
||||
/* open the device by pcap */
|
||||
ethdev->pcap_device_handle = pcap_open_live(str_ethdev, 0, 0, 0, pcap_errbuf);
|
||||
if (!ethdev->pcap_device_handle)
|
||||
ethdev->detail_pcap = ALLOC(struct traffic_mirror_ethdev_pcap, 1);
|
||||
ethdev->detail_pcap->pcap_device_handle = pcap_open_live(str_ethdev, 0, 0, 0, pcap_errbuf);
|
||||
if (!ethdev->detail_pcap->pcap_device_handle)
|
||||
{
|
||||
TFE_LOG_ERROR(logger, "failed at pcap_open_live(), device = %s: %s", str_ethdev, pcap_errbuf);
|
||||
goto errout;
|
||||
@@ -258,7 +258,7 @@ struct traffic_mirror_ethdev * traffic_mirror_ethdev_pcap_create(const char * st
|
||||
|
||||
errout:
|
||||
if (fd > 0) close(fd);
|
||||
if (ethdev->pcap_device_handle) pcap_close(ethdev->pcap_device_handle);
|
||||
if (ethdev->detail_pcap->pcap_device_handle) pcap_close(ethdev->detail_pcap->pcap_device_handle);
|
||||
if (ethdev) FREE(ðdev);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ static inline uint32_t __rte_raw_cksum(const void *buf, size_t len, uint32_t sum
|
||||
|
||||
static inline uint16_t __rte_raw_cksum_reduce(uint32_t sum)
|
||||
{
|
||||
sum = ((sum & 0xffff0000U) >> 16) + (sum & 0xffffU);
|
||||
sum = ((sum & 0xffff0000U) >> 16) + (sum & 0xffffU);
|
||||
sum = ((sum & 0xffff0000U) >> 16U) + (sum & 0xffffU);
|
||||
sum = ((sum & 0xffff0000U) >> 16U) + (sum & 0xffffU);
|
||||
return (uint16_t) sum;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user