]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd, pim6d: send secondary address in PIM hello packet 12017/head
authorSarita Patra <saritap@vmware.com>
Fri, 23 Sep 2022 07:08:23 +0000 (00:08 -0700)
committerSarita Patra <saritap@vmware.com>
Fri, 30 Sep 2022 10:35:49 +0000 (03:35 -0700)
Fixed as per rfc7761 section 4.3.1.
"""
Sending Hello Messages
The Address List option advertises all the secondary addresses
associated with the source interface of the router originating the
message.  The option MUST be included in all Hello messages if there
are secondary addresses associated with the source interface and MAY
be omitted if no secondary addresses exist.
"""

Issue: #12015

Signed-off-by: Sarita Patra <saritap@vmware.com>
pimd/pim_hello.c
pimd/pim_tlv.c
pimd/pim_tlv.h

index 833103c27fc305e5bda46f3edd1ce7879f01c6f8..03ce8687e5f279e49182291e2a6ee6159bb6d03c 100644 (file)
@@ -389,8 +389,10 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,
        uint8_t *curr = tlv_buf;
        uint8_t *pastend = tlv_buf + tlv_buf_size;
        uint8_t *tmp;
+#if PIM_IPV == 4
        struct pim_interface *pim_ifp = ifp->info;
        struct pim_instance *pim = pim_ifp->pim;
+#endif
 
        /*
         * Append options
@@ -452,19 +454,20 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,
 
        /* Secondary Address List */
        if (ifp->connected->count) {
-               curr = pim_tlv_append_addrlist_ucast(curr, pastend,
-                                                    ifp->connected, AF_INET);
+               curr = pim_tlv_append_addrlist_ucast(curr, pastend, ifp,
+                                                    PIM_AF);
                if (!curr) {
                        if (PIM_DEBUG_PIM_HELLO) {
                                zlog_debug(
-                                       "%s: could not set PIM hello v4 Secondary Address List option for interface %s",
-                                       __func__, ifp->name);
+                                       "%s: could not set PIM hello %s Secondary Address List option for interface %s",
+                                       __func__, PIM_AF_NAME, ifp->name);
                        }
                        return -4;
                }
+#if PIM_IPV == 4
                if (pim->send_v6_secondary) {
-                       curr = pim_tlv_append_addrlist_ucast(
-                               curr, pastend, ifp->connected, AF_INET6);
+                       curr = pim_tlv_append_addrlist_ucast(curr, pastend, ifp,
+                                                            AF_INET6);
                        if (!curr) {
                                if (PIM_DEBUG_PIM_HELLO) {
                                        zlog_debug(
@@ -474,6 +477,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,
                                return -4;
                        }
                }
+#endif
        }
 
        return curr - tlv_buf;
index 65975ce14640bca825fc723a93374315ac92c497..c9caf0016ee7aaf77ba82be6a9750b4f3c530039 100644 (file)
@@ -29,6 +29,8 @@
 #include "pim_tlv.h"
 #include "pim_str.h"
 #include "pim_msg.h"
+#include "pim_iface.h"
+#include "pim_addr.h"
 
 #if PIM_IPV == 4
 #define PIM_MSG_ADDRESS_FAMILY PIM_MSG_ADDRESS_FAMILY_IPV4
@@ -226,12 +228,15 @@ int pim_encode_addr_group(uint8_t *buf, afi_t afi, int bidir, int scope,
 }
 
 uint8_t *pim_tlv_append_addrlist_ucast(uint8_t *buf, const uint8_t *buf_pastend,
-                                      struct list *ifconnected, int family)
+                                      struct interface *ifp, int family)
 {
        struct listnode *node;
        uint16_t option_len = 0;
        uint8_t *curr;
        size_t uel;
+       struct list *ifconnected = ifp->connected;
+       struct pim_interface *pim_ifp = ifp->info;
+       pim_addr addr;
 
        node = listhead(ifconnected);
 
@@ -252,7 +257,10 @@ uint8_t *pim_tlv_append_addrlist_ucast(uint8_t *buf, const uint8_t *buf_pastend,
                struct prefix *p = ifc->address;
                int l_encode;
 
-               if (!CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY))
+               addr = pim_addr_from_prefix(p);
+               if (!pim_addr_cmp(pim_ifp->primary_address, addr))
+                       /* don't add the primary address
+                        * into the secondary address list */
                        continue;
 
                if ((curr + uel) > buf_pastend)
index 64b3a0b6ba7206052c5324a506f7f0a7c4fc387d..63bd2c41f69f5e31b6083408141f89e902e859c2 100644 (file)
@@ -82,7 +82,7 @@ uint8_t *pim_tlv_append_2uint16(uint8_t *buf, const uint8_t *buf_pastend,
 uint8_t *pim_tlv_append_uint32(uint8_t *buf, const uint8_t *buf_pastend,
                               uint16_t option_type, uint32_t option_value);
 uint8_t *pim_tlv_append_addrlist_ucast(uint8_t *buf, const uint8_t *buf_pastend,
-                                      struct list *ifconnected, int family);
+                                      struct interface *ifp, int family);
 
 int pim_tlv_parse_holdtime(const char *ifname, pim_addr src_addr,
                           pim_hello_options *hello_options,