]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_upstream.h
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / pimd / pim_upstream.h
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#ifndef PIM_UPSTREAM_H
21#define PIM_UPSTREAM_H
22
23#include <zebra.h>
05e451f8 24#include <prefix.h>
ba4eb1bc 25#include "plist.h"
12e41d03 26
f9717886 27#include <pimd/pim_rpf.h>
ba4eb1bc
CS
28#include "pim_str.h"
29#include "pim_ifchannel.h"
bfea315d 30
12e41d03 31#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0)
ca973133
DS
32#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (1 << 1)
33#define PIM_UPSTREAM_FLAG_MASK_FHR (1 << 2)
34#define PIM_UPSTREAM_FLAG_MASK_SRC_IGMP (1 << 3)
35#define PIM_UPSTREAM_FLAG_MASK_SRC_PIM (1 << 4)
36#define PIM_UPSTREAM_FLAG_MASK_SRC_STREAM (1 << 5)
1bf16443 37#define PIM_UPSTREAM_FLAG_MASK_SRC_MSDP (1 << 6)
54179a37 38#define PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE (1 << 7)
850a9f99
DS
39#define PIM_UPSTREAM_FLAG_MASK_SRC_LHR (1 << 8)
40#define PIM_UPSTREAM_FLAG_ALL 0xFFFFFFFF
12e41d03
DL
41
42#define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
43#define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 44#define PIM_UPSTREAM_FLAG_TEST_FHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
45#define PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
46#define PIM_UPSTREAM_FLAG_TEST_SRC_PIM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
47#define PIM_UPSTREAM_FLAG_TEST_SRC_STREAM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
7667c556 48#define PIM_UPSTREAM_FLAG_TEST_SRC_MSDP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
54179a37 49#define PIM_UPSTREAM_FLAG_TEST_SEND_SG_RPT_PRUNE(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE)
850a9f99 50#define PIM_UPSTREAM_FLAG_TEST_SRC_LHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_LHR)
12e41d03
DL
51
52#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
53#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 54#define PIM_UPSTREAM_FLAG_SET_FHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
55#define PIM_UPSTREAM_FLAG_SET_SRC_IGMP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
56#define PIM_UPSTREAM_FLAG_SET_SRC_PIM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
57#define PIM_UPSTREAM_FLAG_SET_SRC_STREAM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
7667c556 58#define PIM_UPSTREAM_FLAG_SET_SRC_MSDP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
54179a37 59#define PIM_UPSTREAM_FLAG_SET_SEND_SG_RPT_PRUNE(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE)
850a9f99 60#define PIM_UPSTREAM_FLAG_SET_SRC_LHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_LHR)
12e41d03
DL
61
62#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
63#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 64#define PIM_UPSTREAM_FLAG_UNSET_FHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
65#define PIM_UPSTREAM_FLAG_UNSET_SRC_IGMP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
66#define PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
67#define PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
7667c556 68#define PIM_UPSTREAM_FLAG_UNSET_SRC_MSDP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
54179a37 69#define PIM_UPSTREAM_FLAG_UNSET_SEND_SG_RPT_PRUNE(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE)
850a9f99 70#define PIM_UPSTREAM_FLAG_UNSET_SRC_LHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_LHR)
12e41d03 71
12e41d03 72enum pim_upstream_state {
d62a17ae 73 PIM_UPSTREAM_NOTJOINED,
74 PIM_UPSTREAM_JOINED,
12e41d03
DL
75};
76
0c2ebf00 77enum pim_reg_state {
d62a17ae 78 PIM_REG_NOINFO,
79 PIM_REG_JOIN,
80 PIM_REG_JOIN_PENDING,
81 PIM_REG_PRUNE,
0c2ebf00 82};
83
d99764f6 84enum pim_upstream_sptbit {
d62a17ae 85 PIM_UPSTREAM_SPTBIT_FALSE,
86 PIM_UPSTREAM_SPTBIT_TRUE
d99764f6
DS
87};
88
12e41d03
DL
89/*
90 Upstream (S,G) channel in Joined state
d62a17ae 91
12e41d03 92 (S,G) in the "Not Joined" state is not represented
d62a17ae 93
12e41d03
DL
94 See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message
95*/
96struct pim_upstream {
d62a17ae 97 struct pim_upstream *parent;
98 struct in_addr upstream_addr; /* Who we are talking to */
99 struct in_addr upstream_register; /*Who we received a register from*/
100 struct prefix_sg sg; /* (S,G) group key */
101 char sg_str[PIM_SG_LEN];
102 uint32_t flags;
103 struct channel_oil *channel_oil;
104 struct list *sources;
105 struct list *ifchannels;
106
107 enum pim_upstream_state join_state;
108 enum pim_reg_state reg_state;
109 enum pim_upstream_sptbit sptbit;
110
111 int ref_count;
112
113 struct pim_rpf rpf;
114
115 struct thread *t_join_timer;
116
117 /*
118 * RST(S,G)
119 */
120 struct thread *t_rs_timer;
2ddab288 121#define PIM_REGISTER_SUPPRESSION_PERIOD (60)
38de2445 122#define PIM_REGISTER_PROBE_PERIOD (5)
2ddab288 123
d62a17ae 124 /*
125 * KAT(S,G)
126 */
127 struct thread *t_ka_timer;
4a4c4a07
DS
128#define PIM_KEEPALIVE_PERIOD (210)
129#define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time )
130
d62a17ae 131 /* on the RP we restart a timer to indicate if registers are being rxed
132 * for
133 * SG. This is needed by MSDP to determine its local SA cache */
134 struct thread *t_msdp_reg_timer;
1bf16443 135#define PIM_MSDP_REG_RXED_PERIOD (3 * (1.5 * qpim_register_suppress_time))
136
d62a17ae 137 int64_t state_transition; /* Record current state uptime */
12e41d03
DL
138};
139
9b29ea95
DS
140struct pim_upstream *pim_upstream_find(struct pim_instance *pim,
141 struct prefix_sg *sg);
d62a17ae 142struct pim_upstream *pim_upstream_find_or_add(struct prefix_sg *sg,
143 struct interface *ifp, int flags,
144 const char *name);
2002dcdb
DS
145struct pim_upstream *pim_upstream_add(struct pim_instance *pim,
146 struct prefix_sg *sg,
d62a17ae 147 struct interface *ifp, int flags,
0885a9f1
DS
148 const char *name,
149 struct pim_ifchannel *ch);
d62a17ae 150void pim_upstream_ref(struct pim_upstream *up, int flags, const char *name);
9b29ea95
DS
151struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
152 struct pim_upstream *up,
d62a17ae 153 const char *name);
12e41d03 154
9b29ea95
DS
155int pim_upstream_evaluate_join_desired(struct pim_instance *pim,
156 struct pim_upstream *up);
9f44d042 157int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up,
d62a17ae 158 struct pim_ifchannel *ch,
159 struct pim_ifchannel *starch);
9b29ea95
DS
160void pim_upstream_update_join_desired(struct pim_instance *pim,
161 struct pim_upstream *up);
12e41d03
DL
162
163void pim_upstream_join_suppress(struct pim_upstream *up,
d62a17ae 164 struct in_addr rpf_addr, int holdtime);
c48a612c 165
12e41d03 166void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,
d62a17ae 167 struct pim_upstream *up);
c48a612c 168
d62a17ae 169void pim_upstream_join_timer_restart(struct pim_upstream *up,
170 struct pim_rpf *old);
9b29ea95
DS
171void pim_upstream_rpf_genid_changed(struct pim_instance *pim,
172 struct in_addr neigh_addr);
12e41d03
DL
173void pim_upstream_rpf_interface_changed(struct pim_upstream *up,
174 struct interface *old_rpf_ifp);
175
176void pim_upstream_update_could_assert(struct pim_upstream *up);
177void pim_upstream_update_my_assert_metric(struct pim_upstream *up);
178
d62a17ae 179void pim_upstream_keep_alive_timer_start(struct pim_upstream *up,
180 uint32_t time);
cb40b272 181
8e5f97e3
DS
182int pim_upstream_switch_to_spt_desired(struct pim_instance *pim,
183 struct prefix_sg *sg);
184#define SwitchToSptDesired(pim, sg) pim_upstream_switch_to_spt_desired (pim, sg)
d62a17ae 185int pim_upstream_is_sg_rpt(struct pim_upstream *up);
cb40b272 186
d62a17ae 187void pim_upstream_set_sptbit(struct pim_upstream *up,
188 struct interface *incoming);
3a66b17b 189
d62a17ae 190void pim_upstream_start_register_stop_timer(struct pim_upstream *up,
191 int null_register);
627ed2a3 192
d62a17ae 193void pim_upstream_send_join(struct pim_upstream *up);
56638739 194
1eca8576 195void pim_upstream_switch(struct pim_instance *pim, struct pim_upstream *up,
d62a17ae 196 enum pim_upstream_state new_state);
7fcdfb34 197
d62a17ae 198const char *pim_upstream_state2str(enum pim_upstream_state join_state);
e0e127b0 199#define PIM_REG_STATE_STR_LEN 12
d62a17ae 200const char *pim_reg_state2str(enum pim_reg_state state, char *state_str);
4fdc8f36 201
9b29ea95
DS
202int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
203 struct pim_upstream *up);
204int pim_upstream_inherited_olist(struct pim_instance *pim,
205 struct pim_upstream *up);
d62a17ae 206int pim_upstream_empty_inherited_olist(struct pim_upstream *up);
d3dd1804 207
9b29ea95 208void pim_upstream_find_new_rpf(struct pim_instance *pim);
1bf16443 209void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up);
d3dd1804 210
9b29ea95
DS
211void pim_upstream_init(struct pim_instance *pim);
212void pim_upstream_terminate(struct pim_instance *pim);
982bff89 213
d62a17ae 214void join_timer_start(struct pim_upstream *up);
215int pim_upstream_compare(void *arg1, void *arg2);
9b29ea95 216void pim_upstream_register_reevaluate(struct pim_instance *pim);
a7b2b1e2 217
9b29ea95
DS
218void pim_upstream_add_lhr_star_pimreg(struct pim_instance *pim);
219void pim_upstream_remove_lhr_star_pimreg(struct pim_instance *pim,
220 const char *nlist);
df94f9a9 221
9b29ea95
DS
222void pim_upstream_spt_prefix_list_update(struct pim_instance *pim,
223 struct prefix_list *pl);
7c591950
DS
224
225unsigned int pim_upstream_hash_key(void *arg);
74df8d6d 226bool pim_upstream_equal(const void *arg1, const void *arg2);
12e41d03 227#endif /* PIM_UPSTREAM_H */