summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorplsaranya <Saranya_Panjarathina@dell.com>2022-06-22 12:35:07 +0200
committerplsaranya <Saranya_Panjarathina@dell.com>2022-06-23 15:59:03 +0200
commit1ce957d66d92eeb537a2d9b01b872b48ba268acc (patch)
tree03ae79a981eb8a18aa7d0caa9a03a6d43c2607d2 /pimd
parentMerge pull request #11407 from opensourcerouting/ldp_topo1_fix (diff)
downloadfrr-1ce957d66d92eeb537a2d9b01b872b48ba268acc.tar.xz
frr-1ce957d66d92eeb537a2d9b01b872b48ba268acc.zip
Pim6d: Mroute file duplication removal
Mroute duplicate functions removed and made us hybrid for v4 and v6 Signed-off-by: plsaranya <Saranya_Panjarathina@dell.com>
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim6_mroute_msg.c184
-rw-r--r--pimd/pim_mroute.c237
-rw-r--r--pimd/pim_mroute.h17
-rw-r--r--pimd/pim_mroute_msg.c242
-rw-r--r--pimd/subdir.am2
5 files changed, 254 insertions, 428 deletions
diff --git a/pimd/pim6_mroute_msg.c b/pimd/pim6_mroute_msg.c
deleted file mode 100644
index 0b4b31fef..000000000
--- a/pimd/pim6_mroute_msg.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * PIM for Quagga
- * Copyright (C) 2022 Dell Technologies Ltd
- *
- * 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>
-#include "log.h"
-#include "privs.h"
-#include "if.h"
-#include "prefix.h"
-#include "vty.h"
-#include "plist.h"
-#include "sockopt.h"
-#include "lib_errors.h"
-#include "lib/network.h"
-
-#include "pimd.h"
-#include "pim_instance.h"
-#include "pim_mroute.h"
-#include "pim_oil.h"
-#include "pim_str.h"
-#include "pim_time.h"
-#include "pim_iface.h"
-#include "pim_macro.h"
-#include "pim_rp.h"
-#include "pim_oil.h"
-#include "pim_ssm.h"
-#include "pim_sock.h"
-
-int pim_mroute_set(struct pim_instance *pim, int enable)
-{
- int err;
- int opt, data;
- socklen_t data_len = sizeof(data);
-
- /*
- * We need to create the VRF table for the pim mroute_socket
- */
- if (pim->vrf->vrf_id != VRF_DEFAULT) {
- frr_with_privs (&pimd_privs) {
-
- data = pim->vrf->data.l.table_id;
- err = setsockopt(pim->mroute_socket, PIM_IPPROTO,
- MRT6_TABLE, &data, data_len);
- if (err) {
- zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,PIM_IPPROTO, MRT6_TABLE=%d): errno=%d: %s",
- __FILE__, __func__, pim->mroute_socket,
- data, errno, safe_strerror(errno));
- return -1;
- }
- }
- }
-
- frr_with_privs (&pimd_privs) {
- opt = enable ? MRT6_INIT : MRT6_DONE;
- /*
- * *BSD *cares* about what value we pass down
- * here
- */
- data = 1;
- err = setsockopt(pim->mroute_socket, PIM_IPPROTO, opt, &data,
- data_len);
- if (err) {
- zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,PIM_IPPROTO,%s=%d): errno=%d: %s",
- __FILE__, __func__, pim->mroute_socket,
- enable ? "MRT6_INIT" : "MRT6_DONE", data, errno,
- safe_strerror(errno));
- return -1;
- }
- }
-
- if (enable) {
- /* Linux and Solaris IPV6_PKTINFO */
- data = 1;
- if (setsockopt(pim->mroute_socket, PIM_IPPROTO, IPV6_RECVPKTINFO,
- &data, data_len)) {
- zlog_warn(
- "Could not set IPV6_PKTINFO on socket fd=%d: errno=%d: %s",
- pim->mroute_socket, errno,
- safe_strerror(errno));
- }
- }
-
- setsockopt_so_recvbuf(pim->mroute_socket, 1024 * 1024 * 8);
-
- if (set_nonblocking (pim->mroute_socket) < 0) {
- zlog_warn(
- "Could not set non blocking on socket fd=%d: errno=%d: %s",
- pim->mroute_socket, errno,
- safe_strerror(errno));
- }
-
- if (enable) {
-#if defined linux
- int upcalls = MRT6MSG_WRMIFWHOLE;
- opt = MRT6_PIM;
-
- err = setsockopt(pim->mroute_socket, PIM_IPPROTO, opt, &upcalls,
- sizeof(upcalls));
- if (err) {
- zlog_warn(
- "Failure to register for WHOLE and WRONGMIF upcalls %d %s",
- errno, safe_strerror(errno));
- return -1;
- }
-#else
- zlog_warn(
- "PIM-SM will not work properly on this platform, until the ability to receive the WHOLEPKT upcall");
-#endif
- }
-
- return 0;
-}
-static const char *const mrt6msgtype2str[MRT6MSG_WRMIFWHOLE + 1] = {
- "<unknown_upcall?>", "NOCACHE", "WRONGMIF", "WHOLEPKT", "WRMIFWHOLE"};
-
-int pim_mroute_msg(struct pim_instance *pim, const char *buf,
- size_t buf_size, ifindex_t ifindex)
-{
- struct interface *ifp;
- const struct ip6_hdr *ip6_hdr;
- const struct mrt6msg *msg;
-
- if (buf_size < (int)sizeof(struct ip6_hdr))
- return 0;
-
- ip6_hdr = (const struct ip6_hdr *)buf;
-
- if ((ip6_hdr->ip6_vfc & 0xf) == 0) {
- msg = (const struct mrt6msg *)buf;
-
- ifp = pim_if_find_by_vif_index(pim, msg->im6_mif);
-
- if (!ifp)
- return 0;
- if (PIM_DEBUG_MROUTE) {
- zlog_debug(
- "%s: pim kernel upcall %s type=%d ip_p=%d from fd=%d for (S,G)=(%pI6,%pI6) on %s mifi=%d size=%ld",
- __func__, mrt6msgtype2str[msg->im6_msgtype],
- msg->im6_msgtype, ip6_hdr->ip6_nxt,
- pim->mroute_socket, &msg->im6_src,
- &msg->im6_dst, ifp->name, msg->im6_mif,
- (long int)buf_size);
- }
-
- switch (msg->im6_msgtype) {
- case MRT6MSG_WRONGMIF:
- return pim_mroute_msg_wrongvif(pim->mroute_socket, ifp,
- msg);
- case MRT6MSG_NOCACHE:
- return pim_mroute_msg_nocache(pim->mroute_socket, ifp,
- msg);
- case MRT6MSG_WHOLEPKT:
- return pim_mroute_msg_wholepkt(pim->mroute_socket, ifp,
- (const char *)msg,
- buf_size);
- case MRT6MSG_WRMIFWHOLE:
- return pim_mroute_msg_wrvifwhole(pim->mroute_socket,
- ifp, (const char *)msg,
- buf_size);
- default:
- break;
- }
- }
-
- return 0;
-}
-
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 1978afa7c..8f1e6184d 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -26,6 +26,7 @@
#include "plist.h"
#include "sockopt.h"
#include "lib_errors.h"
+#include "lib/network.h"
#include "pimd.h"
#include "pim_rpf.h"
@@ -47,6 +48,111 @@
static void mroute_read_on(struct pim_instance *pim);
+int pim_mroute_set(struct pim_instance *pim, int enable)
+{
+ int err;
+ int opt, data;
+ socklen_t data_len = sizeof(data);
+
+ /*
+ * We need to create the VRF table for the pim mroute_socket
+ */
+ if (pim->vrf->vrf_id != VRF_DEFAULT) {
+ frr_with_privs (&pimd_privs) {
+
+ data = pim->vrf->data.l.table_id;
+ err = setsockopt(pim->mroute_socket, PIM_IPPROTO,
+ MRT_TABLE, &data, data_len);
+ if (err) {
+ zlog_warn(
+ "%s %s: failure: setsockopt(fd=%d,PIM_IPPROTO, MRT_TABLE=%d): errno=%d: %s",
+ __FILE__, __func__, pim->mroute_socket,
+ data, errno, safe_strerror(errno));
+ return -1;
+ }
+ }
+ }
+
+ frr_with_privs (&pimd_privs) {
+ opt = enable ? MRT_INIT : MRT_DONE;
+ /*
+ * *BSD *cares* about what value we pass down
+ * here
+ */
+ data = 1;
+ err = setsockopt(pim->mroute_socket, PIM_IPPROTO, opt, &data,
+ data_len);
+ if (err) {
+ zlog_warn(
+ "%s %s: failure: setsockopt(fd=%d,PIM_IPPROTO,%s=%d): errno=%d: %s",
+ __FILE__, __func__, pim->mroute_socket,
+ enable ? "MRT_INIT" : "MRT_DONE", data, errno,
+ safe_strerror(errno));
+ return -1;
+ }
+ }
+
+#if defined(HAVE_IP_PKTINFO)
+ if (enable) {
+ /* Linux and Solaris IP_PKTINFO */
+ data = 1;
+ if (setsockopt(pim->mroute_socket, PIM_IPPROTO, IP_PKTINFO,
+ &data, data_len)) {
+ zlog_warn(
+ "Could not set IP_PKTINFO on socket fd=%d: errno=%d: %s",
+ pim->mroute_socket, errno,
+ safe_strerror(errno));
+ }
+ }
+#endif
+
+#if PIM_IPV == 6
+ if (enable) {
+ /* Linux and Solaris IPV6_PKTINFO */
+ data = 1;
+ if (setsockopt(pim->mroute_socket, PIM_IPPROTO,
+ IPV6_RECVPKTINFO, &data, data_len)) {
+ zlog_warn(
+ "Could not set IPV6_RECVPKTINFO on socket fd=%d: errno=%d: %s",
+ pim->mroute_socket, errno,
+ safe_strerror(errno));
+ }
+ }
+#endif
+ setsockopt_so_recvbuf(pim->mroute_socket, 1024 * 1024 * 8);
+
+ if (set_nonblocking(pim->mroute_socket) < 0) {
+ zlog_warn(
+ "Could not set non blocking on socket fd=%d: errno=%d: %s",
+ pim->mroute_socket, errno, safe_strerror(errno));
+ return -1;
+ }
+
+ if (enable) {
+#if defined linux
+ int upcalls = GMMSG_WRVIFWHOLE;
+ opt = MRT_PIM;
+
+ err = setsockopt(pim->mroute_socket, PIM_IPPROTO, opt, &upcalls,
+ sizeof(upcalls));
+ if (err) {
+ zlog_warn(
+ "Failure to register for VIFWHOLE and WRONGVIF upcalls %d %s",
+ errno, safe_strerror(errno));
+ return -1;
+ }
+#else
+ zlog_warn(
+ "PIM-SM will not work properly on this platform, until the ability to receive the WRVIFWHOLE upcall");
+#endif
+ }
+
+ return 0;
+}
+
+static const char *const gmmsgtype2str[GMMSG_WRVIFWHOLE + 1] = {
+ "<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"};
+
int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)
{
@@ -504,6 +610,137 @@ int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, const char *buf,
return 0;
}
+#if PIM_IPV == 4
+static int process_igmp_packet(struct pim_instance *pim, const char *buf,
+ size_t buf_size, ifindex_t ifindex)
+{
+ struct interface *ifp;
+ struct pim_interface *pim_ifp;
+ struct in_addr ifaddr;
+ struct gm_sock *igmp;
+ const struct prefix *connected_src;
+ const struct ip *ip_hdr = (const struct ip *)buf;
+
+ /* We have the IP packet but we do not know which interface this
+ * packet was
+ * received on. Find the interface that is on the same subnet as
+ * the source
+ * of the IP packet.
+ */
+ ifp = if_lookup_by_index(ifindex, pim->vrf->vrf_id);
+
+ if (!ifp || !ifp->info)
+ return 0;
+
+ connected_src = pim_if_connected_to_source(ifp, ip_hdr->ip_src);
+
+ if (!connected_src) {
+ if (PIM_DEBUG_IGMP_PACKETS) {
+ zlog_debug(
+ "Recv IGMP packet on interface: %s from a non-connected source: %pI4",
+ ifp->name, &ip_hdr->ip_src);
+ }
+ return 0;
+ }
+
+ pim_ifp = ifp->info;
+ ifaddr = connected_src->u.prefix4;
+ igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->gm_socket_list, ifaddr);
+
+ if (PIM_DEBUG_IGMP_PACKETS) {
+ zlog_debug(
+ "%s(%s): igmp kernel upcall on %s(%p) for %pI4 -> %pI4",
+ __func__, pim->vrf->name, ifp->name, igmp,
+ &ip_hdr->ip_src, &ip_hdr->ip_dst);
+ }
+ if (igmp)
+ pim_igmp_packet(igmp, (char *)buf, buf_size);
+ else if (PIM_DEBUG_IGMP_PACKETS) {
+ zlog_debug(
+ "No IGMP socket on interface: %s with connected source: %pFX",
+ ifp->name, connected_src);
+ }
+ return 0;
+}
+#endif
+
+int pim_mroute_msg(struct pim_instance *pim, const char *buf, size_t buf_size,
+ ifindex_t ifindex)
+{
+ struct interface *ifp;
+ const ipv_hdr *ip_hdr;
+ const kernmsg *msg;
+
+ if (buf_size < (int)sizeof(ipv_hdr))
+ return 0;
+
+ ip_hdr = (const ipv_hdr *)buf;
+
+#if PIM_IPV == 4
+ if (ip_hdr->ip_p == IPPROTO_IGMP) {
+ process_igmp_packet(pim, buf, buf_size, ifindex);
+ } else if (ip_hdr->ip_p) {
+ if (PIM_DEBUG_MROUTE_DETAIL) {
+ zlog_debug(
+ "%s: no kernel upcall proto=%d src: %pI4 dst: %pI4 msg_size=%ld",
+ __func__, ip_hdr->ip_p, &ip_hdr->ip_src,
+ &ip_hdr->ip_dst, (long int)buf_size);
+ }
+
+ } else {
+#else
+
+ if ((ip_hdr->ip6_vfc & 0xf) == 0) {
+#endif
+ msg = (const kernmsg *)buf;
+
+ ifp = pim_if_find_by_vif_index(pim, msg->msg_im_vif);
+
+ if (!ifp)
+ return 0;
+ if (PIM_DEBUG_MROUTE) {
+#if PIM_IPV == 4
+ zlog_debug(
+ "%s: pim kernel upcall %s type=%d ip_p=%d from fd=%d for (S,G)=(%pI4,%pI4) on %s vifi=%d size=%ld",
+ __func__, gmmsgtype2str[msg->msg_im_msgtype],
+ msg->msg_im_msgtype, ip_hdr->ip_p,
+ pim->mroute_socket, &msg->msg_im_src,
+ &msg->msg_im_dst, ifp->name, msg->msg_im_vif,
+ (long int)buf_size);
+#else
+ zlog_debug(
+ "%s: pim kernel upcall %s type=%d ip_p=%d from fd=%d for (S,G)=(%pI6,%pI6) on %s vifi=%d size=%ld",
+ __func__, gmmsgtype2str[msg->msg_im_msgtype],
+ msg->msg_im_msgtype, ip_hdr->ip6_nxt,
+ pim->mroute_socket, &msg->msg_im_src,
+ &msg->msg_im_dst, ifp->name, msg->msg_im_vif,
+ (long int)buf_size);
+#endif
+ }
+
+ switch (msg->msg_im_msgtype) {
+ case GMMSG_WRONGVIF:
+ return pim_mroute_msg_wrongvif(pim->mroute_socket, ifp,
+ msg);
+ case GMMSG_NOCACHE:
+ return pim_mroute_msg_nocache(pim->mroute_socket, ifp,
+ msg);
+ case GMMSG_WHOLEPKT:
+ return pim_mroute_msg_wholepkt(pim->mroute_socket, ifp,
+ (const char *)msg,
+ buf_size);
+ case GMMSG_WRVIFWHOLE:
+ return pim_mroute_msg_wrvifwhole(pim->mroute_socket,
+ ifp, (const char *)msg,
+ buf_size);
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}
+
static void mroute_read(struct thread *t)
{
struct pim_instance *pim;
diff --git a/pimd/pim_mroute.h b/pimd/pim_mroute.h
index 712c91699..d6798c52a 100644
--- a/pimd/pim_mroute.h
+++ b/pimd/pim_mroute.h
@@ -56,6 +56,7 @@ typedef struct sioc_sg_req pim_sioc_sg_req;
#define vc_lcl_ifindex vifc_lcl_ifindex
#define vc_rmt_addr vifc_rmt_addr
+#define msg_im_msgtype im_msgtype
#define msg_im_vif im_vif
#define msg_im_src im_src
#define msg_im_dst im_dst
@@ -64,6 +65,13 @@ typedef struct sioc_sg_req pim_sioc_sg_req;
#define IGMPMSG_WRVIFWHOLE 4 /* For PIM processing */
#endif
+#ifndef GMMSG_NOCACHE
+#define GMMSG_NOCACHE IGMPMSG_NOCACHE /* For PIM processing */
+#define GMMSG_WHOLEPKT IGMPMSG_WHOLEPKT /* For PIM processing */
+#define GMMSG_WRONGVIF IGMPMSG_WRONGVIF /* For PIM processing */
+#define GMMSG_WRVIFWHOLE IGMPMSG_WRVIFWHOLE /* For PIM processing */
+#endif
+
#ifndef PIM_IPPROTO
#define PIM_IPPROTO IPPROTO_IP
#endif
@@ -94,6 +102,7 @@ typedef struct sioc_sg_req pim_sioc_sg_req;
#define MRT_VERSION MRT6_VERSION
#define MRT_ASSERT MRT6_ASSERT
#define MRT_PIM MRT6_PIM
+#define MRT_TABLE MRT6_TABLE
#endif
#ifndef PIM_IPPROTO
@@ -108,6 +117,13 @@ typedef struct sioc_sg_req pim_sioc_sg_req;
#define MRT6MSG_WRMIFWHOLE 4 /* For PIM processing */
#endif
+#ifndef GMMSG_NOCACHE
+#define GMMSG_NOCACHE MRT6MSG_NOCACHE /* For PIM processing */
+#define GMMSG_WHOLEPKT MRT6MSG_WHOLEPKT /* For PIM processing */
+#define GMMSG_WRONGVIF MRT6MSG_WRONGMIF /* For PIM processing */
+#define GMMSG_WRVIFWHOLE MRT6MSG_WRMIFWHOLE /* For PIM processing */
+#endif
+
typedef struct mif6ctl pim_vifctl;
typedef struct mrt6msg kernmsg;
typedef mifi_t vifi_t;
@@ -119,6 +135,7 @@ typedef struct sioc_sg_req6 pim_sioc_sg_req;
#define vc_pifi mif6c_pifi
#define vc_rate_limit vifc_rate_limit
+#define msg_im_msgtype im6_msgtype
#define msg_im_vif im6_mif
#define msg_im_src im6_src
#define msg_im_dst im6_dst
diff --git a/pimd/pim_mroute_msg.c b/pimd/pim_mroute_msg.c
deleted file mode 100644
index ef12ec7a4..000000000
--- a/pimd/pim_mroute_msg.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * PIM for Quagga
- * Copyright (C) 2022 Dell Technologies Ltd
- *
- * 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>
-#include "log.h"
-#include "privs.h"
-#include "if.h"
-#include "prefix.h"
-#include "vty.h"
-#include "plist.h"
-#include "sockopt.h"
-#include "lib_errors.h"
-#include "lib/network.h"
-
-#include "pimd.h"
-#include "pim_instance.h"
-#include "pim_mroute.h"
-#include "pim_oil.h"
-#include "pim_str.h"
-#include "pim_iface.h"
-#include "pim_macro.h"
-#include "pim_rp.h"
-#include "pim_oil.h"
-#include "pim_msg.h"
-#include "pim_sock.h"
-
-
-int pim_mroute_set(struct pim_instance *pim, int enable)
-{
- int err;
- int opt, data;
- socklen_t data_len = sizeof(data);
-
- /*
- * We need to create the VRF table for the pim mroute_socket
- */
- if (pim->vrf->vrf_id != VRF_DEFAULT) {
- frr_with_privs(&pimd_privs) {
-
- data = pim->vrf->data.l.table_id;
- err = setsockopt(pim->mroute_socket, PIM_IPPROTO,
- MRT_TABLE, &data, data_len);
- if (err) {
- zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,PIM_IPPROTO, MRT_TABLE=%d): errno=%d: %s",
- __FILE__, __func__, pim->mroute_socket,
- data, errno, safe_strerror(errno));
- return -1;
- }
-
- }
- }
-
- frr_with_privs(&pimd_privs) {
- opt = enable ? MRT_INIT : MRT_DONE;
- /*
- * *BSD *cares* about what value we pass down
- * here
- */
- data = 1;
- err = setsockopt(pim->mroute_socket, PIM_IPPROTO, opt, &data,
- data_len);
- if (err) {
- zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,PIM_IPPROTO,%s=%d): errno=%d: %s",
- __FILE__, __func__, pim->mroute_socket,
- enable ? "MRT_INIT" : "MRT_DONE", data, errno,
- safe_strerror(errno));
- return -1;
- }
- }
-
-#if defined(HAVE_IP_PKTINFO)
- if (enable) {
- /* Linux and Solaris IP_PKTINFO */
- data = 1;
- if (setsockopt(pim->mroute_socket, PIM_IPPROTO, IP_PKTINFO,
- &data, data_len)) {
- zlog_warn(
- "Could not set IP_PKTINFO on socket fd=%d: errno=%d: %s",
- pim->mroute_socket, errno,
- safe_strerror(errno));
- }
- }
-#endif
-
- setsockopt_so_recvbuf(pim->mroute_socket, 1024 * 1024 * 8);
-
- if (set_nonblocking (pim->mroute_socket) < 0) {
- zlog_warn(
- "Could not set non blocking on socket fd=%d: errno=%d: %s",
- pim->mroute_socket, errno,
- safe_strerror(errno));
- }
-
- if (enable) {
-#if defined linux
- int upcalls = IGMPMSG_WRVIFWHOLE;
- opt = MRT_PIM;
-
- err = setsockopt(pim->mroute_socket, PIM_IPPROTO, opt, &upcalls,
- sizeof(upcalls));
- if (err) {
- zlog_warn(
- "Failure to register for VIFWHOLE and WRONGVIF upcalls %d %s",
- errno, safe_strerror(errno));
- return -1;
- }
-#else
- zlog_warn(
- "PIM-SM will not work properly on this platform, until the ability to receive the WRVIFWHOLE upcall");
-#endif
-
- }
-
- return 0;
-}
-
-static const char *const igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = {
- "<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"};
-
-
-int pim_mroute_msg(struct pim_instance *pim, const char *buf,
- size_t buf_size, ifindex_t ifindex)
-{
- struct interface *ifp;
- const struct ip *ip_hdr;
- const struct igmpmsg *msg;
-
- if (buf_size < (int)sizeof(struct ip))
- return 0;
-
- ip_hdr = (const struct ip *)buf;
-
- if (ip_hdr->ip_p == IPPROTO_IGMP) {
- struct pim_interface *pim_ifp;
- struct in_addr ifaddr;
- struct gm_sock *igmp;
- const struct prefix *connected_src;
-
- /* We have the IP packet but we do not know which interface this
- * packet was
- * received on. Find the interface that is on the same subnet as
- * the source
- * of the IP packet.
- */
- ifp = if_lookup_by_index(ifindex, pim->vrf->vrf_id);
-
- if (!ifp || !ifp->info)
- return 0;
-
- connected_src = pim_if_connected_to_source(ifp, ip_hdr->ip_src);
-
- if (!connected_src) {
- if (PIM_DEBUG_IGMP_PACKETS) {
- zlog_debug(
- "Recv IGMP packet on interface: %s from a non-connected source: %pI4",
- ifp->name, &ip_hdr->ip_src);
- }
- return 0;
- }
-
- pim_ifp = ifp->info;
- ifaddr = connected_src->u.prefix4;
- igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->gm_socket_list,
- ifaddr);
-
- if (PIM_DEBUG_IGMP_PACKETS) {
- zlog_debug(
- "%s(%s): igmp kernel upcall on %s(%p) for %pI4 -> %pI4",
- __func__, pim->vrf->name, ifp->name, igmp,
- &ip_hdr->ip_src, &ip_hdr->ip_dst);
- }
- if (igmp)
- pim_igmp_packet(igmp, (char *)buf, buf_size);
- else if (PIM_DEBUG_IGMP_PACKETS) {
- zlog_debug(
- "No IGMP socket on interface: %s with connected source: %pFX",
- ifp->name, connected_src);
- }
- } else if (ip_hdr->ip_p) {
- if (PIM_DEBUG_MROUTE_DETAIL) {
- zlog_debug(
- "%s: no kernel upcall proto=%d src: %pI4 dst: %pI4 msg_size=%ld",
- __func__, ip_hdr->ip_p, &ip_hdr->ip_src,
- &ip_hdr->ip_dst, (long int)buf_size);
- }
-
- } else {
- msg = (const struct igmpmsg *)buf;
-
- ifp = pim_if_find_by_vif_index(pim, msg->im_vif);
-
- if (!ifp)
- return 0;
- if (PIM_DEBUG_MROUTE) {
- zlog_debug(
- "%s: pim kernel upcall %s type=%d ip_p=%d from fd=%d for (S,G)=(%pI4,%pI4) on %s vifi=%d size=%ld",
- __func__, igmpmsgtype2str[msg->im_msgtype],
- msg->im_msgtype, ip_hdr->ip_p,
- pim->mroute_socket, &msg->im_src, &msg->im_dst,
- ifp->name, msg->im_vif, (long int)buf_size);
- }
-
- switch (msg->im_msgtype) {
- case IGMPMSG_WRONGVIF:
- return pim_mroute_msg_wrongvif(pim->mroute_socket, ifp,
- msg);
- case IGMPMSG_NOCACHE:
- return pim_mroute_msg_nocache(pim->mroute_socket, ifp,
- msg);
- case IGMPMSG_WHOLEPKT:
- return pim_mroute_msg_wholepkt(pim->mroute_socket, ifp,
- (const char *)msg,
- buf_size);
- case IGMPMSG_WRVIFWHOLE:
- return pim_mroute_msg_wrvifwhole(pim->mroute_socket,
- ifp, (const char *)msg,
- buf_size);
- default:
- break;
- }
- }
-
- return 0;
-}
diff --git a/pimd/subdir.am b/pimd/subdir.am
index 4dd63f6b8..1424b2a45 100644
--- a/pimd/subdir.am
+++ b/pimd/subdir.am
@@ -78,7 +78,6 @@ pimd_pimd_SOURCES = \
pimd/pim_msdp_socket.c \
pimd/pim_signals.c \
pimd/pim_zpthread.c \
- pimd/pim_mroute_msg.c \
# end
nodist_pimd_pimd_SOURCES = \
@@ -93,7 +92,6 @@ pimd_pim6d_SOURCES = \
pimd/pim6_mld.c \
pimd/pim6_stubs.c \
pimd/pim6_cmd.c \
- pimd/pim6_mroute_msg.c \
# end
nodist_pimd_pim6d_SOURCES = \