]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_register.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pimd / pim_register.c
index 8403340d861a39bb6b139f142d4779ed22bae8ac..5144fe67b8e6e7fcedf51e9f6f6b78b2b0d24d48 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * PIM for Quagga
  * Copyright (C) 2015 Cumulus Networks, Inc.
  * Donald Sharp
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -36,7 +23,6 @@
 #include "pim_rp.h"
 #include "pim_register.h"
 #include "pim_upstream.h"
-#include "pim_br.h"
 #include "pim_rpf.h"
 #include "pim_oil.h"
 #include "pim_zebra.h"
@@ -139,7 +125,6 @@ int pim_register_stop_recv(struct interface *ifp, uint8_t *buf, int buf_size)
        struct pim_instance *pim = pim_ifp->pim;
        struct pim_upstream *up = NULL;
        struct pim_rpf *rp;
-       pim_addr rpf_addr;
        pim_sgaddr sg;
        struct listnode *up_node;
        struct pim_upstream *child;
@@ -174,12 +159,11 @@ int pim_register_stop_recv(struct interface *ifp, uint8_t *buf, int buf_size)
 
        rp = RP(pim_ifp->pim, sg.grp);
        if (rp) {
-               rpf_addr = pim_addr_from_prefix(&rp->rpf_addr);
                /* As per RFC 7761, Section 4.9.4:
                 * A special wildcard value consisting of an address field of
                 * all zeros can be used to indicate any source.
                 */
-               if ((pim_addr_cmp(sg.src, rpf_addr) == 0) ||
+               if ((pim_addr_cmp(sg.src, rp->rpf_addr) == 0) ||
                    pim_addr_is_any(sg.src)) {
                        handling_star = true;
                        sg.src = PIMADDR_ANY;
@@ -284,11 +268,10 @@ void pim_register_send(const uint8_t *buf, int buf_size, pim_addr src,
        unsigned char *b1;
        struct pim_interface *pinfo;
        struct interface *ifp;
-       pim_addr dst = pim_addr_from_prefix(&rpg->rpf_addr);
 
        if (PIM_DEBUG_PIM_REG) {
                zlog_debug("Sending %s %sRegister Packet to %pPA", up->sg_str,
-                          null_register ? "NULL " : "", &dst);
+                          null_register ? "NULL " : "", &rpg->rpf_addr);
        }
 
        ifp = rpg->source_nexthop.interface;
@@ -310,7 +293,7 @@ void pim_register_send(const uint8_t *buf, int buf_size, pim_addr src,
        if (PIM_DEBUG_PIM_REG) {
                zlog_debug("%s: Sending %s %sRegister Packet to %pPA on %s",
                           __func__, up->sg_str, null_register ? "NULL " : "",
-                          &dst, ifp->name);
+                          &rpg->rpf_addr, ifp->name);
        }
 
        memset(buffer, 0, 10000);
@@ -327,13 +310,14 @@ void pim_register_send(const uint8_t *buf, int buf_size, pim_addr src,
         */
        src = pim_register_get_unicast_v6_addr(pinfo);
 #endif
-       pim_msg_build_header(src, dst, buffer, buf_size + PIM_MSG_REGISTER_LEN,
+       pim_msg_build_header(src, rpg->rpf_addr, buffer,
+                            buf_size + PIM_MSG_REGISTER_LEN,
                             PIM_MSG_TYPE_REGISTER, false);
 
        if (!pinfo->pim_passive_enable)
                ++pinfo->pim_ifstat_reg_send;
 
-       if (pim_msg_send(pinfo->pim_sock_fd, src, dst, buffer,
+       if (pim_msg_send(pinfo->pim->reg_sock, src, rpg->rpf_addr, buffer,
                         buf_size + PIM_MSG_REGISTER_LEN, ifp)) {
                if (PIM_DEBUG_PIM_TRACE) {
                        zlog_debug(
@@ -618,7 +602,7 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
                }
        }
 
-       rp_addr = pim_addr_from_prefix(&(RP(pim, sg.grp))->rpf_addr);
+       rp_addr = (RP(pim, sg.grp))->rpf_addr;
        if (i_am_rp && (!pim_addr_cmp(dest_addr, rp_addr))) {
                sentRegisterStop = 0;
 
@@ -631,7 +615,8 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
 
                        pim_addr_to_prefix(&src, sg.src);
 
-                       if (prefix_list_apply(plist, &src) == PREFIX_DENY) {
+                       if (prefix_list_apply_ext(plist, NULL, &src, true) ==
+                           PREFIX_DENY) {
                                pim_register_stop_send(ifp, &sg, dest_addr,
                                                       src_addr);
                                if (PIM_DEBUG_PIM_PACKETS)
@@ -644,24 +629,13 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
                }
 
                if (*bits & PIM_REGISTER_BORDER_BIT) {
-                       pim_addr pimbr = pim_br_get_pmbr(&sg);
                        if (PIM_DEBUG_PIM_PACKETS)
                                zlog_debug(
-                                       "%s: Received Register message with Border bit set",
+                                       "%s: Received Register message with Border bit set, ignoring",
                                        __func__);
 
-                       if (pim_addr_is_any(pimbr))
-                               pim_br_set_pmbr(&sg, src_addr);
-                       else if (pim_addr_cmp(src_addr, pimbr)) {
-                               pim_register_stop_send(ifp, &sg, dest_addr,
-                                                      src_addr);
-                               if (PIM_DEBUG_PIM_PACKETS)
-                                       zlog_debug(
-                                               "%s: Sending register-Stop to %s and dropping mr. packet",
-                                               __func__, "Sender");
                                /* Drop Packet Silently */
-                               return 0;
-                       }
+                       return 0;
                }
 
                struct pim_upstream *upstream = pim_upstream_find(pim, &sg);