]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_pim.c
Merge pull request #3108 from dmbaturin/master
[mirror_frr.git] / pimd / pim_pim.c
index bd6d16c37bddffda8bb83fb0bc9481d40b7bae15..0696a680e79807e2904b7fa50b0a086714bb84ac 100644 (file)
@@ -38,6 +38,7 @@
 #include "pim_assert.h"
 #include "pim_msg.h"
 #include "pim_register.h"
+#include "pim_errors.h"
 
 static int on_pim_hello_send(struct thread *t);
 static int pim_hello_send(struct interface *ifp, uint16_t holdtime);
@@ -115,7 +116,8 @@ void pim_sock_delete(struct interface *ifp, const char *delete_message)
                  delete_message);
 
        if (!ifp->info) {
-               zlog_err("%s: %s: but PIM not enabled on interface %s (!)",
+               flog_err(EC_PIM_CONFIG,
+                        "%s: %s: but PIM not enabled on interface %s (!)",
                         __PRETTY_FUNCTION__, delete_message, ifp->name);
                return;
        }
@@ -286,7 +288,7 @@ static void pim_sock_read_on(struct interface *ifp);
 
 static int pim_sock_read(struct thread *t)
 {
-       struct interface *ifp;
+       struct interface *ifp, *orig_ifp;
        struct pim_interface *pim_ifp;
        int fd;
        struct sockaddr_in from;
@@ -300,7 +302,7 @@ static int pim_sock_read(struct thread *t)
        static long long count = 0;
        int cont = 1;
 
-       ifp = THREAD_ARG(t);
+       orig_ifp = ifp = THREAD_ARG(t);
        fd = THREAD_FD(t);
 
        pim_ifp = ifp->info;
@@ -327,7 +329,14 @@ static int pim_sock_read(struct thread *t)
                 * it's the right interface because we bind to it
                 */
                ifp = if_lookup_by_index(ifindex, pim_ifp->pim->vrf_id);
-
+               if (!ifp || !ifp->info) {
+                       if (PIM_DEBUG_PIM_PACKETS)
+                               zlog_debug(
+                                       "%s: Received incoming pim packet on interface(%s:%d) not yet configured for pim",
+                                       __PRETTY_FUNCTION__,
+                                       ifp ? ifp->name : "Unknown", ifindex);
+                       goto done;
+               }
                int fail = pim_pim_packet(ifp, buf, len);
                if (fail) {
                        if (PIM_DEBUG_PIM_PACKETS)
@@ -344,7 +353,7 @@ static int pim_sock_read(struct thread *t)
        result = 0; /* good */
 
 done:
-       pim_sock_read_on(ifp);
+       pim_sock_read_on(orig_ifp);
 
        if (result) {
                ++pim_ifp->pim_ifstat_hello_recvfail;
@@ -515,7 +524,7 @@ int pim_msg_send(int fd, struct in_addr src, struct in_addr dst,
        socklen_t tolen;
        unsigned char buffer[10000];
        unsigned char *msg_start;
-       uint8_t ttl = MAXTTL;
+       uint8_t ttl;
        struct pim_msg_header *header;
        struct ip *ip;
 
@@ -564,8 +573,6 @@ int pim_msg_send(int fd, struct in_addr src, struct in_addr dst,
        ip->ip_len = htons(sendlen);
 
        if (PIM_DEBUG_PIM_PACKETS) {
-               struct pim_msg_header *header =
-                       (struct pim_msg_header *)pim_msg;
                char dst_str[INET_ADDRSTRLEN];
                pim_inet4_dump("<dst?>", dst, dst_str, sizeof(dst_str));
                zlog_debug("%s: to %s on %s: msg_size=%d checksum=%x",
@@ -647,7 +654,7 @@ static int pim_hello_send(struct interface *ifp, uint16_t holdtime)
 {
        struct pim_interface *pim_ifp = ifp->info;
 
-       if (pim_if_is_loopback(pim_ifp->pim, ifp))
+       if (if_is_loopback_or_vrf(ifp))
                return 0;
 
        if (hello_send(ifp, holdtime)) {
@@ -669,9 +676,7 @@ static void hello_resched(struct interface *ifp)
 {
        struct pim_interface *pim_ifp;
 
-       zassert(ifp);
        pim_ifp = ifp->info;
-       zassert(pim_ifp);
 
        if (PIM_DEBUG_PIM_HELLO) {
                zlog_debug("Rescheduling %d sec hello on interface %s",
@@ -692,7 +697,6 @@ static int on_pim_hello_send(struct thread *t)
        struct interface *ifp;
 
        ifp = THREAD_ARG(t);
-
        pim_ifp = ifp->info;
 
        /*
@@ -719,9 +723,7 @@ void pim_hello_restart_now(struct interface *ifp)
 {
        struct pim_interface *pim_ifp;
 
-       zassert(ifp);
        pim_ifp = ifp->info;
-       zassert(pim_ifp);
 
        /*
         * Reset next hello timer
@@ -749,9 +751,13 @@ void pim_hello_restart_triggered(struct interface *ifp)
        int triggered_hello_delay_msec;
        int random_msec;
 
-       zassert(ifp);
        pim_ifp = ifp->info;
-       zassert(pim_ifp);
+
+       /*
+        * No need to ever start loopback or vrf device hello's
+        */
+       if (if_is_loopback_or_vrf(ifp))
+               return;
 
        /*
         * There exists situations where we have the a RPF out this