Fix overwriting layer2 data from same source/priority
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 22 Feb 2017 10:13:10 +0000 (11:13 +0100)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 22 Feb 2017 10:13:10 +0000 (11:13 +0100)
src-plugins/subsystems/oonf_layer2.c
src-plugins/subsystems/oonf_layer2.h

index 8ce0c6e..4491b3c 100644 (file)
@@ -208,6 +208,10 @@ struct oonf_layer2_net *
 oonf_layer2_net_add(const char *ifname) {
   struct oonf_layer2_net *l2net;
 
+  if (!ifname) {
+    return NULL;
+  }
+
   l2net = avl_find_element(&_oonf_layer2_net_tree, ifname, l2net, _node);
   if (l2net) {
     return l2net;
index 8f30ede..ff85d6a 100644 (file)
@@ -440,7 +440,9 @@ oonf_layer2_set_origin(struct oonf_layer2_data *l2data,
 static INLINE int
 oonf_layer2_set_value(struct oonf_layer2_data *l2data,
     const struct oonf_layer2_origin *origin, int64_t value) {
-  if (l2data->_origin && l2data->_origin->priority >= origin->priority) {
+  if (l2data->_origin
+      && l2data->_origin != origin
+      && l2data->_origin->priority >= origin->priority) {
     /* only overwrite lower priority data */
     return -1;
   }