Skip to content

Commit 68dc984

Browse files
committed
add config to change tun name (#375)
1 parent 2477f00 commit 68dc984

5 files changed

Lines changed: 19 additions & 3 deletions

File tree

code/bngblaster/src/bbl_config.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4117,7 +4117,7 @@ json_parse_config(json_t *root)
41174117

41184118
const char *schema[] = {
41194119
"io-mode", "io-slots", "io-burst", "qdisc-bypass",
4120-
"tx-interval", "rx-interval", "tx-threads",
4120+
"tx-interval", "rx-interval", "tx-threads", "tun-name",
41214121
"rx-threads", "capture-include-streams", "mac-modifier",
41224122
"lag", "network", "access", "a10nsp", "links", "a10nsp-dynamic"
41234123
};
@@ -4190,6 +4190,13 @@ json_parse_config(json_t *root)
41904190
if(value) {
41914191
g_ctx->config.a10nsp_dynamic = json_boolean_value(value);
41924192
}
4193+
if(json_unpack(section, "{s:s}", "tun-name", &s) == 0) {
4194+
if(strlen(s) > 10) {
4195+
fprintf(stderr, "JSON config error: Invalid value for interfaces->tun-name (string length > 10)\n");
4196+
return false;
4197+
}
4198+
g_ctx->config.tun_name = strdup(s);
4199+
}
41934200
/* LAG Configuration Section */
41944201
sub = json_object_get(section, "lag");
41954202
if(json_is_array(sub)) {
@@ -4668,6 +4675,7 @@ bbl_config_init_defaults()
46684675
g_ctx->config.io_burst = 256;
46694676
g_ctx->config.io_max_stream_len = 9000;
46704677
g_ctx->config.qdisc_bypass = true;
4678+
g_ctx->config.tun_name = "bbl";
46714679
g_ctx->config.sessions = 1;
46724680
g_ctx->config.sessions_max_outstanding = 800;
46734681
g_ctx->config.sessions_start_period_ns = 2500000; /* 400/s */

code/bngblaster/src/bbl_ctx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ typedef struct bbl_ctx_
161161
uint8_t tx_threads;
162162
uint8_t rx_threads;
163163

164+
char *tun_name;
164165
char *json_report_filename;
165166
bool json_report_sessions; /* Include sessions */
166167
bool json_report_streams; /* Include streams */

code/bngblaster/src/bbl_tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ bbl_tun_session_init(bbl_session_s *session)
217217
char dev[IFNAMSIZ];
218218
if(!session->access_config->tun) return true;
219219

220-
snprintf(dev, sizeof(dev), "bbl%d", session->session_id);
220+
snprintf(dev, sizeof(dev), "%s%d", g_ctx->config.tun_name, session->session_id);
221221
session->tun_dev = strdup(dev);
222222
session->tun_fd = bbl_tun_add(session->tun_dev, IFF_TUN|IFF_NO_PI);
223223

docsrc/sources/configuration/interfaces.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@
4646
| | | allows to run multiple BNG Blaster instances with disjoint session |
4747
| | | MAC addresses. |
4848
| | | Default: 0 |
49-
+-----------------------------------+----------------------------------------------------------------------+
49+
+-----------------------------------+----------------------------------------------------------------------+
50+
| **tun-name** | | TUN interface name prefix (`<tun-name><session-id>`). |
51+
| | | Default: bbl (bbl1, bbl2, ...) |
52+
+-----------------------------------+----------------------------------------------------------------------+

schemas/bngblaster-config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
"minimum": 0,
7373
"maximum": 255
7474
},
75+
"tun-name": {
76+
"type": "string",
77+
"description": "TUN interface name prefix"
78+
},
7579
"links": {
7680
"oneOf": [
7781
{

0 commit comments

Comments
 (0)