Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | quagga: Avoid duplicate connected address adding to the list |
| 2 | |
| 3 | commit 27ba970b9("quagga/ripd: Fix two bugs after received SIGHUP signal") |
| 4 | introduces an regression: ifp->connected list is cleaned up when ripd is |
| 5 | restarting, however, for interface addresses which are not specified in |
| 6 | ripd configuration file, they are never to be added into ifp->connected |
| 7 | again, this will lead to some abnormal behavior for route advertising. |
| 8 | |
| 9 | Instead of cleaning up the ifp->connected list to avoid duplicated |
| 10 | connected address being added into this list, we can check this |
| 11 | condition during interface address adding process and return early |
| 12 | when an identical address has already been added. |
| 13 | |
| 14 | Upstream-Status: Pending |
| 15 | |
| 16 | Signed-off-by: Hu Yadi <Yadi.hu@windriver.com> |
| 17 | Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com> |
| 18 | Signed-off-by: Joe MacDonald <joe@deserted.net> |
| 19 | --- |
| 20 | --- a/lib/if.c |
| 21 | +++ b/lib/if.c |
| 22 | @@ -738,6 +738,16 @@ connected_add_by_prefix (struct interfac |
| 23 | struct prefix *destination) |
| 24 | { |
| 25 | struct connected *ifc; |
| 26 | + struct listnode *cnode; |
| 27 | + struct connected *c; |
| 28 | + int ret = 0; |
| 29 | + |
| 30 | + for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c)) |
| 31 | + { |
| 32 | + ret = connected_same_prefix (p, (c->address)); |
| 33 | + if(ret == 1) |
| 34 | + return NULL; |
| 35 | + } |
| 36 | |
| 37 | /* Allocate new connected address. */ |
| 38 | ifc = connected_new (); |
| 39 | --- a/ripd/rip_interface.c |
| 40 | +++ b/ripd/rip_interface.c |
| 41 | @@ -516,13 +516,6 @@ rip_interface_clean (void) |
| 42 | thread_cancel (ri->t_wakeup); |
| 43 | ri->t_wakeup = NULL; |
| 44 | } |
| 45 | - |
| 46 | - for (conn_node = listhead (ifp->connected); conn_node; conn_node = next) |
| 47 | - { |
| 48 | - ifc = listgetdata (conn_node); |
| 49 | - next = conn_node->next; |
| 50 | - listnode_delete (ifp->connected, ifc); |
| 51 | - } |
| 52 | } |
| 53 | } |
| 54 | |