]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pimd.c
pimd: Refactore qpim_static_route_list into pim->static_routes
[mirror_frr.git] / pimd / pimd.c
CommitLineData
12e41d03 1/*
896014f4
DL
2 * PIM for Quagga
3 * Copyright (C) 2008 Everton da Silva Marques
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
12e41d03
DL
19
20#include <zebra.h>
21
22#include "log.h"
23#include "memory.h"
9df99407 24#include "if.h"
dfe43e25
DW
25#include "prefix.h"
26#include "vty.h"
27#include "plist.h"
1bc98276
CS
28#include "hash.h"
29#include "jhash.h"
ba4eb1bc 30#include "vrf.h"
12e41d03
DL
31
32#include "pimd.h"
33#include "pim_cmd.h"
12e41d03
DL
34#include "pim_str.h"
35#include "pim_oil.h"
36#include "pim_pim.h"
12e41d03 37#include "pim_ssmpingd.h"
6250610a 38#include "pim_static.h"
36d6bd7d 39#include "pim_rp.h"
15a5dafe 40#include "pim_ssm.h"
0b6817c5 41#include "pim_zlookup.h"
c2cf4b02 42#include "pim_zebra.h"
12e41d03 43
d62a17ae 44const char *const PIM_ALL_SYSTEMS = MCAST_ALL_SYSTEMS;
45const char *const PIM_ALL_ROUTERS = MCAST_ALL_ROUTERS;
46const char *const PIM_ALL_PIM_ROUTERS = MCAST_ALL_PIM_ROUTERS;
12e41d03
DL
47const char *const PIM_ALL_IGMP_ROUTERS = MCAST_ALL_IGMP_ROUTERS;
48
d62a17ae 49struct thread_master *master = NULL;
50uint32_t qpim_debugs = 0;
d62a17ae 51int qpim_t_periodic =
52 PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */
53struct pim_assert_metric qpim_infinite_assert_metric;
54long qpim_rpf_cache_refresh_delay_msec = 50;
55struct thread *qpim_rpf_cache_refresher = NULL;
56int64_t qpim_rpf_cache_refresh_requests = 0;
57int64_t qpim_rpf_cache_refresh_events = 0;
58int64_t qpim_rpf_cache_refresh_last = 0;
59struct list *qpim_ssmpingd_list = NULL;
60struct in_addr qpim_ssmpingd_group_addr;
61int64_t qpim_scan_oil_events = 0;
62int64_t qpim_scan_oil_last = 0;
d62a17ae 63unsigned int qpim_keep_alive_time = PIM_KEEPALIVE_PERIOD;
64signed int qpim_rp_keep_alive_time = 0;
65int64_t qpim_nexthop_lookups = 0;
66int qpim_packet_process = PIM_DEFAULT_PACKET_PROCESS;
67uint8_t qpim_ecmp_enable = 0;
68uint8_t qpim_ecmp_rebalance_enable = 0;
69struct pim_instance *pimg = NULL;
12e41d03 70
4a4c4a07
DS
71int32_t qpim_register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
72int32_t qpim_register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT;
73
d62a17ae 74void pim_prefix_list_update(struct prefix_list *plist)
15a5dafe 75{
d62a17ae 76 pim_rp_prefix_list_update(plist);
77 pim_ssm_prefix_list_update(plist);
78 pim_upstream_spt_prefix_list_update(plist);
15a5dafe 79}
80
12e41d03
DL
81static void pim_free()
82{
d62a17ae 83 pim_ssmpingd_destroy();
12e41d03 84
d62a17ae 85 pim_oil_terminate();
12e41d03 86
d62a17ae 87 pim_upstream_terminate();
6250610a 88
d62a17ae 89 pim_if_terminate();
90 pim_rp_free();
59d4564e 91
d62a17ae 92 pim_route_map_terminate();
0b6817c5 93
d62a17ae 94 zclient_lookup_free();
0b6817c5 95
d62a17ae 96 zprivs_terminate(&pimd_privs);
12e41d03
DL
97}
98
99void pim_init()
100{
d62a17ae 101 qpim_rp_keep_alive_time = PIM_RP_KEEPALIVE_PERIOD;
102
103 pim_rp_init();
104
105 if (!inet_aton(PIM_ALL_PIM_ROUTERS, &qpim_all_pim_routers_addr)) {
106 zlog_err(
107 "%s %s: could not solve %s to group address: errno=%d: %s",
108 __FILE__, __PRETTY_FUNCTION__, PIM_ALL_PIM_ROUTERS,
109 errno, safe_strerror(errno));
110 zassert(0);
111 return;
112 }
113
114 pim_oil_init();
115
116 pim_upstream_init();
117
d62a17ae 118 /*
119 RFC 4601: 4.6.3. Assert Metrics
120
121 assert_metric
122 infinite_assert_metric() {
123 return {1,infinity,infinity,0}
124 }
125 */
126 qpim_infinite_assert_metric.rpt_bit_flag = 1;
127 qpim_infinite_assert_metric.metric_preference =
128 PIM_ASSERT_METRIC_PREFERENCE_MAX;
129 qpim_infinite_assert_metric.route_metric = PIM_ASSERT_ROUTE_METRIC_MAX;
130 qpim_infinite_assert_metric.ip_address.s_addr = INADDR_ANY;
131
132 pim_if_init();
133 pim_cmd_init();
134 pim_ssmpingd_init();
12e41d03
DL
135}
136
137void pim_terminate()
138{
d62a17ae 139 struct zclient *zclient;
da13682c 140
d62a17ae 141 pim_free();
1bc98276 142
d62a17ae 143 /* reverse prefix_list_init */
144 prefix_list_add_hook(NULL);
145 prefix_list_delete_hook(NULL);
146 prefix_list_reset();
1bc98276 147
d62a17ae 148 pim_vrf_terminate();
da13682c 149
d62a17ae 150 zclient = pim_zebra_zclient_get();
151 if (zclient) {
152 zclient_stop(zclient);
153 zclient_free(zclient);
154 }
12e41d03 155}