1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

improved debugging output

git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@130 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
Steffen Vogel 2014-07-04 09:47:29 +00:00
parent c9de966c57
commit 7ec0753d2b
8 changed files with 45 additions and 37 deletions

View file

@ -18,7 +18,7 @@ RM = rm -f
DOXY = doxygen
# Debug level (if not set via 'make V=?')
V ?= 6
V ?= 5
# Some details about the compiled version
GIT_TAG = $(shell git describe --tags --abbrev=0)

View file

@ -18,6 +18,7 @@
#include <netinet/in.h>
#include <libconfig.h>
#include "msg.h"
#include "tc.h"
/** The type of a node.
@ -26,7 +27,7 @@
*/
enum node_type
{
NODE_INVALID,
NODE_UNKNOWN,
NODE_SERVER,
NODE_WORKSTATION,
NODE_SIM_OPAL,

View file

@ -105,11 +105,8 @@ int config_parse_path(config_setting_t *cfg,
config_setting_lookup_bool(cfg, "enabled", &enabled);
config_setting_lookup_bool(cfg, "reverse", &reverse);
config_setting_lookup_float(cfg, "rate", &path->rate);
path->cfg = cfg;
debug(3, "Loaded path from '%s' to '%s'", path->in->name, path->out->name);
if (enabled) {
list_add(*paths, path);
@ -199,8 +196,6 @@ int config_parse_node(config_setting_t *cfg,
list_add(*nodes, node);
debug(3, "Loaded %s node '%s'", type_str, node->name);
return 0;
}

View file

@ -26,7 +26,8 @@ int if_getegress(struct sockaddr_in *sa)
snprintf(cmd, sizeof(cmd), "ip route get %s", inet_ntoa(sa->sin_addr));
debug(6, "system: %s", cmd);
debug(8, "System: %s", cmd);
FILE *p = popen(cmd, "r");
if (!p)
return -1;
@ -57,12 +58,14 @@ int if_getirqs(struct interface *i)
int n = 0;
struct dirent *entry;
while((entry = readdir(dir)) && n < IF_IRQ_MAX) {
while ((entry = readdir(dir)) && n < IF_IRQ_MAX) {
if (entry->d_type & DT_REG) {
i->irqs[n++] = atoi(entry->d_name);
}
}
debug(7, "Found %u interrupts for interface '%s'", n, i->name);
closedir(dir);
return 0;
}
@ -76,15 +79,13 @@ int if_setaffinity(struct interface *i, int affinity)
snprintf(filename, sizeof(filename), "/proc/irq/%u/smp_affinity", i->irqs[n]);
file = fopen(filename, "w");
if (!file)
continue;
if (file) {
if (fprintf(file, "%8x", affinity) < 0)
error("Failed to set affinity for IRQ %u", i->irqs[n]);
if (fprintf(file, "%8x", affinity) < 0)
error("Failed to set affinity for IRQ %u", i->irqs[n]);
else
debug(3, "Set affinity of MSI IRQ %u (%s) to %#x", i->irqs[n], i->name, affinity);
fclose(file);
fclose(file);
debug(5, "Set affinity of IRQ %u for interface '%s' to %#x", i->irqs[n], i->name, affinity);
}
}
return 0;

View file

@ -56,7 +56,9 @@ int msg_send(struct msg *m, struct node *n)
sizeof(struct sockaddr_in)) < 0)
perror("Failed sendto");
debug(10, "Message sent to node %s (%s:%u)", n->name, inet_ntoa(n->remote.sin_addr), ntohs(n->remote.sin_port));
debug(10, "Message sent to node %s (%s:%u)", n->name,
inet_ntoa(n->remote.sin_addr),
ntohs(n->remote.sin_port));
return 0;
}

View file

@ -67,7 +67,7 @@ enum node_type node_lookup_type(const char *str)
else if (!strcmp(str, "dsp"))
return NODE_SIM_DSP;
else
return NODE_INVALID;
return NODE_UNKNOWN;
}
struct node* node_lookup_name(const char *str, struct node *nodes)

View file

@ -116,17 +116,6 @@ static void quit()
int main(int argc, char *argv[])
{
/* Setup signals */
struct sigaction sa_quit = {
.sa_flags = SA_SIGINFO,
.sa_sigaction = quit
};
sigemptyset(&sa_quit.sa_mask);
sigaction(SIGTERM, &sa_quit, NULL);
sigaction(SIGINT, &sa_quit, NULL);
atexit(&quit);
/* Check arguments */
if (argc != 2) {
printf("Usage: %s CONFIG\n", argv[0]);
@ -140,13 +129,25 @@ int main(int argc, char *argv[])
info("This is %s %s", BLU("s2ss"), BLU(VERSION));
debug(1, "Running with debug level: %u", V);
/* Check priviledges */
if (getuid() != 0)
error("The server requires superuser privileges!");
/* Setup signals */
struct sigaction sa_quit = {
.sa_flags = SA_SIGINFO,
.sa_sigaction = quit
};
sigemptyset(&sa_quit.sa_mask);
sigaction(SIGTERM, &sa_quit, NULL);
sigaction(SIGINT, &sa_quit, NULL);
atexit(&quit);
/* Parse configuration file */
config_init(&config);
config_parse(argv[1], &config, &settings, &nodes, &paths, &interfaces);
if (!paths)
error("No paths found. Terminating...");
/* Check for realtime kernel patch */
struct stat st;
if (stat("/sys/kernel/realtime", &st))

View file

@ -19,7 +19,9 @@ int tc_reset(struct interface *i)
char cmd[128];
snprintf(cmd, sizeof(cmd), "tc qdisc del dev %s root", i->name);
debug(6, "system: %s", cmd);
debug(6, "Reset traffic control for interface '%s'", i->name);
debug(8, "System: %s", cmd);
return system(cmd);
}
@ -36,7 +38,9 @@ int tc_prio(struct interface *i, tc_hdl_t handle, int bands)
for (int i = 0; i < 16; i++)
len += snprintf(cmd+len, sizeof(cmd)-len, " %u", priomap[i] + bands);
debug(6, "system: %s", cmd);
debug(6, "Replace master qdisc for interface '%s'", i->name);
debug(8, "System: %s", cmd);
return system(cmd);
}
@ -64,7 +68,9 @@ int tc_netem(struct interface *i, tc_hdl_t parent, struct netem *em)
if (em->valid & TC_NETEM_CORRUPT)
len += snprintf(cmd+len, sizeof(cmd)-len, " corrupt %u", em->corrupt);
debug(6, "system: %s", cmd);
debug(6, "Setup netem qdisc for interface '%s'", i->name);
debug(8, "System: %s", cmd);
return system(cmd);
}
@ -75,7 +81,9 @@ int tc_mark(struct interface *i, tc_hdl_t flowid, int mark)
"tc filter add dev %s protocol ip handle %u fw flowid %u:%u",
i->name, mark, TC_HDL_MAJ(flowid), TC_HDL_MIN(flowid));
debug(6, "system: %s", cmd);
debug(7, "Add traffic filter to interface '%s': fwmark %u => flowid %u", i->name, mark, flowid);
debug(8, "System: %s", cmd);
return system(cmd);
}