Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #876 - add missing free_umem_and_xsk function #877

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
06/08/2024 Version 4.5.0-beta2
- AF_XDP compile issue due to merge issue (#876)
- memory leak in tcpprep when using include/exclude (#869)
- memory leak in tcpprep when using RegEx (#867)
- fix nanosecond timestamp regression bug (#863)
Expand All @@ -14,7 +15,7 @@
- Infinite loop in tcprewrite at get.c (#827 #842)
- SLL incorrect size and protocol when converted to Ethernet (#826)
- CVE-2023-43279 add check for empty CIDR (#824 #843)
- AF_XDF socket extension (#822 #823)
- AF_XDP socket extension (#822 #823)
- configure.ac: unify search dirs for pcap and add lib32 (#819)
- tcpreplay-edit recomputes IPv4 checksums unnecessarily (#815 #846)
- CVE-2023-4256 double free in tcprewrite DLT_JUNIPER_ETHER (#813 #851)
Expand Down
1 change: 1 addition & 0 deletions docs/INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ written to directly.
This feature requires `libxdp-dev` and `libbpf-dev` packages to be installed.
For example:

$ sudo apt install -y libxdp-dev libbpf-dev
$ ./configure | tail
Linux/BSD netmap: no
Tuntap device support: yes
Expand Down
1 change: 0 additions & 1 deletion src/tcpedit/tcpedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr, u_char **pktdata
newval = *((uint16_t *)ip_hdr);
newval = htons((ntohs(newval) & 0xff00) | (tcpedit->tos & 0xff));
*((uint16_t *)ip_hdr) = newval;
static uint32_t cnt;
csum_replace2(&ip_hdr->ip_sum, oldval, newval);
}

Expand Down
34 changes: 34 additions & 0 deletions src/tcpreplay_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,3 +1400,37 @@ apply_loop_delay(tcpreplay_t *ctx) {

return false;
}

#ifdef HAVE_LIBXDP
void
delete_xsk_socket(struct xsk_socket *xsk)
{
size_t desc_sz = sizeof(struct xdp_desc);
struct xdp_mmap_offsets off;
socklen_t optlen;
int err;

if (!xsk) {
return;
}

optlen = sizeof(off);
err = getsockopt(xsk->fd, SOL_XDP, XDP_MMAP_OFFSETS, &off, &optlen);
if (!err) {
if (xsk->rx) {
munmap(xsk->rx->ring - off.rx.desc, off.rx.desc + xsk->config.rx_size * desc_sz);
}
if (xsk->tx) {
munmap(xsk->tx->ring - off.tx.desc, off.tx.desc + xsk->config.tx_size * desc_sz);
}
}
close(xsk->fd);
}

void
free_umem_and_xsk(sendpacket_t *sp)
{
xsk_umem__delete(sp->xsk_info->umem->umem);
delete_xsk_socket(sp->xsk_info->xsk);
}
#endif /*HAVE_LIBXDP*/
Loading