mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 20:55:25 +00:00
pimd: Move pim_ifchannel_list and vif array into 'struct pim_instance *'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
5ec5d976eb
commit
f88df3a642
@ -158,7 +158,7 @@ static void pim_if_membership_refresh(struct interface *ifp)
|
||||
pim_ifchannel_delete_on_noinfo(ifp);
|
||||
}
|
||||
|
||||
static void pim_show_assert(struct vty *vty)
|
||||
static void pim_show_assert(struct pim_instance *pim, struct vty *vty)
|
||||
{
|
||||
struct pim_interface *pim_ifp;
|
||||
struct pim_ifchannel *ch;
|
||||
@ -171,7 +171,7 @@ static void pim_show_assert(struct vty *vty)
|
||||
vty_out(vty,
|
||||
"Interface Address Source Group State Winner Uptime Timer\n");
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->ifchannel_list, ch_node, ch)) {
|
||||
char ch_src_str[INET_ADDRSTRLEN];
|
||||
char ch_grp_str[INET_ADDRSTRLEN];
|
||||
char winner_str[INET_ADDRSTRLEN];
|
||||
@ -205,7 +205,7 @@ static void pim_show_assert(struct vty *vty)
|
||||
} /* scan interface channels */
|
||||
}
|
||||
|
||||
static void pim_show_assert_internal(struct vty *vty)
|
||||
static void pim_show_assert_internal(struct pim_instance *pim, struct vty *vty)
|
||||
{
|
||||
struct pim_interface *pim_ifp;
|
||||
struct listnode *ch_node;
|
||||
@ -221,7 +221,7 @@ static void pim_show_assert_internal(struct vty *vty)
|
||||
vty_out(vty,
|
||||
"Interface Address Source Group CA eCA ATD eATD\n");
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->ifchannel_list, ch_node, ch)) {
|
||||
pim_ifp = ch->interface->info;
|
||||
|
||||
if (!pim_ifp)
|
||||
@ -249,7 +249,7 @@ static void pim_show_assert_internal(struct vty *vty)
|
||||
} /* scan interface channels */
|
||||
}
|
||||
|
||||
static void pim_show_assert_metric(struct vty *vty)
|
||||
static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty)
|
||||
{
|
||||
struct pim_interface *pim_ifp;
|
||||
struct listnode *ch_node;
|
||||
@ -259,7 +259,7 @@ static void pim_show_assert_metric(struct vty *vty)
|
||||
vty_out(vty,
|
||||
"Interface Address Source Group RPT Pref Metric Address \n");
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->ifchannel_list, ch_node, ch)) {
|
||||
pim_ifp = ch->interface->info;
|
||||
|
||||
if (!pim_ifp)
|
||||
@ -289,7 +289,8 @@ static void pim_show_assert_metric(struct vty *vty)
|
||||
} /* scan interface channels */
|
||||
}
|
||||
|
||||
static void pim_show_assert_winner_metric(struct vty *vty)
|
||||
static void pim_show_assert_winner_metric(struct pim_instance *pim,
|
||||
struct vty *vty)
|
||||
{
|
||||
struct pim_interface *pim_ifp;
|
||||
struct listnode *ch_node;
|
||||
@ -299,7 +300,7 @@ static void pim_show_assert_winner_metric(struct vty *vty)
|
||||
vty_out(vty,
|
||||
"Interface Address Source Group RPT Pref Metric Address \n");
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->ifchannel_list, ch_node, ch)) {
|
||||
pim_ifp = ch->interface->info;
|
||||
|
||||
if (!pim_ifp)
|
||||
@ -373,7 +374,8 @@ static void json_object_pim_ifp_add(struct json_object *json,
|
||||
json_object_boolean_true_add(json, "lanDelayEnabled");
|
||||
}
|
||||
|
||||
static void pim_show_membership(struct vty *vty, u_char uj)
|
||||
static void pim_show_membership(struct pim_instance *pim, struct vty *vty,
|
||||
u_char uj)
|
||||
{
|
||||
struct pim_interface *pim_ifp;
|
||||
struct listnode *ch_node;
|
||||
@ -386,7 +388,7 @@ static void pim_show_membership(struct vty *vty, u_char uj)
|
||||
|
||||
json = json_object_new_object();
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->ifchannel_list, ch_node, ch)) {
|
||||
|
||||
pim_ifp = ch->interface->info;
|
||||
|
||||
@ -1526,7 +1528,7 @@ static void pim_show_interface_traffic_single(struct vty *vty,
|
||||
}
|
||||
}
|
||||
|
||||
static void pim_show_join(struct vty *vty, u_char uj)
|
||||
static void pim_show_join(struct pim_instance *pim, struct vty *vty, u_char uj)
|
||||
{
|
||||
struct pim_interface *pim_ifp;
|
||||
struct in_addr ifaddr;
|
||||
@ -1546,7 +1548,7 @@ static void pim_show_join(struct vty *vty, u_char uj)
|
||||
vty_out(vty,
|
||||
"Interface Address Source Group State Uptime Expire Prune\n");
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->ifchannel_list, ch_node, ch)) {
|
||||
|
||||
pim_ifp = ch->interface->info;
|
||||
|
||||
@ -2351,7 +2353,8 @@ static void pim_show_upstream(struct vty *vty, u_char uj)
|
||||
}
|
||||
}
|
||||
|
||||
static void pim_show_join_desired(struct vty *vty, u_char uj)
|
||||
static void pim_show_join_desired(struct pim_instance *pim, struct vty *vty,
|
||||
u_char uj)
|
||||
{
|
||||
struct listnode *chnode;
|
||||
struct pim_interface *pim_ifp;
|
||||
@ -2369,7 +2372,7 @@ static void pim_show_join_desired(struct vty *vty, u_char uj)
|
||||
"Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD\n");
|
||||
|
||||
/* scan per-interface (S,G) state */
|
||||
for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, chnode, ch)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(pim->ifchannel_list, chnode, ch)) {
|
||||
/* scan all interfaces */
|
||||
pim_ifp = ch->interface->info;
|
||||
if (!pim_ifp)
|
||||
@ -3289,7 +3292,7 @@ DEFUN (show_ip_pim_assert,
|
||||
PIM_STR
|
||||
"PIM interface assert\n")
|
||||
{
|
||||
pim_show_assert(vty);
|
||||
pim_show_assert(pimg, vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -3302,7 +3305,7 @@ DEFUN (show_ip_pim_assert_internal,
|
||||
PIM_STR
|
||||
"PIM interface internal assert state\n")
|
||||
{
|
||||
pim_show_assert_internal(vty);
|
||||
pim_show_assert_internal(pimg, vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -3315,7 +3318,7 @@ DEFUN (show_ip_pim_assert_metric,
|
||||
PIM_STR
|
||||
"PIM interface assert metric\n")
|
||||
{
|
||||
pim_show_assert_metric(vty);
|
||||
pim_show_assert_metric(pimg, vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -3328,7 +3331,7 @@ DEFUN (show_ip_pim_assert_winner_metric,
|
||||
PIM_STR
|
||||
"PIM interface assert winner metric\n")
|
||||
{
|
||||
pim_show_assert_winner_metric(vty);
|
||||
pim_show_assert_winner_metric(pimg, vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -3367,7 +3370,7 @@ DEFUN (show_ip_pim_join,
|
||||
JSON_STR)
|
||||
{
|
||||
u_char uj = use_json(argc, argv);
|
||||
pim_show_join(vty, uj);
|
||||
pim_show_join(pimg, vty, uj);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -3382,7 +3385,7 @@ DEFUN (show_ip_pim_local_membership,
|
||||
JSON_STR)
|
||||
{
|
||||
u_char uj = use_json(argc, argv);
|
||||
pim_show_membership(vty, uj);
|
||||
pim_show_membership(pimg, vty, uj);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -3476,7 +3479,7 @@ DEFUN (show_ip_pim_upstream_join_desired,
|
||||
"JavaScript Object Notation\n")
|
||||
{
|
||||
u_char uj = use_json(argc, argv);
|
||||
pim_show_join_desired(vty, uj);
|
||||
pim_show_join_desired(pimg, vty, uj);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
@ -45,30 +45,27 @@
|
||||
#include "pim_rp.h"
|
||||
#include "pim_nht.h"
|
||||
|
||||
struct list *pim_ifchannel_list = NULL;
|
||||
static int pim_iface_vif_index[MAXVIFS];
|
||||
|
||||
static void pim_if_igmp_join_del_all(struct interface *ifp);
|
||||
static int igmp_join_sock(const char *ifname, ifindex_t ifindex,
|
||||
struct in_addr group_addr,
|
||||
struct in_addr source_addr);
|
||||
|
||||
void pim_if_init(void)
|
||||
void pim_if_init(struct pim_instance *pim)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXVIFS; i++)
|
||||
pim_iface_vif_index[i] = 0;
|
||||
pim->iface_vif_index[i] = 0;
|
||||
|
||||
pim_ifchannel_list = list_new();
|
||||
pim_ifchannel_list->cmp =
|
||||
pim->ifchannel_list = list_new();
|
||||
pim->ifchannel_list->cmp =
|
||||
(int (*)(void *, void *))pim_ifchannel_compare;
|
||||
}
|
||||
|
||||
void pim_if_terminate(void)
|
||||
void pim_if_terminate(struct pim_instance *pim)
|
||||
{
|
||||
if (pim_ifchannel_list)
|
||||
list_free(pim_ifchannel_list);
|
||||
if (pim->ifchannel_list)
|
||||
list_free(pim->ifchannel_list);
|
||||
}
|
||||
|
||||
static void *if_list_clean(struct pim_interface *pim_ifp)
|
||||
@ -955,7 +952,10 @@ struct in_addr pim_find_primary_addr(struct interface *ifp)
|
||||
|
||||
static int pim_iface_next_vif_index(struct interface *ifp)
|
||||
{
|
||||
struct pim_interface *pim_ifp = ifp->info;
|
||||
struct pim_instance *pim = pim_ifp->pim;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* The pimreg vif is always going to be in index 0
|
||||
* of the table.
|
||||
@ -964,7 +964,7 @@ static int pim_iface_next_vif_index(struct interface *ifp)
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < MAXVIFS; i++) {
|
||||
if (pim_iface_vif_index[i] == 0)
|
||||
if (pim->iface_vif_index[i] == 0)
|
||||
return i;
|
||||
}
|
||||
return MAXVIFS;
|
||||
@ -1026,7 +1026,7 @@ int pim_if_add_vif(struct interface *ifp)
|
||||
return -5;
|
||||
}
|
||||
|
||||
pim_iface_vif_index[pim_ifp->mroute_vif_index] = 1;
|
||||
pim_ifp->pim->iface_vif_index[pim_ifp->mroute_vif_index] = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1046,43 +1046,13 @@ int pim_if_del_vif(struct interface *ifp)
|
||||
/*
|
||||
Update vif_index
|
||||
*/
|
||||
pim_iface_vif_index[pim_ifp->mroute_vif_index] = 0;
|
||||
pim_ifp->pim->iface_vif_index[pim_ifp->mroute_vif_index] = 0;
|
||||
|
||||
pim_ifp->mroute_vif_index = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pim_if_add_vif_all()
|
||||
{
|
||||
struct listnode *ifnode;
|
||||
struct listnode *ifnextnode;
|
||||
struct interface *ifp;
|
||||
|
||||
for (ALL_LIST_ELEMENTS(vrf_iflist(pimg->vrf_id), ifnode, ifnextnode,
|
||||
ifp)) {
|
||||
if (!ifp->info)
|
||||
continue;
|
||||
|
||||
pim_if_add_vif(ifp);
|
||||
}
|
||||
}
|
||||
|
||||
void pim_if_del_vif_all()
|
||||
{
|
||||
struct listnode *ifnode;
|
||||
struct listnode *ifnextnode;
|
||||
struct interface *ifp;
|
||||
|
||||
for (ALL_LIST_ELEMENTS(vrf_iflist(pimg->vrf_id), ifnode, ifnextnode,
|
||||
ifp)) {
|
||||
if (!ifp->info)
|
||||
continue;
|
||||
|
||||
pim_if_del_vif(ifp);
|
||||
}
|
||||
}
|
||||
|
||||
// DBS - VRF Revist
|
||||
struct interface *pim_if_find_by_vif_index(ifindex_t vif_index)
|
||||
{
|
||||
|
@ -140,7 +140,6 @@ struct pim_interface {
|
||||
struct bfd_info *bfd_info;
|
||||
};
|
||||
|
||||
extern struct list *pim_ifchannel_list;
|
||||
/*
|
||||
if default_holdtime is set (>= 0), use it;
|
||||
otherwise default_holdtime is 3.5 * hello_period
|
||||
@ -150,8 +149,8 @@ extern struct list *pim_ifchannel_list;
|
||||
? ((pim_ifp)->pim_hello_period * 7 / 2) \
|
||||
: ((pim_ifp)->pim_default_holdtime))
|
||||
|
||||
void pim_if_init(void);
|
||||
void pim_if_terminate(void);
|
||||
void pim_if_init(struct pim_instance *pim);
|
||||
void pim_if_terminate(struct pim_instance *pim);
|
||||
|
||||
struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim);
|
||||
void pim_if_delete(struct interface *ifp);
|
||||
@ -167,8 +166,8 @@ struct interface *pim_if_lookup_address_vrf(struct in_addr src,
|
||||
|
||||
int pim_if_add_vif(struct interface *ifp);
|
||||
int pim_if_del_vif(struct interface *ifp);
|
||||
void pim_if_add_vif_all(void);
|
||||
void pim_if_del_vif_all(void);
|
||||
void pim_if_add_vif_all(struct pim_instance *pim);
|
||||
void pim_if_del_vif_all(struct pim_instance *pim);
|
||||
|
||||
struct interface *pim_if_find_by_vif_index(ifindex_t vif_index);
|
||||
int pim_if_find_vifindex_by_ifindex(ifindex_t ifindex);
|
||||
|
@ -196,7 +196,7 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch)
|
||||
*/
|
||||
listnode_delete(pim_ifp->pim_ifchannel_list, ch);
|
||||
hash_release(pim_ifp->pim_ifchannel_hash, ch);
|
||||
listnode_delete(pim_ifchannel_list, ch);
|
||||
listnode_delete(pim_ifp->pim->ifchannel_list, ch);
|
||||
|
||||
if (PIM_DEBUG_PIM_TRACE)
|
||||
zlog_debug("%s: ifchannel entry %s is deleted ",
|
||||
@ -582,7 +582,7 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
|
||||
/* Attach to list */
|
||||
listnode_add_sort(pim_ifp->pim_ifchannel_list, ch);
|
||||
ch = hash_get(pim_ifp->pim_ifchannel_hash, ch, hash_alloc_intern);
|
||||
listnode_add_sort(pim_ifchannel_list, ch);
|
||||
listnode_add_sort(pim_ifp->pim->ifchannel_list, ch);
|
||||
|
||||
listnode_add_sort(up->ifchannels, ch);
|
||||
|
||||
@ -1057,7 +1057,7 @@ int pim_ifchannel_local_membership_add(struct interface *ifp,
|
||||
}
|
||||
|
||||
if (pim->spt.switchover == PIM_SPT_INFINITY) {
|
||||
if (pimg->spt.plist) {
|
||||
if (pim->spt.plist) {
|
||||
struct prefix_list *plist = prefix_list_lookup(
|
||||
AFI_IP, pim->spt.plist);
|
||||
struct prefix g;
|
||||
@ -1271,8 +1271,9 @@ void pim_ifchannel_scan_forward_start(struct interface *new_ifp)
|
||||
struct listnode *ifnode;
|
||||
struct interface *ifp;
|
||||
struct pim_interface *new_pim_ifp = new_ifp->info;
|
||||
struct pim_instance *pim = new_pim_ifp->pim;
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pimg->vrf_id), ifnode, ifp)) {
|
||||
for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
|
||||
struct pim_interface *loop_pim_ifp = ifp->info;
|
||||
struct listnode *ch_node;
|
||||
struct pim_ifchannel *ch;
|
||||
|
@ -52,6 +52,8 @@ static void pim_instance_terminate(struct pim_instance *pim)
|
||||
|
||||
pim_upstream_terminate(pim);
|
||||
|
||||
pim_if_terminate(pim);
|
||||
|
||||
XFREE(MTYPE_PIM_PIM_INSTANCE, pimg);
|
||||
}
|
||||
|
||||
@ -63,6 +65,8 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
|
||||
if (!pim)
|
||||
return NULL;
|
||||
|
||||
pim_if_init(pim);
|
||||
|
||||
pim->vrf_id = vrf->vrf_id;
|
||||
pim->vrf = vrf;
|
||||
|
||||
|
@ -21,6 +21,17 @@
|
||||
#ifndef __PIM_INSTANCE_H__
|
||||
#define __PIM_INSTANCE_H__
|
||||
|
||||
#if defined(HAVE_LINUX_MROUTE_H)
|
||||
#include <linux/mroute.h>
|
||||
#else
|
||||
/*
|
||||
Below: from <linux/mroute.h>
|
||||
*/
|
||||
|
||||
#ifndef MAXVIFS
|
||||
#define MAXVIFS (256)
|
||||
#endif
|
||||
#endif
|
||||
extern struct pim_instance *pimg; // Pim Global Instance
|
||||
|
||||
enum pim_spt_switchover {
|
||||
@ -63,6 +74,9 @@ struct pim_instance {
|
||||
struct timer_wheel *upstream_sg_wheel;
|
||||
|
||||
struct list *rp_list;
|
||||
|
||||
struct list *ifchannel_list;
|
||||
int iface_vif_index[MAXVIFS];
|
||||
};
|
||||
|
||||
void pim_vrf_init(void);
|
||||
|
@ -94,8 +94,6 @@ static void pim_free()
|
||||
|
||||
pim_oil_terminate();
|
||||
|
||||
pim_if_terminate();
|
||||
|
||||
pim_route_map_terminate();
|
||||
|
||||
zclient_lookup_free();
|
||||
@ -132,7 +130,6 @@ void pim_init()
|
||||
qpim_infinite_assert_metric.route_metric = PIM_ASSERT_ROUTE_METRIC_MAX;
|
||||
qpim_infinite_assert_metric.ip_address.s_addr = INADDR_ANY;
|
||||
|
||||
pim_if_init();
|
||||
pim_cmd_init();
|
||||
pim_ssmpingd_init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user