Skip to content

Commit

Permalink
Feature #822: fix compile issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Sep 4, 2023
1 parent 4b2a762 commit 908fe21
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v3
- run: |
echo "Build Application"
sudo apt-get -y install libpcap-dev autogen
sudo apt-get -y install libpcap-dev autogen libbpf-dev libxdp-dev
./autogen.sh
./configure --disable-local-libopts
- uses: cpp-linter/cpp-linter-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

- run: |
echo "Build Application"
sudo apt-get -y install libpcap-dev autogen
sudo apt-get -y install libpcap-dev autogen libbpf-dev libxdp-dev
./autogen.sh
./configure --disable-local-libopts
make
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-actions-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: List interfaces
run: ip a
- name: Install prereqs
run: sudo apt -y install autogen libpcap-dev
run: sudo apt -y install autogen libpcap-dev libbpf-dev libxdp-dev
- name: Create configure script
run: ./autogen.sh
- name: configure
Expand Down
11 changes: 4 additions & 7 deletions src/common/sendpacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#ifdef HAVE_NET_ROUTE_H
#include <net/route.h>
#endif
Expand Down Expand Up @@ -1353,8 +1350,8 @@ xsk_configure_socket(struct xsk_umem_info *umem, struct xsk_socket_config *cfg,
{
struct xsk_socket_info *xsk;
struct xsk_ring_cons *rxr = NULL;
struct xsk_ring_prod *txr;
int ret;

xsk = (struct xsk_socket_info *)safe_malloc(sizeof(struct xsk_socket_info));
xsk->umem = umem;
ret = xsk_socket__create(&xsk->xsk, device, queue_id, umem->umem, rxr, &xsk->tx, cfg);
Expand Down Expand Up @@ -1440,7 +1437,7 @@ create_umem_area(int nb_of_frames, int frame_size, int nb_of_completion_queue_de
return umem;
}

static struct xsk_socket_info *
struct xsk_socket_info *
create_xsk_socket(struct xsk_umem_info *umem_info,
int nb_of_tx_queue_desc,
int nb_of_rx_queue_desc,
Expand All @@ -1464,10 +1461,10 @@ create_xsk_socket(struct xsk_umem_info *umem_info,
return xsk_info;
}

/**
/*
* gets the hardware address via Linux's PF packet interface
*/
static struct tcpr_ether_addr *
static _U_ struct tcpr_ether_addr *
sendpacket_get_hwaddr_libxdp(sendpacket_t *sp)
{
struct ifreq ifr;
Expand Down
22 changes: 12 additions & 10 deletions src/common/sendpacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ union sendpacket_handle {

#ifdef HAVE_LIBXDP
#include <errno.h>
#include <stdlib.h>
#include <linux/if_xdp.h>
#include <xdp/xsk.h>

Expand Down Expand Up @@ -212,7 +213,7 @@ struct sendpacket_s {
unsigned int batch_size;
unsigned int pckt_count;
int frame_size;
int tx_idx;
unsigned int tx_idx;
int tx_size;
#endif
bool abort;
Expand All @@ -222,12 +223,12 @@ typedef struct sendpacket_s sendpacket_t;
#ifdef HAVE_LIBXDP
struct xsk_umem_info *
create_umem_area(int nb_of_frames, int frame_size, int nb_of_completion_queue_descs, int nb_of_fill_queue_descs);
static struct xsk_socket_info *create_xsk_socket(struct xsk_umem_info *umem,
int nb_of_tx_queue_desc,
int nb_of_rx_queue_desc,
const char *device,
u_int32_t queue_id,
char *errbuf);
struct xsk_socket_info *create_xsk_socket(struct xsk_umem_info *umem,
int nb_of_tx_queue_desc,
int nb_of_rx_queue_desc,
const char *device,
u_int32_t queue_id,
char *errbuf);
static inline void
gen_eth_frame(struct xsk_umem_info *umem, u_int64_t addr, u_char *pkt_data, COUNTER pkt_size)
{
Expand All @@ -242,20 +243,21 @@ kick_tx(struct xsk_socket_info *xsk)
return;
}
printf("%s\n", "Packet sending exited with error!");
exit(ret);
exit (1);
}

static inline void
complete_tx_only(sendpacket_t *sp)
{
int completion_idx = 0;
u_int32_t completion_idx = 0;
if (sp->xsk_info->outstanding_tx == 0) {
return;
}
if (xsk_ring_prod__needs_wakeup(&(sp->xsk_info->tx))) {
sp->xsk_info->app_stats.tx_wakeup_sendtos++;
kick_tx(sp->xsk_info);
}
unsigned int rcvd = xsk_ring_cons__peek(&sp->xsk_info->umem->cq, sp->pckt_count, &(completion_idx));
unsigned int rcvd = xsk_ring_cons__peek(&sp->xsk_info->umem->cq, sp->pckt_count, &completion_idx);
if (rcvd > 0) {
xsk_ring_cons__release(&sp->xsk_info->umem->cq, rcvd);
sp->xsk_info->outstanding_tx -= rcvd;
Expand Down
10 changes: 5 additions & 5 deletions src/send_packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
* we've sent enough packets
*/
while (!ctx->abort && read_next_packet &&
(pktdata = get_next_packet(ctx, pcap, &pkthdr, idx, prev_packet)) != NULL) {
(pktdata = get_next_packet(options, pcap, &pkthdr, idx, prev_packet)) != NULL) {
now_is_now = false;
packetnum++;
#if defined TCPREPLAY || defined TCPREPLAY_EDIT
Expand Down Expand Up @@ -515,7 +515,7 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
#ifdef HAVE_LIBXDP
if (sp->handle_type == SP_TYPE_LIBXDP) {
/* Reserve frames for the batc h*/
while (xsk_ring_prod__reserve(&(sp->xsk_info->tx), sp->batch_size, &(sp->tx_idx)) < sp->batch_size) {
while (xsk_ring_prod__reserve(&(sp->xsk_info->tx), sp->batch_size, &sp->tx_idx) < sp->batch_size) {
complete_tx_only(sp);
}
/* The first packet is already in memory */
Expand Down Expand Up @@ -1315,8 +1315,8 @@ prepare_remaining_elements_of_batch(tcpreplay_t *ctx,
}
sp->pckt_count = pckt_count;
dbgx(2,
"Sending packets with LIBXDP in batch, packet numbers from %llu to %llu\n",
packetnum - pckt_count + 1,
packetnum);
"Sending packets with LIBXDP in batch, packet numbers from " COUNTER_SPEC " to " COUNTER_SPEC "\n",
*packetnum - pckt_count + 1,
*packetnum);
}
#endif /* HAVE_LIBXDP */
4 changes: 2 additions & 2 deletions src/tcpedit/plugins/dlt_en10mb/en10mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ dlt_en10mb_parse_subsmac(tcpeditdlt_t *ctx, en10mb_config_t *config, const char
{
size_t input_len = strlen(input);
size_t possible_entries_number = (input_len / (SUBSMAC_ENTRY_LEN + 1)) + 1;
int entry;
size_t entry;

en10mb_sub_entry_t *entries = safe_malloc(possible_entries_number * sizeof(en10mb_sub_entry_t));

Expand Down Expand Up @@ -524,7 +524,7 @@ dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir)
newl2len = TCPR_802_1Q_H;
}

if (pktlen < newl2len || pktlen + newl2len - ctx->l2len > MAXPACKET) {
if ((uint32_t)pktlen < newl2len || pktlen + newl2len - ctx->l2len > MAXPACKET) {
tcpedit_seterr(ctx->tcpedit,
"Unable to process packet #" COUNTER_SPEC " since its new length is %d bytes.",
ctx->tcpedit->runtime.packetnum,
Expand Down

0 comments on commit 908fe21

Please sign in to comment.