From fe2df4f7ba6906aeab492bcb0fd6c952f60e97aa Mon Sep 17 00:00:00 2001 From: Abhishek N R Date: Tue, 18 Jan 2022 07:17:59 -0800 Subject: [PATCH] pim6d: Adding "ipv6 mld join" CLI Adding the Interface level config command ipv6 mld join This command can be used to configure the static MLD join for IPv6 group addresses on the interfaces. Signed-off-by: Abhishek N R --- pimd/pim6_cmd.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ pimd/pim_iface.c | 5 +++- pimd/pim_nb_config.c | 5 +++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c index e3130b1564..53c032498b 100644 --- a/pimd/pim6_cmd.c +++ b/pimd/pim6_cmd.c @@ -448,6 +448,61 @@ DEFPY (no_ipv6_pim_rp_prefix_list, return pim_process_no_rp_plist_cmd(vty, rp_str, plist); } +DEFPY (interface_ipv6_mld_join, + interface_ipv6_mld_join_cmd, + "ipv6 mld join X:X::X:X$group [X:X::X:X$source]", + IPV6_STR + IFACE_MLD_STR + "MLD join multicast group\n" + "Multicast group address\n" + "Source address\n") +{ + char xpath[XPATH_MAXLEN]; + + if (source_str) { + if (IPV6_ADDR_SAME(&source, &in6addr_any)) { + vty_out(vty, "Bad source address %s\n", source_str); + return CMD_WARNING_CONFIG_FAILED; + } + } else + source_str = "::"; + + snprintf(xpath, sizeof(xpath), FRR_GMP_JOIN_XPATH, "frr-routing:ipv6", + group_str, source_str); + + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); + + return nb_cli_apply_changes(vty, NULL); +} + +DEFPY (interface_no_ipv6_mld_join, + interface_no_ipv6_mld_join_cmd, + "no ipv6 mld join X:X::X:X$group [X:X::X:X$source]", + NO_STR + IPV6_STR + IFACE_MLD_STR + "MLD join multicast group\n" + "Multicast group address\n" + "Source address\n") +{ + char xpath[XPATH_MAXLEN]; + + if (source_str) { + if (IPV6_ADDR_SAME(&source, &in6addr_any)) { + vty_out(vty, "Bad source address %s\n", source_str); + return CMD_WARNING_CONFIG_FAILED; + } + } else + source_str = "::"; + + snprintf(xpath, sizeof(xpath), FRR_GMP_JOIN_XPATH, "frr-routing:ipv6", + group_str, source_str); + + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + + return nb_cli_apply_changes(vty, NULL); +} + void pim_cmd_init(void) { if_cmd_init(pim_interface_config_write); @@ -491,4 +546,6 @@ void pim_cmd_init(void) install_element(VRF_NODE, &ipv6_pim_rp_prefix_list_cmd); install_element(CONFIG_NODE, &no_ipv6_pim_rp_prefix_list_cmd); install_element(VRF_NODE, &no_ipv6_pim_rp_prefix_list_cmd); + install_element(INTERFACE_NODE, &interface_ipv6_mld_join_cmd); + install_element(INTERFACE_NODE, &interface_no_ipv6_mld_join_cmd); } diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 5425aec233..168bf6ea6a 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -1203,6 +1203,7 @@ static int igmp_join_sock(const char *ifname, ifindex_t ifindex, return join_fd; } +#if PIM_IPV == 4 static struct gm_join *igmp_join_new(struct interface *ifp, struct in_addr group_addr, struct in_addr source_addr) @@ -1241,7 +1242,9 @@ static struct gm_join *igmp_join_new(struct interface *ifp, return ij; } +#endif /* PIM_IPV == 4 */ +#if PIM_IPV == 4 ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, struct in_addr source_addr) { @@ -1283,7 +1286,7 @@ ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, return ferr_ok(); } - +#endif /* PIM_IPV == 4 */ int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr, struct in_addr source_addr) diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index 21f57e2d11..ddba5a3edc 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -2806,6 +2806,7 @@ int lib_interface_gmp_address_family_robustness_variable_modify( int lib_interface_gmp_address_family_static_group_create( struct nb_cb_create_args *args) { +#if PIM_IPV == 4 struct interface *ifp; struct ipaddr source_addr; struct ipaddr group_addr; @@ -2848,7 +2849,9 @@ int lib_interface_gmp_address_family_static_group_create( return NB_ERR_INCONSISTENCY; } } - +#else + /* TBD Depends on MLD data structure changes */ +#endif /* PIM_IPV == 4 */ return NB_OK; }