2015-02-04 07:01:14 +01:00
|
|
|
/*
|
2017-05-13 10:25:29 +02:00
|
|
|
* PIM for Quagga
|
|
|
|
* Copyright (C) 2008 Everton da Silva Marques
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
#include "log.h"
|
|
|
|
#include "privs.h"
|
2016-06-18 02:43:21 +02:00
|
|
|
#include "if.h"
|
2016-06-29 18:12:13 +02:00
|
|
|
#include "prefix.h"
|
2016-09-13 21:41:33 +02:00
|
|
|
#include "vty.h"
|
|
|
|
#include "plist.h"
|
2017-05-10 14:36:20 +02:00
|
|
|
#include "sockopt.h"
|
2018-06-18 16:17:36 +02:00
|
|
|
#include "lib_errors.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#include "pimd.h"
|
2016-08-10 22:16:22 +02:00
|
|
|
#include "pim_rpf.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
#include "pim_mroute.h"
|
2015-10-28 20:22:22 +01:00
|
|
|
#include "pim_oil.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
#include "pim_str.h"
|
|
|
|
#include "pim_time.h"
|
|
|
|
#include "pim_iface.h"
|
|
|
|
#include "pim_macro.h"
|
2015-10-27 21:13:23 +01:00
|
|
|
#include "pim_rp.h"
|
2015-10-29 14:41:24 +01:00
|
|
|
#include "pim_oil.h"
|
2015-10-29 19:27:39 +01:00
|
|
|
#include "pim_register.h"
|
2016-07-15 21:42:09 +02:00
|
|
|
#include "pim_ifchannel.h"
|
2016-08-11 02:04:20 +02:00
|
|
|
#include "pim_zlookup.h"
|
2017-03-17 19:51:13 +01:00
|
|
|
#include "pim_ssm.h"
|
2017-05-24 16:37:23 +02:00
|
|
|
#include "pim_sock.h"
|
2019-03-24 20:31:50 +01:00
|
|
|
#include "pim_vxlan.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2017-05-11 03:34:27 +02:00
|
|
|
static void mroute_read_on(struct pim_instance *pim);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2017-05-11 02:52:20 +02:00
|
|
|
static int pim_mroute_set(struct pim_instance *pim, int enable)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
int err;
|
2018-10-30 20:12:07 +01:00
|
|
|
int opt, data;
|
|
|
|
socklen_t data_len = sizeof(data);
|
2016-11-17 17:18:06 +01:00
|
|
|
long flags;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-11 02:52:20 +02:00
|
|
|
/*
|
|
|
|
* We need to create the VRF table for the pim mroute_socket
|
|
|
|
*/
|
2021-05-12 20:31:45 +02:00
|
|
|
if (pim->vrf->vrf_id != VRF_DEFAULT) {
|
2019-08-13 15:47:23 +02:00
|
|
|
frr_with_privs(&pimd_privs) {
|
2017-05-11 15:53:45 +02:00
|
|
|
|
2018-10-30 20:12:07 +01:00
|
|
|
data = pim->vrf->data.l.table_id;
|
2018-08-10 18:36:43 +02:00
|
|
|
err = setsockopt(pim->mroute_socket, IPPROTO_IP,
|
|
|
|
MRT_TABLE,
|
2018-10-30 20:12:07 +01:00
|
|
|
&data, data_len);
|
2018-08-10 18:36:43 +02:00
|
|
|
if (err) {
|
|
|
|
zlog_warn(
|
2020-03-06 15:23:22 +01:00
|
|
|
"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s",
|
|
|
|
__FILE__, __func__, pim->mroute_socket,
|
|
|
|
data, errno, safe_strerror(errno));
|
2018-08-10 18:36:43 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2017-05-11 15:53:45 +02:00
|
|
|
|
2018-08-10 18:36:43 +02:00
|
|
|
}
|
2017-05-11 15:53:45 +02:00
|
|
|
}
|
|
|
|
|
2019-08-13 15:47:23 +02:00
|
|
|
frr_with_privs(&pimd_privs) {
|
2018-10-30 19:17:02 +01:00
|
|
|
opt = enable ? MRT_INIT : MRT_DONE;
|
2018-10-30 20:12:07 +01:00
|
|
|
/*
|
|
|
|
* *BSD *cares* about what value we pass down
|
|
|
|
* here
|
|
|
|
*/
|
|
|
|
data = 1;
|
2018-10-30 19:17:02 +01:00
|
|
|
err = setsockopt(pim->mroute_socket, IPPROTO_IP,
|
2018-10-30 20:12:07 +01:00
|
|
|
opt, &data, data_len);
|
2018-10-30 19:17:02 +01:00
|
|
|
if (err) {
|
|
|
|
zlog_warn(
|
2020-03-06 15:23:22 +01:00
|
|
|
"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s",
|
|
|
|
__FILE__, __func__, pim->mroute_socket,
|
|
|
|
enable ? "MRT_INIT" : "MRT_DONE", data, errno,
|
|
|
|
safe_strerror(errno));
|
2018-10-30 19:17:02 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2017-05-11 02:52:20 +02:00
|
|
|
}
|
|
|
|
|
2017-06-02 19:30:48 +02:00
|
|
|
#if defined(HAVE_IP_PKTINFO)
|
|
|
|
if (enable) {
|
|
|
|
/* Linux and Solaris IP_PKTINFO */
|
2018-10-30 20:12:07 +01:00
|
|
|
data = 1;
|
|
|
|
if (setsockopt(pim->mroute_socket, IPPROTO_IP, IP_PKTINFO,
|
|
|
|
&data, data_len)) {
|
2017-06-02 19:30:48 +02:00
|
|
|
zlog_warn(
|
|
|
|
"Could not set IP_PKTINFO on socket fd=%d: errno=%d: %s",
|
|
|
|
pim->mroute_socket, errno,
|
|
|
|
safe_strerror(errno));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-11 02:52:20 +02:00
|
|
|
setsockopt_so_recvbuf(pim->mroute_socket, 1024 * 1024 * 8);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-11 02:52:20 +02:00
|
|
|
flags = fcntl(pim->mroute_socket, F_GETFL, 0);
|
2016-11-17 17:18:06 +01:00
|
|
|
if (flags < 0) {
|
2017-05-11 02:52:20 +02:00
|
|
|
zlog_warn("Could not get flags on socket fd:%d %d %s",
|
|
|
|
pim->mroute_socket, errno, safe_strerror(errno));
|
|
|
|
close(pim->mroute_socket);
|
2016-11-17 17:18:06 +01:00
|
|
|
return -1;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2017-05-11 02:52:20 +02:00
|
|
|
if (fcntl(pim->mroute_socket, F_SETFL, flags | O_NONBLOCK)) {
|
|
|
|
zlog_warn("Could not set O_NONBLOCK on socket fd:%d %d %s",
|
|
|
|
pim->mroute_socket, errno, safe_strerror(errno));
|
|
|
|
close(pim->mroute_socket);
|
2016-11-17 17:18:06 +01:00
|
|
|
return -1;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-04 17:09:30 +02:00
|
|
|
if (enable) {
|
2017-01-19 15:58:53 +01:00
|
|
|
#if defined linux
|
2016-08-04 17:09:30 +02:00
|
|
|
int upcalls = IGMPMSG_WRVIFWHOLE;
|
|
|
|
opt = MRT_PIM;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-11 02:52:20 +02:00
|
|
|
err = setsockopt(pim->mroute_socket, IPPROTO_IP, opt, &upcalls,
|
2016-08-04 17:09:30 +02:00
|
|
|
sizeof(upcalls));
|
|
|
|
if (err) {
|
|
|
|
zlog_warn(
|
|
|
|
"Failure to register for VIFWHOLE and WRONGVIF upcalls %d %s",
|
|
|
|
errno, safe_strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
2017-01-19 15:58:53 +01:00
|
|
|
#else
|
|
|
|
zlog_warn(
|
|
|
|
"PIM-SM will not work properly on this platform, until the ability to receive the WRVIFWHOLE upcall");
|
|
|
|
#endif
|
2016-08-04 17:09:30 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:26:59 +01:00
|
|
|
static const char *const igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = {
|
2015-10-20 15:00:02 +02:00
|
|
|
"<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"};
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-09 14:05:48 +02:00
|
|
|
static int pim_mroute_msg_nocache(int fd, struct interface *ifp,
|
|
|
|
const struct igmpmsg *msg)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2015-10-23 16:10:30 +02:00
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
2015-10-29 14:41:24 +01:00
|
|
|
struct pim_upstream *up;
|
2016-06-29 18:12:13 +02:00
|
|
|
struct pim_rpf *rpg;
|
2016-08-02 10:38:11 +02:00
|
|
|
struct prefix_sg sg;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-07-03 15:39:50 +02:00
|
|
|
rpg = pim_ifp ? RP(pim_ifp->pim, msg->im_dst) : NULL;
|
2015-10-23 16:10:30 +02:00
|
|
|
/*
|
|
|
|
* If the incoming interface is unknown OR
|
|
|
|
* the Interface type is SSM we don't need to
|
|
|
|
* do anything here
|
|
|
|
*/
|
2018-09-21 17:41:46 +02:00
|
|
|
if (!rpg || pim_rpf_addr_is_inaddr_none(rpg)) {
|
2016-11-03 21:23:50 +01:00
|
|
|
if (PIM_DEBUG_MROUTE_DETAIL)
|
|
|
|
zlog_debug(
|
2018-09-21 17:41:46 +02:00
|
|
|
"%s: Interface is not configured correctly to handle incoming packet: Could be !pim_ifp, !SM, !RP",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__);
|
2018-09-21 17:41:46 +02:00
|
|
|
|
2016-11-03 21:23:50 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-10-23 16:10:30 +02:00
|
|
|
|
2016-06-29 18:12:13 +02:00
|
|
|
/*
|
|
|
|
* If we've received a multicast packet that isn't connected to
|
|
|
|
* us
|
|
|
|
*/
|
2016-08-23 16:35:16 +02:00
|
|
|
if (!pim_if_connected_to_source(ifp, msg->im_src)) {
|
2016-08-17 03:13:22 +02:00
|
|
|
if (PIM_DEBUG_MROUTE_DETAIL)
|
2016-08-17 01:22:32 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Received incoming packet that doesn't originate on our seg",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__);
|
2016-06-29 18:12:13 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-02 10:38:11 +02:00
|
|
|
memset(&sg, 0, sizeof(struct prefix_sg));
|
|
|
|
sg.src = msg->im_src;
|
|
|
|
sg.grp = msg->im_dst;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-09-21 17:41:46 +02:00
|
|
|
if (!(PIM_I_am_DR(pim_ifp))) {
|
|
|
|
if (PIM_DEBUG_MROUTE_DETAIL)
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Interface is not the DR blackholing incoming traffic for %s",
|
|
|
|
__func__, pim_str_sg_dump(&sg));
|
2018-09-21 17:41:46 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We are not the DR, but we are still receiving packets
|
|
|
|
* Let's blackhole those packets for the moment
|
|
|
|
* As that they will be coming up to the cpu
|
|
|
|
* and causing us to consider them.
|
2019-06-14 02:03:08 +02:00
|
|
|
*
|
|
|
|
* This *will* create a dangling channel_oil
|
|
|
|
* that I see no way to get rid of. Just noting
|
|
|
|
* this for future reference.
|
2018-09-21 17:41:46 +02:00
|
|
|
*/
|
2019-07-09 02:00:43 +02:00
|
|
|
up = pim_upstream_find_or_add(
|
2020-03-05 19:17:54 +01:00
|
|
|
&sg, ifp, PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE, __func__);
|
|
|
|
pim_upstream_mroute_add(up->channel_oil, __func__);
|
2018-09-21 17:41:46 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-10 16:26:00 +01:00
|
|
|
up = pim_upstream_find_or_add(&sg, ifp, PIM_UPSTREAM_FLAG_MASK_FHR,
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__);
|
2016-08-09 14:05:48 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
2017-03-10 16:26:00 +01:00
|
|
|
* I moved this debug till after the actual add because
|
|
|
|
* I want to take advantage of the up->sg_str being filled in.
|
2017-07-17 14:03:14 +02:00
|
|
|
*/
|
2017-03-10 16:26:00 +01:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
|
|
|
zlog_debug("%s: Adding a Route %s for WHOLEPKT consumption",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, up->sg_str);
|
2015-10-29 14:41:24 +01:00
|
|
|
}
|
2016-11-17 14:17:25 +01:00
|
|
|
|
2016-09-13 14:20:39 +02:00
|
|
|
PIM_UPSTREAM_FLAG_SET_SRC_STREAM(up->flags);
|
2017-07-13 03:16:00 +02:00
|
|
|
pim_upstream_keep_alive_timer_start(up, pim_ifp->pim->keep_alive_time);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-13 20:22:42 +02:00
|
|
|
up->channel_oil->cc.pktcnt++;
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-04-05 22:14:12 +02:00
|
|
|
// resolve mfcc_parent prior to mroute_add in channel_add_oif
|
2019-02-22 10:59:07 +01:00
|
|
|
if (up->rpf.source_nexthop.interface &&
|
|
|
|
up->channel_oil->oil.mfcc_parent >= MAXVIFS) {
|
2019-11-15 20:09:13 +01:00
|
|
|
pim_upstream_mroute_iif_update(up->channel_oil, __func__);
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-04-05 22:14:12 +02:00
|
|
|
}
|
2017-03-17 19:51:13 +01:00
|
|
|
pim_register_join(up);
|
2020-03-16 02:37:07 +01:00
|
|
|
/* if we have receiver, inherit from parent */
|
|
|
|
pim_upstream_inherited_olist_decide(pim_ifp->pim, up);
|
2015-10-29 14:41:24 +01:00
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2016-08-09 14:05:48 +02:00
|
|
|
static int pim_mroute_msg_wholepkt(int fd, struct interface *ifp,
|
|
|
|
const char *buf)
|
2015-10-20 15:00:02 +02:00
|
|
|
{
|
2015-10-29 14:41:24 +01:00
|
|
|
struct pim_interface *pim_ifp;
|
2016-08-02 10:38:11 +02:00
|
|
|
struct prefix_sg sg;
|
2015-10-28 15:00:31 +01:00
|
|
|
struct pim_rpf *rpg;
|
2015-10-27 21:13:23 +01:00
|
|
|
const struct ip *ip_hdr;
|
2015-10-29 14:41:24 +01:00
|
|
|
struct pim_upstream *up;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-20 01:36:53 +02:00
|
|
|
pim_ifp = ifp->info;
|
|
|
|
|
2015-10-27 21:13:23 +01:00
|
|
|
ip_hdr = (const struct ip *)buf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-02 10:38:11 +02:00
|
|
|
memset(&sg, 0, sizeof(struct prefix_sg));
|
|
|
|
sg.src = ip_hdr->ip_src;
|
|
|
|
sg.grp = ip_hdr->ip_dst;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-20 01:36:53 +02:00
|
|
|
up = pim_upstream_find(pim_ifp->pim, &sg);
|
2015-10-29 14:41:24 +01:00
|
|
|
if (!up) {
|
pimd: Allow SPT switchover
This allows SPT switchover for S,G upon receipt of packets
on the LHR.
1) When we create a *,G from a IGMP Group Report, install
the *,G route with the pimreg device on the OIL.
2) When a packet hits the LHR that matches the *,G, we will
get a WHOLEPKT callback from the kernel and if we cannot
find the S,G, that means we have matched it on the LHR via
the *,G mroute. Create the S,G start the KAT and run
inherited_olist.
3) When the S,G times out, safely remove the S,G via
the KAT expiry
4) When the *,G is removed, remove any S,G associated
with it via the LHR flag.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-23 02:07:57 +01:00
|
|
|
struct prefix_sg star = sg;
|
|
|
|
star.src.s_addr = INADDR_ANY;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-20 01:36:53 +02:00
|
|
|
up = pim_upstream_find(pim_ifp->pim, &star);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-02-06 18:30:51 +01:00
|
|
|
if (up && PIM_UPSTREAM_FLAG_TEST_CAN_BE_LHR(up->flags)) {
|
2017-05-24 16:37:23 +02:00
|
|
|
up = pim_upstream_add(pim_ifp->pim, &sg, ifp,
|
pimd: Allow SPT switchover
This allows SPT switchover for S,G upon receipt of packets
on the LHR.
1) When we create a *,G from a IGMP Group Report, install
the *,G route with the pimreg device on the OIL.
2) When a packet hits the LHR that matches the *,G, we will
get a WHOLEPKT callback from the kernel and if we cannot
find the S,G, that means we have matched it on the LHR via
the *,G mroute. Create the S,G start the KAT and run
inherited_olist.
3) When the S,G times out, safely remove the S,G via
the KAT expiry
4) When the *,G is removed, remove any S,G associated
with it via the LHR flag.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-23 02:07:57 +01:00
|
|
|
PIM_UPSTREAM_FLAG_MASK_SRC_LHR,
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, NULL);
|
2017-03-30 16:50:04 +02:00
|
|
|
if (!up) {
|
|
|
|
if (PIM_DEBUG_MROUTE)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Unable to create upstream information for %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim_str_sg_dump(&sg));
|
2017-03-30 16:50:04 +02:00
|
|
|
return 0;
|
|
|
|
}
|
pimd: Allow SPT switchover
This allows SPT switchover for S,G upon receipt of packets
on the LHR.
1) When we create a *,G from a IGMP Group Report, install
the *,G route with the pimreg device on the OIL.
2) When a packet hits the LHR that matches the *,G, we will
get a WHOLEPKT callback from the kernel and if we cannot
find the S,G, that means we have matched it on the LHR via
the *,G mroute. Create the S,G start the KAT and run
inherited_olist.
3) When the S,G times out, safely remove the S,G via
the KAT expiry
4) When the *,G is removed, remove any S,G associated
with it via the LHR flag.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-23 02:07:57 +01:00
|
|
|
pim_upstream_keep_alive_timer_start(
|
2017-07-13 03:16:00 +02:00
|
|
|
up, pim_ifp->pim->keep_alive_time);
|
2017-05-20 01:36:53 +02:00
|
|
|
pim_upstream_inherited_olist(pim_ifp->pim, up);
|
2019-11-15 20:21:11 +01:00
|
|
|
pim_upstream_update_join_desired(pim_ifp->pim, up);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
pimd: Allow SPT switchover
This allows SPT switchover for S,G upon receipt of packets
on the LHR.
1) When we create a *,G from a IGMP Group Report, install
the *,G route with the pimreg device on the OIL.
2) When a packet hits the LHR that matches the *,G, we will
get a WHOLEPKT callback from the kernel and if we cannot
find the S,G, that means we have matched it on the LHR via
the *,G mroute. Create the S,G start the KAT and run
inherited_olist.
3) When the S,G times out, safely remove the S,G via
the KAT expiry
4) When the *,G is removed, remove any S,G associated
with it via the LHR flag.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-23 02:07:57 +01:00
|
|
|
if (PIM_DEBUG_MROUTE)
|
|
|
|
zlog_debug("%s: Creating %s upstream on LHR",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, up->sg_str);
|
pimd: Allow SPT switchover
This allows SPT switchover for S,G upon receipt of packets
on the LHR.
1) When we create a *,G from a IGMP Group Report, install
the *,G route with the pimreg device on the OIL.
2) When a packet hits the LHR that matches the *,G, we will
get a WHOLEPKT callback from the kernel and if we cannot
find the S,G, that means we have matched it on the LHR via
the *,G mroute. Create the S,G start the KAT and run
inherited_olist.
3) When the S,G times out, safely remove the S,G via
the KAT expiry
4) When the *,G is removed, remove any S,G associated
with it via the LHR flag.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-23 02:07:57 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2016-08-17 03:13:22 +02:00
|
|
|
if (PIM_DEBUG_MROUTE_DETAIL) {
|
2016-07-23 05:12:06 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Unable to find upstream channel WHOLEPKT%s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim_str_sg_dump(&sg));
|
2015-10-29 14:41:24 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-22 10:59:07 +01:00
|
|
|
if (!up->rpf.source_nexthop.interface) {
|
2019-11-12 14:02:06 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s: up %s RPF is not present", __func__,
|
|
|
|
up->sg_str);
|
2019-02-22 10:59:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-29 19:27:39 +01:00
|
|
|
pim_ifp = up->rpf.source_nexthop.interface->info;
|
|
|
|
|
2018-07-03 15:39:50 +02:00
|
|
|
rpg = pim_ifp ? RP(pim_ifp->pim, sg.grp) : NULL;
|
2015-10-27 21:13:23 +01:00
|
|
|
|
2016-09-02 18:17:10 +02:00
|
|
|
if ((pim_rpf_addr_is_inaddr_none(rpg)) || (!pim_ifp)
|
2017-03-21 18:12:30 +01:00
|
|
|
|| (!(PIM_I_am_DR(pim_ifp)))) {
|
2016-07-24 01:54:51 +02:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s: Failed Check send packet", __func__);
|
2015-10-29 19:27:39 +01:00
|
|
|
}
|
2015-10-27 21:13:23 +01:00
|
|
|
return 0;
|
2015-10-23 16:10:30 +02:00
|
|
|
}
|
2015-10-23 16:37:45 +02:00
|
|
|
|
2016-07-14 23:16:42 +02:00
|
|
|
/*
|
|
|
|
* If we've received a register suppress
|
|
|
|
*/
|
|
|
|
if (!up->t_rs_timer) {
|
2017-05-21 15:30:02 +02:00
|
|
|
if (pim_is_grp_ssm(pim_ifp->pim, sg.grp)) {
|
2017-03-17 19:51:13 +01:00
|
|
|
if (PIM_DEBUG_PIM_REG)
|
|
|
|
zlog_debug(
|
|
|
|
"%s register forward skipped as group is SSM",
|
|
|
|
pim_str_sg_dump(&sg));
|
|
|
|
return 0;
|
|
|
|
}
|
2019-11-15 21:28:01 +01:00
|
|
|
|
|
|
|
if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) {
|
|
|
|
if (PIM_DEBUG_PIM_REG)
|
|
|
|
zlog_debug(
|
|
|
|
"%s register forward skipped, not FHR",
|
|
|
|
up->sg_str);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-17 19:51:13 +01:00
|
|
|
pim_register_send((uint8_t *)buf + sizeof(struct ip),
|
|
|
|
ntohs(ip_hdr->ip_len) - sizeof(struct ip),
|
|
|
|
pim_ifp->primary_address, rpg, 0, up);
|
|
|
|
}
|
2015-10-20 15:00:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2016-08-09 14:05:48 +02:00
|
|
|
static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,
|
|
|
|
const struct igmpmsg *msg)
|
2015-10-20 15:00:02 +02:00
|
|
|
{
|
|
|
|
struct pim_ifchannel *ch;
|
|
|
|
struct pim_interface *pim_ifp;
|
2016-08-02 10:38:11 +02:00
|
|
|
struct prefix_sg sg;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-09 14:05:48 +02:00
|
|
|
memset(&sg, 0, sizeof(struct prefix_sg));
|
|
|
|
sg.src = msg->im_src;
|
|
|
|
sg.grp = msg->im_dst;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/*
|
2015-10-20 15:00:02 +02:00
|
|
|
Send Assert(S,G) on iif as response to WRONGVIF kernel upcall.
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
RFC 4601 4.8.2. PIM-SSM-Only Routers
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
iif is the incoming interface of the packet.
|
|
|
|
if (iif is in inherited_olist(S,G)) {
|
|
|
|
send Assert(S,G) on iif
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
if (!ifp) {
|
2016-11-12 01:13:55 +01:00
|
|
|
if (PIM_DEBUG_MROUTE)
|
2016-08-09 14:05:48 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: WRONGVIF (S,G)=%s could not find input interface for input_vif_index=%d",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim_str_sg_dump(&sg), msg->im_vif);
|
2015-10-20 15:00:02 +02:00
|
|
|
return -1;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2016-08-09 14:05:48 +02:00
|
|
|
pim_ifp = ifp->info;
|
|
|
|
if (!pim_ifp) {
|
2016-11-12 01:13:55 +01:00
|
|
|
if (PIM_DEBUG_MROUTE)
|
2016-08-09 14:05:48 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: WRONGVIF (S,G)=%s multicast not enabled on interface %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim_str_sg_dump(&sg), ifp->name);
|
2015-10-20 15:00:02 +02:00
|
|
|
return -2;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2016-08-09 14:05:48 +02:00
|
|
|
|
2016-07-23 05:12:06 +02:00
|
|
|
ch = pim_ifchannel_find(ifp, &sg);
|
2015-10-20 15:00:02 +02:00
|
|
|
if (!ch) {
|
|
|
|
struct prefix_sg star_g = sg;
|
2016-11-12 01:13:55 +01:00
|
|
|
if (PIM_DEBUG_MROUTE)
|
2016-08-09 14:05:48 +02:00
|
|
|
zlog_debug(
|
2015-10-20 15:00:02 +02:00
|
|
|
"%s: WRONGVIF (S,G)=%s could not find channel on interface %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim_str_sg_dump(&sg), ifp->name);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-11-12 01:13:55 +01:00
|
|
|
star_g.src.s_addr = INADDR_ANY;
|
|
|
|
ch = pim_ifchannel_find(ifp, &star_g);
|
|
|
|
if (!ch) {
|
|
|
|
if (PIM_DEBUG_MROUTE)
|
|
|
|
zlog_debug(
|
2015-10-20 15:00:02 +02:00
|
|
|
"%s: WRONGVIF (*,G)=%s could not find channel on interface %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim_str_sg_dump(&star_g),
|
|
|
|
ifp->name);
|
2015-10-20 15:00:02 +02:00
|
|
|
return -3;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
2015-10-20 15:00:02 +02:00
|
|
|
RFC 4601: 4.6.1. (S,G) Assert Message State Machine
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
Transitions from NoInfo State
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
An (S,G) data packet arrives on interface I, AND
|
|
|
|
CouldAssert(S,G,I)==TRUE An (S,G) data packet arrived on an
|
|
|
|
downstream interface that is in our (S,G) outgoing interface
|
|
|
|
list. We optimistically assume that we will be the assert
|
|
|
|
winner for this (S,G), and so we transition to the "I am Assert
|
|
|
|
Winner" state and perform Actions A1 (below), which will
|
|
|
|
initiate the assert negotiation for (S,G).
|
2017-07-17 14:03:14 +02:00
|
|
|
*/
|
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
if (ch->ifassert_state != PIM_IFASSERT_NOINFO) {
|
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2016-08-09 14:05:48 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: WRONGVIF (S,G)=%s channel is not on Assert NoInfo state for interface %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ch->sg_str, ifp->name);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2015-10-20 15:00:02 +02:00
|
|
|
return -4;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2015-10-20 15:00:02 +02:00
|
|
|
|
|
|
|
if (!PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags)) {
|
2016-11-12 01:13:55 +01:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2016-08-09 14:05:48 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: WRONGVIF (S,G)=%s interface %s is not downstream for channel",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ch->sg_str, ifp->name);
|
2015-10-20 15:00:02 +02:00
|
|
|
}
|
2016-11-12 01:13:55 +01:00
|
|
|
return -5;
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
if (assert_action_a1(ch)) {
|
2016-07-24 01:54:51 +02:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2016-08-09 14:05:48 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: WRONGVIF (S,G)=%s assert_action_a1 failure on interface %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ch->sg_str, ifp->name);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
2015-10-20 15:00:02 +02:00
|
|
|
return -6;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-09 18:30:26 +02:00
|
|
|
static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
|
|
|
|
const char *buf)
|
|
|
|
{
|
|
|
|
const struct ip *ip_hdr = (const struct ip *)buf;
|
|
|
|
struct pim_interface *pim_ifp;
|
2019-12-20 13:57:28 +01:00
|
|
|
struct pim_instance *pim;
|
2016-08-09 18:30:26 +02:00
|
|
|
struct pim_ifchannel *ch;
|
|
|
|
struct pim_upstream *up;
|
2017-02-15 02:03:18 +01:00
|
|
|
struct prefix_sg star_g;
|
2016-08-09 18:30:26 +02:00
|
|
|
struct prefix_sg sg;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-19 22:41:25 +02:00
|
|
|
pim_ifp = ifp->info;
|
|
|
|
|
2016-08-09 18:30:26 +02:00
|
|
|
memset(&sg, 0, sizeof(struct prefix_sg));
|
|
|
|
sg.src = ip_hdr->ip_src;
|
|
|
|
sg.grp = ip_hdr->ip_dst;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-09 18:30:26 +02:00
|
|
|
ch = pim_ifchannel_find(ifp, &sg);
|
|
|
|
if (ch) {
|
|
|
|
if (PIM_DEBUG_MROUTE)
|
|
|
|
zlog_debug(
|
|
|
|
"WRVIFWHOLE (S,G)=%s found ifchannel on interface %s",
|
2016-11-17 14:17:25 +01:00
|
|
|
ch->sg_str, ifp->name);
|
2016-08-09 18:30:26 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2017-02-15 02:03:18 +01:00
|
|
|
|
2016-11-12 01:13:55 +01:00
|
|
|
star_g = sg;
|
|
|
|
star_g.src.s_addr = INADDR_ANY;
|
2019-12-20 13:57:28 +01:00
|
|
|
|
|
|
|
pim = pim_ifp->pim;
|
|
|
|
/*
|
|
|
|
* If the incoming interface is the pimreg, then
|
|
|
|
* we know the callback is associated with a pim register
|
|
|
|
* packet and there is nothing to do here as that
|
|
|
|
* normal pim processing will see the packet and allow
|
|
|
|
* us to do the right thing.
|
|
|
|
*/
|
|
|
|
if (ifp == pim->regiface) {
|
|
|
|
return 0;
|
|
|
|
}
|
2016-08-09 18:30:26 +02:00
|
|
|
|
2017-05-20 01:36:53 +02:00
|
|
|
up = pim_upstream_find(pim_ifp->pim, &sg);
|
2016-08-10 22:16:22 +02:00
|
|
|
if (up) {
|
2017-02-15 02:03:18 +01:00
|
|
|
struct pim_upstream *parent;
|
2016-11-01 01:49:18 +01:00
|
|
|
struct pim_nexthop source;
|
2017-05-19 22:41:25 +02:00
|
|
|
struct pim_rpf *rpf = RP(pim_ifp->pim, sg.grp);
|
pimd: avoiding crash in wrvifwhole path
Observed crash in the wrvif whole path.
RCA: Wrongvif path trying to access pim attributes of pim disabled RPF interface.
This was resulting in Null access.
(gdb) p/x rpf->source_nexthop
$19 = {last_lookup = {s_addr = 0xa282828}, last_lookup_time = 0x59c0de0828c98,
interface = 0x1013e5011300, mrib_nexthop_addr = {family = 0x2,
prefixlen = 0x20, u = {prefix = 0x28, prefix4 = {s_addr = 0xa282828},
prefix6 = {__in6_u = {__u6_addr8 = {0x28, 0x28, 0x28, 0xa,
0x0 <repeats 12 times>}, __u6_addr16 = {0x2828, 0xa28, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0}, __u6_addr32 = {0xa282828, 0x0, 0x0, 0x0}}},
lp = {id = {s_addr = 0xa282828}, adv_router = {s_addr = 0x0}},
prefix_eth = {octet = {0x28, 0x28, 0x28, 0xa, 0x0, 0x0}}, val = {0x28,
0x28, 0x28, 0xa, 0x0 <repeats 12 times>}, ptr = 0xa282828,
prefix_evpn = {route_type = 0x28, u = {_ead_addr = {esi = {val = {0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, eth_tag = 0x0},
_macip_addr = {eth_tag = 0x0, ip_prefix_length = 0x0, mac = {
octet = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, ip = {ipa_type = 0x0,
ip = {addr = 0x0, _v4_addr = {s_addr = 0x0}, _v6_addr = {
__in6_u = {__u6_addr8 = {0x0 <repeats 16 times>},
__u6_addr16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
__u6_addr32 = {0x0, 0x0, 0x0, 0x0}}}}}}, _imet_addr = {
eth_tag = 0x0, ip_prefix_length = 0x0, ip = {ipa_type = 0x0, ip = {
addr = 0x0, _v4_addr = {s_addr = 0x0}, _v6_addr = {__in6_u = {
__u6_addr8 = {0x0 <repeats 16 times>}, __u6_addr16 = {0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, __u6_addr32 = {0x0,
0x0, 0x0, 0x0}}}}}}, _es_addr = {esi = {val = {0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}},
---Type <return> to continue, or q <return> to quit---q
ip_prefix_length = 0x0Quit
(gdb) p/x rpf->source_nexthop.interface
$20 = 0x1013e5011300
(gdb) p/x rpf->source_nexthop.interface->info
$21 = 0x0 <======================== Pim & Igmp is disabled on this interface
Fix: Return when the rpf interface is not pim enabled
Signed-off-by: Saravanan K <saravanank@vmware.com>
2020-03-24 09:26:25 +01:00
|
|
|
|
|
|
|
/* No RPF or No RPF interface or No mcast on RPF interface */
|
|
|
|
if (!rpf || !rpf->source_nexthop.interface
|
|
|
|
|| !rpf->source_nexthop.interface->info)
|
2016-11-01 01:49:18 +01:00
|
|
|
return 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-02-15 02:03:18 +01:00
|
|
|
/*
|
|
|
|
* If we have received a WRVIFWHOLE and are at this
|
|
|
|
* point, we could be receiving the packet on the *,G
|
|
|
|
* tree, let's check and if so we can safely drop
|
|
|
|
* it.
|
|
|
|
*/
|
2017-05-20 01:36:53 +02:00
|
|
|
parent = pim_upstream_find(pim_ifp->pim, &star_g);
|
2017-02-15 02:03:18 +01:00
|
|
|
if (parent && parent->rpf.source_nexthop.interface == ifp)
|
|
|
|
return 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-11-01 01:49:18 +01:00
|
|
|
pim_ifp = rpf->source_nexthop.interface->info;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-11-01 01:49:18 +01:00
|
|
|
memset(&source, 0, sizeof(source));
|
2016-08-19 16:05:01 +02:00
|
|
|
/*
|
|
|
|
* If we are the fhr that means we are getting a callback during
|
|
|
|
* the pimreg period, so I believe we can ignore this packet
|
|
|
|
*/
|
2016-09-12 19:02:53 +02:00
|
|
|
if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) {
|
2019-11-22 22:16:26 +01:00
|
|
|
/*
|
|
|
|
* No if channel, but upstream we are at the RP.
|
|
|
|
*
|
|
|
|
* This could be a anycast RP too and we may
|
|
|
|
* not have received a register packet from
|
|
|
|
* the source here at all. So gracefully
|
|
|
|
* bow out of doing a nexthop lookup and
|
|
|
|
* setting the SPTBIT to true
|
|
|
|
*/
|
|
|
|
if (up->upstream_register.s_addr != INADDR_ANY &&
|
|
|
|
pim_nexthop_lookup(pim_ifp->pim, &source,
|
2019-04-01 21:41:32 +02:00
|
|
|
up->upstream_register, 0)) {
|
2016-09-22 21:55:02 +02:00
|
|
|
pim_register_stop_send(source.interface, &sg,
|
|
|
|
pim_ifp->primary_address,
|
|
|
|
up->upstream_register);
|
2017-06-22 18:58:02 +02:00
|
|
|
up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE;
|
|
|
|
}
|
2019-07-09 01:57:01 +02:00
|
|
|
|
2017-05-20 01:36:53 +02:00
|
|
|
pim_upstream_inherited_olist(pim_ifp->pim, up);
|
2016-08-22 20:59:24 +02:00
|
|
|
if (!up->channel_oil->installed)
|
2019-11-15 19:40:00 +01:00
|
|
|
pim_upstream_mroute_add(up->channel_oil,
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__);
|
2016-10-04 13:56:09 +02:00
|
|
|
} else {
|
2017-05-20 19:43:58 +02:00
|
|
|
if (I_am_RP(pim_ifp->pim, up->sg.grp)) {
|
|
|
|
if (pim_nexthop_lookup(pim_ifp->pim, &source,
|
2019-04-01 21:41:32 +02:00
|
|
|
up->upstream_register,
|
|
|
|
0))
|
2016-11-01 01:49:18 +01:00
|
|
|
pim_register_stop_send(
|
|
|
|
source.interface, &sg,
|
|
|
|
pim_ifp->primary_address,
|
|
|
|
up->upstream_register);
|
|
|
|
up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE;
|
|
|
|
}
|
2016-10-04 13:56:09 +02:00
|
|
|
pim_upstream_keep_alive_timer_start(
|
2017-07-13 03:16:00 +02:00
|
|
|
up, pim_ifp->pim->keep_alive_time);
|
2017-05-20 01:36:53 +02:00
|
|
|
pim_upstream_inherited_olist(pim_ifp->pim, up);
|
2016-10-04 13:56:09 +02:00
|
|
|
pim_mroute_msg_wholepkt(fd, ifp, buf);
|
|
|
|
}
|
|
|
|
return 0;
|
2016-08-10 22:16:22 +02:00
|
|
|
}
|
|
|
|
|
2016-08-31 16:50:20 +02:00
|
|
|
pim_ifp = ifp->info;
|
|
|
|
if (pim_if_connected_to_source(ifp, sg.src)) {
|
2017-05-24 16:37:23 +02:00
|
|
|
up = pim_upstream_add(pim_ifp->pim, &sg, ifp,
|
2020-03-05 19:17:54 +01:00
|
|
|
PIM_UPSTREAM_FLAG_MASK_FHR, __func__,
|
|
|
|
NULL);
|
2016-08-31 16:50:20 +02:00
|
|
|
if (!up) {
|
|
|
|
if (PIM_DEBUG_MROUTE)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: WRONGVIF%s unable to create upstream on interface",
|
|
|
|
pim_str_sg_dump(&sg), ifp->name);
|
|
|
|
return -2;
|
|
|
|
}
|
2016-09-13 14:20:39 +02:00
|
|
|
PIM_UPSTREAM_FLAG_SET_SRC_STREAM(up->flags);
|
2017-07-13 03:16:00 +02:00
|
|
|
pim_upstream_keep_alive_timer_start(
|
|
|
|
up, pim_ifp->pim->keep_alive_time);
|
2016-08-31 16:50:20 +02:00
|
|
|
up->channel_oil->cc.pktcnt++;
|
2017-03-17 19:51:13 +01:00
|
|
|
pim_register_join(up);
|
2017-05-20 01:36:53 +02:00
|
|
|
pim_upstream_inherited_olist(pim_ifp->pim, up);
|
2019-11-15 19:40:00 +01:00
|
|
|
if (!up->channel_oil->installed)
|
|
|
|
pim_upstream_mroute_add(up->channel_oil, __func__);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-31 16:50:20 +02:00
|
|
|
// Send the packet to the RP
|
|
|
|
pim_mroute_msg_wholepkt(fd, ifp, buf);
|
2019-07-09 02:00:43 +02:00
|
|
|
} else {
|
|
|
|
up = pim_upstream_add(pim_ifp->pim, &sg, ifp,
|
|
|
|
PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE,
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, NULL);
|
2019-07-09 02:00:43 +02:00
|
|
|
if (!up->channel_oil->installed)
|
2020-03-05 19:17:54 +01:00
|
|
|
pim_upstream_mroute_add(up->channel_oil, __func__);
|
2016-08-31 16:50:20 +02:00
|
|
|
}
|
2016-08-09 18:30:26 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-11 03:44:25 +02:00
|
|
|
static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
|
2017-06-02 00:59:43 +02:00
|
|
|
int buf_size, ifindex_t ifindex)
|
2015-10-20 15:00:02 +02:00
|
|
|
{
|
|
|
|
struct interface *ifp;
|
2016-10-20 15:34:29 +02:00
|
|
|
struct pim_interface *pim_ifp;
|
2015-10-20 15:00:02 +02:00
|
|
|
const struct ip *ip_hdr;
|
|
|
|
const struct igmpmsg *msg;
|
2016-10-20 15:34:29 +02:00
|
|
|
struct in_addr ifaddr;
|
|
|
|
struct igmp_sock *igmp;
|
2020-08-19 21:26:41 +02:00
|
|
|
const struct prefix *connected_src;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-12-22 02:19:47 +01:00
|
|
|
if (buf_size < (int)sizeof(struct ip))
|
|
|
|
return 0;
|
|
|
|
|
2015-10-20 15:00:02 +02:00
|
|
|
ip_hdr = (const struct ip *)buf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-20 15:34:29 +02:00
|
|
|
if (ip_hdr->ip_p == IPPROTO_IGMP) {
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-20 15:34:29 +02:00
|
|
|
/* 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.
|
|
|
|
*/
|
2021-05-12 20:31:45 +02:00
|
|
|
ifp = if_lookup_by_index(ifindex, pim->vrf->vrf_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-06-02 23:17:44 +02:00
|
|
|
if (!ifp || !ifp->info)
|
2016-10-20 15:34:29 +02:00
|
|
|
return 0;
|
2017-06-02 00:59:43 +02:00
|
|
|
|
2020-08-19 21:26:41 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-10-20 15:34:29 +02:00
|
|
|
pim_ifp = ifp->info;
|
2020-08-19 21:26:41 +02:00
|
|
|
ifaddr = connected_src->u.prefix4;
|
2021-12-03 08:05:02 +01:00
|
|
|
igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->socket_list,
|
|
|
|
ifaddr);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-01-07 11:03:07 +01:00
|
|
|
if (PIM_DEBUG_IGMP_PACKETS) {
|
2019-10-08 16:36:02 +02:00
|
|
|
zlog_debug(
|
2020-08-19 21:26:41 +02:00
|
|
|
"%s(%s): igmp kernel upcall on %s(%p) for %pI4 -> %pI4",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim->vrf->name, ifp->name, igmp,
|
2020-08-19 21:26:41 +02:00
|
|
|
&ip_hdr->ip_src, &ip_hdr->ip_dst);
|
2016-10-20 15:34:29 +02:00
|
|
|
}
|
2016-10-28 00:09:09 +02:00
|
|
|
if (igmp)
|
|
|
|
pim_igmp_packet(igmp, (char *)buf, buf_size);
|
2020-08-19 21:26:41 +02:00
|
|
|
else if (PIM_DEBUG_IGMP_PACKETS) {
|
|
|
|
zlog_debug("No IGMP socket on interface: %s with connected source: %pFX",
|
|
|
|
ifp->name, connected_src);
|
|
|
|
}
|
2016-10-20 15:34:29 +02:00
|
|
|
} else if (ip_hdr->ip_p) {
|
2016-08-17 03:13:22 +02:00
|
|
|
if (PIM_DEBUG_MROUTE_DETAIL) {
|
2016-10-20 15:34:29 +02:00
|
|
|
zlog_debug(
|
2020-08-19 21:26:41 +02:00
|
|
|
"%s: no kernel upcall proto=%d src: %pI4 dst: %pI4 msg_size=%d",
|
|
|
|
__func__, ip_hdr->ip_p, &ip_hdr->ip_src, &ip_hdr->ip_dst,
|
2020-03-05 19:17:54 +01:00
|
|
|
buf_size);
|
2015-10-20 15:00:02 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-20 15:34:29 +02:00
|
|
|
} else {
|
|
|
|
msg = (const struct igmpmsg *)buf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-21 14:29:56 +02:00
|
|
|
ifp = pim_if_find_by_vif_index(pim, msg->im_vif);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-12-08 19:50:46 +01:00
|
|
|
if (!ifp)
|
|
|
|
return 0;
|
2016-10-20 15:34:29 +02:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2019-10-08 16:36:02 +02:00
|
|
|
zlog_debug(
|
2020-08-19 21:26:41 +02:00
|
|
|
"%s: pim kernel upcall %s type=%d ip_p=%d from fd=%d for (S,G)=(%pI4,%pI4) on %s vifi=%d size=%d",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, igmpmsgtype2str[msg->im_msgtype],
|
2017-05-11 03:44:25 +02:00
|
|
|
msg->im_msgtype, ip_hdr->ip_p,
|
2020-08-19 21:26:41 +02:00
|
|
|
pim->mroute_socket, &msg->im_src, &msg->im_dst, ifp->name,
|
2017-05-11 03:44:25 +02:00
|
|
|
msg->im_vif, buf_size);
|
2016-10-20 15:34:29 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-20 15:34:29 +02:00
|
|
|
switch (msg->im_msgtype) {
|
|
|
|
case IGMPMSG_WRONGVIF:
|
2017-05-11 03:44:25 +02:00
|
|
|
return pim_mroute_msg_wrongvif(pim->mroute_socket, ifp,
|
|
|
|
msg);
|
2016-10-20 15:34:29 +02:00
|
|
|
case IGMPMSG_NOCACHE:
|
2017-05-11 03:44:25 +02:00
|
|
|
return pim_mroute_msg_nocache(pim->mroute_socket, ifp,
|
|
|
|
msg);
|
2016-10-20 15:34:29 +02:00
|
|
|
case IGMPMSG_WHOLEPKT:
|
2017-05-11 03:44:25 +02:00
|
|
|
return pim_mroute_msg_wholepkt(pim->mroute_socket, ifp,
|
2016-10-20 15:34:29 +02:00
|
|
|
(const char *)msg);
|
|
|
|
case IGMPMSG_WRVIFWHOLE:
|
2017-05-11 03:44:25 +02:00
|
|
|
return pim_mroute_msg_wrvifwhole(
|
|
|
|
pim->mroute_socket, ifp, (const char *)msg);
|
2016-10-20 15:34:29 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-10-20 15:00:02 +02:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mroute_read(struct thread *t)
|
|
|
|
{
|
2017-05-11 03:34:27 +02:00
|
|
|
struct pim_instance *pim;
|
2016-11-17 17:18:06 +01:00
|
|
|
static long long count;
|
|
|
|
char buf[10000];
|
|
|
|
int result = 0;
|
|
|
|
int cont = 1;
|
|
|
|
int rd;
|
2017-06-02 00:59:43 +02:00
|
|
|
ifindex_t ifindex;
|
2017-05-11 03:34:27 +02:00
|
|
|
pim = THREAD_ARG(t);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-11-17 17:18:06 +01:00
|
|
|
while (cont) {
|
2017-06-02 00:59:43 +02:00
|
|
|
rd = pim_socket_recvfromto(pim->mroute_socket, (uint8_t *)buf,
|
|
|
|
sizeof(buf), NULL, NULL, NULL, NULL,
|
|
|
|
&ifindex);
|
2017-05-11 02:04:02 +02:00
|
|
|
if (rd <= 0) {
|
2016-11-17 17:18:06 +01:00
|
|
|
if (errno == EINTR)
|
|
|
|
continue;
|
|
|
|
if (errno == EWOULDBLOCK || errno == EAGAIN)
|
2017-03-31 22:28:22 +02:00
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_warn(
|
|
|
|
"%s: failure reading rd=%d: fd=%d: errno=%d: %s",
|
|
|
|
__func__, rd, pim->mroute_socket, errno,
|
|
|
|
safe_strerror(errno));
|
2016-11-17 17:18:06 +01:00
|
|
|
goto done;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-06-02 00:59:43 +02:00
|
|
|
result = pim_mroute_msg(pim, buf, rd, ifindex);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-11-17 17:18:06 +01:00
|
|
|
count++;
|
2018-12-21 14:57:22 +01:00
|
|
|
if (count % router->packet_process == 0)
|
2016-11-17 17:18:06 +01:00
|
|
|
cont = 0;
|
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
/* Keep reading */
|
2016-11-17 17:18:06 +01:00
|
|
|
done:
|
2017-05-11 03:34:27 +02:00
|
|
|
mroute_read_on(pim);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-05-11 03:34:27 +02:00
|
|
|
static void mroute_read_on(struct pim_instance *pim)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2018-12-20 16:34:04 +01:00
|
|
|
thread_add_read(router->master, mroute_read, pim, pim->mroute_socket,
|
2017-05-11 03:34:27 +02:00
|
|
|
&pim->thread);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2017-05-11 03:34:27 +02:00
|
|
|
static void mroute_read_off(struct pim_instance *pim)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2017-05-11 03:34:27 +02:00
|
|
|
THREAD_OFF(pim->thread);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2017-05-10 14:45:25 +02:00
|
|
|
int pim_mroute_socket_enable(struct pim_instance *pim)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
2019-08-13 15:47:23 +02:00
|
|
|
frr_with_privs(&pimd_privs) {
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2018-08-10 18:36:43 +02:00
|
|
|
fd = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2018-08-10 18:36:43 +02:00
|
|
|
if (fd < 0) {
|
|
|
|
zlog_warn("Could not create mroute socket: errno=%d: %s",
|
|
|
|
errno,
|
|
|
|
safe_strerror(errno));
|
|
|
|
return -2;
|
|
|
|
}
|
2017-08-25 01:54:21 +02:00
|
|
|
|
2017-06-02 19:30:48 +02:00
|
|
|
#ifdef SO_BINDTODEVICE
|
2018-08-10 18:36:43 +02:00
|
|
|
if (pim->vrf->vrf_id != VRF_DEFAULT
|
2018-08-13 19:52:57 +02:00
|
|
|
&& setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,
|
|
|
|
pim->vrf->name, strlen(pim->vrf->name))) {
|
2018-08-10 18:36:43 +02:00
|
|
|
zlog_warn("Could not setsockopt SO_BINDTODEVICE: %s",
|
|
|
|
safe_strerror(errno));
|
|
|
|
close(fd);
|
|
|
|
return -3;
|
|
|
|
}
|
2017-06-02 19:30:48 +02:00
|
|
|
#endif
|
2017-06-02 00:59:43 +02:00
|
|
|
|
2018-08-10 18:36:43 +02:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2017-05-11 02:52:20 +02:00
|
|
|
pim->mroute_socket = fd;
|
|
|
|
if (pim_mroute_set(pim, 1)) {
|
2015-02-04 07:01:14 +01:00
|
|
|
zlog_warn(
|
|
|
|
"Could not enable mroute on socket fd=%d: errno=%d: %s",
|
|
|
|
fd, errno, safe_strerror(errno));
|
|
|
|
close(fd);
|
2017-05-11 02:52:20 +02:00
|
|
|
pim->mroute_socket = -1;
|
2015-02-04 07:01:14 +01:00
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
|
2017-05-10 14:45:25 +02:00
|
|
|
pim->mroute_socket_creation = pim_time_monotonic_sec();
|
2015-10-20 03:23:16 +02:00
|
|
|
|
2017-05-11 03:34:27 +02:00
|
|
|
mroute_read_on(pim);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-10 14:45:25 +02:00
|
|
|
int pim_mroute_socket_disable(struct pim_instance *pim)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2017-05-11 02:52:20 +02:00
|
|
|
if (pim_mroute_set(pim, 0)) {
|
2015-02-04 07:01:14 +01:00
|
|
|
zlog_warn(
|
|
|
|
"Could not disable mroute on socket fd=%d: errno=%d: %s",
|
2017-05-11 03:44:25 +02:00
|
|
|
pim->mroute_socket, errno, safe_strerror(errno));
|
2015-02-04 07:01:14 +01:00
|
|
|
return -2;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-10 14:45:25 +02:00
|
|
|
if (close(pim->mroute_socket)) {
|
2015-02-04 07:01:14 +01:00
|
|
|
zlog_warn("Failure closing mroute socket: fd=%d errno=%d: %s",
|
2017-05-11 03:44:25 +02:00
|
|
|
pim->mroute_socket, errno, safe_strerror(errno));
|
2015-02-04 07:01:14 +01:00
|
|
|
return -3;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-11 03:34:27 +02:00
|
|
|
mroute_read_off(pim);
|
2017-05-10 14:45:25 +02:00
|
|
|
pim->mroute_socket = -1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
For each network interface (e.g., physical or a virtual tunnel) that
|
|
|
|
would be used for multicast forwarding, a corresponding multicast
|
|
|
|
interface must be added to the kernel.
|
|
|
|
*/
|
2016-06-18 02:43:21 +02:00
|
|
|
int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,
|
|
|
|
unsigned char flags)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2016-06-18 02:43:21 +02:00
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
2015-02-04 07:01:14 +01:00
|
|
|
struct vifctl vc;
|
|
|
|
int err;
|
|
|
|
|
2017-07-31 23:16:54 +02:00
|
|
|
if (PIM_DEBUG_MROUTE)
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s: Add Vif %d (%s[%s])", __func__,
|
2017-08-01 00:02:23 +02:00
|
|
|
pim_ifp->mroute_vif_index, ifp->name,
|
|
|
|
pim_ifp->pim->vrf->name);
|
2017-07-31 23:16:54 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
memset(&vc, 0, sizeof(vc));
|
2016-06-18 02:43:21 +02:00
|
|
|
vc.vifc_vifi = pim_ifp->mroute_vif_index;
|
2016-08-04 15:07:30 +02:00
|
|
|
#ifdef VIFF_USE_IFINDEX
|
2016-06-18 02:43:21 +02:00
|
|
|
vc.vifc_lcl_ifindex = ifp->ifindex;
|
2016-08-04 15:07:30 +02:00
|
|
|
#else
|
|
|
|
if (ifaddr.s_addr == INADDR_ANY) {
|
|
|
|
zlog_warn(
|
|
|
|
"%s: unnumbered interfaces are not supported on this platform",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__);
|
2016-08-04 15:07:30 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
memcpy(&vc.vifc_lcl_addr, &ifaddr, sizeof(vc.vifc_lcl_addr));
|
|
|
|
#endif
|
2015-10-20 03:23:16 +02:00
|
|
|
vc.vifc_flags = flags;
|
2015-02-04 07:01:14 +01:00
|
|
|
vc.vifc_threshold = PIM_MROUTE_MIN_TTL;
|
|
|
|
vc.vifc_rate_limit = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
#ifdef PIM_DVMRP_TUNNEL
|
|
|
|
if (vc.vifc_flags & VIFF_TUNNEL) {
|
|
|
|
memcpy(&vc.vifc_rmt_addr, &vif_remote_addr,
|
|
|
|
sizeof(vc.vifc_rmt_addr));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-14 20:33:53 +02:00
|
|
|
err = setsockopt(pim_ifp->pim->mroute_socket, IPPROTO_IP, MRT_ADD_VIF,
|
2015-10-20 03:23:16 +02:00
|
|
|
(void *)&vc, sizeof(vc));
|
2015-02-04 07:01:14 +01:00
|
|
|
if (err) {
|
2016-10-20 16:09:30 +02:00
|
|
|
char ifaddr_str[INET_ADDRSTRLEN];
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
pim_inet4_dump("<ifaddr?>", ifaddr, ifaddr_str,
|
|
|
|
sizeof(ifaddr_str));
|
|
|
|
|
2015-10-29 14:41:24 +01:00
|
|
|
zlog_warn(
|
2017-07-31 23:16:54 +02:00
|
|
|
"%s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_ADD_VIF,vif_index=%d,ifaddr=%s,flag=%d): errno=%d: %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim_ifp->pim->mroute_socket, ifp->ifindex,
|
|
|
|
ifaddr_str, flags, errno, safe_strerror(errno));
|
2015-02-04 07:01:14 +01:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-14 20:33:53 +02:00
|
|
|
int pim_mroute_del_vif(struct interface *ifp)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2017-05-14 20:33:53 +02:00
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
2015-02-04 07:01:14 +01:00
|
|
|
struct vifctl vc;
|
|
|
|
int err;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-14 20:33:53 +02:00
|
|
|
if (PIM_DEBUG_MROUTE)
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s: Del Vif %d (%s[%s])", __func__,
|
2017-07-31 23:16:54 +02:00
|
|
|
pim_ifp->mroute_vif_index, ifp->name,
|
2017-08-01 00:02:23 +02:00
|
|
|
pim_ifp->pim->vrf->name);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
memset(&vc, 0, sizeof(vc));
|
2017-05-14 20:33:53 +02:00
|
|
|
vc.vifc_vifi = pim_ifp->mroute_vif_index;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-14 20:33:53 +02:00
|
|
|
err = setsockopt(pim_ifp->pim->mroute_socket, IPPROTO_IP, MRT_DEL_VIF,
|
2015-02-04 07:01:14 +01:00
|
|
|
(void *)&vc, sizeof(vc));
|
|
|
|
if (err) {
|
|
|
|
zlog_warn(
|
|
|
|
"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_DEL_VIF,vif_index=%d): errno=%d: %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__FILE__, __func__, pim_ifp->pim->mroute_socket,
|
|
|
|
pim_ifp->mroute_vif_index, errno, safe_strerror(errno));
|
2015-02-04 07:01:14 +01:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-15 20:46:04 +01:00
|
|
|
/*
|
|
|
|
* Prevent creating MFC entry with OIF=IIF.
|
|
|
|
*
|
|
|
|
* This is a protection against implementation mistakes.
|
|
|
|
*
|
|
|
|
* PIM protocol implicitely ensures loopfree multicast topology.
|
|
|
|
*
|
|
|
|
* IGMP must be protected against adding looped MFC entries created
|
|
|
|
* by both source and receiver attached to the same interface. See
|
|
|
|
* TODO T22.
|
|
|
|
* We shall allow igmp to create upstream when it is DR for the intf.
|
|
|
|
* Assume RP reachable via non DR.
|
|
|
|
*/
|
|
|
|
bool pim_mroute_allow_iif_in_oil(struct channel_oil *c_oil,
|
|
|
|
int oif_index)
|
|
|
|
{
|
|
|
|
#ifdef PIM_ENFORCE_LOOPFREE_MFC
|
|
|
|
struct interface *ifp_out;
|
|
|
|
struct pim_interface *pim_ifp;
|
|
|
|
|
|
|
|
if (c_oil->up &&
|
|
|
|
PIM_UPSTREAM_FLAG_TEST_ALLOW_IIF_IN_OIL(c_oil->up->flags))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
ifp_out = pim_if_find_by_vif_index(c_oil->pim, oif_index);
|
|
|
|
if (!ifp_out)
|
|
|
|
return false;
|
|
|
|
pim_ifp = ifp_out->info;
|
|
|
|
if (!pim_ifp)
|
|
|
|
return false;
|
|
|
|
if ((c_oil->oif_flags[oif_index] & PIM_OIF_FLAG_PROTO_IGMP) &&
|
|
|
|
PIM_I_am_DR(pim_ifp))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-11-15 18:29:04 +01:00
|
|
|
static inline void pim_mroute_copy(struct mfcctl *oil,
|
|
|
|
struct channel_oil *c_oil)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
oil->mfcc_origin = c_oil->oil.mfcc_origin;
|
|
|
|
oil->mfcc_mcastgrp = c_oil->oil.mfcc_mcastgrp;
|
|
|
|
oil->mfcc_parent = c_oil->oil.mfcc_parent;
|
|
|
|
|
|
|
|
for (i = 0; i < MAXVIFS; ++i) {
|
2019-11-15 20:46:04 +01:00
|
|
|
if ((oil->mfcc_parent == i) &&
|
|
|
|
!pim_mroute_allow_iif_in_oil(c_oil, i)) {
|
|
|
|
oil->mfcc_ttls[i] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-11-15 18:29:04 +01:00
|
|
|
if (c_oil->oif_flags[i] & PIM_OIF_FLAG_MUTE)
|
|
|
|
oil->mfcc_ttls[i] = 0;
|
|
|
|
else
|
|
|
|
oil->mfcc_ttls[i] = c_oil->oil.mfcc_ttls[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 19:40:00 +01:00
|
|
|
/* This function must not be called directly 0
|
|
|
|
* use pim_upstream_mroute_add or pim_static_mroute_add instead
|
|
|
|
*/
|
|
|
|
static int pim_mroute_add(struct channel_oil *c_oil, const char *name)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2017-05-21 15:16:49 +02:00
|
|
|
struct pim_instance *pim = c_oil->pim;
|
2020-03-18 12:42:36 +01:00
|
|
|
struct mfcctl tmp_oil = { {0} };
|
2015-02-04 07:01:14 +01:00
|
|
|
int err;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-18 23:58:40 +02:00
|
|
|
pim->mroute_add_last = pim_time_monotonic_sec();
|
|
|
|
++pim->mroute_add_events;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-15 18:29:04 +01:00
|
|
|
/* Copy the oil to a temporary structure to fixup (without need to
|
|
|
|
* later restore) before sending the mroute add to the dataplane
|
|
|
|
*/
|
|
|
|
pim_mroute_copy(&tmp_oil, c_oil);
|
2016-06-27 18:54:30 +02:00
|
|
|
|
2016-08-02 15:21:51 +02:00
|
|
|
/* The linux kernel *expects* the incoming
|
|
|
|
* vif to be part of the outgoing list
|
|
|
|
* in the case of a (*,G).
|
|
|
|
*/
|
|
|
|
if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY) {
|
2019-11-15 18:29:04 +01:00
|
|
|
tmp_oil.mfcc_ttls[c_oil->oil.mfcc_parent] = 1;
|
2019-03-26 21:43:23 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
2016-08-02 15:21:51 +02:00
|
|
|
* If we have an unresolved cache entry for the S,G
|
|
|
|
* it is owned by the pimreg for the incoming IIF
|
|
|
|
* So set pimreg as the IIF temporarily to cause
|
|
|
|
* the packets to be forwarded. Then set it
|
|
|
|
* to the correct IIF afterwords.
|
2017-07-17 14:03:14 +02:00
|
|
|
*/
|
2016-08-02 15:21:51 +02:00
|
|
|
if (!c_oil->installed && c_oil->oil.mfcc_origin.s_addr != INADDR_ANY
|
|
|
|
&& c_oil->oil.mfcc_parent != 0) {
|
2019-11-15 18:29:04 +01:00
|
|
|
tmp_oil.mfcc_parent = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2017-05-18 23:58:40 +02:00
|
|
|
err = setsockopt(pim->mroute_socket, IPPROTO_IP, MRT_ADD_MFC,
|
2019-11-15 18:29:04 +01:00
|
|
|
&tmp_oil, sizeof(tmp_oil));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-02 15:21:51 +02:00
|
|
|
if (!err && !c_oil->installed
|
2016-07-12 21:16:53 +02:00
|
|
|
&& c_oil->oil.mfcc_origin.s_addr != INADDR_ANY
|
2019-11-15 18:29:04 +01:00
|
|
|
&& c_oil->oil.mfcc_parent != 0) {
|
|
|
|
tmp_oil.mfcc_parent = c_oil->oil.mfcc_parent;
|
2017-05-18 23:58:40 +02:00
|
|
|
err = setsockopt(pim->mroute_socket, IPPROTO_IP, MRT_ADD_MFC,
|
2019-11-15 18:29:04 +01:00
|
|
|
&tmp_oil, sizeof(tmp_oil));
|
2019-06-07 15:28:39 +02:00
|
|
|
}
|
2019-03-24 20:31:50 +01:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
if (err) {
|
|
|
|
zlog_warn(
|
|
|
|
"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_ADD_MFC): errno=%d: %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__FILE__, __func__, pim->mroute_socket, errno,
|
|
|
|
safe_strerror(errno));
|
2015-02-04 07:01:14 +01:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2016-12-06 16:08:09 +01:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2017-01-19 18:09:26 +01:00
|
|
|
char buf[1000];
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s(%s), vrf %s Added Route: %s", __func__, name,
|
|
|
|
pim->vrf->name,
|
2017-01-19 18:09:26 +01:00
|
|
|
pim_channel_oil_dump(c_oil, buf, sizeof(buf)));
|
2016-12-06 16:08:09 +01:00
|
|
|
}
|
|
|
|
|
2020-03-09 08:00:28 +01:00
|
|
|
if (!c_oil->installed) {
|
|
|
|
c_oil->installed = 1;
|
|
|
|
c_oil->mroute_creation = pim_time_monotonic_sec();
|
|
|
|
}
|
2019-04-01 08:38:28 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-15 20:09:13 +01:00
|
|
|
static int pim_upstream_get_mroute_iif(struct channel_oil *c_oil,
|
|
|
|
const char *name)
|
2019-11-15 19:40:00 +01:00
|
|
|
{
|
|
|
|
vifi_t iif = MAXVIFS;
|
|
|
|
struct interface *ifp = NULL;
|
|
|
|
struct pim_interface *pim_ifp;
|
|
|
|
struct pim_upstream *up = c_oil->up;
|
|
|
|
|
|
|
|
if (up) {
|
|
|
|
if (PIM_UPSTREAM_FLAG_TEST_USE_RPT(up->flags)) {
|
|
|
|
if (up->parent)
|
|
|
|
ifp = up->parent->rpf.source_nexthop.interface;
|
|
|
|
} else {
|
|
|
|
ifp = up->rpf.source_nexthop.interface;
|
|
|
|
}
|
|
|
|
if (ifp) {
|
|
|
|
pim_ifp = (struct pim_interface *)ifp->info;
|
|
|
|
if (pim_ifp)
|
|
|
|
iif = pim_ifp->mroute_vif_index;
|
|
|
|
}
|
|
|
|
}
|
2019-11-15 20:09:13 +01:00
|
|
|
return iif;
|
|
|
|
}
|
2019-11-15 19:40:00 +01:00
|
|
|
|
2019-11-15 20:09:13 +01:00
|
|
|
static int pim_upstream_mroute_update(struct channel_oil *c_oil,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
char buf[1000];
|
2019-11-15 19:40:00 +01:00
|
|
|
|
|
|
|
if (c_oil->oil.mfcc_parent >= MAXVIFS) {
|
|
|
|
/* the c_oil cannot be installed as a mroute yet */
|
|
|
|
if (PIM_DEBUG_MROUTE)
|
|
|
|
zlog_debug(
|
|
|
|
"%s(%s) %s mroute not ready to be installed; %s",
|
2019-11-15 20:09:13 +01:00
|
|
|
__func__, name,
|
2019-11-15 19:40:00 +01:00
|
|
|
pim_channel_oil_dump(c_oil, buf,
|
|
|
|
sizeof(buf)),
|
|
|
|
c_oil->installed ?
|
|
|
|
"uninstall" : "skip");
|
|
|
|
/* if already installed flush it out as we are going to stop
|
|
|
|
* updates to it leaving it in a stale state
|
|
|
|
*/
|
|
|
|
if (c_oil->installed)
|
|
|
|
pim_mroute_del(c_oil, name);
|
|
|
|
/* return success (skipped) */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pim_mroute_add(c_oil, name);
|
|
|
|
}
|
|
|
|
|
2019-11-15 20:12:41 +01:00
|
|
|
/* IIF associated with SGrpt entries are re-evaluated when the parent
|
|
|
|
* (*,G) entries IIF changes
|
|
|
|
*/
|
|
|
|
static void pim_upstream_all_sources_iif_update(struct pim_upstream *up)
|
|
|
|
{
|
|
|
|
struct listnode *listnode;
|
|
|
|
struct pim_upstream *child;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(up->sources, listnode,
|
|
|
|
child)) {
|
|
|
|
if (PIM_UPSTREAM_FLAG_TEST_USE_RPT(child->flags))
|
|
|
|
pim_upstream_mroute_iif_update(child->channel_oil,
|
|
|
|
__func__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 20:09:13 +01:00
|
|
|
/* In the case of "PIM state machine" added mroutes an upstream entry
|
|
|
|
* must be present to decide on the SPT-forwarding vs. RPT-forwarding.
|
|
|
|
*/
|
|
|
|
int pim_upstream_mroute_add(struct channel_oil *c_oil, const char *name)
|
|
|
|
{
|
2019-11-15 20:12:41 +01:00
|
|
|
vifi_t iif;
|
|
|
|
|
|
|
|
iif = pim_upstream_get_mroute_iif(c_oil, name);
|
|
|
|
|
|
|
|
if (c_oil->oil.mfcc_parent != iif) {
|
|
|
|
c_oil->oil.mfcc_parent = iif;
|
|
|
|
if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY &&
|
|
|
|
c_oil->up)
|
|
|
|
pim_upstream_all_sources_iif_update(c_oil->up);
|
|
|
|
} else {
|
|
|
|
c_oil->oil.mfcc_parent = iif;
|
|
|
|
}
|
2019-11-15 20:09:13 +01:00
|
|
|
|
|
|
|
return pim_upstream_mroute_update(c_oil, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for IIF changes and update the dateplane entry only if the IIF
|
|
|
|
* has changed.
|
|
|
|
*/
|
|
|
|
int pim_upstream_mroute_iif_update(struct channel_oil *c_oil, const char *name)
|
|
|
|
{
|
|
|
|
vifi_t iif;
|
|
|
|
char buf[1000];
|
|
|
|
|
|
|
|
iif = pim_upstream_get_mroute_iif(c_oil, name);
|
|
|
|
if (c_oil->oil.mfcc_parent == iif) {
|
|
|
|
/* no change */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
c_oil->oil.mfcc_parent = iif;
|
|
|
|
|
2019-11-15 20:12:41 +01:00
|
|
|
if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY &&
|
|
|
|
c_oil->up)
|
|
|
|
pim_upstream_all_sources_iif_update(c_oil->up);
|
|
|
|
|
2019-11-15 20:09:13 +01:00
|
|
|
if (PIM_DEBUG_MROUTE_DETAIL)
|
|
|
|
zlog_debug("%s(%s) %s mroute iif update %d",
|
|
|
|
__func__, name,
|
|
|
|
pim_channel_oil_dump(c_oil, buf,
|
|
|
|
sizeof(buf)), iif);
|
|
|
|
/* XXX: is this hack needed? */
|
|
|
|
c_oil->oil_inherited_rescan = 1;
|
|
|
|
return pim_upstream_mroute_update(c_oil, name);
|
|
|
|
}
|
|
|
|
|
2019-11-15 19:40:00 +01:00
|
|
|
int pim_static_mroute_add(struct channel_oil *c_oil, const char *name)
|
|
|
|
{
|
|
|
|
return pim_mroute_add(c_oil, name);
|
|
|
|
}
|
|
|
|
|
2019-11-15 20:09:13 +01:00
|
|
|
void pim_static_mroute_iif_update(struct channel_oil *c_oil,
|
|
|
|
int input_vif_index,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
if (c_oil->oil.mfcc_parent == input_vif_index)
|
|
|
|
return;
|
|
|
|
|
|
|
|
c_oil->oil.mfcc_parent = input_vif_index;
|
|
|
|
if (input_vif_index == MAXVIFS)
|
|
|
|
pim_mroute_del(c_oil, name);
|
|
|
|
else
|
|
|
|
pim_static_mroute_add(c_oil, name);
|
|
|
|
}
|
|
|
|
|
2016-12-06 16:08:09 +01:00
|
|
|
int pim_mroute_del(struct channel_oil *c_oil, const char *name)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2017-05-21 15:16:49 +02:00
|
|
|
struct pim_instance *pim = c_oil->pim;
|
2015-02-04 07:01:14 +01:00
|
|
|
int err;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-18 23:58:40 +02:00
|
|
|
pim->mroute_del_last = pim_time_monotonic_sec();
|
|
|
|
++pim->mroute_del_events;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-27 05:13:42 +02:00
|
|
|
if (!c_oil->installed) {
|
2016-07-24 01:54:51 +02:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2017-01-19 18:09:26 +01:00
|
|
|
char buf[1000];
|
|
|
|
zlog_debug(
|
2017-01-22 00:18:08 +01:00
|
|
|
"%s %s: vifi %d for route is %s not installed, do not need to send del req. ",
|
2020-03-05 19:17:54 +01:00
|
|
|
__FILE__, __func__, c_oil->oil.mfcc_parent,
|
2017-01-19 18:09:26 +01:00
|
|
|
pim_channel_oil_dump(c_oil, buf, sizeof(buf)));
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
return -2;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2017-05-18 23:58:40 +02:00
|
|
|
err = setsockopt(pim->mroute_socket, IPPROTO_IP, MRT_DEL_MFC,
|
2017-01-22 00:18:08 +01:00
|
|
|
&c_oil->oil, sizeof(c_oil->oil));
|
|
|
|
if (err) {
|
|
|
|
if (PIM_DEBUG_MROUTE)
|
|
|
|
zlog_warn(
|
|
|
|
"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_DEL_MFC): errno=%d: %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__FILE__, __func__, pim->mroute_socket, errno,
|
2017-01-22 00:18:08 +01:00
|
|
|
safe_strerror(errno));
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2016-09-27 00:39:54 +02:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
2017-01-19 18:09:26 +01:00
|
|
|
char buf[1000];
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s(%s), vrf %s Deleted Route: %s", __func__, name,
|
|
|
|
pim->vrf->name,
|
2017-08-01 00:02:23 +02:00
|
|
|
pim_channel_oil_dump(c_oil, buf, sizeof(buf)));
|
2016-12-06 16:08:09 +01:00
|
|
|
}
|
2017-01-19 18:09:26 +01:00
|
|
|
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-04-05 22:14:12 +02:00
|
|
|
// Reset kernel installed flag
|
2016-07-12 21:22:10 +02:00
|
|
|
c_oil->installed = 0;
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2016-07-13 17:41:41 +02:00
|
|
|
|
|
|
|
void pim_mroute_update_counters(struct channel_oil *c_oil)
|
|
|
|
{
|
2017-05-21 15:16:49 +02:00
|
|
|
struct pim_instance *pim = c_oil->pim;
|
2016-07-13 17:41:41 +02:00
|
|
|
struct sioc_sg_req sgreq;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-07-13 17:41:41 +02:00
|
|
|
c_oil->cc.oldpktcnt = c_oil->cc.pktcnt;
|
|
|
|
c_oil->cc.oldbytecnt = c_oil->cc.bytecnt;
|
|
|
|
c_oil->cc.oldwrong_if = c_oil->cc.wrong_if;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-27 05:13:42 +02:00
|
|
|
if (!c_oil->installed) {
|
2017-07-13 03:16:00 +02:00
|
|
|
c_oil->cc.lastused = 100 * pim->keep_alive_time;
|
2016-09-27 05:13:42 +02:00
|
|
|
if (PIM_DEBUG_MROUTE) {
|
|
|
|
struct prefix_sg sg;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-27 05:13:42 +02:00
|
|
|
sg.src = c_oil->oil.mfcc_origin;
|
|
|
|
sg.grp = c_oil->oil.mfcc_mcastgrp;
|
2021-02-08 02:15:22 +01:00
|
|
|
zlog_debug(
|
|
|
|
"Channel%s is not installed no need to collect data from kernel",
|
|
|
|
pim_str_sg_dump(&sg));
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
return;
|
2016-09-27 05:13:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&sgreq, 0, sizeof(sgreq));
|
|
|
|
sgreq.src = c_oil->oil.mfcc_origin;
|
|
|
|
sgreq.grp = c_oil->oil.mfcc_mcastgrp;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-22 20:59:24 +02:00
|
|
|
pim_zlookup_sg_statistics(c_oil);
|
2017-05-18 23:58:40 +02:00
|
|
|
if (ioctl(pim->mroute_socket, SIOCGETSGCNT, &sgreq)) {
|
2019-10-08 16:36:02 +02:00
|
|
|
struct prefix_sg sg;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-10-08 16:36:02 +02:00
|
|
|
sg.src = c_oil->oil.mfcc_origin;
|
|
|
|
sg.grp = c_oil->oil.mfcc_mcastgrp;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-10-08 16:36:02 +02:00
|
|
|
zlog_warn("ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=%s: errno=%d: %s",
|
|
|
|
(unsigned long)SIOCGETSGCNT, pim_str_sg_dump(&sg),
|
|
|
|
errno, safe_strerror(errno));
|
2017-07-17 14:03:14 +02:00
|
|
|
return;
|
2016-09-27 05:13:42 +02:00
|
|
|
}
|
2016-07-13 17:41:41 +02:00
|
|
|
|
|
|
|
c_oil->cc.pktcnt = sgreq.pktcnt;
|
|
|
|
c_oil->cc.bytecnt = sgreq.bytecnt;
|
|
|
|
c_oil->cc.wrong_if = sgreq.wrong_if;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|