Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream Scaling #258

Merged
merged 13 commits into from
May 23, 2024
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Debug Build")
set(CMAKE_BUILD_TYPE Debug)
add_definitions(-DBBL_DEBUG)
else()
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
message("Release Build")
set(CMAKE_BUILD_TYPE Release)
else()
message("Release Build with Debug Symbols")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()

if (BNGBLASTER_TIMER_LOGGING)
Expand Down
3 changes: 3 additions & 0 deletions code/bngblaster/src/bbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ main(int argc, char *argv[])
g_ctx->multicast_endpoint = ENDPOINT_ENABLED;
}

/* Smear all stream buckets. */
io_stream_smear_all();

/* Start threads. */
io_thread_start_all();

Expand Down
7 changes: 1 addition & 6 deletions code/bngblaster/src/bbl_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ json_parse_config(json_t *root)
if(json_is_object(section)) {

const char *schema[] = {
"autostart", "stop-verified", "max-burst",
"autostart", "stop-verified",
"stream-autostart",
"stream-rate-calculation",
"stream-delay-calculation",
Expand All @@ -3441,10 +3441,6 @@ json_parse_config(json_t *root)
if(value) {
g_ctx->config.traffic_stop_verified = json_boolean_value(value);
}
JSON_OBJ_GET_NUMBER(section, value, "traffic", "max-burst", 1, 65535);
if(value) {
g_ctx->config.stream_max_burst = json_number_value(value);
}
JSON_OBJ_GET_BOOL(section, value, "traffic", "stream-autostart");
if(value) {
g_ctx->config.stream_autostart = json_boolean_value(value);
Expand Down Expand Up @@ -4204,7 +4200,6 @@ bbl_config_init_defaults()
g_ctx->config.stream_autostart = true;
g_ctx->config.stream_rate_calc = true;
g_ctx->config.stream_delay_calc = true;
g_ctx->config.stream_max_burst = 1024;
g_ctx->config.multicast_traffic_autostart = true;
g_ctx->config.session_traffic_autostart = true;
}
24 changes: 8 additions & 16 deletions code/bngblaster/src/bbl_lag.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,15 @@ static void
bbl_lag_select(bbl_lag_s *lag)
{
bbl_lag_member_s *member;
bbl_stream_s *stream = lag->stream_head;
bbl_stream_s *stream;
io_handle_s *io;

uint8_t active_count = 0;
uint8_t key;

CIRCLEQ_FOREACH(member, &lag->lag_member_qhead, lag_member_qnode) {
io = member->interface->io.tx;
io->stream_pps = 0;
io->stream_count = 0;
io->stream_head = NULL;
io->stream_cur = NULL;
io_stream_clear(io);

member->primary = false;
if(member->interface->state != INTERFACE_DISABLED) {
Expand All @@ -167,24 +164,19 @@ bbl_lag_select(bbl_lag_s *lag)
active_count >= lag->config->lacp_min_active_links) {
bbl_lag_update_state(lag, INTERFACE_UP);
/* Distribute streams */
stream = lag->stream_head;
while(stream) {
key = stream->flow_id % active_count;
io = lag->active_list[key]->interface->io.tx;
stream->io = io;
stream->io_next = io->stream_head;
io->stream_head = stream;
io->stream_cur = stream;
io->stream_pps += stream->pps;
io->stream_count++;
io_stream_add(io, stream);
stream = stream->lag_next;
}
for(key=0; key <active_count; key++) {
io = lag->active_list[key]->interface->io.tx;
io_stream_smear(io);
}
} else {
bbl_lag_update_state(lag, INTERFACE_DOWN);
while(stream) {
stream->io = NULL;
stream->io_next = NULL;
stream = stream->lag_next;
}
}
lag->active_count = active_count;
}
Expand Down
57 changes: 47 additions & 10 deletions code/bngblaster/src/bbl_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,19 +1809,56 @@ bbl_session_ctrl_traffic_stop(int fd, uint32_t session_id, json_t *arguments __a
}

int
bbl_session_ctrl_traffic_reset(int fd, uint32_t session_id __attribute__((unused)), json_t *arguments __attribute__((unused)))
bbl_session_ctrl_traffic_reset(int fd, uint32_t session_id, json_t *arguments)
{
bbl_stream_s *stream = g_ctx->stream_head;

g_ctx->stats.session_traffic_flows_verified = 0;
bbl_session_s *session;
uint32_t i;

/* Iterate over all traffic streams */
while(stream) {
if(stream->session && stream->session_traffic) {
stream->session->session_traffic.flows_verified = 0;
bbl_stream_reset(stream);
int session_group_id = -1;

if(json_unpack(arguments, "{s:i}", "session-group-id", &session_group_id) == 0) {
if(session_group_id < 0 || session_group_id > UINT16_MAX) {
return bbl_ctrl_status(fd, "error", 400, "invalid session-group-id");
}
stream = stream->next;
}

if(session_id) {
session = bbl_session_get(session_id);
if(session) {
if(g_ctx->stats.session_traffic_flows_verified >= session->session_traffic.flows_verified) {
g_ctx->stats.session_traffic_flows_verified -= session->session_traffic.flows_verified;
}
session->session_traffic.flows_verified = 0;
bbl_stream_reset(session->session_traffic.ipv4_up);
bbl_stream_reset(session->session_traffic.ipv4_down);
bbl_stream_reset(session->session_traffic.ipv6_up);
bbl_stream_reset(session->session_traffic.ipv6_down);
bbl_stream_reset(session->session_traffic.ipv6pd_up);
bbl_stream_reset(session->session_traffic.ipv6pd_down);
} else {
return bbl_ctrl_status(fd, "warning", 404, "session not found");
}
} else {
/* Iterate over all sessions */
for(i = 0; i < g_ctx->sessions; i++) {
session = &g_ctx->session_list[i];
if(session) {
if(session_group_id >= 0 && session->session_group_id != session_group_id) {
/* Skip sessions with wrong session-group-id if present. */
continue;
}
if(g_ctx->stats.session_traffic_flows_verified >= session->session_traffic.flows_verified) {
g_ctx->stats.session_traffic_flows_verified -= session->session_traffic.flows_verified;
}
session->session_traffic.flows_verified = 0;
bbl_stream_reset(session->session_traffic.ipv4_up);
bbl_stream_reset(session->session_traffic.ipv4_down);
bbl_stream_reset(session->session_traffic.ipv6_up);
bbl_stream_reset(session->session_traffic.ipv6_down);
bbl_stream_reset(session->session_traffic.ipv6pd_up);
bbl_stream_reset(session->session_traffic.ipv6pd_down);
}
}
}
return bbl_ctrl_status(fd, "ok", 200, NULL);
}
Expand Down
Loading
Loading