mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 13:13:08 +00:00
pimd: pim_br switch to struct prefix
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
ad410c6c7b
commit
65e1fcd766
@ -30,8 +30,7 @@
|
|||||||
#include "linklist.h"
|
#include "linklist.h"
|
||||||
|
|
||||||
struct pim_br {
|
struct pim_br {
|
||||||
struct in_addr source;
|
struct prefix sg;
|
||||||
struct in_addr group;
|
|
||||||
struct in_addr pmbr;
|
struct in_addr pmbr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,14 +39,14 @@ struct in_addr pim_br_unknown = { .s_addr = 0 };
|
|||||||
static struct list *pim_br_list = NULL;
|
static struct list *pim_br_list = NULL;
|
||||||
|
|
||||||
struct in_addr
|
struct in_addr
|
||||||
pim_br_get_pmbr (struct in_addr source, struct in_addr group)
|
pim_br_get_pmbr (struct prefix *sg)
|
||||||
{
|
{
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct pim_br *pim_br;
|
struct pim_br *pim_br;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO (pim_br_list, node, pim_br)) {
|
for (ALL_LIST_ELEMENTS_RO (pim_br_list, node, pim_br)) {
|
||||||
if (source.s_addr == pim_br->source.s_addr &&
|
if (sg->u.sg.src.s_addr == pim_br->sg.u.sg.src.s_addr &&
|
||||||
group.s_addr == pim_br->group.s_addr)
|
sg->u.sg.grp.s_addr == pim_br->sg.u.sg.grp.s_addr)
|
||||||
return pim_br->pmbr;
|
return pim_br->pmbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,14 +54,14 @@ pim_br_get_pmbr (struct in_addr source, struct in_addr group)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr br)
|
pim_br_set_pmbr (struct prefix *sg, struct in_addr br)
|
||||||
{
|
{
|
||||||
struct listnode *node, *next;
|
struct listnode *node, *next;
|
||||||
struct pim_br *pim_br;
|
struct pim_br *pim_br;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS (pim_br_list, node, next, pim_br)) {
|
for (ALL_LIST_ELEMENTS (pim_br_list, node, next, pim_br)) {
|
||||||
if (source.s_addr == pim_br->source.s_addr &&
|
if (sg->u.sg.src.s_addr == pim_br->sg.u.sg.src.s_addr &&
|
||||||
group.s_addr == pim_br->group.s_addr)
|
sg->u.sg.grp.s_addr == pim_br->sg.u.sg.grp.s_addr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +72,7 @@ pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr br)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pim_br->source = source;
|
pim_br->sg = *sg;
|
||||||
pim_br->group = group;
|
|
||||||
|
|
||||||
listnode_add(pim_br_list, pim_br);
|
listnode_add(pim_br_list, pim_br);
|
||||||
}
|
}
|
||||||
@ -86,14 +84,14 @@ pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr br)
|
|||||||
* Remove the (S,G) from the stored values
|
* Remove the (S,G) from the stored values
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pim_br_clear_pmbr (struct in_addr source, struct in_addr group)
|
pim_br_clear_pmbr (struct prefix *sg)
|
||||||
{
|
{
|
||||||
struct listnode *node, *next;
|
struct listnode *node, *next;
|
||||||
struct pim_br *pim_br;
|
struct pim_br *pim_br;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS (pim_br_list, node, next, pim_br)) {
|
for (ALL_LIST_ELEMENTS (pim_br_list, node, next, pim_br)) {
|
||||||
if (source.s_addr == pim_br->source.s_addr &&
|
if (sg->u.sg.src.s_addr == pim_br->sg.u.sg.src.s_addr &&
|
||||||
group.s_addr == pim_br->group.s_addr)
|
sg->u.sg.grp.s_addr == pim_br->sg.u.sg.grp.s_addr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
#ifndef PIM_BR_H
|
#ifndef PIM_BR_H
|
||||||
#define PIM_BR_H
|
#define PIM_BR_H
|
||||||
|
|
||||||
struct in_addr pim_br_get_pmbr (struct in_addr source, struct in_addr group);
|
struct in_addr pim_br_get_pmbr (struct prefix *sg);
|
||||||
|
|
||||||
void pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr value);
|
void pim_br_set_pmbr (struct prefix *sg, struct in_addr value);
|
||||||
void pim_br_clear_pmbr (struct in_addr source, struct in_addr group);
|
void pim_br_clear_pmbr (struct prefix *sg);
|
||||||
|
|
||||||
void pim_br_init (void);
|
void pim_br_init (void);
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ pim_check_is_my_ip_address (struct in_addr dest_addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pim_register_stop_send (struct interface *ifp, struct in_addr source,
|
pim_register_stop_send (struct interface *ifp, struct prefix *sg,
|
||||||
struct in_addr group, struct in_addr originator)
|
struct in_addr originator)
|
||||||
{
|
{
|
||||||
struct pim_interface *pinfo;
|
struct pim_interface *pinfo;
|
||||||
unsigned char buffer[3000];
|
unsigned char buffer[3000];
|
||||||
@ -80,12 +80,12 @@ pim_register_stop_send (struct interface *ifp, struct in_addr source,
|
|||||||
memset (buffer, 0, 3000);
|
memset (buffer, 0, 3000);
|
||||||
b1 = (uint8_t *)buffer + PIM_MSG_REGISTER_STOP_LEN;
|
b1 = (uint8_t *)buffer + PIM_MSG_REGISTER_STOP_LEN;
|
||||||
|
|
||||||
length = pim_encode_addr_group (b1, AFI_IP, 0, 0, group);
|
length = pim_encode_addr_group (b1, AFI_IP, 0, 0, sg->u.sg.grp);
|
||||||
b1length += length;
|
b1length += length;
|
||||||
b1 += length;
|
b1 += length;
|
||||||
|
|
||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.u.prefix4 = source;
|
p.u.prefix4 = sg->u.sg.src;
|
||||||
p.prefixlen = 32;
|
p.prefixlen = 32;
|
||||||
length = pim_encode_addr_ucast (b1, &p);
|
length = pim_encode_addr_ucast (b1, &p);
|
||||||
b1length += length;
|
b1length += length;
|
||||||
@ -243,8 +243,6 @@ pim_register_recv (struct interface *ifp,
|
|||||||
{
|
{
|
||||||
int sentRegisterStop = 0;
|
int sentRegisterStop = 0;
|
||||||
struct ip *ip_hdr;
|
struct ip *ip_hdr;
|
||||||
struct in_addr group = { .s_addr = 0 };
|
|
||||||
struct in_addr source = { .s_addr = 0 };
|
|
||||||
struct prefix sg;
|
struct prefix sg;
|
||||||
uint32_t *bits;
|
uint32_t *bits;
|
||||||
|
|
||||||
@ -288,21 +286,22 @@ pim_register_recv (struct interface *ifp,
|
|||||||
*/
|
*/
|
||||||
#define PIM_MSG_REGISTER_BIT_RESERVED_LEN 4
|
#define PIM_MSG_REGISTER_BIT_RESERVED_LEN 4
|
||||||
ip_hdr = (struct ip *)(tlv_buf + PIM_MSG_REGISTER_BIT_RESERVED_LEN);
|
ip_hdr = (struct ip *)(tlv_buf + PIM_MSG_REGISTER_BIT_RESERVED_LEN);
|
||||||
source = ip_hdr->ip_src;
|
memset (&sg, 0, sizeof (struct prefix));
|
||||||
group = ip_hdr->ip_dst;
|
sg.u.sg.src = ip_hdr->ip_src;
|
||||||
|
sg.u.sg.grp = ip_hdr->ip_dst;
|
||||||
|
|
||||||
if (I_am_RP (group) && (dest_addr.s_addr == ((RP (group))->rpf_addr.s_addr))) {
|
if (I_am_RP (sg.u.sg.grp) && (dest_addr.s_addr == ((RP (sg.u.sg.grp))->rpf_addr.s_addr))) {
|
||||||
sentRegisterStop = 0;
|
sentRegisterStop = 0;
|
||||||
|
|
||||||
if (*bits & PIM_REGISTER_BORDER_BIT) {
|
if (*bits & PIM_REGISTER_BORDER_BIT) {
|
||||||
struct in_addr pimbr = pim_br_get_pmbr (source, group);
|
struct in_addr pimbr = pim_br_get_pmbr (&sg);
|
||||||
if (PIM_DEBUG_PIM_PACKETS)
|
if (PIM_DEBUG_PIM_PACKETS)
|
||||||
zlog_debug("%s: Received Register message with Border bit set", __func__);
|
zlog_debug("%s: Received Register message with Border bit set", __func__);
|
||||||
|
|
||||||
if (pimbr.s_addr == pim_br_unknown.s_addr)
|
if (pimbr.s_addr == pim_br_unknown.s_addr)
|
||||||
pim_br_set_pmbr(source, group, src_addr);
|
pim_br_set_pmbr(&sg, src_addr);
|
||||||
else if (src_addr.s_addr != pimbr.s_addr) {
|
else if (src_addr.s_addr != pimbr.s_addr) {
|
||||||
pim_register_stop_send (ifp, source, group, src_addr);
|
pim_register_stop_send (ifp, &sg, src_addr);
|
||||||
if (PIM_DEBUG_PIM_PACKETS)
|
if (PIM_DEBUG_PIM_PACKETS)
|
||||||
zlog_debug("%s: Sending register-Stop to %s and dropping mr. packet",
|
zlog_debug("%s: Sending register-Stop to %s and dropping mr. packet",
|
||||||
__func__, "Sender");
|
__func__, "Sender");
|
||||||
@ -311,9 +310,6 @@ pim_register_recv (struct interface *ifp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (&sg, 0, sizeof (struct prefix));
|
|
||||||
sg.u.sg.src = source;
|
|
||||||
sg.u.sg.grp = group;
|
|
||||||
struct pim_upstream *upstream = pim_upstream_find (&sg);
|
struct pim_upstream *upstream = pim_upstream_find (&sg);
|
||||||
/*
|
/*
|
||||||
* If we don't have a place to send ignore the packet
|
* If we don't have a place to send ignore the packet
|
||||||
@ -326,14 +322,14 @@ pim_register_recv (struct interface *ifp,
|
|||||||
|
|
||||||
if (upstream->join_state == PIM_UPSTREAM_PRUNE)
|
if (upstream->join_state == PIM_UPSTREAM_PRUNE)
|
||||||
{
|
{
|
||||||
pim_register_stop_send (ifp, source, group, src_addr);
|
pim_register_stop_send (ifp, &sg, src_addr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) ||
|
if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) ||
|
||||||
((SwitchToSptDesired(&sg)) &&
|
((SwitchToSptDesired(&sg)) &&
|
||||||
(inherited_olist(source, group) == NULL))) {
|
(inherited_olist(source, group) == NULL))) {
|
||||||
pim_register_stop_send (ifp, source, group, src_addr);
|
pim_register_stop_send (ifp, &sg, src_addr);
|
||||||
sentRegisterStop = 1;
|
sentRegisterStop = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,13 +345,13 @@ pim_register_recv (struct interface *ifp,
|
|||||||
if (!(upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) &&
|
if (!(upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) &&
|
||||||
!(*bits & PIM_REGISTER_NR_BIT))
|
!(*bits & PIM_REGISTER_NR_BIT))
|
||||||
{
|
{
|
||||||
pim_rp_set_upstream_addr (&upstream->upstream_addr, source);
|
pim_rp_set_upstream_addr (&upstream->upstream_addr, sg.u.sg.src);
|
||||||
pim_nexthop_lookup (&upstream->rpf.source_nexthop,
|
pim_nexthop_lookup (&upstream->rpf.source_nexthop,
|
||||||
upstream->upstream_addr, NULL);
|
upstream->upstream_addr, NULL);
|
||||||
upstream->rpf.source_nexthop.interface = ifp;
|
upstream->rpf.source_nexthop.interface = ifp;
|
||||||
upstream->sg.u.sg.src.s_addr = source.s_addr;
|
upstream->sg.u.sg.src = sg.u.sg.src;
|
||||||
upstream->rpf.rpf_addr = upstream->rpf.source_nexthop.mrib_nexthop_addr;
|
upstream->rpf.rpf_addr = upstream->rpf.source_nexthop.mrib_nexthop_addr;
|
||||||
upstream->channel_oil->oil.mfcc_origin = source;
|
upstream->channel_oil->oil.mfcc_origin = sg.u.sg.src;
|
||||||
pim_scan_individual_oil (upstream->channel_oil);
|
pim_scan_individual_oil (upstream->channel_oil);
|
||||||
pim_upstream_send_join (upstream);
|
pim_upstream_send_join (upstream);
|
||||||
|
|
||||||
@ -363,7 +359,7 @@ pim_register_recv (struct interface *ifp,
|
|||||||
//inherited_olist(S,G,rpt)
|
//inherited_olist(S,G,rpt)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pim_register_stop_send (ifp, source, group, src_addr);
|
pim_register_stop_send (ifp, &sg, src_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -686,7 +686,7 @@ pim_upstream_keep_alive_timer (struct thread *t)
|
|||||||
|
|
||||||
if (I_am_RP (up->sg.u.sg.grp))
|
if (I_am_RP (up->sg.u.sg.grp))
|
||||||
{
|
{
|
||||||
pim_br_clear_pmbr (up->sg.u.sg.src, up->sg.u.sg.grp);
|
pim_br_clear_pmbr (&up->sg);
|
||||||
/*
|
/*
|
||||||
* We need to do more here :)
|
* We need to do more here :)
|
||||||
* But this is the start.
|
* But this is the start.
|
||||||
|
Loading…
Reference in New Issue
Block a user