]> git.puffer.fish Git - mirror/frr.git/commitdiff
pim6d: Parse BSM packet for PIMv6
authorMobashshera Rasool <mrasool@vmware.com>
Mon, 28 Feb 2022 07:06:18 +0000 (23:06 -0800)
committerMobashshera Rasool <mrasool@vmware.com>
Fri, 25 Mar 2022 10:57:19 +0000 (03:57 -0700)
Modify pim_bsm_process to accomodate v4 and v6 address
for parsing the received packet.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
pimd/pim_bsm.c
pimd/pim_bsm.h
pimd/pim_nht.c
pimd/pim_nht.h
pimd/pim_pim.c

index d2e299a0077c5f814294e32ea3fe1c266adda8cb..66c37e7aed9ef800aeb3f7d9a4d6e6c52294f231 100644 (file)
@@ -1271,7 +1271,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,
        return true;
 }
 
-int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,
+int pim_bsm_process(struct interface *ifp, pim_sgaddr *sg, uint8_t *buf,
                    uint32_t buf_size, bool no_fwd)
 {
        struct bsm_hdr *bshdr;
@@ -1371,7 +1371,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,
        }
 
 #if PIM_IPV == 4
-       if (ip_hdr->ip_dst.s_addr == qpim_all_pim_routers_addr.s_addr)
+       if (!pim_addr_cmp(sg->grp, qpim_all_pim_routers_addr))
 #else
        if (0)
 #endif
@@ -1380,18 +1380,16 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,
                 * match RPF towards the BSR's IP address, or they have
                 * no-forward set
                 */
-               if (!no_fwd
-                   && !pim_nht_bsr_rpf_check(pim, bshdr->bsr_addr.addr, ifp,
-                                             ip_hdr->ip_src)) {
+               if (!no_fwd && !pim_nht_bsr_rpf_check(pim, bshdr->bsr_addr.addr,
+                                                     ifp, sg->src)) {
                        if (PIM_DEBUG_BSM)
                                zlog_debug(
-                                       "BSM check: RPF to BSR %s is not %pI4%%%s",
-                                       bsr_str, &ip_hdr->ip_src, ifp->name);
+                                       "BSM check: RPF to BSR %s is not %pPA%%%s",
+                                       bsr_str, &sg->src, ifp->name);
                        pim->bsm_dropped++;
                        return -1;
                }
-       } else if (if_address_is_local(&ip_hdr->ip_dst, AF_INET,
-                                      pim->vrf->vrf_id)) {
+       } else if (if_address_is_local(&sg->grp, PIM_AF, pim->vrf->vrf_id)) {
                /* Unicast BSM received - if ucast bsm not enabled on
                 * the interface, drop it
                 */
index fceabef9e66d645af926f07415ca6f9c3e84895b..910067109ec377032205dd23ce33e501b5026435 100644 (file)
@@ -207,11 +207,8 @@ void pim_bsm_proc_init(struct pim_instance *pim);
 void pim_bsm_proc_free(struct pim_instance *pim);
 void pim_bsm_clear(struct pim_instance *pim);
 void pim_bsm_write_config(struct vty *vty, struct interface *ifp);
-int  pim_bsm_process(struct interface *ifp,
-                    struct ip *ip_hdr,
-                    uint8_t *buf,
-                    uint32_t buf_size,
-                    bool no_fwd);
+int pim_bsm_process(struct interface *ifp, pim_sgaddr *sg, uint8_t *buf,
+                   uint32_t buf_size, bool no_fwd);
 bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp);
 struct bsgrp_node *pim_bsm_get_bsgrp_node(struct bsm_scope *scope,
                                          struct prefix *grp);
index 3babddd877122721aff4c3e2cd7539ed93274dbb..753857005a05556462c67e8c89b9b69b21370161 100644 (file)
@@ -279,7 +279,7 @@ void pim_nht_bsr_del(struct pim_instance *pim, struct in_addr addr)
 }
 
 bool pim_nht_bsr_rpf_check(struct pim_instance *pim, struct in_addr bsr_addr,
-                          struct interface *src_ifp, struct in_addr src_ip)
+                          struct interface *src_ifp, pim_addr src_ip)
 {
        struct pim_nexthop_cache *pnc = NULL;
        struct pim_nexthop_cache lookup;
index 568c2eb23202719f265869e6eae481e1be3e09c4..d51f622ece479284886d87241fbbcbea3817457d 100644 (file)
@@ -76,6 +76,6 @@ void pim_nht_bsr_add(struct pim_instance *pim, struct in_addr bsr_addr);
 void pim_nht_bsr_del(struct pim_instance *pim, struct in_addr bsr_addr);
 /* RPF(bsr_addr) == src_ip%src_ifp? */
 bool pim_nht_bsr_rpf_check(struct pim_instance *pim, struct in_addr bsr_addr,
-                          struct interface *src_ifp, struct in_addr src_ip);
+                          struct interface *src_ifp, pim_addr src_ip);
 
 #endif
index 535448f013a0412a28be98a4adc97a040a344d13..e28902de5e33e525d5557362fae1cf8e8c8a0a42 100644 (file)
@@ -310,8 +310,8 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
                                       pim_msg_len - PIM_MSG_HEADER_LEN);
                break;
        case PIM_MSG_TYPE_BOOTSTRAP:
-               return pim_bsm_process(ifp, ip_hdr, pim_msg, pim_msg_len,
-                                      no_fwd);
+               return pim_bsm_process(ifp, ip_hdr->ip_src, ip_hdr->ip_dst,
+                                      pim_msg, pim_msg_len, no_fwd);
                break;
 
        default: