]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Allow a interface in a vrf to be configured.
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 3 Feb 2017 17:33:37 +0000 (12:33 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 3 Feb 2017 17:33:37 +0000 (12:33 -0500)
This fixes the issue a crash when we have configured an interface
inside of a vrf, and apply pim commands to it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_igmp.c
pimd/pim_pim.c
pimd/pim_sock.c
pimd/pim_sock.h

index 4a23e4f6684bd26cf4bf5d20f905c859e43fb31a..24b9e54ea5fa8e8b3a456a3210e295ed81fb222a 100644 (file)
@@ -41,20 +41,20 @@ static void group_timer_off(struct igmp_group *group);
 /* This socket is used for TXing IGMP packets only, IGMP RX happens
  * in pim_mroute_msg()
  */
-static int igmp_sock_open(struct in_addr ifaddr, ifindex_t ifindex, uint32_t pim_options)
+static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp, uint32_t pim_options)
 {
   int fd;
   int join = 0;
   struct in_addr group;
 
-  fd = pim_socket_mcast(IPPROTO_IGMP, ifaddr, ifindex, 1);
+  fd = pim_socket_mcast(IPPROTO_IGMP, ifaddr, ifp, 1);
 
   if (fd < 0)
     return -1;
 
   if (PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(pim_options)) {
     if (inet_aton(PIM_ALL_ROUTERS, &group)) {
-      if (!pim_socket_join(fd, group, ifaddr, ifindex))
+      if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex))
        ++join;
     }
     else {
@@ -69,7 +69,7 @@ static int igmp_sock_open(struct in_addr ifaddr, ifindex_t ifindex, uint32_t pim
     IGMP routers must receive general queries for querier election.
   */
   if (inet_aton(PIM_ALL_SYSTEMS, &group)) {
-    if (!pim_socket_join(fd, group, ifaddr, ifindex))
+    if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex))
       ++join;
   }
   else {
@@ -79,7 +79,7 @@ static int igmp_sock_open(struct in_addr ifaddr, ifindex_t ifindex, uint32_t pim
   }
 
   if (inet_aton(PIM_ALL_IGMP_ROUTERS, &group)) {
-    if (!pim_socket_join(fd, group, ifaddr, ifindex)) {
+    if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex)) {
       ++join;
     }
   }
@@ -901,7 +901,7 @@ struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
 
   pim_ifp = ifp->info;
 
-  fd = igmp_sock_open(ifaddr, ifp->ifindex, pim_ifp->options);
+  fd = igmp_sock_open(ifaddr, ifp, pim_ifp->options);
   if (fd < 0) {
     zlog_warn("Could not open IGMP socket for %s on %s",
              inet_ntoa(ifaddr), ifp->name);
index 1dbbd7c65582d25e26a8a6653a4ddcc409f972c7..963b5c233d7b0a3eeba4e221d6237cb7e1b428ea 100644 (file)
@@ -389,15 +389,15 @@ static void pim_sock_read_on(struct interface *ifp)
                 pim_ifp->pim_sock_fd);
 }
 
-static int pim_sock_open(struct in_addr ifaddr, ifindex_t ifindex)
+static int pim_sock_open(struct in_addr ifaddr, struct interface *ifp)
 {
   int fd;
 
-  fd = pim_socket_mcast(IPPROTO_PIM, ifaddr, ifindex, 0 /* loop=false */);
+  fd = pim_socket_mcast(IPPROTO_PIM, ifaddr, ifp, 0 /* loop=false */);
   if (fd < 0)
     return -1;
 
-  if (pim_socket_join(fd, qpim_all_pim_routers_addr, ifaddr, ifindex)) {
+  if (pim_socket_join(fd, qpim_all_pim_routers_addr, ifaddr, ifp->ifindex)) {
     close(fd);
     return -2;
   }
@@ -808,7 +808,7 @@ int pim_sock_add(struct interface *ifp)
 
   ifaddr = pim_ifp->primary_address;
 
-  pim_ifp->pim_sock_fd = pim_sock_open(ifaddr, ifp->ifindex);
+  pim_ifp->pim_sock_fd = pim_sock_open(ifaddr, ifp);
   if (pim_ifp->pim_sock_fd < 0) {
     if (PIM_DEBUG_PIM_PACKETS)
       zlog_debug("Could not open PIM socket on interface %s",
index 11cd61b59286f366a7eb35887192a7c200b34546..6e7837af44daf1d5690f745141faa8a17bcf73d0 100644 (file)
@@ -111,7 +111,7 @@ pim_socket_bind (int fd, struct interface *ifp)
   return ret;
 }
 
-int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char loop)
+int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp, u_char loop)
 {
   int rcvbuf = 1024 * 1024 * 8;
 #ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
@@ -132,9 +132,6 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char lo
   if (protocol == IPPROTO_PIM)
     {
       int ret;
-      struct interface *ifp = NULL;
-
-      ifp = if_lookup_by_index_vrf (ifindex, VRF_DEFAULT);
 
       ret = pim_socket_bind (fd, ifp);
       if (ret)
@@ -222,7 +219,7 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char lo
 
   memset (&mreq, 0, sizeof (mreq));
 #ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
-  mreq.imr_ifindex = ifindex;
+  mreq.imr_ifindex = ifp->ifindex;
 #else
   /*
    * I am not sure what to do here yet for *BSD
index aaf82e862a62abc0bcb924ad4559ab8a98b7543c..b4ce901d1019e9432d25e5c4b98209ad2526e1e1 100644 (file)
@@ -39,7 +39,7 @@
 int pim_socket_bind (int fd, struct interface *ifp);
 int pim_socket_ip_hdr (int fd);
 int pim_socket_raw(int protocol);
-int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char loop);
+int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp, u_char loop);
 int pim_socket_join(int fd, struct in_addr group,
                    struct in_addr ifaddr, ifindex_t ifindex);
 int pim_socket_join_source(int fd, ifindex_t ifindex,