Skip to content

Commit

Permalink
Merge pull request FRRouting#17252 from nabahr/mcast-mode
Browse files Browse the repository at this point in the history
Fix PIMD RPF lookup mode and nexthop tracking
  • Loading branch information
rzalamena authored Dec 16, 2024
2 parents 30467f8 + 06c3436 commit 3bebb7b
Show file tree
Hide file tree
Showing 67 changed files with 1,982 additions and 1,508 deletions.
1 change: 0 additions & 1 deletion doc/developer/grpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ Below is how to compile and run the program, with the example output:
]
},
"frr-zebra:zebra": {
"mcast-rpf-lookup": "mrib-then-urib",
"workqueue-hold-timer": 10,
"zapi-packets": 1000,
"import-kernel-table": {
Expand Down
138 changes: 97 additions & 41 deletions doc/user/pim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,32 +217,47 @@ PIM Routers
never do SM over. This command is vrf aware, to configure for a vrf, specify
the vrf in the router pim block.

Global Multicast
----------------
.. clicmd:: rpf-lookup-mode MODE

These commands are valid at the top-level of the configuration (or also per
vrf where indicated), instead of under the 'router pim' submode.
MODE sets the method used to perform RPF lookups. Supported modes:

.. clicmd:: ip multicast rpf-lookup-mode WORD
urib-only
Performs the lookup on the Unicast RIB. The Multicast RIB is never used.

Modify how PIM does RPF lookups in the zebra routing table. You can use
these choices:
mrib-only
Performs the lookup on the Multicast RIB. The Unicast RIB is never used.

longer-prefix
Lookup the RPF in both tables using the longer prefix as a match
mrib-then-urib
Tries to perform the lookup on the Multicast RIB. If any route is found,
that route is used. Otherwise, the Unicast RIB is tried.

lower-distance
Lookup the RPF in both tables using the lower distance as a match
Performs a lookup on the Multicast RIB and Unicast RIB each. The result
with the lower administrative distance is used; if they're equal, the
Multicast RIB takes precedence.

mrib-only
Lookup in the Multicast RIB only
longer-prefix
Performs a lookup on the Multicast RIB and Unicast RIB each. The result
with the longer prefix length is used; if they're equal, the
Multicast RIB takes precedence.

mrib-then-urib
Lookup in the Multicast RIB then the Unicast Rib, returning first found.
This is the default value for lookup if this command is not entered
The ``mrib-then-urib`` setting is the default behavior if nothing is
configured. If this is the desired behavior, it should be explicitly
configured to make the configuration immune against possible changes in
what the default behavior is.

urib-only
Lookup in the Unicast Rib only.
.. warning::

Unreachable routes do not receive special treatment and do not cause
fallback to a second lookup.

.. _pim-global-configuration:

Global Multicast
================

These commands are valid at the top-level of the configuration (or also per
vrf where indicated), instead of under the 'router pim' submode.

.. clicmd:: ip igmp generate-query-once [version (2-3)]

Expand All @@ -257,6 +272,70 @@ vrf where indicated), instead of under the 'router pim' submode.
'no' form of the command disables the warning generation. This command is
vrf aware. To configure per vrf, enter vrf submode.


.. _pim-multicast-rib:

Multicast RIB Commands
----------------------

The Multicast RIB provides a separate table of unicast destinations which
is used for Multicast Reverse Path Forwarding decisions. It is used with
a multicast source's IP address, hence contains not multicast group
addresses but unicast addresses.

This table is fully separate from the default unicast table. However,
RPF lookup can include the unicast table.

.. clicmd:: ip mroute PREFIX NEXTHOP [DISTANCE]

Adds a static route entry to the Multicast RIB. This performs exactly as the
``ip route`` command, except that it inserts the route in the Multicast RIB
instead of the Unicast RIB.
These routes are only used for RPF lookup and will not be used by zebra for
insertion into the kernel *or* for normal rib processing. As such it is
possible to create weird states with these commands. Use with caution. Most
of the time this will not be necessary.

.. clicmd:: show [ip|ipv6] rpf

Prints the entire Multicast RIB. Note that this is independent of the
configured RPF lookup mode, the Multicast RIB may be printed yet not
used at all.

.. clicmd:: show [ip|ipv6] rpf ADDR

Performs a Multicast RPF lookup using the Multicast RIB only.
ADDR specifies the multicast source address to look up. Note that this is
independent of the configured RPF lookup mode.

::

> show ip rpf 192.0.2.1
Routing entry for 192.0.2.0/24 using Multicast RIB
Known via "kernel", distance 0, metric 0, best
* 198.51.100.1, via eth0


Indicates that a multicast source lookup for 192.0.2.1 against the
Multicast RIB would use an entry for 192.0.2.0/24 with a gateway of
198.51.100.1.

.. clicmd:: show ip pim [vrf NAME] nexthop-lookup ADDR [GROUP]

Performs a nexthop lookup according to the configured RPF lookup mode.
This performs the lookup for a given source address, and optionally with
a group address, which may effect the nexthop decision.

::

> show ip pim nexthop-lookup 192.0.2.1
(192.0.2.1, *) --- Nexthop 198.10.10.1 Interface eth1


Indicates the a source lookup for 192.0.2.1 according to the configured RPF
lookup mode would use the gateway address 192.10.10.1 on interface eth1.


.. _pim-interface-configuration:

PIM Interface Configuration
Expand Down Expand Up @@ -410,29 +489,6 @@ is in a vrf, enter the interface command with the vrf keyword at the end.

:ref:`bfd-pim-peer-config`


.. _pim-multicast-rib:

PIM Multicast RIB
=================

In order to influence Multicast RPF lookup, it is possible to insert
into zebra routes for the Multicast RIB. These routes are only
used for RPF lookup and will not be used by zebra for insertion
into the kernel *or* for normal rib processing. As such it is
possible to create weird states with these commands. Use with
caution. Most of the time this will not be necessary.

.. clicmd:: ip mroute A.B.C.D/M A.B.C.D (1-255)

Insert into the Multicast Rib Route A.B.C.D/M with specified nexthop. The
distance can be specified as well if desired.

.. clicmd:: ip mroute A.B.C.D/M INTERFACE (1-255)

Insert into the Multicast Rib Route A.B.C.D/M using the specified INTERFACE.
The distance can be specified as well if desired.

.. _msdp-configuration:

Multicast Source Discovery Protocol (MSDP) Configuration
Expand Down Expand Up @@ -778,7 +834,7 @@ cause great confusion.

.. seealso::

:ref:`multicast-rib-commands`
:ref:`pim-multicast-rib`


PIM Debug Commands
Expand Down
82 changes: 0 additions & 82 deletions doc/user/zebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1113,88 +1113,6 @@ and this section also helps that case.
!
...

.. _multicast-rib-commands:

Multicast RIB Commands
======================

The Multicast RIB provides a separate table of unicast destinations which
is used for Multicast Reverse Path Forwarding decisions. It is used with
a multicast source's IP address, hence contains not multicast group
addresses but unicast addresses.

This table is fully separate from the default unicast table. However,
RPF lookup can include the unicast table.

WARNING: RPF lookup results are non-responsive in this version of FRR,
i.e. multicast routing does not actively react to changes in underlying
unicast topology!

.. clicmd:: ip multicast rpf-lookup-mode MODE


MODE sets the method used to perform RPF lookups. Supported modes:

urib-only
Performs the lookup on the Unicast RIB. The Multicast RIB is never used.

mrib-only
Performs the lookup on the Multicast RIB. The Unicast RIB is never used.

mrib-then-urib
Tries to perform the lookup on the Multicast RIB. If any route is found,
that route is used. Otherwise, the Unicast RIB is tried.

lower-distance
Performs a lookup on the Multicast RIB and Unicast RIB each. The result
with the lower administrative distance is used; if they're equal, the
Multicast RIB takes precedence.

longer-prefix
Performs a lookup on the Multicast RIB and Unicast RIB each. The result
with the longer prefix length is used; if they're equal, the
Multicast RIB takes precedence.

The ``mrib-then-urib`` setting is the default behavior if nothing is
configured. If this is the desired behavior, it should be explicitly
configured to make the configuration immune against possible changes in
what the default behavior is.

.. warning::

Unreachable routes do not receive special treatment and do not cause
fallback to a second lookup.

.. clicmd:: show [ip|ipv6] rpf ADDR

Performs a Multicast RPF lookup, as configured with ``ip multicast
rpf-lookup-mode MODE``. ADDR specifies the multicast source address to look
up.

::

> show ip rpf 192.0.2.1
Routing entry for 192.0.2.0/24 using Unicast RIB
Known via "kernel", distance 0, metric 0, best
* 198.51.100.1, via eth0


Indicates that a multicast source lookup for 192.0.2.1 would use an
Unicast RIB entry for 192.0.2.0/24 with a gateway of 198.51.100.1.

.. clicmd:: show [ip|ipv6] rpf

Prints the entire Multicast RIB. Note that this is independent of the
configured RPF lookup mode, the Multicast RIB may be printed yet not
used at all.

.. clicmd:: ip mroute PREFIX NEXTHOP [DISTANCE]


Adds a static route entry to the Multicast RIB. This performs exactly as the
``ip route`` command, except that it inserts the route in the Multicast RIB
instead of the Unicast RIB.

.. _zebra-route-filtering:

zebra Route Filtering
Expand Down
2 changes: 1 addition & 1 deletion lib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_BFD_CLIENT_DEREGISTER),
DESC_ENTRY(ZEBRA_INTERFACE_ENABLE_RADV),
DESC_ENTRY(ZEBRA_INTERFACE_DISABLE_RADV),
DESC_ENTRY(ZEBRA_NEXTHOP_LOOKUP_MRIB),
DESC_ENTRY(ZEBRA_NEXTHOP_LOOKUP),
DESC_ENTRY(ZEBRA_INTERFACE_LINK_PARAMS),
DESC_ENTRY(ZEBRA_MPLS_LABELS_ADD),
DESC_ENTRY(ZEBRA_MPLS_LABELS_DELETE),
Expand Down
2 changes: 1 addition & 1 deletion lib/zclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ typedef enum {
ZEBRA_BFD_CLIENT_DEREGISTER,
ZEBRA_INTERFACE_ENABLE_RADV,
ZEBRA_INTERFACE_DISABLE_RADV,
ZEBRA_NEXTHOP_LOOKUP_MRIB,
ZEBRA_NEXTHOP_LOOKUP,
ZEBRA_INTERFACE_LINK_PARAMS,
ZEBRA_MPLS_LABELS_ADD,
ZEBRA_MPLS_LABELS_DELETE,
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_bsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ void pim_bsm_clear(struct pim_instance *pim)
__func__, &nht_p);
}

pim_delete_tracked_nexthop(pim, nht_p, NULL, rp_info);
pim_nht_delete_tracked(pim, nht_p, NULL, rp_info);

pim_get_all_mcast_group(&g_all);
rp_all = pim_rp_find_match_group(pim, &g_all);
Expand Down
4 changes: 2 additions & 2 deletions pimd/pim_bsr_rpdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ void pim_crp_nht_update(struct pim_instance *pim, struct pim_nexthop_cache *pnc)
struct bsr_crp_rp *rp, ref;
bool ok;

ref.addr = pnc->rpf.rpf_addr;
ref.addr = pnc->addr;
rp = bsr_crp_rps_find(scope->ebsr_rps, &ref);
assertf(rp, "addr=%pPA", &ref.addr);

ok = CHECK_FLAG(pnc->flags, PIM_NEXTHOP_VALID);
ok = pim_nht_pnc_is_valid(pim, pnc);
if (ok == rp->nht_ok)
return;

Expand Down
33 changes: 31 additions & 2 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2914,7 +2914,7 @@ DEFPY (show_ip_pim_nexthop,

DEFPY (show_ip_pim_nexthop_lookup,
show_ip_pim_nexthop_lookup_cmd,
"show ip pim [vrf NAME] nexthop-lookup A.B.C.D$source A.B.C.D$group",
"show ip pim [vrf NAME] nexthop-lookup A.B.C.D$source [A.B.C.D$group]",
SHOW_STR
IP_STR
PIM_STR
Expand All @@ -2926,6 +2926,14 @@ DEFPY (show_ip_pim_nexthop_lookup,
return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group);
}

ALIAS_DEPRECATED (show_ip_pim_nexthop_lookup,
show_ip_rpf_source_cmd,
"show ip rpf A.B.C.D$source",
SHOW_STR
IP_STR
"Display RPF information for multicast source\n"
"Nexthop lookup for specific source address\n");

DEFPY (show_ip_pim_interface_traffic,
show_ip_pim_interface_traffic_cmd,
"show ip pim [vrf NAME] interface traffic [WORD$if_name] [json$json]",
Expand Down Expand Up @@ -3288,7 +3296,7 @@ DEFUN (show_ip_rib,
return CMD_WARNING;
}

if (!pim_nexthop_lookup(vrf->info, &nexthop, addr, 0)) {
if (!pim_nht_lookup(vrf->info, &nexthop, addr, 0)) {
vty_out(vty,
"Failure querying RIB nexthop for unicast address %s\n",
addr_str);
Expand Down Expand Up @@ -8869,6 +8877,24 @@ DEFPY_ATTR(ip_pim_mlag,
return ret;
}

DEFPY_YANG(pim_rpf_lookup_mode, pim_rpf_lookup_mode_cmd,
"[no] rpf-lookup-mode ![urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix]$mode",
NO_STR
"RPF lookup behavior\n"
"Lookup in unicast RIB only\n"
"Lookup in multicast RIB only\n"
"Try multicast RIB first, fall back to unicast RIB\n"
"Lookup both, use entry with lower distance\n"
"Lookup both, use entry with longer prefix\n")
{
if (no)
nb_cli_enqueue_change(vty, "./mcast-rpf-lookup", NB_OP_DESTROY, NULL);
else
nb_cli_enqueue_change(vty, "./mcast-rpf-lookup", NB_OP_MODIFY, mode);

return nb_cli_apply_changes(vty, NULL);
}

struct cmd_node pim_node = {
.name = "pim",
.node = PIM_NODE,
Expand Down Expand Up @@ -9036,6 +9062,8 @@ void pim_cmd_init(void)
install_element(PIM_NODE, &pim_bsr_candidate_rp_group_cmd);
install_element(PIM_NODE, &pim_bsr_candidate_bsr_cmd);

install_element(PIM_NODE, &pim_rpf_lookup_mode_cmd);

install_element(INTERFACE_NODE, &interface_ip_igmp_cmd);
install_element(INTERFACE_NODE, &interface_no_ip_igmp_cmd);
install_element(INTERFACE_NODE, &interface_ip_igmp_join_cmd);
Expand Down Expand Up @@ -9159,6 +9187,7 @@ void pim_cmd_init(void)
install_element(VIEW_NODE, &show_ip_ssmpingd_cmd);
install_element(VIEW_NODE, &show_ip_pim_nexthop_cmd);
install_element(VIEW_NODE, &show_ip_pim_nexthop_lookup_cmd);
install_element(VIEW_NODE, &show_ip_rpf_source_cmd);
install_element(VIEW_NODE, &show_ip_pim_bsrp_cmd);
install_element(VIEW_NODE, &show_ip_pim_bsm_db_cmd);
install_element(VIEW_NODE, &show_ip_pim_bsr_rpinfo_cmd);
Expand Down
Loading

0 comments on commit 3bebb7b

Please sign in to comment.