Fix "domain 0" cases in MPR plugin
authorHenning Rogge <hrogge@gmail.com>
Sun, 7 May 2017 18:24:43 +0000 (20:24 +0200)
committerHenning Rogge <hrogge@gmail.com>
Sun, 7 May 2017 18:24:43 +0000 (20:24 +0200)
src-plugins/nhdp/mpr/mpr.c
src-plugins/nhdp/mpr/neighbor-graph-routing.c
src-plugins/nhdp/mpr/neighbor-graph.c
src-plugins/nhdp/mpr/neighbor-graph.h

index d09dfbe..2d6e283 100644 (file)
@@ -141,17 +141,19 @@ _cleanup(void) {
  * @param graph MPR neighbor graph instance
  */
 static void
-_update_nhdp_routing(struct neighbor_graph *graph) {
-  struct nhdp_link *lnk;
+_update_nhdp_routing(struct nhdp_domain *domain, struct neighbor_graph *graph) {
   struct n1_node *current_mpr_node;
+  struct nhdp_link *lnk;
+  struct nhdp_neighbor_domaindata *neighbordata;
   
   list_for_each_element(nhdp_db_get_link_list(), lnk, _global_node) {
-    lnk->neigh->_domaindata[0].neigh_is_mpr = false;
+    neighbordata = nhdp_domain_get_neighbordata(domain, lnk->neigh);
+    neighbordata->neigh_is_mpr = false;
     current_mpr_node = avl_find_element(&graph->set_mpr,
         &lnk->neigh->originator,
         current_mpr_node, _avl_node);
     if (current_mpr_node != NULL) {
-      lnk->neigh->_domaindata[0].neigh_is_mpr = true;
+      neighbordata->neigh_is_mpr = true;
     }
   }
 }
@@ -205,7 +207,7 @@ _cb_update_flooding_mpr(struct nhdp_domain *domain) {
     
     mpr_calculate_neighbor_graph_flooding(domain, &flooding_data);
     mpr_calculate_mpr_rfc7181(domain, &flooding_data.neigh_graph);
-    mpr_print_sets(&flooding_data.neigh_graph);
+    mpr_print_sets(domain, &flooding_data.neigh_graph);
 #ifndef NDEBUG
     _validate_mpr_set(domain, &flooding_data.neigh_graph);
 #endif
@@ -231,11 +233,11 @@ _cb_update_routing_mpr(struct nhdp_domain *domain) {
   memset(&routing_graph, 0, sizeof(routing_graph));
   mpr_calculate_neighbor_graph_routing(domain, &routing_graph);
   mpr_calculate_mpr_rfc7181(domain, &routing_graph);
-  mpr_print_sets(&routing_graph);
+  mpr_print_sets(domain, &routing_graph);
 #ifndef NDEBUG
   _validate_mpr_set(domain, &routing_graph);
 #endif
-  _update_nhdp_routing(&routing_graph);
+  _update_nhdp_routing(domain, &routing_graph);
   mpr_clear_neighbor_graph(&routing_graph);
 }
 
index 16d6729..e3b41e8 100644 (file)
@@ -93,8 +93,11 @@ static struct neighbor_graph_interface _rt_api_interface = {
  * @return true if reachable, false otherwise
  */
 static bool
-_is_reachable_neighbor_tuple(struct nhdp_neighbor *neigh) {
-  if (neigh->_domaindata[0].metric.in <= RFC7181_METRIC_MAX
+_is_reachable_neighbor_tuple(const struct nhdp_domain *domain, struct nhdp_neighbor *neigh) {
+  struct nhdp_neighbor_domaindata *neighbordata;
+  neighbordata = nhdp_domain_get_neighbordata(domain, neigh);
+
+  if (neighbordata->metric.in <= RFC7181_METRIC_MAX
       && neigh->symmetric > 0) {
     return true;
   }
@@ -108,9 +111,9 @@ _is_reachable_neighbor_tuple(struct nhdp_neighbor *neigh) {
  * @return true if allowed, false otherwise
  */
 static bool
-_is_allowed_neighbor_tuple(const struct nhdp_domain *domain __attribute__((unused)),
+_is_allowed_neighbor_tuple(const struct nhdp_domain *domain,
     struct nhdp_neighbor *neigh) {
-  if (_is_reachable_neighbor_tuple(neigh)) {
+  if (_is_reachable_neighbor_tuple(domain, neigh)) {
     // FIXME Willingness handling appears to be broken; routing willingness is always 0
     //      && neigh->_domaindata[0].willingness > RFC5444_WILLINGNESS_NEVER) {
     return true;
@@ -275,7 +278,7 @@ _calculate_n1(const struct nhdp_domain *domain, struct neighbor_graph *graph) {
     neigh->selection_is_mpr = false;
     if (_is_allowed_neighbor_tuple(domain, neigh)) {
       OONF_DEBUG(LOG_MPR, "Add neighbor %s in: %u", netaddr_to_string(&buf1, &neigh->originator),
-                 neigh->_domaindata[0].metric.in);
+          nhdp_domain_get_neighbordata(domain, neigh)->metric.in);
       mpr_add_n1_node_to_set(&graph->set_n1, neigh, NULL, 0);
     }
   }
index ebdaaad..b02b2b8 100644 (file)
@@ -238,17 +238,22 @@ mpr_print_addr_set(struct avl_tree *set) {
 }
 
 void
-mpr_print_n1_set(struct avl_tree *set) {
+mpr_print_n1_set(struct nhdp_domain *domain, struct avl_tree *set) {
   struct n1_node *current_node;
 #ifdef OONF_LOG_DEBUG_INFO
+  struct nhdp_neighbor_domaindata *neighbordata;
   struct netaddr_str buf1;
 #endif
 
   avl_for_each_element(set, current_node, _avl_node) {
+#ifdef OONF_LOG_DEBUG_INFO
+    neighbordata = nhdp_domain_get_neighbordata(domain, current_node->neigh);
+
     OONF_DEBUG(LOG_MPR, "%s in: %u out: %u",
         netaddr_to_string(&buf1, &current_node->addr),
-               current_node->neigh->_domaindata[0].metric.in,
-               current_node->neigh->_domaindata[0].metric.out);
+               neighbordata->metric.in,
+               neighbordata->metric.out);
+#endif
   }
 }
 
@@ -257,18 +262,18 @@ mpr_print_n1_set(struct avl_tree *set) {
  * @param graph neighbor graph instance
  */
 void
-mpr_print_sets(struct neighbor_graph *graph) {
+mpr_print_sets(struct nhdp_domain *domain, struct neighbor_graph *graph) {
   OONF_DEBUG(LOG_MPR, "Set N");
   mpr_print_addr_set(&graph->set_n);
 
   OONF_DEBUG(LOG_MPR, "Set N1");
-  mpr_print_n1_set(&graph->set_n1);
+  mpr_print_n1_set(domain, &graph->set_n1);
 
   OONF_DEBUG(LOG_MPR, "Set N2");
   mpr_print_addr_set(&graph->set_n2);
 
   OONF_DEBUG(LOG_MPR, "Set MPR");
-  mpr_print_n1_set(&graph->set_mpr);
+  mpr_print_n1_set(domain, &graph->set_mpr);
 }
 
 /**
index 21933c7..24686d5 100644 (file)
@@ -117,9 +117,9 @@ uint32_t mpr_calculate_minimal_d_z_y(const struct nhdp_domain *,
 
 void mpr_print_addr_set(struct avl_tree *set);
 
-void mpr_print_n1_set(struct avl_tree *set);
+void mpr_print_n1_set(struct nhdp_domain *domain, struct avl_tree *set);
 
-void mpr_print_sets(struct neighbor_graph *graph);
+void mpr_print_sets(struct nhdp_domain *, struct neighbor_graph *graph);
 
 uint32_t mpr_calculate_d_of_y_s(const struct nhdp_domain *domain, struct neighbor_graph *graph, struct addr_node *y, struct avl_tree *subset_s);