pimd: Detection of interface primary address changes.
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 8ceecf8..fdbb79b 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -282,6 +282,7 @@
}
static void detect_primary_address_change(struct interface *ifp,
+ int force_prim_as_any,
const char *caller)
{
struct pim_interface *pim_ifp;
@@ -292,7 +293,10 @@
if (!pim_ifp)
return;
- new_prim_addr = pim_find_primary_addr(ifp);
+ if (force_prim_as_any)
+ new_prim_addr = qpim_inaddr_any;
+ else
+ new_prim_addr = pim_find_primary_addr(ifp);
changed = new_prim_addr.s_addr != pim_ifp->primary_address.s_addr;
@@ -344,7 +348,7 @@
ifaddr = ifc->address->u.prefix4;
- detect_primary_address_change(ifp, __PRETTY_FUNCTION__);
+ detect_primary_address_change(ifp, 0, __PRETTY_FUNCTION__);
if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
struct igmp_sock *igmp;
@@ -443,7 +447,7 @@
pim_sock_delete(ifc->ifp, "last address has been removed from interface");
}
-void pim_if_addr_del(struct connected *ifc)
+void pim_if_addr_del(struct connected *ifc, int force_prim_as_any)
{
struct interface *ifp;
@@ -461,7 +465,7 @@
"secondary" : "primary");
}
- detect_primary_address_change(ifp, __PRETTY_FUNCTION__);
+ detect_primary_address_change(ifp, force_prim_as_any, __PRETTY_FUNCTION__);
pim_if_addr_del_igmp(ifc);
pim_if_addr_del_pim(ifc);
@@ -503,7 +507,7 @@
if (p->family != AF_INET)
continue;
- pim_if_addr_del(ifc);
+ pim_if_addr_del(ifc, 1 /* force_prim_as_any=true */);
}
}
diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h
index 6a2f7c9..4b06b9f 100644
--- a/pimd/pim_iface.h
+++ b/pimd/pim_iface.h
@@ -113,7 +113,7 @@
struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim);
void pim_if_delete(struct interface *ifp);
void pim_if_addr_add(struct connected *ifc);
-void pim_if_addr_del(struct connected *ifc);
+void pim_if_addr_del(struct connected *ifc, int force_prim_as_any);
void pim_if_addr_add_all(struct interface *ifp);
void pim_if_addr_del_all(struct interface *ifp);
void pim_if_addr_del_all_igmp(struct interface *ifp);