修正pcap模式下解密流量转发发包缓冲区未初始化的问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user