]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_assert.c
lib: Remove unnecessary comparison, for linked list
[mirror_frr.git] / pimd / pim_assert.c
index cbd44388c167fcfd88a2bf7c10eadb34a6355c70..2cc98f73298b04dac3ee2dd9d41a158e429b2239 100644 (file)
@@ -24,6 +24,7 @@
 #include "if.h"
 
 #include "pimd.h"
+#include "pim_instance.h"
 #include "pim_str.h"
 #include "pim_tlv.h"
 #include "pim_msg.h"
@@ -34,6 +35,7 @@
 #include "pim_hello.h"
 #include "pim_macro.h"
 #include "pim_assert.h"
+#include "pim_zebra.h"
 #include "pim_ifchannel.h"
 
 static int assert_action_a3(struct pim_ifchannel *ch);
@@ -50,6 +52,8 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,
        int winner_changed = !!pim_addr_cmp(ch->ifassert_winner, winner);
        int metric_changed = !pim_assert_metric_match(
                &ch->ifassert_winner_metric, &winner_metric);
+       enum pim_rpf_result rpf_result;
+       struct pim_rpf old_rpf;
 
        if (PIM_DEBUG_PIM_EVENTS) {
                if (ch->ifassert_state != new_state) {
@@ -74,6 +78,22 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,
        ch->ifassert_creation = pim_time_monotonic_sec();
 
        if (winner_changed || metric_changed) {
+               if (winner_changed) {
+                       old_rpf.source_nexthop.interface =
+                               ch->upstream->rpf.source_nexthop.interface;
+                       rpf_result = pim_rpf_update(pim_ifp->pim, ch->upstream,
+                                                   &old_rpf, __func__);
+                       if (rpf_result == PIM_RPF_CHANGED ||
+                           (rpf_result == PIM_RPF_FAILURE &&
+                            old_rpf.source_nexthop.interface))
+                               pim_zebra_upstream_rpf_changed(
+                                       pim_ifp->pim, ch->upstream, &old_rpf);
+                       /* update kernel multicast forwarding cache (MFC) */
+                       if (ch->upstream->rpf.source_nexthop.interface &&
+                           ch->upstream->channel_oil)
+                               pim_upstream_mroute_iif_update(
+                                       ch->upstream->channel_oil, __func__);
+               }
                pim_upstream_update_join_desired(pim_ifp->pim, ch->upstream);
                pim_ifchannel_update_could_assert(ch);
                pim_ifchannel_update_assert_tracking_desired(ch);
@@ -283,6 +303,15 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
 
        pim_ifp = ifp->info;
        assert(pim_ifp);
+
+       if (pim_ifp->pim_passive_enable) {
+               if (PIM_DEBUG_PIM_PACKETS)
+                       zlog_debug(
+                               "skip receiving PIM message on passive interface %s",
+                               ifp->name);
+               return 0;
+       }
+
        ++pim_ifp->pim_ifstat_assert_recv;
 
        return dispatch_assert(ifp, msg_source_addr, sg.grp, msg_metric);
@@ -440,11 +469,12 @@ static int pim_assert_do(struct pim_ifchannel *ch,
                           metric.metric_preference, metric.route_metric,
                           PIM_FORCE_BOOLEAN(metric.rpt_bit_flag));
        }
-       ++pim_ifp->pim_ifstat_assert_send;
+       if (!pim_ifp->pim_passive_enable)
+               ++pim_ifp->pim_ifstat_assert_send;
 
        if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address,
                         qpim_all_pim_routers_addr, pim_msg, pim_msg_size,
-                        ifp->name)) {
+                        ifp)) {
                zlog_warn("%s: could not send PIM message on interface %s",
                          __func__, ifp->name);
                return -3;