Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Containerfile.grout
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2025 Christophe Fontaine

FROM registry.access.redhat.com/ubi9 as ubi-builder
COPY grout.*.rpm grout-prometheus.*.rpm /tmp
COPY grout.*.rpm /tmp
RUN mkdir -p /tmp/null
RUN dnf -y install --nodocs --setopt=install_weak_deps=0 --releasever 9 --installroot /tmp/null /tmp/grout*.rpm
RUN dnf -y --installroot /tmp/null clean all
Expand Down
2 changes: 0 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ deb:
GROUT_VERSION='$(debversion)' dpkg-buildpackage -b
$Q arch=`dpkg-architecture -qDEB_HOST_ARCH` && \
mv -vf ../grout-headers_$(debversion)_all.deb grout-headers_all.deb && \
mv -vf ../grout-prometheus_$(debversion)_all.deb grout-prometheus_all.deb && \
mv -vf ../grout_$(debversion)_$$arch.deb grout_$$arch.deb && \
mv -vf ../grout-dbgsym_$(debversion)_$$arch.deb grout-dbgsym_$$arch.deb && \
mv -vf ../grout-frr_$(debversion)_$$arch.deb grout-frr_$$arch.deb && \
Expand All @@ -96,7 +95,6 @@ rpm:
$Q arch=`rpm --eval '%{_arch}'` && \
version="$(rpmversion)-$(rpmrelease)" && \
mv -vf ~/rpmbuild/RPMS/noarch/grout-headers-$$version.noarch.rpm grout-headers.noarch.rpm && \
mv -vf ~/rpmbuild/RPMS/noarch/grout-prometheus-$$version.noarch.rpm grout-prometheus.noarch.rpm && \
mv -vf ~/rpmbuild/RPMS/$$arch/grout-$$version.$$arch.rpm grout.$$arch.rpm && \
mv -vf ~/rpmbuild/RPMS/$$arch/grout-debuginfo-$$version.$$arch.rpm grout-debuginfo.$$arch.rpm && \
mv -vf ~/rpmbuild/RPMS/$$arch/grout-frr-$$version.$$arch.rpm grout-frr.$$arch.rpm && \
Expand Down
12 changes: 11 additions & 1 deletion api/gr_net_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef __GROUT_MAIN__
#include <rte_ether.h>
Expand Down Expand Up @@ -42,6 +41,17 @@ static inline const char *gr_af_name(addr_family_t af) {
return "?";
}

// Check if address family value is valid.
static inline bool gr_af_valid(addr_family_t af) {
switch (af) {
case GR_AF_UNSPEC:
case GR_AF_IP4:
case GR_AF_IP6:
return true;
}
return false;
}

// Custom printf specifiers for network addresses.

// struct rte_ether_addr *
Expand Down
1 change: 1 addition & 0 deletions cli/ec_node_dyn.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <assert.h>
#include <errno.h>
#include <string.h>

EC_LOG_TYPE_REGISTER(node_dyn);

Expand Down
1 change: 1 addition & 0 deletions cli/ecoli.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <errno.h>
#include <stdarg.h>
#include <string.h>

struct ec_node *with_help(const char *help, struct ec_node *node) {
if (node == NULL)
Expand Down
1 change: 1 addition & 0 deletions cli/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <ecoli.h>

#include <errno.h>
#include <string.h>

static STAILQ_HEAD(, cli_context) contexts = STAILQ_HEAD_INITIALIZER(contexts);

Expand Down
1 change: 1 addition & 0 deletions cli/interact.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <errno.h>
#include <signal.h>
#include <string.h>
#include <wordexp.h>

#define __PROMPT "grout#"
Expand Down
20 changes: 0 additions & 20 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,6 @@ Description: API headers for grout clients
a CLI that uses that library. The CLI can be used as an interactive shell, but
also in scripts one command at a time, or by batches.

Package: grout-prometheus
Architecture: all
Depends:
${misc:Depends},
python3,
Description: Prometheus exporter for grout
grout stands for Graph Router. In English, "grout" refers to thin mortar that
hardens to fill gaps between tiles.
.
grout is a DPDK based network processing application. It uses the rte_graph
library for data path processing.
.
Its main purpose is to simulate a network function or a physical router for
testing/replicating real (usually closed source) VNF/CNF behavior with an
opensource tool.
.
It comes with a client library to configure it over a standard UNIX socket and
a CLI that uses that library. The CLI can be used as an interactive shell, but
also in scripts one command at a time, or by batches.

Package: grout-frr
Architecture: linux-any
Depends:
Expand Down
2 changes: 0 additions & 2 deletions debian/grout-prometheus.install

This file was deleted.

4 changes: 0 additions & 4 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ override_dh_auto_configure:

override_dh_auto_install:
meson install -C $(build) --skip-subprojects --destdir=$(dest)
install -D -m 0755 subprojects/dpdk/usertools/dpdk-telemetry-exporter.py \
$(dest)/usr/bin/grout-telemetry-exporter
install -D -m 0644 -t $(dest)/usr/share/dpdk/telemetry-endpoints \
subprojects/dpdk/usertools/telemetry-endpoints/*

override_dh_installsystemd:
dh_installsystemd --no-start --no-stop-on-upgrade
76 changes: 12 additions & 64 deletions docs/grout.8.scdoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ Grout is a software router based on DPDK _rte_graph_.
# SYNOPSIS

*grout*
\[*-B* _SIZE_]
\[*-D* _PATH_]
\[*-L* _TYPE_:_LEVEL_]
\[*-M* _MODE_]
\[*-M* _ADDR_:_PORT_]
\[*-S*]
\[*-T* _REGEXP_]
\[*-V*]
\[*-h*]
\[*-m* _PERMISSIONS_]
Expand All @@ -27,53 +23,18 @@ Grout is a software router based on DPDK _rte_graph_.
\[*-u* _MTU_]
\[*-v*]
\[*-x*]
\[*--* _EAL ARGS_...]

# OPTIONS

*-B*, *--trace-bufsz* _SIZE_
Specify maximum size of allocated memory for trace output for each
thread. Valid unit can be either B or K or M for Bytes, KBytes and
MBytes respectively. For example:

```
--trace-bufsz 2M
```

By default, size of trace output file is 1MB and parameter must be
specified once only.

*-D*, *--trace-dir* _PATH_
Specify trace directory for trace output. For example:

```
--trace-dir /tmp
```

By default, trace output will created at home directory and parameter
must be specified once only.

*-h*, *--help*
Display usage help.

*-L*, *--log-level* _TYPE_:_LEVEL_
Specify log level for a specific component. For example:

```
--log-level lib.eal:debug
```

Can be specified multiple times.

*-M*, *--trace-mode* _o_|_overwrite_|_d_|_discard_
Specify the mode of update of trace output file. Either update on a file
can be wrapped or discarded when file size reaches its maximum limit.
For example:
*-M*, *--metrics* _ADDR_:_PORT_
Change the listen address and port where openmetrics will be exported
via HTTP GET in a dedicated thread. To disable, use *-M* _:0_.

```
--trace-mode discard
```

Default mode is _overwrite_ and parameter must be specified once only.
Default: _127.0.0.1:9111_

*-m*, *--socket-mode* _PERMISSIONS_
Change the API socket file permissions after creating it. Only octal
Expand Down Expand Up @@ -101,25 +62,6 @@ Grout is a software router based on DPDK _rte_graph_.
*-t*, *--test-mode*
Run in test mode (no huge pages).

*-T*, *--trace* _REGEXP_
Enable trace based on regular expression trace name. By default, the
trace is disabled. User must specify this option to enable trace. For
example:

Global trace configuration for EAL only:

```
--trace eal
```

Global trace configuration for ALL the components:

```
--trace ".*"
```

Can be specified multiple times up to 32 times.

*-u*, *--max-mtu* _MTU_
Maximum Transmission Unit.

Expand All @@ -134,6 +76,12 @@ Grout is a software router based on DPDK _rte_graph_.
*-x*, *--trace-packets*
Print all ingress/egress packets (for debugging purposes).

# EXTRA EAL ARGUMENTS

Any DPDK EAL argument can be specified after an optional *--*. This is an
advanced debugging/development feature that can break things. Use with great
care.

# SEE ALSO

*grcli*(1)
Expand Down
1 change: 1 addition & 0 deletions main/dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ int dpdk_init(void) {
gr_vec_add(eal_args, "");
gr_vec_add(eal_args, "-l");
gr_vec_add(eal_args, main_lcore);
gr_vec_add(eal_args, "--no-telemetry");
#ifdef RTE_BUS_PCI
gr_vec_add(eal_args, "-a");
gr_vec_add(eal_args, "pci:0000:00:00.0");
Expand Down
2 changes: 2 additions & 0 deletions main/gr_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct gr_config {
gr_vec char **eal_extra_args;
cpu_set_t control_cpus; // control plane threads allowed CPUs
cpu_set_t datapath_cpus; // datapath threads allowed CPUs
const char *metrics_addr; // openmetrics listen address (NULL to disable)
uint16_t metrics_port; // openmetrics listen port (0 to disable)
};

extern struct gr_config gr_config;
65 changes: 65 additions & 0 deletions main/gr_metrics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2026 Robin Jarry

#pragma once

#include <sched.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/queue.h>

enum gr_metric_type {
GR_METRIC_COUNTER,
GR_METRIC_GAUGE,
};

// Metric definition (static, registered once per metric name)
struct gr_metric {
const char *name; // will be prefixed with "grout_"
const char *help;
enum gr_metric_type type;
};

// Convenience macros for static metric definitions.
#define METRIC_COUNTER(v, n, h) \
static const struct gr_metric v = {.name = (n), .help = (h), .type = GR_METRIC_COUNTER}
#define METRIC_GAUGE(v, n, h) \
static const struct gr_metric v = {.name = (n), .help = (h), .type = GR_METRIC_GAUGE}

// Opaque writer context
struct gr_metrics_writer;

// Label context - holds base labels for multiple emit calls
struct gr_metrics_ctx {
struct gr_metrics_writer *w;
char labels[512];
size_t labels_len;
};

// Initialize context with base labels (varargs: key, val, ..., NULL)
void gr_metrics_ctx_init(struct gr_metrics_ctx *, struct gr_metrics_writer *, ...);

// Add more labels to existing context (varargs: key, val, ..., NULL)
void gr_metrics_labels_add(struct gr_metrics_ctx *, ...);

// Emit metric value using context's labels
void gr_metric_emit(struct gr_metrics_ctx *, const struct gr_metric *, uint64_t value);

// Collector registration (groups related metrics + callback)
struct gr_metrics_collector {
const char *name;
void (*collect)(struct gr_metrics_writer *);
STAILQ_ENTRY(gr_metrics_collector) next;
};

void gr_metrics_register(struct gr_metrics_collector *);

// Start the openmetrics HTTP server in a dedicated thread
void gr_metrics_start(void);

// Stop the openmetrics HTTP server
void gr_metrics_stop(void);

// Change the thread affinity of the openmetrics thread
int gr_metrics_set_affinity(size_t set_size, const cpu_set_t *affinity);
Loading
Loading