Skip to content

Commit

Permalink
Bug #876 - add missing free_umem_and_xsk function
Browse files Browse the repository at this point in the history
Missed in merge.
  • Loading branch information
fklassen committed Jun 9, 2024
1 parent 555a92f commit a7ab3f7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
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
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*/

0 comments on commit a7ab3f7

Please sign in to comment.