Skip to content

Commit

Permalink
treewide: rename the project to grout
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Jarry <[email protected]>
  • Loading branch information
rjarry committed Jun 21, 2024
1 parent 31fe01e commit 33fed97
Show file tree
Hide file tree
Showing 122 changed files with 1,592 additions and 1,595 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^".*'
Priority: -1
- Regex: '^<(br_|br\.)'
- Regex: '^<(gr_|gr\.)'
Priority: 100
- Regex: '^<(rte_|event|ecoli|stb_|numa.h|libsmartcols.h)'
Priority: 500
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- uses: actions/upload-artifact@v4
with:
path: |
build/br
build/br-cli
build/grout
build/grcli
build/subprojects/ecoli/src/libecoli.so
retention-days: 5
- run: make unit-tests
Expand All @@ -57,7 +57,7 @@ jobs:
with:
path: build
merge-multiple: true
- run: chmod -c a+x build/br* build/subprojects/ecoli/src/libecoli.so
- run: chmod -c a+x build/grout* build/subprojects/ecoli/src/libecoli.so
- run: sudo smoke/run.sh build
lint:
runs-on: ubuntu-latest
Expand Down
45 changes: 21 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Boring Router: a sample router based on DPDK
# Grout: a graph router based on DPDK

`brouter` stands for *Boring Router*. *Boring* because it should work in all
circumstances, without any fuss nor extended configuration/tuning.

*Boring Router* is a DPDK based network processing application. It uses the
`rte_graph` library for data path processing.
Grout is a DPDK based network processing application. It uses the `rte_graph`
library for data path processing.

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
Expand All @@ -31,32 +28,32 @@ apt install build-essential gcovr libcmocka-dev libedit-dev libevent-dev \
### Build

```
git clone https://github.com/rjarry/brouter
cd brouter
git clone https://github.com/rjarry/grout
cd grout
make
```

### Start the router
### Start the router daemon

```console
[root@dio brouter]$ taskset --cpu-list 6-19,26-39 ./build/br -v
BR: dpdk_init: DPDK version: DPDK 23.11.0
BR: dpdk_init: EAL arguments: -l 6 -a 0000:00:00.0 --in-memory --log-level=*:info
[root@dio grout]$ taskset --cpu-list 6-19,26-39 ./build/grout -v
GROUT: dpdk_init: DPDK version: DPDK 23.11.0
GROUT: dpdk_init: EAL arguments: -l 6 -a 0000:00:00.0 --in-memory --log-level=*:info
EAL: Detected CPU lcores: 40
EAL: Detected NUMA nodes: 1
...
BR: listen_api_socket: listening on API socket /run/br.sock
GROUT: listen_api_socket: listening on API socket /run/grout.sock
```

### Start the CLI

By default, the CLI will start an interactive shell with command completion:

```console
[root@dio brouter]$ ./build/br-cli
Welcome to the boring router CLI.
[root@dio grout]$ ./build/grcli
Welcome to the grout CLI.
Use ? for help and <tab> for command completion.
br# ?
grout# ?
quit Exit the CLI.
add Create objects in the configuration.
del Delete objects from the configuration.
Expand All @@ -68,7 +65,7 @@ set Modify existing objects in the configuration.
Multiple commands can be piped into standard input:

```console
[root@dio brouter]$ ./build/br-cli -ex < commands.list
[root@dio grout]$ ./build/grcli -ex < commands.list
+ add interface port p0 devargs 0000:18:00.0 rxqs 1 qsize 2048
Created interface 0
+ add interface port p1 devargs 0000:18:00.1 rxqs 1 qsize 2048
Expand Down Expand Up @@ -115,8 +112,8 @@ IP MAC IFACE AGE STATE
The CLI can be used as a one-shot command (with bash completion built-in):

```console
[root@dio brouter]$ complete -o default -C './build/br-cli -c' ./build/br-cli
[root@dio brouter]$ ./build/br-cli <TAB><TAB>
[root@dio grout]$ complete -o default -C './build/grcli -c' ./build/grcli
[root@dio grout]$ ./build/grcli <TAB><TAB>
add (Create objects in the configuration.)
clear (Clear counters or temporary entries.)
del (Delete objects from the configuration.)
Expand All @@ -131,16 +128,16 @@ show (Display information about the configuration.)
-s (Path to the control plane API socket.)
--trace-commands (Print executed commands.)
-x (Print executed commands.)
[root@dio brouter]$ ./build/br-cli show <TAB><TAB>
[root@dio grout]$ ./build/grcli show <TAB><TAB>
graph (Show packet processing graph info.)
interface (Display interface details.)
ip (Show IPv4 stack details.)
port (Display DPDK port information.)
stats (Print statistics.)
[root@dio brouter]$ ./build/br-cli show stats <TAB><TAB>
[root@dio grout]$ ./build/grcli show stats <TAB><TAB>
hardware (Print hardware stats.)
software (Print software stats.)
[root@dio brouter]$ ./build/br-cli show stats software
[root@dio grout]$ ./build/grcli show stats software
NODE CALLS PACKETS PKTS/CALL CYCLES/CALL CYCLES/PKT
port_rx 757792 22623757 29.9 1776.4 59.5
ip_input 333675 22623757 67.8 3091.0 45.6
Expand All @@ -154,10 +151,10 @@ ip_forward 333675 22623757 67.8 691.8 10.2
## Packet graph

```console
[root@dio brouter]$ ./build/br-cli show graph dot | dot -Tsvg > docs/graph.svg
[root@dio grout]$ ./build/grcli show graph dot | dot -Tsvg > docs/graph.svg
```

![docs/graph.svg](https://raw.githubusercontent.com/rjarry/brouter/main/docs/graph.svg)
![docs/graph.svg](https://raw.githubusercontent.com/rjarry/grout/main/docs/graph.svg)

## License

Expand Down
13 changes: 0 additions & 13 deletions api/br_bitops.h

This file was deleted.

24 changes: 12 additions & 12 deletions api/br_api.h → api/gr_api.h
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2024 Robin Jarry

#ifndef _BR_API
#define _BR_API
#ifndef _GR_API
#define _GR_API

#include <stddef.h>
#include <stdint.h>

struct br_api_request {
struct gr_api_request {
uint32_t id;
uint32_t type;
uint32_t payload_len;
};

struct br_api_response {
uint32_t for_id; // matches br_api_request.id
struct gr_api_response {
uint32_t for_id; // matches gr_api_request.id
uint32_t status; // uses errno values
uint32_t payload_len;
};

#define BR_API_MAX_MSG_LEN (128 * 1024)
#define GR_API_MAX_MSG_LEN (128 * 1024)

#define REQUEST_TYPE(module, id) (((uint32_t)(0xffff & module) << 16) | (0xffff & id))
#define PAYLOAD(header) ((void *)(header + 1))

#define BR_DEFAULT_SOCK_PATH "/run/br.sock"
#define GR_DEFAULT_SOCK_PATH "/run/grout.sock"

struct br_api_client;
struct gr_api_client;

struct br_api_client *br_api_client_connect(const char *sock_path);
struct gr_api_client *gr_api_client_connect(const char *sock_path);

int br_api_client_disconnect(struct br_api_client *);
int gr_api_client_disconnect(struct gr_api_client *);

int br_api_client_send_recv(
const struct br_api_client *,
int gr_api_client_send_recv(
const struct gr_api_client *,
uint32_t req_type,
size_t tx_len,
const void *tx_data,
Expand Down
22 changes: 11 additions & 11 deletions api/br_api_client_impl.h → api/gr_api_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

// This file must be included in *one* of your client application files.

#ifndef _BR_API_CLIENT_IMPL
#define _BR_API_CLIENT_IMPL
#ifndef _GR_API_CLIENT_IMPL
#define _GR_API_CLIENT_IMPL

#include "br_api.h"
#include "gr_api.h"

#include <errno.h>
#include <getopt.h>
Expand All @@ -18,17 +18,17 @@
#include <sys/un.h>
#include <unistd.h>

struct br_api_client {
struct gr_api_client {
int sock_fd;
};

struct br_api_client *br_api_client_connect(const char *sock_path) {
struct gr_api_client *gr_api_client_connect(const char *sock_path) {
union {
struct sockaddr_un un;
struct sockaddr a;
} addr;

struct br_api_client *client = calloc(1, sizeof(*client));
struct gr_api_client *client = calloc(1, sizeof(*client));
if (client == NULL)
goto err;

Expand All @@ -49,23 +49,23 @@ struct br_api_client *br_api_client_connect(const char *sock_path) {
return NULL;
}

int br_api_client_disconnect(struct br_api_client *client) {
int gr_api_client_disconnect(struct gr_api_client *client) {
if (client == NULL)
return 0;
int ret = close(client->sock_fd);
free(client);
return ret;
}

int br_api_client_send_recv(
const struct br_api_client *client,
int gr_api_client_send_recv(
const struct gr_api_client *client,
uint32_t req_type,
size_t tx_len,
const void *tx_data,
void **rx_data
) {
struct br_api_request *req = NULL;
struct br_api_response resp;
struct gr_api_request *req = NULL;
struct gr_api_response resp;
static uint32_t message_id;
uint32_t id = ++message_id;
void *payload = NULL;
Expand Down
13 changes: 13 additions & 0 deletions api/gr_bitops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2024 Robin Jarry

#ifndef _GR_BITOPS
#define _GR_BITOPS

#include <stdint.h>

#define GR_BIT16(n) (UINT16_C(1) << (n))
#define GR_BIT32(n) (UINT32_C(1) << (n))
#define GR_BIT64(n) (UINT64_C(1) << (n))

#endif
4 changes: 2 additions & 2 deletions api/br_macro.h → api/gr_macro.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2024 Robin Jarry

#ifndef _BR_MACRO
#define _BR_MACRO
#ifndef _GR_MACRO
#define _GR_MACRO

#define ARRAY_DIM(array) (sizeof(array) / sizeof(array[0]))
#define MEMBER_SIZE(type, member) (sizeof(((type *)0)->member))
Expand Down
16 changes: 8 additions & 8 deletions api/br_net_types.h → api/gr_net_types.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2024 Robin Jarry

#ifndef _BR_NET_TYPES
#define _BR_NET_TYPES
#ifndef _GR_NET_TYPES
#define _GR_NET_TYPES

#include <arpa/inet.h>
#include <errno.h>
Expand All @@ -22,16 +22,16 @@ struct eth_addr {
uint8_t bytes[6];
};

static inline bool br_eth_addr_eq(const struct eth_addr *a, const struct eth_addr *b) {
static inline bool gr_eth_addr_eq(const struct eth_addr *a, const struct eth_addr *b) {
return memcmp(a->bytes, b->bytes, sizeof(a->bytes)) == 0;
}

static inline bool br_eth_addr_is_zero(const struct eth_addr *mac) {
static inline bool gr_eth_addr_is_zero(const struct eth_addr *mac) {
struct eth_addr zero = {0};
return br_eth_addr_eq(mac, &zero);
return gr_eth_addr_eq(mac, &zero);
}

static inline int br_eth_addr_parse(const char *s, struct eth_addr *mac) {
static inline int gr_eth_addr_parse(const char *s, struct eth_addr *mac) {
if (s == NULL)
goto err;
int ret = sscanf(
Expand Down Expand Up @@ -63,7 +63,7 @@ struct ip4_net {
uint8_t prefixlen;
};

static inline int br_ip4_net_parse(const char *s, struct ip4_net *net, bool zero_mask) {
static inline int gr_ip4_net_parse(const char *s, struct ip4_net *net, bool zero_mask) {
char *addr = NULL;
int ret = -1;

Expand All @@ -89,7 +89,7 @@ static inline int br_ip4_net_parse(const char *s, struct ip4_net *net, bool zero
return ret;
}

static inline int br_ip4_net_format(const struct ip4_net *net, char *buf, size_t len) {
static inline int gr_ip4_net_format(const struct ip4_net *net, char *buf, size_t len) {
const char *tmp;
int n;

Expand Down
4 changes: 2 additions & 2 deletions api/br_stb_ds.h → api/gr_stb_ds.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2024 Robin Jarry

#ifndef _BR_CORE_STB_DS
#define _BR_CORE_STB_DS
#ifndef _GR_CORE_STB_DS
#define _GR_CORE_STB_DS

#include <stb_ds.h>

Expand Down
4 changes: 2 additions & 2 deletions api/br_string.h → api/gr_string.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2024 Robin Jarry

#ifndef _BR_STRING
#define _BR_STRING
#ifndef _GR_STRING
#define _GR_STRING

#include <stddef.h>

Expand Down
8 changes: 4 additions & 4 deletions api/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Copyright (c) 2024 Robin Jarry

api_headers += files(
'br_api.h',
'br_api_client_impl.h',
'br_bitops.h',
'br_net_types.h',
'gr_api.h',
'gr_api_client_impl.h',
'gr_bitops.h',
'gr_net_types.h',
)

src += files(
Expand Down
4 changes: 2 additions & 2 deletions api/stb_ds_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright (c) 2024 Robin Jarry

#define STB_DS_IMPLEMENTATION
#include <br_stb_ds.h>
#include <br_string.h>
#include <gr_stb_ds.h>
#include <gr_string.h>

#include <stddef.h>

Expand Down
Loading

0 comments on commit 33fed97

Please sign in to comment.