<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Yes you are right Erik,<br>
<br>
the previous fix doesn't update the neighbor set. So we end up with a
"ghost" neighbor entry. :(<br>
<br>
Ok, so could we delete (or decrease linkcount if > 1) and recreate
a neighbor entry with the new main address?<br>
<br>
Do you think it will work?<br>
<blockquote cite="midBAY112-DAV12C955839706F30521458FF1F50@phx.gbl"
type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.2800.1498" name="GENERATOR">
<style></style>
<font face="Arial" size="2"></font>
<div><font face="Arial" size="2">Bill,</font></div>
<div><font face="Arial" size="2"><br>
I'm afraid that this fix is not enough.</font></div>
<div><font face="Arial" size="2"> </font></div>
<div><font face="Arial" size="2">Is updating
'neighbor->neighbor_main_addr' safe? It seems that the neighbor
set is hashed through 'neighbor_main_addr'. If 'neighbor_main_addr' is
changed, the neighbor entry must get another position in the hash table.</font></div>
<div><font face="Arial" size="2"> </font></div>
<div><font face="Arial" size="2">Also, a problem arises when a node
is neighbor to another node via two separate network interfaces (i.e.
via 2 links).</font></div>
<div> </div>
<div><font face="Arial" size="2">In that case there will be one
neighbor entry with linkcount 2 (1 for each link).<br>
<br>
When the main IP address of the neighbor node changes, the HELLO
messages from that interface are sent with the new IP address as source
('remote'), and with the new IP address as originator address
('remote_main').</font></div>
<div> </div>
<div><font face="Arial" size="2">Because 'remote' does not match any
existing link, the while(tmp_link_set) loop will not find any existing
link, so a new link entry is made.</font></div>
<div> </div>
<div><font face="Arial" size="2">Also, since ''remote_main' does not
match any existing neighbor entry, a new neighbor entry is made:</font></div>
<div><font face="Arial" size="2"> if(NULL == (neighbor =
olsr_lookup_neighbor_table(remote_main)))<br>
{<br>
</font></div>
<div><font face="Arial" size="2">The linkcount will be 1:</font></div>
<div><font face="Arial" size="2"> neighbor->linkcount++;<br>
</font></div>
<div><font face="Arial" size="2">Next, a HELLO message comes in via
the second network interface, with the new IP address as
originator address ('remote_main'). </font><font face="Arial" size="2">The
fix you propose will correctly update the (old) neighbor entry (the one
with with 'linkcount' 2):</font></div>
<div><font face="Arial" size="2">
COPY_IP(&tmp_link_set->neighbor->neighbor_main_addr, remote_main);</font></div>
<div> </div>
<div><font face="Arial" size="2">After a while, the link with the old
remote IP address will time out. However, the old, but updated neigbor
entry will not be removed, since its 'linkcount' > 1. Its
'linkcount' value will be decreased from 2 to 1.</font></div>
<div> </div>
<div><font face="Arial" size="2">The result: we have two neighbor
entries, each with 'linkcount' 1, and each with the same
'neighbor_main_addr'.</font></div>
<div><font face="Arial" size="2"><br>
Besides this, there is a small bug in the function chk_if_changed
(src/unix/ifnet.c)<br>
<br>
memcpy(&main_addr, <br>
&((struct sockaddr_in
*)&ifp->int_addr)->sin_addr.s_addr, <br>
ipsize);<br>
}</font></div>
<div> </div>
<div><font face="Arial" size="2"> ifp->int_addr = ifr.ifr_addr;<br>
</font></div>
<div><font face="Arial" size="2">The memcpy is copying the existing
IP address in main_addr, not the new IP address. Or: ifr.ifr_addr is
copied into ifp->int_addr too late.</font></div>
<div> </div>
<div><font face="Arial" size="2">Last: the olsr_process_received_mid
function only adds MID aliases, not remove. I have written a function
that removes the MID aliases which are registered but no longer
declared in the received MID message. Here is the code:</font></div>
<div> </div>
<div><font face="Arial" size="2">/**<br>
*Remove aliases from 'entry' which are not listed in
'declared_aliases'.<br>
*<br>
<a href="mailto:*@param">*@param</a> entry the MID entry<br>
<a href="mailto:*@param">*@param</a> declared_aliases the list of
declared aliases for the MID entry<br>
*<br>
<a href="mailto:*@return">*@return</a> nada<br>
*/<br>
void<br>
olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias
*declared_aliases)<br>
{<br>
struct mid_entry *entry;<br>
olsr_u32_t hash;<br>
struct mid_address *registered_aliases;<br>
struct mid_address *previous_alias;<br>
struct mid_alias *save_declared_aliases = declared_aliases;</font></div>
<div> </div>
<div><font face="Arial" size="2"> hash = olsr_hashing(m_addr);</font></div>
<div> </div>
<div><font face="Arial" size="2"> /* Check for registered entry */<br>
for(entry = mid_set[hash].next;<br>
entry != &mid_set[hash];<br>
entry = entry->next)<br>
{<br>
if(COMP_IP(&entry->main_addr, m_addr))</font></div>
<div><font face="Arial" size="2"> break;<br>
}<br>
if(entry == &mid_set[hash])<br>
{<br>
/* MID entry not found, nothing to prune here */<br>
return;<br>
}</font></div>
<div> </div>
<div><font face="Arial" size="2"> registered_aliases =
entry->aliases;<br>
previous_alias = NULL;</font></div>
<div> </div>
<div><font face="Arial" size="2"> while(registered_aliases != 0)<br>
{<br>
struct mid_address *current_alias = registered_aliases;<br>
registered_aliases = registered_aliases->next_alias;</font></div>
<div> </div>
<div><font face="Arial" size="2"> declared_aliases =
save_declared_aliases;</font></div>
<div> </div>
<div><font face="Arial" size="2"> /* Go through the list of
declared aliases to find the matching current alias */<br>
while(declared_aliases != 0 &&<br>
! COMP_IP(¤t_alias->alias,
&declared_aliases->alias_addr))<br>
{<br>
declared_aliases = declared_aliases->next;<br>
}</font></div>
<div> </div>
<div><font face="Arial" size="2"> if (declared_aliases == 0)<br>
{<br>
/* Current alias not found in list of declared aliases: free
current alias */<br>
OLSR_PRINTF(1, "MID remove: (%s, ",
olsr_ip_to_string(&entry->main_addr))<br>
OLSR_PRINTF(1, "%s)\n",
olsr_ip_to_string(¤t_alias->alias))</font></div>
<div> </div>
<div><font face="Arial" size="2"> /* Update linked list as
seen by 'entry' */<br>
if (previous_alias != NULL)<br>
{<br>
previous_alias->next_alias =
current_alias->next_alias;<br>
}<br>
else<br>
{<br>
entry->aliases = current_alias->next_alias;<br>
}</font></div>
<div> </div>
<div><font face="Arial" size="2"> /* Remove from hash table
*/<br>
DEQUEUE_ELEM(current_alias);<br>
<br>
free(current_alias);</font></div>
<div> </div>
<div><font face="Arial" size="2"> /*<br>
*Recalculate topology<br>
*/<br>
changes_neighborhood = OLSR_TRUE;<br>
changes_topology = OLSR_TRUE;<br>
}<br>
else<br>
{<br>
previous_alias = current_alias;<br>
}<br>
}<br>
}</font></div>
<div> </div>
<div><font face="Arial" size="2"><br>
</font> </div>
<div> </div>
<div><font face="Arial" size="2">Regards,</font></div>
<div><font face="Arial" size="2">Erik</font></div>
<div> </div>
<div><br>
<br>
<font face="Arial" size="2">----- Original Message ----- <br>
From: "Acinonyx" <</font><a href="mailto:acinonyxs@yahoo.gr"><font
face="Arial" size="2">acinonyxs@yahoo.gr</font></a><font face="Arial"
size="2">><br>
To: "OLSR development" <</font><a href="mailto:olsr-dev@olsr.org"><font
face="Arial" size="2">olsr-dev@olsr.org</font></a><font face="Arial"
size="2">><br>
Sent: Friday, November 10, 2006 11:16 PM<br>
Subject: Re: [olsr-dev] bug in mdi code<br>
<br>
<br>
> Ok, here is a patch i made. It adds neighbor main address update on<br>
> every link entry update.<br>
><br>
> I tested it and it works.<br>
><br>
> Bill<br>
><br>
> -------------------<br>
> diff -Naur olsrd-0.4.10/src/link_set.c
olsrd-0.4.10-patched/src/link_set.c<br>
> --- olsrd-0.4.10/src/link_set.c 2005-11-17 06:25:44.000000000 +0200<br>
> +++ olsrd-0.4.10-patched/src/link_set.c 2006-11-10
23:45:24.000000000 +0200<br>
> @@ -403,7 +466,10 @@<br>
> {<br>
> if(COMP_IP(remote,
&tmp_link_set->neighbor_iface_addr) &&<br>
> COMP_IP(local, &tmp_link_set->local_iface_addr))<br>
> - return tmp_link_set;<br>
> + {<br>
> +
COPY_IP(&tmp_link_set->neighbor->neighbor_main_addr,<br>
> remote_main);<br>
> + return tmp_link_set;<br>
> + }<br>
> tmp_link_set = tmp_link_set->next;<br>
> }<br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> olsr-dev mailing list<br>
> </font><a href="mailto:olsr-dev@olsr.org"><font face="Arial"
size="2">olsr-dev@olsr.org</font></a><br>
<font face="Arial" size="2">> </font><a
href="https://www.olsr.org/mailman/listinfo/olsr-dev"><font
face="Arial" size="2">https://www.olsr.org/mailman/listinfo/olsr-dev</font></a><br>
<font face="Arial" size="2">><br>
</font></div>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
olsr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:olsr-dev@olsr.org">olsr-dev@olsr.org</a>
<a class="moz-txt-link-freetext" href="https://www.olsr.org/mailman/listinfo/olsr-dev">https://www.olsr.org/mailman/listinfo/olsr-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>