fix session traffic

This commit is contained in:
Christian Giese
2022-11-02 17:52:51 +01:00
committed by Christian Giese
parent 84a9932e91
commit bdd4c2d3fc
2 changed files with 33 additions and 8 deletions
+5 -2
View File
@@ -1369,17 +1369,20 @@ json_parse_stream(json_t *stream, bbl_stream_config_s *stream_config)
if(stream_config->stream_group_id == 0 &&
stream_config->direction != BBL_DIRECTION_DOWN) {
fprintf(stderr, "JSON config error: Invalid value for stream->direction (must be downstream for RAW streams)\n");
fprintf(stderr, "JSON config error: Invalid value for stream->direction (must be downstream for RAW streams)\n");
return false;
}
if(json_unpack(stream, "{s:s}", "network-interface", &s) == 0) {
stream_config->network_interface = strdup(s);
}
if(json_unpack(stream, "{s:s}", "a10nsp-interface", &s) == 0) {
stream_config->a10nsp_interface = strdup(s);
}
if(stream_config->network_interface && stream_config->a10nsp_interface) {
fprintf(stderr, "JSON config error: Not allowed to set stream->network-interface and stream->a10nsp-interface\n");
return false;
}
value = json_object_get(stream, "source-port");
if(value) {
+28 -6
View File
@@ -1425,8 +1425,30 @@ bbl_stream_session_add(bbl_stream_config_s *config, bbl_session_s *session)
}
}
if(config->session_traffic && !(network_interface || a10nsp_interface)) {
/* Skip session traffic if no network/a10nsp interface is found. */
return true;
}
tx_interval = SEC / config->pps;
if(config->direction & BBL_DIRECTION_UP) {
if(config->type == BBL_SUB_TYPE_IPV4) {
if(!((network_interface && network_interface->ip.address) ||
config->ipv4_destination_address ||
config->ipv4_network_address ||
a10nsp_interface)) {
LOG(ERROR, "Failed to add stream %s (upstream) because of missing IPv4 destination address\n", config->name);
return false;
}
} else {
if(!((network_interface && *(uint64_t*)network_interface->ip6.address) ||
*(uint64_t*)config->ipv6_destination_address ||
*(uint64_t*)config->ipv6_network_address ||
a10nsp_interface)) {
LOG(ERROR, "Failed to add stream %s (upstream) because of missing IPv6 destination address\n", config->name);
return false;
}
}
stream = calloc(1, sizeof(bbl_stream_s));
stream->endpoint = &g_endpoint;
stream->flow_id = g_ctx->flow_id++;
@@ -1467,11 +1489,11 @@ bbl_stream_session_add(bbl_stream_config_s *config, bbl_session_s *session)
g_ctx->stats.session_traffic_flows++;
session->session_traffic.flows++;
LOG(DEBUG, "Session traffic stream %s (upstream) added to %s (access) with %lf PPS\n",
access_interface->name, config->name, config->pps);
config->name, access_interface->name, config->pps);
} else {
g_ctx->stats.stream_traffic_flows++;
LOG(DEBUG, "Traffic stream %s (upstream) added to %s (access) with %lf PPS\n",
access_interface->name, config->name, config->pps);
config->name, access_interface->name, config->pps);
}
}
if(config->direction & BBL_DIRECTION_DOWN) {
@@ -1516,11 +1538,11 @@ bbl_stream_session_add(bbl_stream_config_s *config, bbl_session_s *session)
g_ctx->stats.session_traffic_flows++;
session->session_traffic.flows++;
LOG(DEBUG, "Session traffic stream %s (downstream) added to %s (network) with %lf PPS\n",
network_interface->name, config->name, config->pps);
config->name, network_interface->name, config->pps);
} else {
g_ctx->stats.stream_traffic_flows++;
LOG(DEBUG, "Traffic stream %s (downstream) added to %s (network) with %lf PPS\n",
network_interface->name, config->name, config->pps);
config->name, network_interface->name, config->pps);
}
} else if(a10nsp_interface) {
stream->a10nsp_interface = a10nsp_interface;
@@ -1530,11 +1552,11 @@ bbl_stream_session_add(bbl_stream_config_s *config, bbl_session_s *session)
g_ctx->stats.session_traffic_flows++;
session->session_traffic.flows++;
LOG(DEBUG, "Session traffic stream %s (downstream) added to %s (a10nsp) with %lf PPS\n",
network_interface->name, config->name, config->pps);
config->name, network_interface->name, config->pps);
} else {
g_ctx->stats.stream_traffic_flows++;
LOG(DEBUG, "Traffic stream %s (downstream) added to %s (a10nsp) with %lf PPS\n",
network_interface->name, config->name, config->pps);
config->name, network_interface->name, config->pps);
}
} else {
LOG(ERROR, "Failed to add stream %s (downstream) because of missing interface\n", config->name);