]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_assert.c
Merge pull request #5494 from opensourcerouting/mlag-module
[mirror_frr.git] / pimd / pim_assert.c
index 4a60afd891e304945fc9bc704d90b807e76f640e..53ab22754ca1103336300b75138a4c6f829dd25c 100644 (file)
@@ -1,22 +1,21 @@
 /*
-  PIM for Quagga
-  Copyright (C) 2008  Everton da Silva Marques
-
-  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
-*/
+ * PIM for Quagga
+ * Copyright (C) 2008  Everton da Silva Marques
+ *
+ * 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>
 
@@ -48,6 +47,7 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,
                             struct in_addr winner,
                             struct pim_assert_metric winner_metric)
 {
+       struct pim_interface *pim_ifp = ch->interface->info;
        int winner_changed = (ch->ifassert_winner.s_addr != winner.s_addr);
        int metric_changed = !pim_assert_metric_match(
                &ch->ifassert_winner_metric, &winner_metric);
@@ -82,7 +82,7 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,
        ch->ifassert_creation = pim_time_monotonic_sec();
 
        if (winner_changed || metric_changed) {
-               pim_upstream_update_join_desired(ch->upstream);
+               pim_upstream_update_join_desired(pim_ifp->pim, ch->upstream);
                pim_ifchannel_update_could_assert(ch);
                pim_ifchannel_update_assert_tracking_desired(ch);
        }
@@ -147,13 +147,7 @@ static int dispatch_assert(struct interface *ifp, struct in_addr source_addr,
        memset(&sg, 0, sizeof(struct prefix_sg));
        sg.src = source_addr;
        sg.grp = group_addr;
-       ch = pim_ifchannel_add(ifp, &sg, 0);
-       if (!ch) {
-               zlog_warn(
-                       "%s: (S,G)=%s failure creating channel on interface %s",
-                       __PRETTY_FUNCTION__, pim_str_sg_dump(&sg), ifp->name);
-               return -1;
-       }
+       ch = pim_ifchannel_add(ifp, &sg, 0, 0);
 
        switch (ch->ifassert_state) {
        case PIM_IFASSERT_NOINFO:
@@ -229,6 +223,7 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
        int offset;
        uint8_t *curr;
        int curr_size;
+       struct pim_interface *pim_ifp = NULL;
 
        on_trace(__PRETTY_FUNCTION__, ifp, src_addr);
 
@@ -264,11 +259,11 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
        curr += offset;
        curr_size -= offset;
 
-       if (curr_size != 8) {
+       if (curr_size < 8) {
                char src_str[INET_ADDRSTRLEN];
                pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
                zlog_warn(
-                       "%s: preference/metric size is not 8: size=%d from %s on interface %s",
+                       "%s: preference/metric size is less than 8 bytes: size=%d from %s on interface %s",
                        __PRETTY_FUNCTION__, curr_size, src_str, ifp->name);
                return -3;
        }
@@ -310,6 +305,10 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
 
        msg_metric.ip_address = src_addr;
 
+       pim_ifp = ifp->info;
+       zassert(pim_ifp);
+       ++pim_ifp->pim_ifstat_assert_recv;
+
        return dispatch_assert(ifp, msg_source_addr.u.prefix4, sg.grp,
                               msg_metric);
 }
@@ -413,7 +412,7 @@ int pim_assert_build_msg(uint8_t *pim_msg, int buf_size, struct interface *ifp,
          Add PIM header
        */
        pim_msg_size = pim_msg_curr - pim_msg;
-       pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_ASSERT);
+       pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_ASSERT, false);
 
        return pim_msg_size;
 }
@@ -470,6 +469,7 @@ 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_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address,
                         qpim_all_pim_routers_addr, pim_msg, pim_msg_size,
@@ -563,8 +563,8 @@ static void pim_assert_timer_set(struct pim_ifchannel *ch, int interval)
                           ch->interface->name);
        }
 
-       THREAD_TIMER_ON(master, ch->t_ifassert_timer, on_assert_timer, ch,
-                       interval);
+       thread_add_timer(router->master, on_assert_timer, ch, interval,
+                        &ch->t_ifassert_timer);
 }
 
 static void pim_assert_timer_reset(struct pim_ifchannel *ch)
@@ -728,7 +728,7 @@ void assert_action_a5(struct pim_ifchannel *ch)
          winner metric as AssertWinnerMetric(S,G,I).
          Set Assert Timer to Assert_Time.
          If (I is RPF_interface(S)) AND (UpstreamJPState(S,G) == true)
-         set SPTbit(S,G) to TRUE.
+         set SPTbit(S,G) to true.
 */
 static void assert_action_a6(struct pim_ifchannel *ch,
                             struct pim_assert_metric winner_metric)
@@ -737,7 +737,7 @@ static void assert_action_a6(struct pim_ifchannel *ch,
 
        /*
          If (I is RPF_interface(S)) AND (UpstreamJPState(S,G) == true) set
-         SPTbit(S,G) to TRUE.
+         SPTbit(S,G) to true.
        */
        if (ch->upstream->rpf.source_nexthop.interface == ch->interface)
                if (ch->upstream->join_state == PIM_UPSTREAM_JOINED)