* we start to make the peer's value approach decayto, getting
* half of the way there each time. */
if (remote->awol >= REMOTE_AWOL_THRESHOLD) {
+ printlog(LOG_WARN, "AWOL remote limiter detected.\n");
remote->rate += ((decayto - remote->rate) / 2);
} else {
remote->awol++;
static int underlimit_flowcount_count = 0;
static int underlimit_normal_count = 0;
+extern uint8_t system_loglevel;
/**
* Called for each identity each estimate interval. Uses flow table information
printlog(LOG_DEBUG, "%.3f %.3f IdealUnd IdealOve\n",ideal_under,ideal_over);
- printf("local_rate: %d, idealweight: %.3f, localweight: %.3f, total_weight: %.3f\n",
+ if (system_loglevel == LOG_DEBUG) {
+ printf("local_rate: %d, idealweight: %.3f, localweight: %.3f, total_weight: %.3f\n",
local_rate, idealweight, ident->localweight, total_weight);
+ }
//printf("Dampen: %d, dampen_increase: %d, peer_weights: %.3f, regime: %d\n",
// dampen, dampen_increase, peer_weights, regime);
dropprob = 0.0;
}
- printf("local rate: %d, aggregate demand: %.3f, drop prob: %.3f\n",
+ if (system_loglevel == LOG_DEBUG) {
+ printf("local rate: %d, aggregate demand: %.3f, drop prob: %.3f\n",
ident->common.rate, aggdemand, dropprob);
+ }
return dropprob;
}
ident->locallimit = limiter->nodelimit;
}
- printf("FPS: Setting local limit to %d\n", ident->locallimit);
+ if (system_loglevel == LOG_DEBUG) {
+ printf("FPS: Setting local limit to %d\n", ident->locallimit);
+ }
printlog(LOG_DEBUG, "%d Limit ID:%d\n", ident->locallimit, ident->id);
snprintf(cmd, CMD_BUFFER_SIZE,
toaddr.sin_addr.s_addr = remote->addr; /* Already in network byte order. */
toaddr.sin_port = remote->port;
if (sendto(sock, &msg, sizeof(msg), 0, (struct sockaddr *) &toaddr, sizeof(struct sockaddr_in)) < 0) {
- printlog(LOG_CRITICAL, "ERR: limiter_send_mesh: sento failed.\n");
+ printlog(LOG_WARN, "WARN: limiter_send_mesh: sento failed.\n");
result = errno;
- printlog(LOG_CRITICAL, " - The error was |%d|\n", strerror(result));
+ printlog(LOG_WARN, " - The error was |%d|\n", strerror(result));
break;
}
}
message_to_nbo(&msg);
if (sendto(sock, &msg, sizeof(msg), 0, (struct sockaddr *) &toaddr, sizeof(struct sockaddr_in)) < 0) {
- printlog(LOG_CRITICAL, "ERR: limiter_send_gossip: sento failed.\n");
+ printlog(LOG_WARN, "WARN: limiter_send_gossip: sento failed.\n");
result = errno;
break;
}
#include "common_accounting.h"
#include "samplehold.h"
+#include "logging.h"
static int match(const key_flow *key, const sampled_flow *flow) {
if (flow->state != FLOW_USED)
if (lookup == NULL) {
/* Table is full!?! */
- printf("Full table!\n");
+ printlog(LOG_WARN, "samplehold.c: Table full!\n");
return 0;
}
if (flow == NULL) {
flow = malloc(sizeof(standard_flow));
if (flow == NULL) {
- printf("Malloc returned null.\n");
- printlog(LOG_CRITICAL, "ALLOC: Malloc returned NULL.\n");
+ printlog(LOG_CRITICAL, "standard.c: Malloc returned NULL.\n");
return NULL;
}
table->common->bytes_since = 0;
table->common->last_update = now;
- //printf("Flows: ");
-
/* Update per-flow information. */
for (current = table->flows_head; current; current = current->next) {
time_delta = timeval_subtract(now, current->last_update);
maxflowrate = current->rate;
}
- //printf("%d, ", current->rate);
-
src.s_addr = ntohl(current->source_ip);
dst.s_addr = ntohl(current->dest_ip);
strcpy(sip, inet_ntoa(src));
current->rate);
}
- //printf("\n");
printlog(LOG_DEBUG, "FLOW:--\n--\n");
table->common->max_flow_rate = maxflowrate;
leaf_t *leaf = NULL;
identity_t *ident = NULL;
- map_reset_iterate(instance->leaf_map);
- while ((leaf = (leaf_t *) map_next(instance->leaf_map))) {
- printf("%x:", leaf->xid);
- ident = leaf->parent;
- while (ident) {
- printf("%d:",ident->id);
- ident = ident->parent;
+ if (system_loglevel == LOG_DEBUG) {
+ map_reset_iterate(instance->leaf_map);
+ while ((leaf = (leaf_t *) map_next(instance->leaf_map))) {
+ printf("%x:", leaf->xid);
+ ident = leaf->parent;
+ while (ident) {
+ printf("%d:",ident->id);
+ ident = ident->parent;
+ }
+ printf("Leaf's parent pointer is %p\n", leaf->parent);
}
- printf("Leaf's parent pointer is %p\n", leaf->parent);
- }
- printf("instance->last_machine is %p\n", instance->last_machine);
+ printf("instance->last_machine is %p\n", instance->last_machine);
+ }
}
static int assign_htb_hierarchy(drl_instance_t *instance) {
} else {
/* Pointerific! */
instance->machines[i]->htb_parent =
- instance->machines[i]->parent->htb_node;
+ instance->machines[i]->parent->htb_node;
}
instance->machines[i]->htb_node = next_node;
instance->leaves[i].xid, instance->leaves[i].xid);
if (execute_cmd(cmd)) {
- //FIXME: remove this print and do a log.
- printf("GRD: pfifo qdisc wasn't there!\n");
+ printlog(LOG_DEBUG, "GRD: pfifo qdisc wasn't there!\n");
}
/* Add the netem qdisc. */
sprintf(cmd, "/sbin/tc qdisc del dev eth0 parent 1:1000 handle 1000 pfifo");
if (execute_cmd(cmd)) {
- //FIXME: remove this print and do a log.
- printf("GRD: pfifo qdisc wasn't there!\n");
+ printlog(LOG_DEBUG, "GRD: pfifo qdisc wasn't there!\n");
}
/* Add the netem qdisc. */
sprintf(cmd, "/sbin/tc qdisc del dev eth0 parent 1:1fff handle 1fff pfifo");
if (execute_cmd(cmd)) {
- //FIXME: remove this print and do a log.
- printf("GRD: pfifo qdisc wasn't there!\n");
+ printlog(LOG_DEBUG, "GRD: pfifo qdisc wasn't there!\n");
}
/* Add the netem qdisc. */
* see estimate.c
*/
if (pthread_create(&estimate_thread, NULL, (void*(*)(void*)) &handle_estimation, &limiter)!=0) {
- ulogd_log(ULOGD_ERROR, "couldn't start estimate thread for 0x%x %s\n",limiter.localaddr,
- limiter.ip);
+ printlog(LOG_CRITICAL, "Couldn't start estimate thread.\n");
fprintf(stderr, "An error has occured starting ulogd_DRL. Refer to your logfile (%s) for additional information.\n", drl_logfile.u.string);
exit(EXIT_FAILURE);
}
return c;
}
-
-/* print out some error information if a system call failes */
-void print_system_error(int ret){
- if (WIFSIGNALED(ret) &&
- (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT)){
- /* received some kind of signal during program execution */
- printf("enforce received signal during program execution.");
- } else {
- perror("enforce failed (ret==-1):");
- }
-}
void map_insert(map_handle map, void *key, int keylen, void *value);
int map_size(map_handle map);
-/* sundry items */
-void print_system_error(int ret);
-
-
#endif