Skip to content

Commit bd14632

Browse files
authored
Merge pull request #212 from CESNET/appfs-telemetry
Introduce Appfs telemetry
2 parents f616af2 + d44905d commit bd14632

29 files changed

+645
-39
lines changed

.github/workflows/c-cpp.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ jobs:
1818
- name: Install dependencies
1919
run: |
2020
sudo apt-get update
21-
sudo apt-get -y install git build-essential autoconf libtool libpcap-dev pkg-config libxml2-dev libunwind-dev
21+
sudo apt-get -y install git build-essential autoconf libtool libpcap-dev pkg-config libxml2-dev libunwind-dev libfuse3-dev fuse3 cmake
2222
( git clone --depth 1 https://github.com/CESNET/nemea-framework /tmp/nemea-framework; cd /tmp/nemea-framework; ./bootstrap.sh &&./configure --bindir=/usr/bin/nemea/ -q &&make -j10 && sudo make install; sudo ldconfig)
2323
( git clone --depth 1 https://github.com/CESNET/nemea-modules /tmp/nemea-modules; cd /tmp/nemea-modules; ./bootstrap.sh &&./configure --bindir=/usr/bin/nemea/ -q &&make -j10 && sudo make install; )
24+
( git clone -b release --depth 1 https://github.com/CESNET/telemetry /tmp/telemetry; cd /tmp/telemetry; mkdir build && cd build; cmake -DCMAKE_INSTALL_PREFIX=/usr .. &&make -j10 && sudo make install; )
2425
- name: autoreconf
2526
run: autoreconf -i
2627
- name: configure

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ jobs:
3030
- name: Install dependencies
3131
run: |
3232
sudo apt-get update
33-
sudo apt-get -y install git build-essential autoconf libtool libpcap-dev pkg-config libxml2-dev
33+
sudo apt-get -y install git build-essential autoconf libtool libpcap-dev pkg-config libxml2-dev libfuse3-dev fuse3 cmake
3434
( git clone --depth 1 https://github.com/CESNET/nemea-framework /tmp/nemea-framework; cd /tmp/nemea-framework; ./bootstrap.sh &&./configure --bindir=/usr/bin/nemea/ -q &&make -j10 && sudo make install; sudo ldconfig)
35+
( git clone -b release --depth 1 https://github.com/CESNET/telemetry /tmp/telemetry; cd /tmp/telemetry; mkdir build && cd build; cmake -DCMAKE_INSTALL_PREFIX=/usr .. &&make -j10 && sudo make install; )
3536
# Initializes the CodeQL tools for scanning.
3637
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@v1
38+
uses: github/codeql-action/init@v2
3839
with:
3940
languages: ${{ matrix.language }}
4041
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -45,7 +46,7 @@ jobs:
4546
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
4647
# If this step fails, then you should remove it and run the build manually (see below)
4748
#- name: Autobuild
48-
# uses: github/codeql-action/autobuild@v1
49+
# uses: github/codeql-action/autobuild@v2
4950

5051
# ℹ️ Command-line programs to run using the OS shell.
5152
# 📚 https://git.io/JvXDl
@@ -64,4 +65,4 @@ jobs:
6465
make
6566
6667
- name: Perform CodeQL Analysis
67-
uses: github/codeql-action/analyze@v1
68+
uses: github/codeql-action/analyze@v2

.github/workflows/coverity.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ jobs:
1616
- name: Install dependencies
1717
run: |
1818
sudo apt-get update
19-
sudo apt-get -y install git build-essential autoconf libtool libpcap-dev pkg-config libxml2-dev
19+
sudo apt-get -y install git build-essential autoconf libtool libpcap-dev pkg-config libxml2-dev libfuse3-dev fuse3 cmake
2020
( git clone --depth 1 https://github.com/CESNET/nemea-framework /tmp/nemea-framework; cd /tmp/nemea-framework; ./bootstrap.sh &&./configure --bindir=/usr/bin/nemea/ -q &&make -j10 && sudo make install; sudo ldconfig)
2121
( git clone --depth 1 https://github.com/CESNET/nemea-modules /tmp/nemea-modules; cd /tmp/nemea-modules; ./bootstrap.sh &&./configure --bindir=/usr/bin/nemea/ -q &&make -j10 && sudo make install; )
22+
( git clone -b release --depth 1 https://github.com/CESNET/telemetry /tmp/telemetry; cd /tmp/telemetry; mkdir build && cd build; cmake -DCMAKE_INSTALL_PREFIX=/usr .. &&make -j10 && sudo make install; )
2223
- name: autoreconf
2324
run: autoreconf -i
2425
- name: configure

Makefile.am

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ bin_PROGRAMS=ipfixprobe ipfixprobe_stats
99

1010
DISTCHECK_CONFIGURE_FLAGS="--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)"
1111

12-
ipfixprobe_LDFLAGS=-lpthread -ldl -latomic
13-
ipfixprobe_CFLAGS=-I$(srcdir)/include/ -fPIC
14-
ipfixprobe_CXXFLAGS=-std=gnu++17 -Wno-write-strings -I$(srcdir)/include/ -fPIC
12+
ipfixprobe_LDFLAGS=-lpthread -ldl -latomic -ltelemetry -lappFs
13+
ipfixprobe_CFLAGS=-I$(srcdir)/include/ -fPIC -DFUSE_USE_VERSION=30
14+
ipfixprobe_CXXFLAGS=-std=gnu++17 -Wno-write-strings -I$(srcdir)/include/ -fPIC -DFUSE_USE_VERSION=30
1515

1616
if OS_CYGWIN
1717
ipfixprobe_CXXFLAGS+=-Wl,--export-all-symbols
@@ -20,6 +20,7 @@ ipfixprobe_CXXFLAGS+=-Wl,--export-dynamic
2020
endif
2121

2222
ipfixprobe_input_src=\
23+
input/input.cpp \
2324
input/benchmark.cpp \
2425
input/benchmark.hpp \
2526
input/parser.cpp \
@@ -200,7 +201,9 @@ ipfixprobe_headers_src=\
200201
include/ipfixprobe/ring.h \
201202
include/ipfixprobe/byte-utils.hpp \
202203
include/ipfixprobe/ipfix-elements.hpp \
203-
include/ipfixprobe/rtp.hpp
204+
include/ipfixprobe/rtp.hpp \
205+
include/ipfixprobe/telemetry-utils.hpp \
206+
include/ipfixprobe/parser-stats.hpp
204207

205208
ipfixprobe_src=\
206209
$(ipfixprobe_input_src) \
@@ -228,7 +231,7 @@ endif
228231

229232
ipfixprobe_SOURCES=$(ipfixprobe_src) main.cpp
230233

231-
ipfixprobe_stats_CXXFLAGS=-std=gnu++11 -Wno-write-strings -I$(srcdir)/include/
234+
ipfixprobe_stats_CXXFLAGS=-std=gnu++17 -Wno-write-strings -I$(srcdir)/include/
232235
ipfixprobe_stats_SOURCES=ipfixprobe_stats.cpp \
233236
include/ipfixprobe/options.hpp \
234237
include/ipfixprobe/utils.hpp \

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ See `ipfixprobe -h output` for more information and complete list of output plug
127127
- `-f NUM` Export max flows per second
128128
- `-c SIZE` Quit after number of packets are processed on each interface
129129
- `-P FILE` Create pid file
130+
- `-t PATH` Mount point of AppFs telemetry directory
130131
- `-d` Run as a standalone process
131132
- `-h [PLUGIN]` Print help text. Supported help for input, storage, output and process plugins
132133
- `-V` Show version and exit
@@ -147,8 +148,8 @@ Here are the examples of various plugins usage:
147148
# Capture from a COMBO card using ndp plugin, sends ipfix data to 127.0.0.1:4739 using TCP by default
148149
./ipfixprobe -i 'ndp;dev=/dev/nfb0:0' -i 'ndp;dev=/dev/nfb0:1' -i 'ndp;dev=/dev/nfb0:2'
149150
150-
# Capture from eth0 interface using pcap plugin, split biflows into flows and prints them to console without mac addresses
151-
./ipfixprobe -i 'pcap;ifc=eth0' -s 'cache;split' -o 'text;m'
151+
# Capture from eth0 interface using pcap plugin, split biflows into flows and prints them to console without mac addresses, telemetry data are exposed via the appFs library in /var/run/ipfixprobe directory
152+
./ipfixprobe -i 'pcap;ifc=eth0' -s 'cache;split' -o 'text;m' -t /var/run/ipfixprobe
152153
153154
# Read packets from pcap file, enable 4 processing plugins, sends L7 HTTP extended biflows to unirec interface named `http` and data from 3 other plugins to the `stats` interface
154155
./ipfixprobe -i 'pcap;file=pcaps/http.pcap' -p http -p pstats -p idpcontent -p phists -o 'unirec;i=u:http:timeout=WAIT,u:stats:timeout=WAIT;p=http,(pstats,phists,idpcontent)'
@@ -168,6 +169,11 @@ Here are the examples of various plugins usage:
168169
`./ipfixprobe -i 'dpdk-ring;r=rx_ipfixprobe_0;e= --proc-type=secondary' -i 'dpdk-ring;r=rx_ipfixprobe_1' -i 'dpdk-ring;r=rx_ipfixprobe_2' -i 'dpdk-ring;r=rx_ipfixprobe_3' -o 'text'`
169170
```
170171

172+
## Telemetry
173+
174+
`ipfixprobe` can expose telemetry data using the appFs library, which leverages the fuse3 library (filesystem in userspace) to allow telemetry data to be accessed and manipulated
175+
through standard filesystem operations.
176+
171177
## Flow Data Extension - Processing Plugins
172178

173179
`ipfixprobe` can be extended by new plugins for exporting various new information from flow.

include/ipfixprobe/input.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@
3131
#define IPXP_INPUT_HPP
3232

3333
#include <string>
34+
#include <memory>
35+
#include <telemetry.hpp>
3436

37+
#include "telemetry-utils.hpp"
3538
#include "plugin.hpp"
3639
#include "packet.hpp"
40+
#include "parser-stats.hpp"
3741

3842
namespace ipxp {
3943

4044
/**
4145
* \brief Base class for packet receivers.
4246
*/
43-
class InputPlugin : public Plugin
47+
class InputPlugin : public TelemetryUtils, public Plugin
4448
{
4549
public:
4650
enum class Result {
@@ -55,10 +59,24 @@ class InputPlugin : public Plugin
5559
uint64_t m_parsed;
5660
uint64_t m_dropped;
5761

58-
InputPlugin() : m_seen(0), m_parsed(0), m_dropped(0) {}
62+
InputPlugin();
5963
virtual ~InputPlugin() {}
6064

6165
virtual Result get(PacketBlock &packets) = 0;
66+
67+
void set_telemetry_dirs(
68+
std::shared_ptr<telemetry::Directory> plugin_dir,
69+
std::shared_ptr<telemetry::Directory> queues_dir);
70+
71+
protected:
72+
virtual void configure_telemetry_dirs(
73+
std::shared_ptr<telemetry::Directory> plugin_dir,
74+
std::shared_ptr<telemetry::Directory> queues_dir) {};
75+
76+
ParserStats m_parser_stats;
77+
78+
private:
79+
void create_parser_stats_telemetry(std::shared_ptr<telemetry::Directory> queues_dir);
6280
};
6381

6482
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* \file
3+
* \brief Definition of the ParserStats structure for storing parser statistics
4+
* \author Pavel Siska <[email protected]>
5+
* \date 2024
6+
*/
7+
/*
8+
* Copyright (C) 2024 CESNET
9+
*
10+
* LICENSE TERMS
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions
14+
* are met:
15+
* 1. Redistributions of source code must retain the above copyright
16+
* notice, this list of conditions and the following disclaimer.
17+
* 2. Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in
19+
* the documentation and/or other materials provided with the
20+
* distribution.
21+
* 3. Neither the name of the Company nor the names of its contributors
22+
* may be used to endorse or promote products derived from this
23+
* software without specific prior written permission.
24+
*/
25+
26+
#pragma once
27+
28+
#include <cstdint>
29+
30+
namespace ipxp {
31+
32+
/**
33+
* \brief Structure for storing parser statistics.
34+
*/
35+
struct ParserStats {
36+
uint64_t mpls_packets;
37+
uint64_t vlan_packets;
38+
uint64_t pppoe_packets;
39+
uint64_t trill_packets;
40+
41+
uint64_t ipv4_packets;
42+
uint64_t ipv6_packets;
43+
44+
uint64_t tcp_packets;
45+
uint64_t udp_packets;
46+
47+
uint64_t seen_packets;
48+
uint64_t unknown_packets;
49+
};
50+
51+
} // namespace ipxp

include/ipfixprobe/storage.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@
3030
#ifndef IPXP_STORAGE_HPP
3131
#define IPXP_STORAGE_HPP
3232

33-
#include <string>
34-
3533
#include "plugin.hpp"
3634
#include "packet.hpp"
3735
#include "flowifc.hpp"
3836
#include "ring.h"
3937
#include "process.hpp"
4038

39+
#include <string>
40+
#include <memory>
41+
#include <telemetry.hpp>
42+
4143
namespace ipxp {
4244

4345
/**
@@ -94,6 +96,13 @@ class StoragePlugin : public Plugin
9496
{
9597
}
9698

99+
/**
100+
* \brief set telemetry directory for the storage
101+
*/
102+
virtual void set_telemetry_dir(std::shared_ptr<telemetry::Directory> dir)
103+
{
104+
}
105+
97106
/**
98107
* \brief Add plugin to internal list of plugins.
99108
* Plugins are always called in the same order, as they were added.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* \file
3+
* \brief Contains the TelemetryUtils class for managing telemetry data.
4+
* \author Pavel Siska <[email protected]>
5+
* \date 2024
6+
*/
7+
/*
8+
* Copyright (C) 2024 CESNET
9+
*
10+
* LICENSE TERMS
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions
14+
* are met:
15+
* 1. Redistributions of source code must retain the above copyright
16+
* notice, this list of conditions and the following disclaimer.
17+
* 2. Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in
19+
* the documentation and/or other materials provided with the
20+
* distribution.
21+
* 3. Neither the name of the Company nor the names of its contributors
22+
* may be used to endorse or promote products derived from this
23+
* software without specific prior written permission.
24+
*/
25+
26+
#pragma once
27+
28+
#include <string_view>
29+
#include <memory>
30+
#include <telemetry.hpp>
31+
32+
namespace ipxp {
33+
34+
class TelemetryUtils {
35+
public:
36+
37+
/**
38+
* @brief Register a File in the telemetry holder
39+
*
40+
* If the file is already registered, it will not be registered again.
41+
*
42+
* @param directory Directory to register the file in
43+
* @param filename Name of the file
44+
* @param ops File operations
45+
*/
46+
void register_file(
47+
std::shared_ptr<telemetry::Directory> directory,
48+
const std::string_view& filename,
49+
telemetry::FileOps ops)
50+
{
51+
if (directory->getEntry(filename)) {
52+
return;
53+
}
54+
55+
auto file = directory->addFile(filename, ops);
56+
m_holder.add(file);
57+
}
58+
59+
protected:
60+
telemetry::Holder m_holder;
61+
};
62+
63+
}

init/ipfixprobed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ if [ -e "$CONFFILE" ]; then
8484
fi
8585
output="-o ipfix;host=${HOST:-127.0.0.1};port=${PORT:-4739};id=${LINK:-0};dir=${DIR:-0};${UDP_PARAM};template=${TEMPLATE_REFRESH_RATE:-300}"
8686

87+
telemetry=""
88+
if [ "$USE_FUSE" = "1" ]; then
89+
telemetry="-t ${FUSE_MOUNT_POINT}"
90+
fi
91+
92+
exec /usr/bin/ipfixprobe "${dpdkinput[@]}" $input $storage $process $output $telemetry
93+
8794
exec /usr/bin/ipfixprobe "${dpdkinput[@]}" $input $storage $process $output
8895
else
8996
echo "Configuration file '$CONFFILE' does not exist, exitting." >&2

0 commit comments

Comments
 (0)