blob: a07e33f9fde71c6de8bb28326eb33666f99a954a [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001quagga: Avoid duplicate connected address adding to the list
2
3commit 27ba970b9("quagga/ripd: Fix two bugs after received SIGHUP signal")
4introduces an regression: ifp->connected list is cleaned up when ripd is
5restarting, however, for interface addresses which are not specified in
6ripd configuration file, they are never to be added into ifp->connected
7again, this will lead to some abnormal behavior for route advertising.
8
9Instead of cleaning up the ifp->connected list to avoid duplicated
10connected address being added into this list, we can check this
11condition during interface address adding process and return early
12when an identical address has already been added.
13
14Upstream-Status: Pending
15
16Signed-off-by: Hu Yadi <Yadi.hu@windriver.com>
17Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
18Signed-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