// SPDX-License-Identifier: GPL-3.0-or-later
#include "daemon/common.h"
#define RRD_TYPE_TC "tc"
#define PLUGIN_TC_NAME "tc.plugin"
// ----------------------------------------------------------------------------
// /sbin/tc processor
// this requires the script plugins.d/tc-qos-helper.sh
#define TC_LINE_MAX 1024
struct tc_class {
STRING *id;
STRING *name;
STRING *leafid;
STRING *parentid;
bool hasparent;
bool isleaf;
bool isqdisc;
bool render;
bool name_updated;
bool updated;
int unupdated; // the number of times, this has been found un-updated
unsigned long long bytes;
unsigned long long packets;
unsigned long long dropped;
unsigned long long tokens;
unsigned long long ctokens;
//unsigned long long overlimits;
//unsigned long long requeues;
//unsigned long long lended;
//unsigned long long borrowed;
//unsigned long long giants;
RRDDIM *rd_bytes;
RRDDIM *rd_packets;
RRDDIM *rd_dropped;
RRDDIM *rd_tokens;
RRDDIM *rd_ctokens;
};
struct tc_device {
STRING *id;
STRING *name;
STRING *family;
bool name_updated;
bool family_updated;
char enabled;
char enabled_bytes;
char enabled_packets;
char enabled_dropped;
char enabled_tokens;
char enabled_ctokens;
char enabled_all_classes_qdiscs;
RRDSET *st_bytes;
RRDSET *st_packets;
RRDSET *st_dropped;
RRDSET *st_tokens;
RRDSET *st_ctokens;
DICTIONARY *classes;
};
// ----------------------------------------------------------------------------
// tc_class index
static void tc_class_free_callback(const char *name __maybe_unused, void *value, void *data __maybe_unused) {
// struct tc_device *d = data;
struct tc_class *c = value;
string_freez(c->id);
string_freez(c->name);
string_freez(c->leafid);
string_freez(c->parentid);
}
static void tc_class_conflict_callback(const char *name __maybe_unused, void *old_value, void *new_value, void *data __maybe_unused) {
struct tc_device *d = data; (void)d;
struct tc_class *c = old_value; (void)c;
struct tc_class *new_c = new_value; (void)new_c;
error("TC: class '%s' is already in device '%s'. Ignoring duplicate."