Skip to content

Commit

Permalink
capture: use SCPacketSetLiveDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonish committed Oct 9, 2024
1 parent 23d7e0e commit 525fe96
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/lib/libcapture/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void *SimpleWorker(void *arg)
PKT_SET_SRC(p, PKT_SRC_WIRE);
p->ts = SCTIME_FROM_TIMEVAL(&pkthdr.ts);
p->datalink = datalink;
p->livedev = device;
SCPacketSetLiveDevice(p, device);
SCPacketSetReleasePacket(p, ReleasePacket);

if (PacketSetData(p, packet, pkthdr.len) == -1) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/pfring/source-pfring.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static inline void PfringProcessPacket(void *user, struct pfring_pkthdr *h, Pack

ptv->bytes += h->caplen;
ptv->pkts++;
p->livedev = ptv->livedev;
SCPacketSetLiveDevice(p, ptv->livedev);

/* PF_RING may fail to set timestamp */
if (h->ts.tv_sec == 0) {
Expand Down
5 changes: 3 additions & 2 deletions src/source-af-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ static void AFPReadFromRingSetupPacket(
* acts as an indicator that we've reached a frame that is not yet released by
* us in autofp mode. It will be cleared when the frame gets released to the kernel. */
h.h2->tp_status |= TP_STATUS_USER_BUSY;
p->livedev = ptv->livedev;
SCPacketSetLiveDevice(p, ptv->livedev);

p->datalink = ptv->datalink;
ptv->pkts++;

Expand Down Expand Up @@ -970,7 +971,7 @@ static inline int AFPParsePacketV3(AFPThreadVars *ptv, struct tpacket_block_desc
AFPReadApplyBypass(ptv, p);

ptv->pkts++;
p->livedev = ptv->livedev;
SCPacketSetLiveDevice(p, ptv->livedev);
p->datalink = ptv->datalink;

if ((ptv->flags & AFP_VLAN_IN_HEADER) &&
Expand Down
2 changes: 1 addition & 1 deletion src/source-af-xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ static TmEcode ReceiveAFXDPLoop(ThreadVars *tv, void *data, void *slot)

PKT_SET_SRC(p, PKT_SRC_WIRE);
p->datalink = LINKTYPE_ETHERNET;
p->livedev = ptv->livedev;
SCPacketSetLiveDevice(p, ptv->livedev);
SCPacketSetReleaesPacket(p, AFXDPReleasePacket);
p->flags |= PKT_IGNORE_CHECKSUM;

Expand Down
2 changes: 1 addition & 1 deletion src/source-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static inline Packet *PacketInitFromMbuf(DPDKThreadVars *ptv, struct rte_mbuf *m
p->dpdk_v.copy_mode = ptv->copy_mode;
p->dpdk_v.out_port_id = ptv->out_port_id;
p->dpdk_v.out_queue_id = ptv->queue_id;
p->livedev = ptv->livedev;
SCPacketSetLiveDevice(p, ptv->livedev);

if (ptv->checksum_mode == CHECKSUM_VALIDATION_DISABLE) {
p->flags |= PKT_IGNORE_CHECKSUM;
Expand Down
2 changes: 1 addition & 1 deletion src/source-netmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ static void NetmapProcessPacket(NetmapThreadVars *ntv, const struct nm_pkthdr *p
}

PKT_SET_SRC(p, PKT_SRC_WIRE);
p->livedev = ntv->livedev;
SCPacketSetLiveDevice(p, ntv->livedev);
p->datalink = LINKTYPE_ETHERNET;
p->ts = SCTIME_FROM_TIMEVAL(&ph->ts);
ntv->pkts++;
Expand Down
3 changes: 2 additions & 1 deletion src/source-pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "suricata-common.h"
#include "suricata.h"
#include "decode.h"
#include "packet.h"
#include "packet-queue.h"
#include "threads.h"
#include "threadvars.h"
Expand Down Expand Up @@ -342,7 +343,7 @@ static void PcapCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt)
ptv->pkts++;
ptv->bytes += h->caplen;
(void) SC_ATOMIC_ADD(ptv->livedev->pkts, 1);
p->livedev = ptv->livedev;
SCPacketSetLiveDevice(p, ptv->livedev);

if (unlikely(PacketCopyData(p, pkt, h->caplen))) {
TmqhOutputPacketpool(ptv->tv, p);
Expand Down

0 comments on commit 525fe96

Please sign in to comment.