From e282ed443fdc632e5849ae1739a759c3b41d2bd0 Mon Sep 17 00:00:00 2001 From: thorkill Date: Tue, 14 Jul 2015 12:11:37 +0200 Subject: [PATCH] Define proper multicast subnets --- src/net_setup.c | 22 +++++++++++++++++++++- src/subnet.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/net_setup.c b/src/net_setup.c index 8b50e4eb..5afad112 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -341,6 +341,7 @@ void update_edge_weight(void) { c->edge->weight, c->edge->avg_rtt*10); + /* avg_rtt is in ms */ if (edge_update_weigth(c->edge, c->edge->avg_rtt*10)) send_add_edge(c, c->edge); } @@ -601,13 +602,25 @@ bool setup_myself_reloadable(void) { free(bmode); } - const char* const DEFAULT_BROADCAST_SUBNETS[] = { "ff:ff:ff:ff:ff:ff", "255.255.255.255", "224.0.0.0/4", "ff00::/8" }; + const char* const DEFAULT_BROADCAST_SUBNETS[] = { "ff:ff:ff:ff:ff:ff", "255.255.255.255"}; + for (size_t i = 0; i < sizeof(DEFAULT_BROADCAST_SUBNETS) / sizeof(*DEFAULT_BROADCAST_SUBNETS); i++) { subnet_t *s = new_subnet(); if (!str2net(s, DEFAULT_BROADCAST_SUBNETS[i])) abort(); subnet_add(NULL, s); } + + const char* const DEFAULT_MULTICAST_SUBNETS[] = { "224.0.0.0/4", "ff00::/8"}; + + for (size_t i = 0; i < sizeof(DEFAULT_MULTICAST_SUBNETS) / sizeof(*DEFAULT_MULTICAST_SUBNETS); i++) { + subnet_t *s = new_subnet(); + if (!str2net(s, DEFAULT_MULTICAST_SUBNETS[i])) + abort(); + s->multicast = true; + subnet_add(NULL, s); + } + for (config_t* cfg = lookup_config(config_tree, "BroadcastSubnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { subnet_t *s; if (!get_config_subnet(cfg, &s)) @@ -615,6 +628,13 @@ bool setup_myself_reloadable(void) { subnet_add(NULL, s); } + for (config_t* cfg = lookup_config(config_tree, "MulticastSubnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { + subnet_t *s; + if (!get_config_subnet(cfg, &s)) + continue; + subnet_add(NULL, s); + } + #if !defined(SOL_IP) || !defined(IP_TOS) if(priorityinheritance) logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "PriorityInheritance"); diff --git a/src/subnet.h b/src/subnet.h index 2932cea0..ff5ba36f 100644 --- a/src/subnet.h +++ b/src/subnet.h @@ -52,6 +52,7 @@ typedef struct subnet_t { subnet_type_t type; /* subnet type (IPv4? IPv6? MAC? something even weirder?) */ time_t expires; /* expiry time */ + bool multicast; /* true if this subnet is a multicast local-link only */ int weight; /* weight (higher value is higher priority) */ /* And now for the actual subnet: */