Skip to content

Commit

Permalink
Merge pull request #17622 from opensourcerouting/msdp-originator
Browse files Browse the repository at this point in the history
pimd: MSDP originador ID configuration
  • Loading branch information
Jafaral authored Dec 12, 2024
2 parents f170e9b + e3af4b8 commit f7720ab
Show file tree
Hide file tree
Showing 13 changed files with 350 additions and 20 deletions.
4 changes: 4 additions & 0 deletions doc/user/pim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ Commands available for MSDP

To apply it immediately call `clear ip msdp peer A.B.C.D`.

.. clicmd:: msdp originator-id A.B.C.D

Use the specified originator ID instead of the multicast RP group.

.. clicmd:: msdp shutdown

Shutdown the MSDP sessions in this PIM instance.
Expand Down
19 changes: 19 additions & 0 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7616,6 +7616,24 @@ DEFPY(msdp_peer_sa_limit, msdp_peer_sa_limit_cmd,
return nb_cli_apply_changes(vty, "%s", xpath);
}

DEFPY(msdp_originator_id, msdp_originator_id_cmd,
"[no] msdp originator-id ![A.B.C.D$originator_id]",
NO_STR
CFG_MSDP_STR
"Configure MSDP RP originator\n"
"MSDP RP originator identifier\n")
{
char xpath_value[XPATH_MAXLEN];

snprintf(xpath_value, sizeof(xpath_value), "./msdp/originator-id");
if (no)
nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY, NULL);
else
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, originator_id_str);

return nb_cli_apply_changes(vty, NULL);
}

static void ip_msdp_show_mesh_group(struct vty *vty, struct pim_msdp_mg *mg,
struct json_object *json)
{
Expand Down Expand Up @@ -9012,6 +9030,7 @@ void pim_cmd_init(void)
install_element(PIM_NODE, &msdp_log_sa_changes_cmd);
install_element(PIM_NODE, &msdp_shutdown_cmd);
install_element(PIM_NODE, &msdp_peer_sa_limit_cmd);
install_element(PIM_NODE, &msdp_originator_id_cmd);

install_element(PIM_NODE, &pim_bsr_candidate_rp_cmd);
install_element(PIM_NODE, &pim_bsr_candidate_rp_group_cmd);
Expand Down
36 changes: 27 additions & 9 deletions pimd/pim_msdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ static void pim_msdp_sa_deref(struct pim_msdp_sa *sa,
static int pim_msdp_mg_mbr_comp(const void *p1, const void *p2);
static void pim_msdp_mg_mbr_free(struct pim_msdp_mg_mbr *mbr);

void pim_msdp_originator_id(struct pim_instance *pim, const struct prefix *group,
struct in_addr *originator_id)
{
struct rp_info *rp_info;

originator_id->s_addr = INADDR_ANY;

/* Originator ID was configured, use it. */
if (pim->msdp.originator_id.s_addr != INADDR_ANY) {
*originator_id = pim->msdp.originator_id;
return;
}

rp_info = pim_rp_find_match_group(pim, group);
if (rp_info) {
*originator_id = rp_info->rp.rpf_addr;
return;
}
}

/************************ SA cache management ******************************/
/* RFC-3618:Sec-5.1 - global active source advertisement timer */
static void pim_msdp_sa_adv_timer_cb(struct event *t)
Expand Down Expand Up @@ -354,7 +374,6 @@ void pim_msdp_sa_ref(struct pim_instance *pim, struct pim_msdp_peer *mp,
pim_sgaddr *sg, struct in_addr rp)
{
struct pim_msdp_sa *sa;
struct rp_info *rp_info;
struct prefix grp;

/* Check peer SA limit. */
Expand Down Expand Up @@ -395,12 +414,7 @@ void pim_msdp_sa_ref(struct pim_instance *pim, struct pim_msdp_peer *mp,

/* send an immediate SA update to peers */
pim_addr_to_prefix(&grp, sa->sg.grp);
rp_info = pim_rp_find_match_group(pim, &grp);
if (rp_info) {
sa->rp = rp_info->rp.rpf_addr;
} else {
sa->rp = pim->msdp.originator_id;
}
pim_msdp_originator_id(pim, &grp, &sa->rp);
pim_msdp_pkt_sa_tx_one(sa);
}
sa->flags &= ~PIM_MSDP_SAF_STALE;
Expand Down Expand Up @@ -1013,8 +1027,6 @@ struct pim_msdp_peer *pim_msdp_peer_add(struct pim_instance *pim,
mp->peer = *peer;
pim_inet4_dump("<peer?>", mp->peer, mp->key_str, sizeof(mp->key_str));
mp->local = *local;
/* XXX: originator_id setting needs to move to the mesh group */
pim->msdp.originator_id = *local;
if (mesh_group_name)
mp->mesh_group_name =
XSTRDUP(MTYPE_PIM_MSDP_MG_NAME, mesh_group_name);
Expand Down Expand Up @@ -1340,6 +1352,12 @@ bool pim_msdp_peer_config_write(struct vty *vty, struct pim_instance *pim)
written = true;
}

if (pim->msdp.originator_id.s_addr != INADDR_ANY)
vty_out(vty, " msdp originator-id %pI4\n", &pim->msdp.originator_id);

if (pim->msdp.shutdown)
vty_out(vty, " msdp shutdown\n");

return written;
}

Expand Down
10 changes: 10 additions & 0 deletions pimd/pim_msdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,16 @@ void pim_msdp_peer_restart(struct pim_msdp_peer *mp);
*/
void pim_msdp_shutdown(struct pim_instance *pim, bool state);

/**
* Get the configured originator ID for the SA RP field or the RP for the group.
*
* \param[in] pim PIM instance that MSDP connection belongs to.
* \param[in] group Multicast group.
* \param[out] originator_id Originator output value.
*/
void pim_msdp_originator_id(struct pim_instance *pim, const struct prefix *group,
struct in_addr *originator_id);

extern bool pim_msdp_log_neighbor_events(const struct pim_instance *pim);
extern bool pim_msdp_log_sa_events(const struct pim_instance *pim);

Expand Down
14 changes: 3 additions & 11 deletions pimd/pim_msdp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ static void pim_msdp_pkt_sa_gen(struct pim_instance *pim,
{
struct listnode *sanode;
struct pim_msdp_sa *sa;
struct rp_info *rp_info;
struct prefix group_all;
struct in_addr rp;
int sa_count;
Expand All @@ -420,14 +419,8 @@ static void pim_msdp_pkt_sa_gen(struct pim_instance *pim,
zlog_debug(" sa gen %d", local_cnt);
}

rp = pim->msdp.originator_id;
if (pim_get_all_mcast_group(&group_all)) {
rp_info = pim_rp_find_match_group(pim, &group_all);
if (rp_info) {
rp = rp_info->rp.rpf_addr;
}
}

pim_get_all_mcast_group(&group_all);
pim_msdp_originator_id(pim, &group_all, &rp);
local_cnt = pim_msdp_pkt_sa_fill_hdr(pim, local_cnt, rp);

for (ALL_LIST_ELEMENTS_RO(pim->msdp.sa_list, sanode, sa)) {
Expand Down Expand Up @@ -457,8 +450,7 @@ static void pim_msdp_pkt_sa_gen(struct pim_instance *pim,
zlog_debug(" sa gen for remainder %d",
local_cnt);
}
local_cnt = pim_msdp_pkt_sa_fill_hdr(
pim, local_cnt, rp);
local_cnt = pim_msdp_pkt_sa_fill_hdr(pim, local_cnt, rp);
}
}

Expand Down
7 changes: 7 additions & 0 deletions pimd/pim_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ const struct frr_yang_module_info frr_pim_info = {
.modify = pim_msdp_log_sa_events_modify,
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/msdp/originator-id",
.cbs = {
.modify = pim_msdp_originator_id_modify,
.destroy = pim_msdp_originator_id_destroy,
}
},
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/msdp/shutdown",
.cbs = {
Expand Down
2 changes: 2 additions & 0 deletions pimd/pim_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ int pim_msdp_keep_alive_modify(struct nb_cb_modify_args *args);
int pim_msdp_connection_retry_modify(struct nb_cb_modify_args *args);
int pim_msdp_log_neighbor_events_modify(struct nb_cb_modify_args *args);
int pim_msdp_log_sa_events_modify(struct nb_cb_modify_args *args);
int pim_msdp_originator_id_modify(struct nb_cb_modify_args *args);
int pim_msdp_originator_id_destroy(struct nb_cb_destroy_args *args);
int pim_msdp_shutdown_modify(struct nb_cb_modify_args *args);
int pim_msdp_mesh_group_create(struct nb_cb_create_args *args);
int pim_msdp_mesh_group_destroy(struct nb_cb_destroy_args *args);
Expand Down
46 changes: 46 additions & 0 deletions pimd/pim_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ pim6_msdp_err(pim_msdp_peer_authentication_key_modify, nb_cb_modify_args);
pim6_msdp_err(pim_msdp_peer_authentication_key_destroy, nb_cb_destroy_args);
pim6_msdp_err(pim_msdp_log_neighbor_events_modify, nb_cb_modify_args);
pim6_msdp_err(pim_msdp_log_sa_events_modify, nb_cb_modify_args);
pim6_msdp_err(pim_msdp_originator_id_modify, nb_cb_modify_args);
pim6_msdp_err(pim_msdp_originator_id_destroy, nb_cb_destroy_args);
pim6_msdp_err(pim_msdp_shutdown_modify, nb_cb_modify_args);

#if PIM_IPV != 6
Expand Down Expand Up @@ -1171,6 +1173,50 @@ int pim_msdp_log_sa_events_modify(struct nb_cb_modify_args *args)
return NB_OK;
}

/*
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/msdp/originator-id
*/
int pim_msdp_originator_id_modify(struct nb_cb_modify_args *args)
{
struct pim_instance *pim;
struct vrf *vrf;

switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
break;
case NB_EV_APPLY:
vrf = nb_running_get_entry(args->dnode, NULL, true);
pim = vrf->info;
yang_dnode_get_ipv4(&pim->msdp.originator_id, args->dnode, NULL);
break;
}

return NB_OK;
}

int pim_msdp_originator_id_destroy(struct nb_cb_destroy_args *args)
{
struct pim_instance *pim;
struct vrf *vrf;

switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
break;
case NB_EV_APPLY:
vrf = nb_running_get_entry(args->dnode, NULL, true);
pim = vrf->info;
pim->msdp.originator_id.s_addr = INADDR_ANY;
break;
}

return NB_OK;
}

/*
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/msdp/shutdown
Expand Down
Empty file.
31 changes: 31 additions & 0 deletions tests/topotests/msdp_topo3/r1/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
log commands
!
interface r1-eth0
ip address 192.168.1.1/24
ip pim
!
interface r1-eth1
ip address 192.168.100.1/24
ip igmp
ip pim passive
!
interface lo
ip address 10.254.254.1/32
ip pim
ip pim use-source 10.254.254.1
!
router bgp 65100
no bgp ebgp-requires-policy
no bgp network import-check
neighbor 192.168.1.2 remote-as 65200
!
address-family ipv4 unicast
redistribute connected
exit-address-family
!
router pim
msdp originator-id 10.254.254.1
msdp log sa-events
msdp peer 192.168.1.2 source 192.168.1.1
rp 192.168.1.1
!
28 changes: 28 additions & 0 deletions tests/topotests/msdp_topo3/r2/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
log commands
!
interface r2-eth0
ip address 192.168.1.2/24
ip pim
!
interface r2-eth1
ip address 192.168.101.1/24
ip igmp
ip pim passive
!
interface lo
ip address 10.254.254.2/32
!
router bgp 65200
no bgp ebgp-requires-policy
no bgp network import-check
neighbor 192.168.1.1 remote-as 65100
!
address-family ipv4 unicast
redistribute connected
exit-address-family
!
router pim
msdp log sa-events
msdp peer 192.168.1.1 source 192.168.1.2
rp 192.168.1.2
!
Loading

0 comments on commit f7720ab

Please sign in to comment.