]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Bind pim kernel fd to appropriate vrf
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 1 Jun 2017 22:59:43 +0000 (18:59 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 24 Jul 2017 17:51:38 +0000 (13:51 -0400)
Bind the pim kernel fd to the appropriate vrf, modify
the callback up into pim with the IGMP report to
retrieve the incoming interface and use that to
lookup the correct interface to use.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_iface.c
pimd/pim_iface.h
pimd/pim_mroute.c

index 124166880ca32d7ab98f56d9b5191dace35181c9..2d8b2b7979d1c614b93a5be1e7c20442a05f134e 100644 (file)
@@ -1582,15 +1582,3 @@ int pim_if_connected_to_source(struct interface *ifp, struct in_addr src)
 
        return 0;
 }
-
-struct interface *pim_if_lookup_address_vrf(struct in_addr src, vrf_id_t vrf_id)
-{
-       struct listnode *ifnode;
-       struct interface *ifp;
-
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
-               if (pim_if_connected_to_source(ifp, src) && ifp->info)
-                       return ifp;
-       }
-       return NULL;
-}
index e4b1b8e675a40dcd807a91d77489c17bcbdb1697..703b83b05d1573101eb1f31d022d10f827950c0d 100644 (file)
@@ -161,9 +161,6 @@ void pim_if_addr_del_all(struct interface *ifp);
 void pim_if_addr_del_all_igmp(struct interface *ifp);
 void pim_if_addr_del_all_pim(struct interface *ifp);
 
-struct interface *pim_if_lookup_address_vrf(struct in_addr src,
-                                           vrf_id_t vrf_id);
-
 int pim_if_add_vif(struct interface *ifp);
 int pim_if_del_vif(struct interface *ifp);
 void pim_if_add_vif_all(struct pim_instance *pim);
index 5b826b0580fb5e17bd8b886d3eab8a59054411a0..884295dbbdd3ce8c7a6ca616e0f1041ad4519168 100644 (file)
@@ -529,7 +529,7 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
 }
 
 static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
-                         int buf_size)
+                         int buf_size, ifindex_t ifindex)
 {
        struct interface *ifp;
        struct pim_interface *pim_ifp;
@@ -552,22 +552,11 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
                 * the source
                 * of the IP packet.
                 */
-               ifp = pim_if_lookup_address_vrf(ip_hdr->ip_src, pim->vrf_id);
+               ifp = if_lookup_by_index(ifindex, pim->vrf_id);
 
-               if (!ifp) {
-                       if (PIM_DEBUG_MROUTE_DETAIL) {
-                               pim_inet4_dump("<src?>", ip_hdr->ip_src,
-                                              ip_src_str, sizeof(ip_src_str));
-                               pim_inet4_dump("<dst?>", ip_hdr->ip_dst,
-                                              ip_dst_str, sizeof(ip_dst_str));
-
-                               zlog_warn(
-                                       "%s(%s): igmp kernel upcall could not find usable interface for %s -> %s",
-                                       __PRETTY_FUNCTION__, pim->vrf->name,
-                                       ip_src_str, ip_dst_str);
-                       }
+               if (!ifp)
                        return 0;
-               }
+
                pim_ifp = ifp->info;
                ifaddr = pim_find_primary_addr(ifp);
                igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->igmp_socket_list,
@@ -653,11 +642,13 @@ static int mroute_read(struct thread *t)
        int result = 0;
        int cont = 1;
        int rd;
-
+       ifindex_t ifindex;
        pim = THREAD_ARG(t);
 
        while (cont) {
-               rd = read(pim->mroute_socket, buf, sizeof(buf));
+               rd = pim_socket_recvfromto(pim->mroute_socket, (uint8_t *)buf,
+                                          sizeof(buf), NULL, NULL, NULL, NULL,
+                                          &ifindex);
                if (rd <= 0) {
                        if (errno == EINTR)
                                continue;
@@ -673,7 +664,7 @@ static int mroute_read(struct thread *t)
                        goto done;
                }
 
-               result = pim_mroute_msg(pim, buf, rd);
+               result = pim_mroute_msg(pim, buf, rd, ifindex);
 
                count++;
                if (count % qpim_packet_process == 0)
@@ -707,6 +698,9 @@ int pim_mroute_socket_enable(struct pim_instance *pim)
 
        fd = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
 
+       setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, pim->vrf->name,
+                  strlen(pim->vrf->name));
+
        if (pimd_privs.change(ZPRIVS_LOWER))
                zlog_err("pim_mroute_socket_enable: could not lower privs, %s",
                         safe_strerror(errno));