Commit Graph

241 Commits

Author SHA1 Message Date
Anuradha Karuppiah
448139e704 pimd: stop overloading SRC_IGMP upstream for vxlan local membership
A local membership is created on the vxlan termination device ipmr-lo. This
is done to -
1. Pull multicast vxlan tunnel traffic to the VTEP for termination by
triggering JoinDesired on the BUM multicast group.
2. Include the OIF in the mroute to signal to the dataplane component
that flow needs to be vxlan terminated.

Earlier we were overloading the PIM_UPSTREAM_FLAG_MASK_SRC_IGMP for
this local membership creation but that is creating confusion both in
the state machine and in the show outputs. To avoid that we use the
more apparent PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_TERM. With this change -
1. We get LHR functionality for VXLAN_TERM mroutes
2. OIF is populated with PIM_OIF_FLAG_PROTO_PIM only

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-02-14 09:18:30 -08:00
Quentin Young
f08e675074 pimd: readd iph length checks
Kernel might not hand us a bad packet, but better safe than sorry here.
Validate the IP header length field. Also adds an additional check that
the packet length is sufficient for an IGMP packet, and a check that we
actually have enough for an ip header at all.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-22 13:34:40 -05:00
Jafar Al-Gharaibeh
94c1ae82da
Merge pull request #5355 from AnuradhaKaruppiah/pim-state-machine-fixes
PIM state machine fixes
2019-12-06 17:47:07 -06:00
David Lamparter
2b64873d24 *: generously apply const
const const const your boat, merrily down the stream...

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-02 15:01:29 +01:00
Anuradha Karuppiah
2bc31c4422 pimd: prevent LHR from register forwarding packets for non-FHR sources
SPT switchover handling is done by adding pimreg in the OIL of the (*, G)
entry on the LHR. This causes multicast data with that destination to be
sent to pimd as IGMPMSG_WHOLEPKT. These packets trigger creation of (S,G)
and also register forwarding. However register forwarding must only be done
if the router is also a FHR. That FHR check was missing causing strange
source registrations from multicast routers that were not directly
connected to the source.

Relevant logs from LHR -
PIM: pim_mroute_msg: pim kernel upcall WHOLEPKT type=3 ip_p=0 from fd=9 for (S,G)=(6.0.0.30,239.1.1.111) on pimreg vifi=0  size=98
PIM: Sending (6.0.0.30,239.1.1.111) Register Packet to 81.0.0.5
PIM: pim_register_send: Sending (6.0.0.30,239.1.1.111) Register Packet to 81.0.0.5 on swp2

And 6.0.0.30 is clearly not directly connected on that router -
root@tor-11:~# ip route |grep 6.0.0.30 -A2
6.0.0.30 proto ospf metric 20
	nexthop via 6.0.0.22 dev swp1 weight 1 onlink
	nexthop via 6.0.0.23 dev swp2 weight 1 onlink
root@tor-11:~#

Ticket: CM-24549

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-11-15 14:16:09 -08:00
Anuradha Karuppiah
60eb7e6b80 pimd: enforce PIM_ENFORCE_LOOPFREE_MFC at the time of MFC programming
This is needed for two reasons -
1. The inherited OIL needs to be setup independent of the RPF interface
to allow correct computation of the JoinDesired macro.
2. The RPF interface is computed at the time of MFC programming so
it is not possible to permanently evict the OIF at that time oif_add

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-11-15 14:16:08 -08:00
Anuradha Karuppiah
a53a9b3e6b pimd: fixup join desired handling to match the RFC defined macro
This commit includes the following changes -
1. kat needs to be included when evaluting join desired on a (S,G)
   entry.
2. there were cases where we were adding OIF based on joindesired
   being true for unrelated reasons (on other OIFs). cleaned up those
   cases.
3. make all calls to pim_upstream_switch conditional on the JoinDesired
   macro.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-11-15 12:00:29 -08:00
Anuradha Karuppiah
70c86421c9 pimd: update (S,G,rpt)'s IIF when the parent (*,G)'s IIF changes
If a source is being forwarded along the RPT it uses the parent (*,G)'s
IIF. When the parent's IIF changes all the children need to be updated

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-11-15 12:00:29 -08:00
Anuradha Karuppiah
7984af1840 pimd: set mfcc_parent at the time of MFCC programming
mfcc_parent for an (S, G) entry was being updated on any upstream RPF
change. With the change to use RPT for (S,G) in some cases we can no
longer do that. Instead the upstream entry's RPF neigbor is managed
separately form the channel_oil's mfcc_parent i.e. via NHT. And the
mfcc_parent is evaluated at the time of mroute programming.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-11-15 12:00:29 -08:00
Anuradha Karuppiah
69e3538cd8 pimd: decide between SPT based and RPT based forwarding
An (S,G) mroute can be created as a result of rpt prune. However that
entry needs to stay on the parent (*,G)'s tree (IIF) till a decision is
made to switch the source to the SPT.

The decision to stay on the RPT is made based on the SPTbit setting
according to - RFC7761, Section 4.2 “Data Packet Forwarding Rules”

However those rules are hard to achieve when hw acceleration i.e.
control and data planes are separate. So instead of relying on data
we make the decision of using SPT if we have decided to join the SPT -
Use_RPT(S,G) {
    if (Joined(S,G) == TRUE          // we have decided to join the SPT
            OR Directly_Connected(S) == TRUE // source is directly connected
            OR I_am_RP(G) == TRUE)   // RP
        //use_spt
        return FALSE;
    //use_rpt
    return TRUE;
}

To make that change some re-org was needed -
1. pim static mroutes and dynamic (upstream mroutes) top level APIs
have been separated. This is to limit the state machine to dynamic
mroutes.
2. c_oil->oil.mfcc_parent is re-evaluated based on if we decided
to use the SPT or stay on the RPT.
3. upstream mroute re-eval is done when any of the criteria involved
in Use_RPT changes.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-11-15 12:00:29 -08:00
Anuradha Karuppiah
5a5f404e1b pimd: build a temp copy of the OIL for kernel mroute add
1. This avoids the needs to re-run "muting" decisions.
2. Avoids the need to restore's pim OIL after fixup and send to kernel
(this is getting harder to manage).

In the future we need to also move the PIM maintained channel OIL from
an array of MAXVIFs to a simple DLL. This will be a significant
optimization in memory usage and preformance (OIL reads, copies etc).

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-11-15 09:29:04 -08:00
Donald Sharp
23fc858a5e pimd: debug igmp trace turns on non igmp debugs
When you turn on `debug igmp trace` we are seeing a bunch
of debugs associated with pim processing.  This is because we were
using PIM_DEBUG_TRACE which is both `debug igmp trace` and `debug pim trace`
when tracing igmp code it would be nice to only see igmp work.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-12 09:38:04 -05:00
Donald Sharp
fb9670aa53 pimd: Fix zlog_warn when we mean debug and vice versa
There are several places in the pim where we are mixing up
zlog_warn w/ zlog_debug and vice versa.  If we are protecting
a zlog_warn w/ a debug is it really a warn?  If we have an actual
error situation we should also warn about it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-08 10:36:02 -04:00
David Lamparter
0cf6db21ec *: frr_elevate_privs -> frr_with_privs
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:18:35 +02:00
Donald Sharp
02434c43a5 pimd: Always create upstream reference when adding channel oil
Modify the code to create an upstream reference whenever the code
creates an channel_oil via the pim_mroute.c code.  This code also
starts a keep alive timer to clean up the reference if we do
nothing with it after the normal time.

I've left alone the source->channel_oil creation because these
are kept and tracked independently already.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-18 07:56:37 -04:00
Donald Sharp
46dd6edb06 pimd: pim_upstream *always* creates a channel_oil
Modify code base so that pim_upstream *always* creates a channel_oil
and as such we do not need to create it later or play other games.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-18 07:56:37 -04:00
Donald Sharp
afb2f47031 pimd: Add pim_channel_oil_change_iif
Add a function that allows you to modify the channel oil's incoming
interface and to appropriately install/remove it from the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-18 07:54:04 -04:00
Donald Sharp
9e132a491a pimd: Ensure channel_oil_add is created through all paths
If we create a channel_oil ensure that all paths that
we can go down will create one.  Future commits
can remove the (up->channel_oil) tests.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-19 19:13:10 -04:00
Donald Sharp
11884868d4 pimd: ALLOC functions cannot fail.
There is no need to check for ALLOC function failures
in the code base.  If we cannot get more memory we
assert.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-19 19:07:12 -04:00
Donald Sharp
8a3e7e9ed9 pimd: Add debugs for channel_oil creation and deletion
Add some debugs so we can see channel oil creation and deletion
events.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-14 19:22:43 -04:00
Donald Sharp
42e01756c1 pimd: Compiler warning about unset usage
While this is impossible, make the compilers a bit happier
for those of us having to use something old.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com
2019-06-07 09:29:45 -04:00
Anuradha Karuppiah
37c3fd98e7 pimd: handling termination device in the MFC
1. special handling of term device in orig mroutes -
The multicast-vxlan termination device ipmr-lo is added to the (*, G)
mroute -
(0.0.0.0, 239.1.1.100)          Iif: uplink-1   Oifs: uplink-1 ipmr-lo
This means that it will be inherited into all the SG entries including the
origination mroute. However we cannot terminate the traffic we originate
so some special handling is needed to exclude the termination device
in the origination entries -
27.0.0.7, 239.1.1.100)          Iif: lo         Oifs: uplink-1

2. special handling of term device on the MLAG pair -
Both MLAG switches pull down BUM-MDT traffic but only one (the DF) can
terminate the traffic. The non-DF must not exclude the termination device
from the MFC to prevent dups to the overlay.
DF -
root@TORC11:~# ip mr |grep "(0.0.0.0, 239.1.1.100)"
(0.0.0.0, 239.1.1.100)           Iif: uplink-1   Oifs: uplink-1 ipmr-lo  State: resolved
root@TORC11:~#
non-DF -
root@TORC12:~# ip mr |grep "(0.0.0.0, 239.1.1.100)"
(0.0.0.0, 239.1.1.100)           Iif: uplink-1   Oifs: uplink-1  State: resolved
root@TORC12:~#

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-04-20 08:33:23 -07:00
Anuradha Karuppiah
76e4825a1c pimd: provide a per-SG control to disabled register encapsulation of data
In a MLAG setup both of the VTEPs can rx and reg-encapsulate BUM traffic
toward the RP. To prevent these duplicates we need a mechanism to disable
register encaps on specific mroutes.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-04-20 08:33:21 -07:00
Jafar Al-Gharaibeh
dbf2f94c2c
Merge pull request #4060 from donaldsharp/pim_cherrybomb
Pim cherrybomb
2019-04-03 23:02:32 -05:00
Donald Sharp
a4b43d14f0
Merge pull request #4053 from patrasar/3672
pimd: Introduce mroute_creation in channel oil data structure
2019-04-02 13:47:28 -04:00
Donald Sharp
ade155e146 pimd: pim_nexthop_lookup should return true/false
The current reverse logic led to this code construct
if (!pim_nexthop_lookup(...)) {
	//Do something successfull
}

This is backwards and will cause logic errors when people
use this code.  Fix to use true/false for success/failure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-02 08:20:36 -04:00
Sarita Patra
e7cd85bda7 pimd: Introduce mroute_creation in channel oil data structure
Issue: (*,G) mroute uptime is not updated in mroute table,
after deleting and adding the RP

Root cause: When RP gets deleted or becomes not reachable, then
we un-install the entry from the kernel, but still maintains the
entry in the stack. When  RP gets re-configured or becomes reachable,
"show ip mroute" shows the uptime, when the channel_oil gets created.

Fix: Introduce a new time mroute_creation in the channel_oil, gets
updated when mroute gets installed in the kernel.

Signed-off-by: Sarita Patra <saritap@vmware.com>
2019-03-31 23:38:28 -07:00
Donald Sharp
4171408128 pimd: Cleanup extra paranthesis around S,G printout
When we are displaying S,G string data we already auto
display the string as (S,G) no need to have ((S,G)).
Cleanup some that were found during log look through.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-28 15:51:49 -04:00
Sarita Patra
957d93eaf2 pimd: Handling Null incoming interface of dummy upstream
When FRR receives IGMP/PIM (*, G) join and RP is not configured or not
reachable, then we are creating a dummy upstream with incoming interface
as NULL and upstream address as INADDR_ANY.

Added upstream address and incoming interface validation where it is necessary,
before doing any operation on the upstream.

Signed-off-by: Sarita Patra <saritap@vmware.com>
2019-02-24 21:26:58 -08:00
Donald Sharp
75373ccac4 pimd: Move packet_process variable to pim_router
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-04 12:23:39 -05:00
Donald Sharp
36417fcc20 pimd: Create a struct pim_router and move thread master into it
Create a `struct pim_router` and move the thread master into it.
Future commits will further move global varaibles into the pim_router
structure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-04 12:21:00 -05:00
Donald Sharp
e5a2ebe691 pimd: Send 1 on all systems for MRT_INIT
When sending a sockoption for MRT_INIT, *bsd requires that
the data passed in must be 1.  While linux does not, the
code was sending in a positive value that was causing issues
on *bsd of protocol not supported.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-31 07:26:35 -04:00
Donald Sharp
f0b009a4db pimd: *bsd needs priviledge escalation to init PIM
When trying to run PIM on *bsd, the kernel expects to only
allow the pim kernel socket to work if we elevate priviledges.
So do so.

This commit gets us further in the startup of PIM on *bsd
but is not sufficient to get it fully started yet.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-31 07:26:35 -04:00
Donald Sharp
b5469d021c pimd: blackhole traffic when we are not DR for Stream received
Suppose we have a bridge with a host and two routers attached
to it.

r1     r2
|      |
--------
    |
  host

host is sending traffic.
r1 and r2 are pim neighbors and r2 is the DR.

Both r1 and r2 will receive data from the stream up the pim
kernel socket.  r1 will notice that it is not the DR and
stop processing in pim.  This code adds a bit more code to blackhole
the route when r1 detects it is not the DR in this scenario.

This is being done because the kernel is both keeping state and
sending data to the pim process to continue processing this.
Additionally if we happen to be running this on a asic, then
blackholing the route in the asic can save a significant amount
of cpu time handling this situation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-21 11:41:46 -04:00
David Lamparter
633fc9b133 *: frr_elevate_privs whitespace fixes
(... and one superfluous variable removed)

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
David Lamparter
01b9e3fd0d *: use frr_elevate_privs() (1/2: coccinelle)
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
Quentin Young
af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp
3613d89844 pimd: Convert over to use LIB_ERR_XXX for zlog_err
Convert, where appropriate, the zlog_err functions to zlog_ferr
for the LIB_ERR_XXX enums

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
F. Aragon
2ffc213bf8
ospfd pimd: null check (PVS-Studio)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-06 00:49:24 +02:00
F. Aragon
b575a12c87
bgpd lib ospfd pimd ripngd: null chk (PVS-Studio)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-03 15:39:50 +02:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Donald Sharp
d1ee84e951 pimd: We do not need to BINDTODEVICE for default vrf
The changes introduced in PR #1044 caused pim to notice
when a setsockopt call failed.  The kicker here is that
this used to just work because we ignored the issue
pre.  So VRF's need to BINDTODEVICE to get igmp callbacks
but the default vrf does not need to do so.

With the fix we now see IGMP group join:
root@dell-s6000-02 ~/frr# vtysh -c "show ip igmp group"
Interface Address         Group           Mode Timer    Srcs V Uptime
br1       20.0.11.1       232.2.3.4       EXCL 00:04:14    1 3 00:00:05

Fixes: #1121
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-07 11:14:30 -04:00
Donald Sharp
e691f179b6 pimd: Cleanup a variety of SA issues
1) Error check return from setsockopt and sockets
2) Check return codes for str2prefix
3) Clean up some potential NULL References

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-24 20:34:28 -04:00
Donald Sharp
d62fd596f9 pimd: Add some more vrf debug information
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-02 07:57:24 -04:00
Donald Sharp
08f4f9013c pimd: Clean up mroute_add_vif debugging
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-02 07:57:13 -04:00
Donald Sharp
19b807ca17 pimd: Allow the keepalive time to be per vrf.
Allow the keepalive period to be per vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-28 08:03:50 -04:00
Donald Sharp
df766618e2 pimd: Set sptbit when we send the register stop
Ticket: CM-15512
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:40 -04:00
Donald Sharp
0885a9f1f4 pimd: Fix code to not send joins when SGRPT Prune is received
When we receive a SGRPT Prune we were switching the upstream
to JOINED and immediately sending a join.  This was not
the right thing to do.

This was happening because we were making decisions about the
new ifchannel before it was fully formed.

Rework ifchannel startup to provide enough information to
the pim upstream data structure to make the right decisions

Ticket: CM-16425
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:40 -04:00
Donald Sharp
1ef8c24eb9 pimd: We may receive a igmp packet in on unconfiged intf
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
466e4e5b16 pimd: Fix dropped(?) telling of the kernel to recv cmsg data
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
90450a3d25 pimd: Bind pim kernel fd to appropriate vrf
Bind the pim kernel fd to the appropriate vrf, modify
the callback up into pim with the IGMP report to
retrieve the incoming interface and use that to
lookup the correct interface to use.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
1eca85760b pimd: Fix crash when attempting to use channel_oil->pim before it is assigned
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
2002dcdb94 pimd: Cleanup some basic crashes from mistakes made converting to vrf
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:38 -04:00
Donald Sharp
7c2bfc2a1d pimd: Add some vrf knowledge to some debugging statements
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:37 -04:00
Donald Sharp
6f439a7058 pimd: Cleanup pim_ssm.c to use 'struct pim_instance *'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:36 -04:00
Donald Sharp
9a0f71c994 pimd: Finish up pim_mroute.c 'struct pim_instance' awareness
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:36 -04:00
Donald Sharp
611925dc02 pimd: Convert channel_oil_hash and list into 'struct pim_instance *'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:36 -04:00
Donald Sharp
7cfc7bcfe7 pimd: Convert vif and ifindex lookups to use 'struct pim_instance *'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:36 -04:00
Donald Sharp
d9c9a9ee06 pimd: Convert pim_rp.c to use 'struct pim_instance *'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:36 -04:00
Donald Sharp
9b29ea95fc pimd: Remove pimg from pim_upstream.c
Move the upstream_list, hash and wheel into 'struct pim_instance'
Remove all pimg to pim in pim_upstream

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:35 -04:00
Donald Sharp
fec883d95a pimd: pim_rp.c -> convert pimg to pim
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:35 -04:00
Donald Sharp
f509d94116 pimd: Fix mistake in uplifting to new thread model
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:35 -04:00
Donald Sharp
856e863fda pimd: If c_oil->pim is set use that pim instance in pim_mroute.c
As a transitory mechanism, if c_oil->pim is set, use that particular
pim instance, else use the default pimg.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:35 -04:00
Donald Sharp
44a1bd88ee pimd: Use actual vrf table_id for pim vrf creation
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
ea3d967be0 pimd: pim_mroute_[add|del]_vif become VRF aware
Make the pim_mroute_[add|del]_vif functions be vrf aware.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
f507c1966e pimg: Actually properly create the pim socket per vrf
Create the actual pim socket per vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
405d63578a pimd: Convert upcalls from kernel to use appropriate pim instance
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
8ea5d94477 pimd: Move thread read to struct pim_instance
When we are handling the thread read/writes for
a pim mroute socket, make it so that it can
be appropriately handled by the 'struct pim_instance'
instead of defaulting to the default VRF's

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
cdbfaec57b pimd: Call code to create appropriate MRT_TABLE
When dealing with vrf's we need to create a table within
the linux kernel to handle the vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
61e99c94ae pimd: Ensure a 0 read fails cleanly
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
6beed98735 pimd: Modify pim_mroute_socket_[enable|disable] to be vrf aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:34 -04:00
Donald Sharp
fe232c1948 pimd: Use setsockopt_so_recvbuf instead of doing it ourselves
This change allows other non-linux platforms to be a bit
more forgiving if we ask for a very very large size.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:33 -04:00
Donald Sharp
ff673f4525 pimd: Start conversion of socket and counters for VRF
Convert the socket fd to be owned by the pimg pointer as
well as the counters associated with the fd.  This will
allow us to future proof our code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:33 -04:00
Donald Sharp
0708beb1f4 pimd: Cleanup use of VRF_DEFAULT to pimg->vrf_id
Use the appropriate vrf_id instead of always defaulting
to VRF_DEFAULT

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:33 -04:00
whitespace / reindent
d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
Donald Sharp
4a07939b68 pimd: Thread changes allow pim to crash a boo
When we add a thread pointer to thread_add_XXX functions
when the specified function is called, thread.c is setting
the thread pointer to NULL.  This was causing pim to
liberally pull it's zassert grenade pin's.

Additionally clean up code to not set the NULL pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-17 20:33:43 -04:00
David Lamparter
896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
Quentin Young
ffa2c8986d *: remove THREAD_ON macros, add nullity check
The way thread.c is written, a caller who wishes to be able to cancel a
thread or avoid scheduling it twice must keep a reference to the thread.
Typically this is done with a long lived pointer whose value is checked
for null in order to know if the thread is currently scheduled.  The
check-and-schedule idiom is so common that several wrapper macros in
thread.h existed solely to provide it.

This patch removes those macros and adds a new parameter to all
thread_add_* functions which is a pointer to the struct thread * to
store the result of a scheduling call. If the value passed is non-null,
the thread will only be scheduled if the value is null. This helps with
consistency.

A Coccinelle spatch has been used to transform code of the form:

  if (t == NULL)
    t = thread_add_* (...)

to the form

  thread_add_* (..., &t)

The THREAD_ON macros have also been transformed to the underlying
thread.c calls.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09 20:44:19 +00:00
Renato Westphal
94f6a203b7 Merge pull request #345 from chiragshah6/pim_dev
pimd: Pim ECMP changes along with nexthop tracking using cached DB
2017-04-24 16:59:58 -03:00
Chirag Shah
cba4448178 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-06 11:18:07 -07:00
Donald Sharp
2830b01863 pimd: Fix crash when failure to create upstream
When we have a *,G mroute that starts receiving any particular
S,G, we will get wholepkt callbacks due to the pimreg in the
OIL for the *,G.

So we need to do SPT switchover, but this can fail if we
do not have a path to the S( but we do to the RP!).

In this case fail gracefully.

Ticket: CM-15621
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-04-05 12:38:12 -04:00
Donald Sharp
850a9f99b8 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-04-05 12:38:12 -04:00
Donald Sharp
e43223bcc3 pimd: Cleanup unused variable write
There exists a common pattern in pim where we were setting
a variable to a value in the error case when we would no
longer need it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-31 16:28:22 -04:00
anuradhak
d2772e7b65 pimd: Remove interface type SSM.
Interface type has been replaced with the SSM range config. And SSM
groups can now co-exists with ASM groups. I have left the pim ssm
per-interface cli control hidden. It now enables pim-sm with a warning.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-15344
Testing Done: pim-smoke
2017-03-23 09:48:04 -07:00
anuradhak
15a5dafe44 pimd: Allow SSM groups to co-exist with ASM groups.
SSM groups (232/8 or user configured SSM range) can exist in the same
multicast network as ASM groups. For such groups all RPT related state
machine operations have to be skipped as defined by section 4.8 of
RFC4601 -
1. Source registration is skipped for SSM groups. For SSM groups mroute
is setup on the FHR when a new multicast flow is rxed; however source
registration (i.e. pimreg join) is skipped. This will let the ASIC black
hole the traffic till a valid OIL is added to the mroute.
2. (*,G) IGMP registrations are ignored for SSM groups.

Sample output:
=============
fhr#  sh ip pim group-type
SSM group range : 232.0.0.0/8
fhr#  sh ip pim group-type 232.1.1.1
Group type: SSM
fhr#  sh ip pim group-type 239.1.1.1
Group type: ASM
fhr#

Sample config:
=============
fhr(config)# ip pim ssm prefix-list ssm-ranges
fhr(config)#

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-15344
Testing Done:
1. SSM/ASM source-registration/igmp-joins.
2. On the fly multicast group type changes.
3. pim-smoke.
2017-03-23 09:47:53 -07:00
Donald Sharp
e711cd3cec pimd: Carefully Reconstruct FHR state when interface bounces
When an interface bounces and we receive a packet before
pim has a chance to fully bring the 'struct pim_usptream'
back up correctly, first check to see if we already have
an associated data structure before creating it again.

This removes a case where both the c_oil and up ref counts
were being incremented and never removed properly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-16 18:58:01 -04:00
Chirag Shah
1bc9827622 pimd: Nexthop tracking support
Add pim Nexthop tracking feature 1st part where, specific RP or Source address (unicast address)
register with Zebra. Once nexthop update received from Zebra for a given address, scan RP or upstream
entries impacted by the change in nexthop.

Reviewed By: CCR-5761, Donald Sharp <sharpd@cumulusnetworks.com>
Testing Done: Tested with multiple RPs and multiple *,G entries at LHR.
Add new Nexthop or remove one of the link towards RP and verify RP and upstream nexthop update.
similar test done at RP with multiple S,G entries to reach source.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-03-16 18:53:28 -04:00
anuradhak
0c2ebf00a6 pimd: add new/distinct enumeration for pim register state
With the separation of register-state and upstream-join-state we no
longer need an enumeration that covers both states. This commit includes
the following -
1. Defined new enumeration for reg state (this 1:1 with RFC4601).
2. Dropped JOIN_PENDING enum value from upstream join state. RFC4601
only define two values NOT_JOINED and JOINED for this state.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-14700
Testing Done: Verified register setup manually and ran pim-smoke
2017-03-10 10:48:41 -08:00
anuradhak
e0e127b009 pimd: Separate the register and upstream join states on the FHR
On the FHR upstream-join-state is not particularly relevant as we
don't need to send upstream JPs for the SG. So that field was being
overloaded with the register-state. However some of the events that
triggered changes to the JoinDesired macro were accidentally overwriting
the state with join info (instead of treating it as register info)
confusing the register state machine.

To make the PIM RFC macros' implemention simple I have separated out
the register-state. And upstream->state now solely describes the
upstream-join-state independent of the role of the PIM router.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-14700
Testing Done: verified pim-register state-machine with separate and
combined FHR/RP routers. Also ran pim-smoke.
2017-03-10 10:48:38 -08:00
Donald Sharp
b8d16be287 pimd: Hide 'ip multicast-routing' command
Automatically turn on pim if the daemon is turned on.
Hide the 'ip multicast-routing' command
Disable the 'no ip multicast-routing' command
Do not display the 'ip multicast-routing' command.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-02 10:33:23 -05:00
Donald Sharp
b7ddd2ec48 pimd: Intelligently drop wrvifwhole packets in some cases
Suppose we have this

(*,G) IIF = swp1  OIL: swp3
(S,G) IIF = swp2  OIL: swp3 swp4

There exists situations where we can receive the mcast
packet for (S,G) on both swp1 and swp2.  In this case
the packet received on swp1 will be sent from the kernel
to us as a WRVIF and WRVIFWHOLE.

As per normal, WRVIF packet processing handles the assert
case so we know we have not received the packet on a downstream
interface, so no assert.

The WRVIFWHOLE packet processing can then check to see if
it received the packet as a result of the (*,G) mroute
from upstream.  If we have then we can safely drop
the packet.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-24 10:03:41 -05:00
Chirag Shah
e81d9709ff pimd: ifdown sequnce stale report entry
Ticket: CM-14652
Testing Done: Tested via sending IGMP report and flap port and verified pim upstream and mroute, the entry is deleted. Run pim-smoke

Even after Report received port down event, IGMP entry alawys exists in upstream, mroute, kernel.
The entry exist because it was recreated after delete due missing check if group has no more source list,
    mode is exclude, last source address was * means (*, G) so do not trigger to create entry.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-14 15:54:29 -05:00
Chirag Shah
429a291bf0 pimd: mroute entries unresolved IIF issue
Ticket:CM-14056
Reviewed By:sharpd, CCR-5603
Testing Done: verified multiple ifdown/ifup event on submitter setup and dev setup with 2k s,g entries, ran pim-smoke.

1. during ifdown event, pim vif for bridge was not resetting vif_index to -1 due to errno received from
kernel during vif del sequence. It could be timing issue where kernel may have delete prior to pimd sending request.
For vif_del even kernel returns error, reset vif_index to -1 in pimd DB so next if up event VIF receives new vif_index
and reprograms in kernel.
2. during mroute del sequence reset mfcc_parent to MAXVIF.
3. during mroute add check if parent mfcc_parent is MAXVIF then do not download to kernel such mroute entry.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-02-14 15:53:34 -05:00
Donald Sharp
6431763d95 pimd: Send proper length register packets
PIM Register packets are 20 bytes too long.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-08 09:46:43 -05:00
Donald Sharp
0b6817c5e7 pimd: Cleanup shutdown a bit more.
Cleanup the shutdown of pim a bit more.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-30 12:53:47 -05:00
Donald Sharp
781a1745c0 pimd: Fixup tracking of where we got OIF's from.
This commit does these three things:

1) Add code to 'show ip pim state' to show where OIF's got their
decision to include that interface

2) Add code in pim_mroute_[add|del] to display what we think we are
adding to the kernel

3) Add code to properly track where we got the incoming request from and
to appropriately not remove a OIL if we have state still

Ticket: CM-14034
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-01-30 12:49:38 -05:00
Donald Sharp
77b7d90beb pimd: PIM_MRT is a linux specific piece of code.
The PIM_MRT and registration for WRVIFWHOLECACHE
is a bit of linux specific code.  Until such
time that this gets implemented we will have
issues being able to work within the context
of PIM-SM.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-19 09:58:53 -05:00
Donald Sharp
b58ed1f8a8 Merge remote-tracking branch 'origin/master' into pim_lib_work2 2017-01-17 21:01:56 -05:00
Donald Sharp
38f380f56d pimd: Fix crash w/ ifp null in pim_mroute.c
When you do a series of ifdown/ifup for
an interface that is receiving packets
through the kernel pim socket, it is
possible that the interface has been
deleted but the kernel is still going
to deliver us a packet.  In that case
do not allow us to crash.

Ticket: CM-13981
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:19 -05:00
Donald Sharp
6a78764e46 pimd: Clarify pim_mroute_[add|del] function debugging
When debugging is turned on for 'debug mroute' we
are unable to tell when a mroute has been added
or deleted from the mrib.  Notice when we
do it and who called it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-21 20:26:18 -05:00