summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2023-06-08 09:46:38 +0200
committerGitHub <noreply@github.com>2023-06-08 09:46:38 +0200
commit99bd15405cbd83aea2c8f71eebeeba11f8be0ec4 (patch)
tree541f787d564f03efced386e11b77af23085b356b /pimd
parentMerge pull request #13390 from ryndia/master (diff)
parentpimd, pim6d: Move mld/igmp deletion code to a common api (diff)
downloadfrr-99bd15405cbd83aea2c8f71eebeeba11f8be0ec4.tar.xz
frr-99bd15405cbd83aea2c8f71eebeeba11f8be0ec4.zip
Merge pull request #13421 from mobash-rasool/igmp-ups2
pimd, pim6d: re-arrange some code and pimv6 deletion flow fix
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim_iface.c58
-rw-r--r--pimd/pim_iface.h2
-rw-r--r--pimd/pim_nb_config.c90
3 files changed, 65 insertions, 85 deletions
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index b1beb4563..f26fd818b 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -1762,3 +1762,61 @@ void pim_iface_init(void)
if_zapi_callbacks(pim_ifp_create, pim_ifp_up, pim_ifp_down,
pim_ifp_destroy);
}
+
+static void pim_if_membership_clear(struct interface *ifp)
+{
+ struct pim_interface *pim_ifp;
+
+ pim_ifp = ifp->info;
+ assert(pim_ifp);
+
+ if (pim_ifp->pim_enable && pim_ifp->gm_enable)
+ return;
+
+ pim_ifchannel_membership_clear(ifp);
+}
+
+void pim_pim_interface_delete(struct interface *ifp)
+{
+ struct pim_interface *pim_ifp = ifp->info;
+
+ if (!pim_ifp)
+ return;
+
+ pim_ifp->pim_enable = false;
+
+ pim_if_membership_clear(ifp);
+
+ /*
+ * pim_sock_delete() removes all neighbors from
+ * pim_ifp->pim_neighbor_list.
+ */
+ pim_sock_delete(ifp, "pim unconfigured on interface");
+ pim_upstream_nh_if_update(pim_ifp->pim, ifp);
+
+ if (!pim_ifp->gm_enable) {
+ pim_if_addr_del_all(ifp);
+ pim_if_delete(ifp);
+ }
+}
+
+void pim_gm_interface_delete(struct interface *ifp)
+{
+ struct pim_interface *pim_ifp = ifp->info;
+
+ if (!pim_ifp)
+ return;
+
+ pim_ifp->gm_enable = false;
+
+ pim_if_membership_clear(ifp);
+
+#if PIM_IPV == 4
+ igmp_sock_delete_all(ifp);
+#else
+ gm_ifp_teardown(ifp);
+#endif
+
+ if (!pim_ifp->pim_enable)
+ pim_if_delete(ifp);
+}
diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h
index 973840a75..0312f719d 100644
--- a/pimd/pim_iface.h
+++ b/pimd/pim_iface.h
@@ -243,5 +243,7 @@ bool pim_if_is_vrf_device(struct interface *ifp);
int pim_if_ifchannel_count(struct pim_interface *pim_ifp);
void pim_iface_init(void);
+void pim_pim_interface_delete(struct interface *ifp);
+void pim_gm_interface_delete(struct interface *ifp);
#endif /* PIM_IFACE_H */
diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c
index d7e415455..86c40d180 100644
--- a/pimd/pim_nb_config.c
+++ b/pimd/pim_nb_config.c
@@ -45,20 +45,6 @@ MACRO_REQUIRE_SEMICOLON()
#define yang_dnode_get_pimaddr yang_dnode_get_ipv4
#endif /* PIM_IPV != 6 */
-static void pim_if_membership_clear(struct interface *ifp)
-{
- struct pim_interface *pim_ifp;
-
- pim_ifp = ifp->info;
- assert(pim_ifp);
-
- if (pim_ifp->pim_enable && pim_ifp->gm_enable) {
- return;
- }
-
- pim_ifchannel_membership_clear(ifp);
-}
-
/*
* When PIM is disabled on interface, IGMPv3 local membership
* information is not injected into PIM interface state.
@@ -161,32 +147,6 @@ static int pim_cmd_interface_add(struct interface *ifp)
return 1;
}
-static int pim_cmd_interface_delete(struct interface *ifp)
-{
- struct pim_interface *pim_ifp = ifp->info;
-
- if (!pim_ifp)
- return 1;
-
- pim_ifp->pim_enable = false;
-
- pim_if_membership_clear(ifp);
-
- /*
- * pim_sock_delete() removes all neighbors from
- * pim_ifp->pim_neighbor_list.
- */
- pim_sock_delete(ifp, "pim unconfigured on interface");
- pim_upstream_nh_if_update(pim_ifp->pim, ifp);
-
- if (!pim_ifp->gm_enable) {
- pim_if_addr_del_all(ifp);
- pim_if_delete(ifp);
- }
-
- return 1;
-}
-
static int interface_pim_use_src_cmd_worker(struct interface *ifp,
pim_addr source_addr, char *errmsg, size_t errmsg_len)
{
@@ -1573,12 +1533,7 @@ int lib_interface_pim_address_family_destroy(struct nb_cb_destroy_args *args)
if (!pim_ifp)
return NB_OK;
- if (!pim_cmd_interface_delete(ifp)) {
- snprintf(args->errmsg, args->errmsg_len,
- "Unable to delete interface information %s",
- ifp->name);
- return NB_ERR_INCONSISTENCY;
- }
+ pim_pim_interface_delete(ifp);
}
return NB_OK;
@@ -1626,11 +1581,7 @@ int lib_interface_pim_address_family_pim_enable_modify(struct nb_cb_modify_args
if (!pim_ifp)
return NB_ERR_INCONSISTENCY;
- if (!pim_cmd_interface_delete(ifp)) {
- snprintf(args->errmsg, args->errmsg_len,
- "Unable to delete interface information");
- return NB_ERR_INCONSISTENCY;
- }
+ pim_pim_interface_delete(ifp);
}
break;
}
@@ -2565,7 +2516,6 @@ int lib_interface_gmp_address_family_create(struct nb_cb_create_args *args)
int lib_interface_gmp_address_family_destroy(struct nb_cb_destroy_args *args)
{
struct interface *ifp;
- struct pim_interface *pim_ifp;
switch (args->event) {
case NB_EV_VALIDATE:
@@ -2574,19 +2524,7 @@ int lib_interface_gmp_address_family_destroy(struct nb_cb_destroy_args *args)
break;
case NB_EV_APPLY:
ifp = nb_running_get_entry(args->dnode, NULL, true);
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- return NB_OK;
-
- pim_ifp->gm_enable = false;
-
- pim_if_membership_clear(ifp);
-
- pim_if_addr_del_all_igmp(ifp);
-
- if (!pim_ifp->pim_enable)
- pim_if_delete(ifp);
+ pim_gm_interface_delete(ifp);
}
return NB_OK;
@@ -2600,7 +2538,6 @@ int lib_interface_gmp_address_family_enable_modify(
{
struct interface *ifp;
bool gm_enable;
- struct pim_interface *pim_ifp;
int mcast_if_count;
const char *ifp_name;
const struct lyd_node *if_dnode;
@@ -2630,25 +2567,8 @@ int lib_interface_gmp_address_family_enable_modify(
if (gm_enable)
return pim_cmd_gm_start(ifp);
- else {
- pim_ifp = ifp->info;
-
- if (!pim_ifp)
- return NB_ERR_INCONSISTENCY;
-
- pim_ifp->gm_enable = false;
-
- pim_if_membership_clear(ifp);
-
-#if PIM_IPV == 4
- pim_if_addr_del_all_igmp(ifp);
-#else
- gm_ifp_teardown(ifp);
-#endif
-
- if (!pim_ifp->pim_enable)
- pim_if_delete(ifp);
- }
+ else
+ pim_gm_interface_delete(ifp);
}
return NB_OK;
}