+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Multicast traceroute for FRRouting
* Copyright (C) 2017 Mladen Sablic
- *
- * 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
*/
/* based on draft-ietf-idmr-traceroute-ipm-07 */
#include <zebra.h>
#include "pimd.h"
+#include "pim_instance.h"
#include "pim_util.h"
#include "pim_sock.h"
#include "pim_rp.h"
zlog_debug("mtrace pim_nexthop_lookup OK");
if (PIM_DEBUG_MTRACE)
- zlog_debug("mtrace next_hop=%pI4",
- &nexthop.mrib_nexthop_addr.u.prefix4);
+ zlog_debug("mtrace next_hop=%pPAs", &nexthop.mrib_nexthop_addr);
- if (nexthop.mrib_nexthop_addr.family == AF_INET)
- nh_addr = nexthop.mrib_nexthop_addr.u.prefix4;
+ nh_addr = nexthop.mrib_nexthop_addr;
ifp_in = nexthop.interface;
}
ifp_in = up->rpf.source_nexthop.interface;
- nh_addr = up->rpf.source_nexthop.mrib_nexthop_addr.u.prefix4;
+ nh_addr = up->rpf.source_nexthop.mrib_nexthop_addr;
total = htonl(MTRACE_UNKNOWN_COUNT);
if (PIM_DEBUG_MTRACE)
if (ip_hdr->ip_ttl-- <= 1)
return -1;
- ip_hdr->ip_sum = in_cksum(ip_hdr, ip_hdr->ip_hl * 4);
-
- fd = pim_socket_raw(IPPROTO_RAW);
-
- if (fd < 0)
- return -1;
-
- pim_socket_ip_hdr(fd);
-
if (interface == NULL) {
memset(&nexthop, 0, sizeof(nexthop));
if (!pim_nexthop_lookup(pim, &nexthop, ip_hdr->ip_dst, 0)) {
- close(fd);
if (PIM_DEBUG_MTRACE)
zlog_debug(
"Dropping mtrace packet, no route to destination");
if_out = interface;
}
+ ip_hdr->ip_sum = in_cksum(ip_hdr, ip_hdr->ip_hl * 4);
+
+ fd = pim_socket_raw(IPPROTO_RAW);
+
+ if (fd < 0)
+ return -1;
+
+ pim_socket_ip_hdr(fd);
+
ret = pim_socket_bind(fd, if_out);
if (ret < 0) {
}
/* Collecting IGMP Rx stats */
- igmp->rx_stats.mtrace_req++;
+ igmp->igmp_stats.mtrace_req++;
if (PIM_DEBUG_MTRACE)
mtrace_debug(pim_ifp, mtracep, igmp_msg_len);
}
/* 6.2.2 8. If this router is the Rendez-vous Point */
- if (pim_rp_i_am_rp(pim, mtracep->grp_addr)) {
+ if (mtracep->grp_addr.s_addr != INADDR_ANY &&
+ pim_rp_i_am_rp(pim, mtracep->grp_addr)) {
mtrace_rsp_set_fwd_code(rspp, MTRACE_FWD_CODE_REACHED_RP);
/* 7.7.1. PIM-SM ...RP has not performed source-specific join */
if (rspp->src_mask == MTRACE_SRC_MASK_GROUP)
mtracep->checksum = checksum;
/* Collecting IGMP Rx stats */
- igmp->rx_stats.mtrace_rsp++;
+ igmp->igmp_stats.mtrace_rsp++;
if (PIM_DEBUG_MTRACE)
mtrace_debug(pim_ifp, mtracep, igmp_msg_len);