Skip to content

Commit

Permalink
Removed obsolete sysdig code
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Dec 16, 2024
1 parent 45d0525 commit 0ad494e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 1,022 deletions.
44 changes: 12 additions & 32 deletions userland/examples/pfcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

#include "pfutils.c"

#include "pfring_mod_sysdig.h"

#include "third-party/sort.c"
#include "third-party/node.c"
#include "third-party/ahocorasick.c"
Expand All @@ -71,7 +69,7 @@ pcap_dumper_t *dumper = NULL;
u_int string_id = 1;
char *out_pcap_file = NULL;
FILE *match_dumper = NULL;
u_int8_t do_close_dump = 0, is_sysdig = 0, chunk_mode = 0, check_ts = 0;
u_int8_t do_close_dump = 0, chunk_mode = 0, check_ts = 0;
u_int8_t check_seq_ip = 0, asymm_rss = 0, burst_mode = 0, rss_q_0_only = 0;
int num_packets = 0;
time_t last_ts = 0;
Expand Down Expand Up @@ -549,16 +547,6 @@ void print_packet(const struct pfring_pkthdr *h, const u_char *p, u_int8_t dump_
s / 3600, (s % 3600) / 60, s % 60,
usec, nsec);

if(is_sysdig) {
struct sysdig_event_header *ev = (struct sysdig_event_header*)p;

snprintf(&dump_str[strlen(dump_str)], sizeof(dump_str)-strlen(dump_str), "[cpu_id=%u][tid=%lu][%u|%s]",
h->extended_hdr.if_index, (long unsigned int)ev->thread_id,
ev->event_type, sysdig_event2name(ev->event_type));
printf("%s\n", dump_str);
return;
}

if(use_extended_pkt_header) {
char bigbuf[4096], pbuf[64];;
u_int len;
Expand Down Expand Up @@ -782,7 +770,6 @@ void printHelp(void) {
printf("-b <cpu %%> CPU pergentage priority (0-99)\n");
printf("-a Active packet wait\n");
printf("-N <num> Read <num> packets and exit\n");
printf("-q Force printing packets as sysdig events with -v\n");
printf("-m Long packet header (with PF_RING extensions)\n");
printf("-r Rehash RSS packets\n");
printf("-c <cluster id> Cluster ID (kernel clustering)\n");
Expand Down Expand Up @@ -1093,7 +1080,7 @@ int main(int argc, char* argv[]) {
startTime.tv_sec = 0;
thiszone = gmt_to_local(0);

while((c = getopt(argc,argv,"Bhi:Ic:C:Fd:H:Jl:Lv:ae:n:w:o:p:P:qb:rg:u:mtsSx:f:z:N:MQ:RTUK:0")) != '?') {
while((c = getopt(argc,argv,"Bhi:Ic:C:Fd:H:Jl:Lv:ae:n:w:o:p:P:b:rg:u:mtsSx:f:z:N:MQ:RTUK:0")) != '?') {
if((c == 255) || (c == -1)) break;

switch(c) {
Expand Down Expand Up @@ -1149,7 +1136,6 @@ int main(int argc, char* argv[]) {
break;
case 'i':
device = strdup(optarg);
if(strcmp(device, "sysdig:") == 0) is_sysdig = 1;
break;
case 'I':
json_info = 1;
Expand Down Expand Up @@ -1185,9 +1171,6 @@ int main(int argc, char* argv[]) {
case 'P':
rule_priority = atoi(optarg);
break;
case 'q':
is_sysdig = 1;
break;
case 'Q':
cluster_queue_id = atoi(optarg);
break;
Expand Down Expand Up @@ -1411,19 +1394,16 @@ int main(int argc, char* argv[]) {
}

if (!quiet) {
if(is_sysdig) {
printf("Capturing from sysdig\n");
} else {
int ifindex = -1;
u_char mac_address[6] = { 0 };
rc = pfring_get_bound_device_address(pd, mac_address);
pfring_get_bound_device_ifindex(pd, &ifindex);
printf("Capturing from %s [mac: %s][if_index: %d][speed: %uMb/s]\n",
device, rc == 0 ? etheraddr_string(mac_address, buf) : "unknown",
ifindex, pfring_get_interface_speed(pd));
printf("# Device RX channels: %d\n", pfring_get_num_rx_channels(pd));
printf("# Polling threads: %d\n", num_threads);
}
int ifindex = -1;
u_char mac_address[6] = { 0 };

rc = pfring_get_bound_device_address(pd, mac_address);
pfring_get_bound_device_ifindex(pd, &ifindex);
printf("Capturing from %s [mac: %s][if_index: %d][speed: %uMb/s]\n",
device, rc == 0 ? etheraddr_string(mac_address, buf) : "unknown",
ifindex, pfring_get_interface_speed(pd));
printf("# Device RX channels: %d\n", pfring_get_num_rx_channels(pd));
printf("# Polling threads: %d\n", num_threads);
}

sample_filtering_rules();
Expand Down
18 changes: 2 additions & 16 deletions userland/examples_zc/zbalance.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#include "pfring.h"
#include "pfring_zc.h"
#include "pfring_mod_sysdig.h"

#include "zutils.c"

Expand Down Expand Up @@ -170,7 +169,7 @@ void printHelp(void) {
printf("-c <cluster id> Cluster id\n");
printf("-m <hash mode> Hashing modes:\n"
" 0 - No hash: Round-Robin (default)\n"
" 1 - IP hash or TID (thread id) in case of '-i sysdig'\n"
" 1 - IP hash\n"
" 2 - Fan-out\n");
printf("-r <id> Balancer thread core affinity\n");
printf("-g <id:id...> Consumer threads core affinity mask\n");
Expand Down Expand Up @@ -222,16 +221,6 @@ int64_t rr_distribution_func(pfring_zc_pkt_buff *pkt_handle, pfring_zc_queue *in

/* *************************************** */

int64_t sysdig_distribution_func(pfring_zc_pkt_buff *pkt_handle, pfring_zc_queue *in_queue, void *user) {
/* NOTE: pkt_handle->hash contains the CPU id */
struct sysdig_event_header *ev = (struct sysdig_event_header*)pfring_zc_pkt_buff_data(pkt_handle, in_queue);
long num_out_queues = (long) user;

return(ev->thread_id % num_out_queues);
}

/* *************************************** */

int main(int argc, char* argv[]) {
char *device = NULL, *dev, c;
long i;
Expand Down Expand Up @@ -362,10 +351,7 @@ int main(int argc, char* argv[]) {
if (hash_mode < 2) { /* balancer */
pfring_zc_distribution_func func;

if(strcmp(device, "sysdig") == 0)
func = (hash_mode == 0) ? rr_distribution_func : sysdig_distribution_func;
else
func = (hash_mode == 0) ? rr_distribution_func : NULL /* built-in IP-based */;
func = (hash_mode == 0) ? rr_distribution_func : NULL /* built-in IP-based */;

zw = pfring_zc_run_balancer(
inzq,
Expand Down
1 change: 0 additions & 1 deletion userland/examples_zc/zbalance_DC_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#include "pfring.h"
#include "pfring_zc.h"
#include "pfring_mod_sysdig.h"

#include "zutils.c"

Expand Down
20 changes: 5 additions & 15 deletions userland/examples_zc/zcount_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#include "pfring.h"
#include "pfring_zc.h"
#include "pfring_mod_sysdig.h"

#include "zutils.c"

Expand Down Expand Up @@ -178,22 +177,13 @@ void *packet_consumer_thread(void *_id) {

if (unlikely(g->verbose)) {
u_char *pkt_data = pfring_zc_pkt_buff_data(buffer, zq);

int i;

if (buffer->ts.tv_nsec)
printf("[%u.%u] ", buffer->ts.tv_sec, buffer->ts.tv_nsec);

if(g->dump_as_sysdig_event) {
struct sysdig_event_header *ev = (struct sysdig_event_header*)pkt_data;

printf("[cpu_id=%u][tid=%lu][%u|%s]",
buffer->hash, ev->thread_id,
ev->event_type, sysdig_event2name(ev->event_type));
} else {
int i;

for(i = 0; i < buffer->len; i++)
printf("%02X ", pkt_data[i]);
}

for(i = 0; i < buffer->len; i++)
printf("%02X ", pkt_data[i]);

printf("\n");
}
Expand Down
2 changes: 1 addition & 1 deletion userland/examples_zc/zfilter_mt_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include "pfring.h"
#include "pfring_zc.h"
#include "pfring_mod_sysdig.h"


#include "zutils.c"

Expand Down
2 changes: 1 addition & 1 deletion userland/examples_zc/zreplicator.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include "pfring.h"
#include "pfring_zc.h"
#include "pfring_mod_sysdig.h"


#include "zutils.c"

Expand Down
2 changes: 1 addition & 1 deletion userland/lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ NBPF_OBJS = `$(AR) t ${NBPF_LIB} | grep -F .o | tr '\n' ' '`
# Object files
#
OBJS_MIN = pfring.o pfring_mod.o pfring_utils.o pfring_mod_stack.o pfring_hw_filtering.o pfring_runtime_manager.o \
pfring_hw_timestamp.o pfring_mod_sysdig.o pfring_mod_pcap.o pfring_device.o ${PF_RING_ZC_OBJS} \
pfring_hw_timestamp.o pfring_mod_pcap.o pfring_device.o ${PF_RING_ZC_OBJS} \
${AF_XDP_OBJS} ${FIBERBLAZE_OBJS} ${NT_OBJS} ${MLX_OBJS} ${NPCAP_OBJS}

OBJS = ${OBJS_MIN} ${PF_RING_FT_OBJS}
Expand Down
6 changes: 0 additions & 6 deletions userland/lib/pfring.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "pfring_mod.h"
#include "pfring_mod_stack.h"
#include "pfring_mod_sysdig.h"
#include "pfring_mod_pcap.h"

#ifndef DLT_EN10MB
Expand Down Expand Up @@ -86,11 +85,6 @@ static pfring_module_info pfring_module_list[] = {
.open = pfring_mod_stack_open,
.findalldevs = NULL
},
{
.name = "sysdig",
.open = pfring_mod_sysdig_open,
.findalldevs = NULL
},
{
.name = "pcap",
.open = pfring_mod_pcap_open,
Expand Down
Loading

0 comments on commit 0ad494e

Please sign in to comment.