summaryrefslogtreecommitdiffstats
path: root/pimd/pim_pim.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-07-02 19:22:49 +0200
committerDonald Sharp <sharpd@cumulusnetwroks.com>2016-05-26 02:38:33 +0200
commitc29c0f61de9d8ae208aeffe919942b113f3271d4 (patch)
tree0431b40d7cc623b310087f4b0d0ce11202c327f0 /pimd/pim_pim.c
parentpimd: Stop DR election on every hello (diff)
downloadfrr-c29c0f61de9d8ae208aeffe919942b113f3271d4.tar.xz
frr-c29c0f61de9d8ae208aeffe919942b113f3271d4.zip
pimd: Ensure new generation_id is different from previous
The RFC states that an interfaces generation_id must be changed if it experiences an if down. From 4.3.1: The GenID option contains a randomly generated 32-bit value that is regenerated each time PIM forwarding is started or restarted on the interface, including when the router itself restarts. Since we are only grabbing a new generation_id without comparing it to the previous generation_id, it is possible that random can generate the exact same number. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'pimd/pim_pim.c')
-rw-r--r--pimd/pim_pim.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index 7dcb50199..41c26a888 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -698,6 +698,7 @@ int pim_sock_add(struct interface *ifp)
{
struct pim_interface *pim_ifp;
struct in_addr ifaddr;
+ uint32_t old_genid;
pim_ifp = ifp->info;
zassert(pim_ifp);
@@ -720,7 +721,18 @@ int pim_sock_add(struct interface *ifp)
pim_ifp->t_pim_sock_read = 0;
pim_ifp->pim_sock_creation = pim_time_monotonic_sec();
- pim_ifp->pim_generation_id = random();
+ /*
+ * Just ensure that the new generation id
+ * actually chooses something different.
+ * Actually ran across a case where this
+ * happened, pre-switch to random().
+ * While this is unlikely to happen now
+ * let's make sure it doesn't.
+ */
+ old_genid = pim_ifp->pim_generation_id;
+
+ while (old_genid == pim_ifp->pim_generation_id)
+ pim_ifp->pim_generation_id = random();
zlog_info("PIM INTERFACE UP: on interface %s ifindex=%d",
ifp->name, ifp->ifindex);