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

stats: always use tcp/udp prefix #9934

Closed
Closed
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
21 changes: 18 additions & 3 deletions src/app-layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,23 @@ void AppLayerRegisterGlobalCounters(void)
StatsRegisterGlobalCounter("app_layer.expectations", ExpectationGetCounter);
}

static bool AppLayerParserBothTcpUdp(AppProto alproto)
{
switch (alproto) {
case ALPROTO_DCERPC:
// fallthrough
case ALPROTO_DNS:
// fallthrough
case ALPROTO_ENIP:
// fallthrough
case ALPROTO_KRB5:
// fallthrough
case ALPROTO_NFS:
return true;
}
return false;
}

#define IPPROTOS_MAX 2
void AppLayerSetupCounters(void)
{
Expand All @@ -1061,16 +1078,14 @@ void AppLayerSetupCounters(void)
for (uint8_t p = 0; p < IPPROTOS_MAX; p++) {
const uint8_t ipproto = ipprotos[p];
const uint8_t ipproto_map = FlowGetProtoMapping(ipproto);
const uint8_t other_ipproto = ipproto == IPPROTO_TCP ? IPPROTO_UDP : IPPROTO_TCP;
const char *ipproto_suffix = (ipproto == IPPROTO_TCP) ? "_tcp" : "_udp";

for (AppProto alproto = 0; alproto < ALPROTO_MAX; alproto++) {
if (alprotos[alproto] == 1) {
const char *tx_str = "app_layer.tx.";
const char *alproto_str = AppLayerGetProtoName(alproto);

if (AppLayerParserProtoIsRegistered(ipproto, alproto) &&
AppLayerParserProtoIsRegistered(other_ipproto, alproto)) {
if (AppLayerParserBothTcpUdp(alproto)) {
snprintf(applayer_counter_names[ipproto_map][alproto].name,
sizeof(applayer_counter_names[ipproto_map][alproto].name),
"%s%s%s", str, alproto_str, ipproto_suffix);
Expand Down
Loading