summaryrefslogtreecommitdiffstats
path: root/pimd/pim_iface.c
diff options
context:
space:
mode:
authoranlan_cs <anlan_cs@126.com>2024-09-30 07:06:26 +0200
committeranlan_cs <anlan_cs@126.com>2024-09-30 07:31:29 +0200
commit5291228bf7bd6f1582a54369e469a6e3b769eb17 (patch)
treeeb60c61a5e2bd8d6ba8530157fc05e760707dd76 /pimd/pim_iface.c
parentMerge pull request #16939 from sri-mohan1/srib-24-frr-a (diff)
downloadfrr-5291228bf7bd6f1582a54369e469a6e3b769eb17.tar.xz
frr-5291228bf7bd6f1582a54369e469a6e3b769eb17.zip
pimd: fix missing IPV4 check
In `pim_if_addr_add()`, some code inside `PIM_IPV == 4` ( the case of `igmp->mtrace_only` ) wrongly accepts ipv6 address. So, clearly add IPV4 check. Signed-off-by: anlan_cs <anlan_cs@126.com>
Diffstat (limited to 'pimd/pim_iface.c')
-rw-r--r--pimd/pim_iface.c107
1 files changed, 48 insertions, 59 deletions
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 1dc9307e4..20e3ba184 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -527,77 +527,66 @@ void pim_if_addr_add(struct connected *ifc)
detect_address_change(ifp, 0, __func__);
- // if (ifc->address->family != AF_INET)
- // return;
-
#if PIM_IPV == 4
- struct in_addr ifaddr = ifc->address->u.prefix4;
+ if (ifc->address->family == AF_INET) {
+ struct in_addr ifaddr = ifc->address->u.prefix4;
- if (pim_ifp->gm_enable) {
- struct gm_sock *igmp;
+ if (pim_ifp->gm_enable) {
+ struct gm_sock *igmp;
- /* lookup IGMP socket */
- igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->gm_socket_list,
- ifaddr);
- if (!igmp) {
- /* if addr new, add IGMP socket */
- if (ifc->address->family == AF_INET)
+ /* lookup IGMP socket */
+ igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->gm_socket_list, ifaddr);
+ if (!igmp) {
+ /* if addr new, add IGMP socket */
pim_igmp_sock_add(pim_ifp->gm_socket_list,
ifaddr, ifp, false);
- } else if (igmp->mtrace_only) {
- igmp_sock_delete(igmp);
- pim_igmp_sock_add(pim_ifp->gm_socket_list, ifaddr, ifp,
- false);
- }
+ } else if (igmp->mtrace_only) {
+ igmp_sock_delete(igmp);
+ pim_igmp_sock_add(pim_ifp->gm_socket_list, ifaddr, ifp, false);
+ }
- /* Replay Static IGMP groups */
- if (pim_ifp->gm_join_list) {
- struct listnode *node;
- struct listnode *nextnode;
- struct gm_join *ij;
- int join_fd;
-
- for (ALL_LIST_ELEMENTS(pim_ifp->gm_join_list, node,
- nextnode, ij)) {
- /* Close socket and reopen with Source and Group
- */
- close(ij->sock_fd);
- join_fd = gm_join_sock(
- ifp->name, ifp->ifindex, ij->group_addr,
- ij->source_addr, pim_ifp);
- if (join_fd < 0) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<grp?>", ij->group_addr,
- group_str,
- sizeof(group_str));
- pim_inet4_dump(
- "<src?>", ij->source_addr,
- source_str, sizeof(source_str));
- zlog_warn(
- "%s: gm_join_sock() failure for IGMP group %s source %s on interface %s",
- __func__, group_str, source_str,
- ifp->name);
- /* warning only */
- } else
- ij->sock_fd = join_fd;
+ /* Replay Static IGMP groups */
+ if (pim_ifp->gm_join_list) {
+ struct listnode *node;
+ struct listnode *nextnode;
+ struct gm_join *ij;
+ int join_fd;
+
+ for (ALL_LIST_ELEMENTS(pim_ifp->gm_join_list, node, nextnode, ij)) {
+ /* Close socket and reopen with Source and Group
+ */
+ close(ij->sock_fd);
+ join_fd = gm_join_sock(ifp->name, ifp->ifindex,
+ ij->group_addr, ij->source_addr,
+ pim_ifp);
+ if (join_fd < 0) {
+ char group_str[INET_ADDRSTRLEN];
+ char source_str[INET_ADDRSTRLEN];
+ pim_inet4_dump("<grp?>", ij->group_addr, group_str,
+ sizeof(group_str));
+ pim_inet4_dump("<src?>", ij->source_addr,
+ source_str, sizeof(source_str));
+ zlog_warn("%s: gm_join_sock() failure for IGMP group %s source %s on interface %s",
+ __func__, group_str, source_str,
+ ifp->name);
+ /* warning only */
+ } else
+ ij->sock_fd = join_fd;
+ }
}
- }
- } /* igmp */
- else {
- struct gm_sock *igmp;
-
- /* lookup IGMP socket */
- igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->gm_socket_list,
- ifaddr);
- if (ifc->address->family == AF_INET) {
+ } /* igmp */
+ else {
+ struct gm_sock *igmp;
+
+ /* lookup IGMP socket */
+ igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->gm_socket_list, ifaddr);
if (igmp)
igmp_sock_delete(igmp);
/* if addr new, add IGMP socket */
pim_igmp_sock_add(pim_ifp->gm_socket_list, ifaddr, ifp,
true);
- }
- } /* igmp mtrace only */
+ } /* igmp mtrace only */
+ }
#endif
if (pim_ifp->pim_enable) {