[Olsr-cvs] olsrd-current/src lq_avl.c, 1.2, 1.3 lq_avl.h, 1.3, 1.4 lq_list.c, 1.4, 1.5 lq_list.h, 1.4, 1.5 lq_packet.c, 1.22, 1.23 lq_route.c, 1.43, 1.44 net_olsr.c, 1.17, 1.18

Bernd Petrovitsch (spam-protected)
Sat Feb 10 18:36:53 CET 2007


Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28744/src

Modified Files:
	lq_avl.c lq_avl.h lq_list.c lq_list.h lq_packet.c lq_route.c 
	net_olsr.c 
Log Message:
applied fixes from Sven-Ola:
- he corrected a copy-paste error made by me. Thanks.
- he killed the parts disabled by DISABLE_SVEN_OLA 


Index: lq_route.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_route.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** lq_route.c	31 Jan 2007 12:36:50 -0000	1.43
--- lq_route.c	10 Feb 2007 17:36:51 -0000	1.44
***************
*** 2,5 ****
--- 2,6 ----
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
   * Copyright (c) 2004, Thomas Lopatic ((spam-protected))
+  * IPv4 performance optimization (c) 2006, sven-ola(gmx.de)
   * All rights reserved.
   *
***************
*** 78,94 ****
  }
  
- #ifdef DISABLE_SVEN_OLA
- static int avl_comp_ipv4(void *ip1, void *ip2)
- {
-   if (*(unsigned int *)ip1 < *(unsigned int *)ip2)
-     return -1;
- 
-   if (*(unsigned int *)ip1 == *(unsigned int *)ip2)
-     return 0;
- 
-   return 1;
- }
- #endif
- 
  static int (*avl_comp)(void *, void *);
  
--- 79,82 ----
***************
*** 207,213 ****
  
    // add the vertex to the list, if it's not us
- #ifndef DISABLE_SVEN_OLA
    if (NULL == comp) {
!     if (svenola_avl_comp_ipv4(&olsr_cnf->main_addr, node->key) != 0)
      {
        vert->node.data = vert;
--- 195,200 ----
  
    // add the vertex to the list, if it's not us
    if (NULL == comp) {
!     if (inline_avl_comp_ipv4(&olsr_cnf->main_addr, node->key) != 0)
      {
        vert->node.data = vert;
***************
*** 215,224 ****
      }
    }
!   else
! #endif
!   if ((*comp)(&olsr_cnf->main_addr, node->key) != 0)
!   {
!     vert->node.data = vert;
!     list_add_tail(vertex_list, &vert->node);
    }
  
--- 202,211 ----
      }
    }
!   else {
!     if ((*comp)(&olsr_cnf->main_addr, node->key) != 0)
!     {
!       vert->node.data = vert;
!       list_add_tail(vertex_list, &vert->node);
!     }
    }
  
***************
*** 278,283 ****
  
  // XXX - bad complexity
! #define SVEN_OPT
! #undef SVEN_OPT_DBG
  
  /*
--- 265,269 ----
  
  // XXX - bad complexity
! #define SVEN_OLA_OPTIMIZE
  
  /*
***************
*** 288,300 ****
   * more sufficient to have them sorted/popped from a list rather than 
   * searching the complete list by every call. (spam-protected), 11/2006
   */
   
! #ifdef SVEN_OPT
  static struct dijk_vertex **etx_cache = 0;
  static int etx_cache_count;
  static int etx_cache_get;
- #ifdef SVEN_OPT_DBG
- static int etx_cache_saved = 0;
- #endif
  
  static int etx_cache_compare(const void *a, const void *b)
--- 274,287 ----
   * more sufficient to have them sorted/popped from a list rather than 
   * searching the complete list by every call. (spam-protected), 11/2006
+  * 
+  * The SVEN_OLA_OPTIMIZE changes work in our berlin environment. However,
+  * they may introduce bugs, e.g. they are untested for IPv6. For this 
+  * reason, the source still contains the ifdef SVEN_OLA_OPIMIZE.
   */
   
! #ifdef SVEN_OLA_OPTIMIZE
  static struct dijk_vertex **etx_cache = 0;
  static int etx_cache_count;
  static int etx_cache_get;
  
  static int etx_cache_compare(const void *a, const void *b)
***************
*** 315,351 ****
  static struct dijk_vertex *extract_best_route(struct list *vertex_list)
  {
- #ifdef SVEN_OPT_DBG
-   float best_etx = INFINITE_ETX + 1.0;
- #endif
    struct list_node *node;
    struct dijk_vertex *vert;
    struct dijk_vertex *res = NULL;
  
- #ifdef SVEN_OPT_DBG
-   node = list_get_head(vertex_list);
- 
-   // loop through all vertices
-   
-   while (node != NULL)
-   {
-     vert = node->data;
- 
-     // see whether the current vertex is better than what we have
- 
-     if (!vert->done && vert->path_etx < best_etx)
-     {
-       best_etx = vert->path_etx;
-       res = vert;
-     }
-     else if (!vert->done && vert->path_etx == best_etx && vert < res)
-     {
-       // Otherwise order is undefined if etx==etx and debug will complain
-       best_etx = vert->path_etx;
-       res = vert;
-     }
- 
-     node = list_get_next(node);
-   }
- #endif
    if (NULL == etx_cache)
    {
--- 302,309 ----
***************
*** 361,367 ****
      {
        etx_cache = olsr_malloc(sizeof(etx_cache[0]) * count, "ETX Cache");
- #ifdef SVEN_OPT_DBG
-       printf("count=%d, Malloc(%d)=%p\n", count, sizeof(etx_cache[0]) * count, etx_cache);
- #endif
        node = list_get_head(vertex_list);
        etx_cache_count = 0;
--- 319,322 ----
***************
*** 377,422 ****
          node = list_get_next(node);
        }
- #ifdef SVEN_OPT_DBG
-       printf("qsort(etx_cache_count=%d)\n", etx_cache_count);
- #endif
        qsort(etx_cache, etx_cache_count, sizeof(etx_cache[0]), etx_cache_compare);
- #ifdef SVEN_OPT_DBG
-       if (0 < etx_cache_count)
-       {
-         int i = 0; 
-         while(i < etx_cache_count && i < 10)
-         {
-           printf("%d: %p=%f\n", i, etx_cache[i], etx_cache[i]->path_etx);
-           i++;
-         }
-       }
- #endif
      }
    }
  
- #ifdef SVEN_OPT_DBG
-   if (NULL != etx_cache)
-   {
-     struct dijk_vertex *rescache = NULL;
-     if (etx_cache_get < etx_cache_count)
-     {
-       rescache = etx_cache[etx_cache_get++];
-     }
-     if (res != rescache)
-     {
-       printf("miss: etx_cache_get=%d, res=%p,%f != rescache=%p,%f\n",
-         etx_cache_get, res, (NULL != res ? res->path_etx : -1), rescache, (NULL != rescache ? rescache->path_etx : -1));
-     }
-     else
-     {
-       etx_cache_saved++;
-     }
-   }
- #else
    if (NULL != etx_cache && etx_cache_get < etx_cache_count)
    {
      res = etx_cache[etx_cache_get++];
    }
- #endif
  
    // if we've found a vertex, remove it from the set
--- 332,343 ----
***************
*** 427,431 ****
    return res;
  }
! #endif // SVEN_OPT
  
  static struct dijk_vertex *extract_best(struct list *vertex_list)
--- 348,352 ----
    return res;
  }
! #endif // SVEN_OLA_OPTIMIZE
  
  static struct dijk_vertex *extract_best(struct list *vertex_list)
***************
*** 533,541 ****
  
    if (olsr_cnf->ipsize == 4)
- #ifndef DISABLE_SVEN_OLA
      avl_comp = 0;
- #else
-     avl_comp = avl_comp_ipv4;
- #endif
    else
      avl_comp = avl_comp_ipv6;
--- 454,458 ----
***************
*** 779,787 ****
    // add HNA routes - the set of unprocessed network nodes contains
    // all reachable network nodes
! #ifdef SVEN_OPT
! #ifdef SVEN_OPT_DBG
!   printf("free etx_cache, saved compares=%d, etx_cache=%p\n", etx_cache_saved, etx_cache);
!   etx_cache_saved = 0;
! #endif
    if (NULL != etx_cache) {
      free(etx_cache);
--- 696,700 ----
    // add HNA routes - the set of unprocessed network nodes contains
    // all reachable network nodes
! #ifdef SVEN_OLA_OPTIMIZE
    if (NULL != etx_cache) {
      free(etx_cache);
***************
*** 795,799 ****
      // from the set of unprocessed network nodes
  
! #ifdef SVEN_OPT
      vert = extract_best_route(&vertex_list);
  #else
--- 708,712 ----
      // from the set of unprocessed network nodes
  
! #ifdef SVEN_OLA_OPTIMIZE
      vert = extract_best_route(&vertex_list);
  #else

Index: lq_list.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_list.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** lq_list.h	31 Jan 2007 12:36:50 -0000	1.4
--- lq_list.h	10 Feb 2007 17:36:51 -0000	1.5
***************
*** 2,5 ****
--- 2,6 ----
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
   * Copyright (c) 2004, Thomas Lopatic ((spam-protected))
+  * IPv4 performance optimization (c) 2006, sven-ola(gmx.de)
   * All rights reserved.
   *
***************
*** 59,74 ****
  void list_init(struct list *list);
  
! #ifndef DISABLE_SVEN_OLA
! #define list_get_head(node) (node)->head
! #define list_get_tail(node) (node)->tail
! #define list_get_next(node) (node)->next
! #define list_get_prev(node) (node)->prev
! #else
! struct list_node *list_get_head(struct list *list);
! struct list_node *list_get_tail(struct list *list);
! 
! struct list_node *list_get_next(struct list_node *node);
! struct list_node *list_get_prev(struct list_node *node);
! #endif
  
  void list_add_head(struct list *list, struct list_node *node);
--- 60,67 ----
  void list_init(struct list *list);
  
! #define list_get_head(node) ((node)->head)
! #define list_get_tail(node) ((node)->tail)
! #define list_get_next(node) ((node)->next)
! #define list_get_prev(node) ((node)->prev)
  
  void list_add_head(struct list *list, struct list_node *node);

Index: lq_avl.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lq_avl.h	31 Jan 2007 12:36:50 -0000	1.3
--- lq_avl.h	10 Feb 2007 17:36:51 -0000	1.4
***************
*** 2,5 ****
--- 2,6 ----
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
   * Copyright (c) 2004, Thomas Lopatic ((spam-protected))
+  * IPv4 performance optimization (c) 2006, sven-ola(gmx.de)
   * All rights reserved.
   *
***************
*** 63,70 ****
  int avl_insert(struct avl_tree *, struct avl_node *);
  
! #ifndef DISABLE_SVEN_OLA
! #define svenola_avl_comp_ipv4(ip1, ip2) \
    (*(unsigned int *)ip1 == *(unsigned int *)ip2 ? 0 : \
    *(unsigned int *)ip1 < *(unsigned int *)ip2 ? -1 : +1)
! #endif
  #endif
--- 64,70 ----
  int avl_insert(struct avl_tree *, struct avl_node *);
  
! #define inline_avl_comp_ipv4(ip1, ip2) \
    (*(unsigned int *)ip1 == *(unsigned int *)ip2 ? 0 : \
    *(unsigned int *)ip1 < *(unsigned int *)ip2 ? -1 : +1)
! 
  #endif

Index: lq_list.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_list.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** lq_list.c	31 Jan 2007 12:36:50 -0000	1.4
--- lq_list.c	10 Feb 2007 17:36:51 -0000	1.5
***************
*** 2,5 ****
--- 2,6 ----
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
   * Copyright (c) 2004, Thomas Lopatic ((spam-protected))
+  * IPv4 performance optimization (c) 2006, sven-ola(gmx.de)
   * All rights reserved.
   *
***************
*** 49,74 ****
  }
  
- #ifdef DISABLE_SVEN_OLA
- struct list_node *list_get_head(struct list *list)
- {
-   return list->head;
- }
- 
- struct list_node *list_get_tail(struct list *list)
- {
-   return list->tail;
- }
- 
- struct list_node *list_get_next(struct list_node *node)
- {
-   return node->next;
- }
- 
- struct list_node *list_get_prev(struct list_node *node)
- {
-   return node->prev;
- }
- #endif
- 
  void list_add_head(struct list *list, struct list_node *node)
  {
--- 50,53 ----

Index: lq_packet.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_packet.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** lq_packet.c	31 Jan 2007 12:36:50 -0000	1.22
--- lq_packet.c	10 Feb 2007 17:36:51 -0000	1.23
***************
*** 3,6 ****
--- 3,7 ----
   * Copyright (c) 2003, Andreas Tønnesen ((spam-protected))
   *               2004, Thomas Lopatic ((spam-protected))
+  *               2006, for some fixups, sven-ola(gmx.de)
   * All rights reserved.
   *
***************
*** 168,172 ****
    if (olsr_cnf->lq_fish > 0)
    {
!     // SVEN_OLA: Too lazy to find the different iface inits. This will do it too.
      if (outif->ttl_index >= (int)(sizeof(ttl_list) / sizeof(ttl_list[0])))
        outif->ttl_index = 0;
--- 169,173 ----
    if (olsr_cnf->lq_fish > 0)
    {
!     // Sven-Ola: Too lazy to find the different iface inits. This will do it too.
      if (outif->ttl_index >= (int)(sizeof(ttl_list) / sizeof(ttl_list[0])))
        outif->ttl_index = 0;
***************
*** 801,805 ****
    struct hello_neighbor *new_neigh;
  
!   // SVEN_OLA: Check the message source addr
    if(!olsr_validate_address(&lq_hello->comm.orig))
      {
--- 802,806 ----
    struct hello_neighbor *new_neigh;
  
!   // Sven-Ola: Check the message source addr
    if(!olsr_validate_address(&lq_hello->comm.orig))
      {
***************
*** 827,831 ****
    for (neigh = lq_hello->neigh; neigh != NULL; neigh = neigh->next)
      {
!       // SVEN_OLA: Also check the neighbours
        if(!olsr_validate_address(&neigh->addr)) continue;
        
--- 828,832 ----
    for (neigh = lq_hello->neigh; neigh != NULL; neigh = neigh->next)
      {
!       // Sven-Ola: Also check the neighbours
        if(!olsr_validate_address(&neigh->addr)) continue;
        
***************
*** 861,865 ****
    struct tc_mpr_addr *new_neigh;
  
!   // SVEN_OLA: Check the message source addr
    if(!olsr_validate_address(&lq_tc->from)||!olsr_validate_address(&lq_tc->comm.orig))
      {
--- 862,866 ----
    struct tc_mpr_addr *new_neigh;
  
!   // Sven-Ola: Check the message source addr
    if(!olsr_validate_address(&lq_tc->from)||!olsr_validate_address(&lq_tc->comm.orig))
      {
***************
*** 887,891 ****
    for (neigh = lq_tc->neigh; neigh != NULL; neigh = neigh->next)
      {
!       // SVEN_OLA: Also check the neighbours
        if(!olsr_validate_address(&neigh->main)) continue;
        
--- 888,892 ----
    for (neigh = lq_tc->neigh; neigh != NULL; neigh = neigh->next)
      {
!       // Sven-Ola: Also check the neighbours
        if(!olsr_validate_address(&neigh->main)) continue;
        

Index: net_olsr.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** net_olsr.c	15 Nov 2006 23:07:59 -0000	1.17
--- net_olsr.c	10 Feb 2007 17:36:51 -0000	1.18
***************
*** 90,94 ****
    {
      "0.0.0.0",
-     //SVEN_OLA: This address is not plausible too
      "127.0.0.1",
      NULL
--- 90,93 ----

Index: lq_avl.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** lq_avl.c	31 Jan 2007 12:36:50 -0000	1.2
--- lq_avl.c	10 Feb 2007 17:36:51 -0000	1.3
***************
*** 2,5 ****
--- 2,6 ----
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
   * Copyright (c) 2004, Thomas Lopatic ((spam-protected))
+  * IPv4 performance optimization (c) 2006, sven-ola(gmx.de)
   * All rights reserved.
   *
***************
*** 41,47 ****
  
  #include <stddef.h>
- #ifndef DISABLE_SVEN_OLA
  #include <time.h>
- #endif
  
  #include "lq_avl.h"
--- 42,46 ----
***************
*** 56,60 ****
  }
  
- #ifndef DISABLE_SVEN_OLA
  static struct avl_node *avl_find_rec_ipv4(struct avl_node *node, void *key)
  {
--- 55,58 ----
***************
*** 71,75 ****
    return node;
  }
- #endif
  
  static struct avl_node *avl_find_rec(struct avl_node *node, void *key,
--- 69,72 ----
***************
*** 78,86 ****
    int diff;
  
- #ifndef DISABLE_SVEN_OLA
    if (0 == comp) {
      return avl_find_rec_ipv4(node, key);
    }
! #endif
    diff = (*comp)(key, node->key);
  
--- 75,82 ----
    int diff;
  
    if (0 == comp) {
      return avl_find_rec_ipv4(node, key);
    }
! 
    diff = (*comp)(key, node->key);
  
***************
*** 113,125 ****
    node = avl_find_rec(tree->root, key, tree->comp);
  
- #ifndef DISABLE_SVEN_OLA
    if (0 == tree->comp) {
!     if (0 != svenola_avl_comp_ipv4(node->key, key))
        return NULL;
    }
-   else
- #endif
-   if ((*tree->comp)(node->key, key) != 0)
-     return NULL;
  
    return node;
--- 109,120 ----
    node = avl_find_rec(tree->root, key, tree->comp);
  
    if (0 == tree->comp) {
!     if (0 != inline_avl_comp_ipv4(node->key, key))
!       return NULL;
!   }
!   else {
!     if ((*tree->comp)(node->key, key) != 0)
        return NULL;
    }
  
    return node;
***************
*** 261,271 ****
    node = avl_find_rec(tree->root, new->key, tree->comp);
  
- #ifndef DISABLE_SVEN_OLA
    if (0 == tree->comp) {
!     diff = svenola_avl_comp_ipv4(new->key, node->key);
    }
-   else
- #endif
-   diff = (*tree->comp)(new->key, node->key);
  
    if (diff == 0)
--- 256,265 ----
    node = avl_find_rec(tree->root, new->key, tree->comp);
  
    if (0 == tree->comp) {
!     diff = inline_avl_comp_ipv4(new->key, node->key);
!   }
!   else {
!     diff = (*tree->comp)(new->key, node->key);
    }
  
    if (diff == 0)





More information about the Olsr-cvs mailing list