]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_oil.h
pimd: Convert the channel_oil_list|hash to a rb_tree
[mirror_frr.git] / pimd / pim_oil.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_OIL_H
21#define PIM_OIL_H
22
23#include "pim_mroute.h"
5923b739 24#include "pim_iface.h"
12e41d03 25
0fba6e63
DS
26/*
27 * Where did we get this (S,G) from?
28 *
29 * IGMP - Learned from IGMP
30 * PIM - Learned from PIM
31 * SOURCE - Learned from Source multicast packet received
781a1745 32 * STAR - Inherited
0fba6e63
DS
33 */
34#define PIM_OIF_FLAG_PROTO_IGMP (1 << 0)
35#define PIM_OIF_FLAG_PROTO_PIM (1 << 1)
11e0acfb
DS
36#define PIM_OIF_FLAG_PROTO_STAR (1 << 2)
37#define PIM_OIF_FLAG_PROTO_VXLAN (1 << 3)
d45432cd
AK
38#define PIM_OIF_FLAG_PROTO_ANY \
39 (PIM_OIF_FLAG_PROTO_IGMP | PIM_OIF_FLAG_PROTO_PIM \
11e0acfb 40 | PIM_OIF_FLAG_PROTO_STAR | PIM_OIF_FLAG_PROTO_VXLAN)
12e41d03 41
5923b739
AK
42/* OIF is present in the OIL but must not be used for forwarding traffic */
43#define PIM_OIF_FLAG_MUTE (1 << 4)
1865a44a
DS
44/*
45 * We need a pimreg vif id from the kernel.
46 * Since ifindex == vif id for most cases and the number
47 * of expected interfaces is at most 100, using MAXVIFS -1
48 * is probably ok.
49 * Don't come running to me if this assumption is bad,
50 * fix it.
51 */
e34a317a
DS
52#define PIM_OIF_PIM_REGISTER_VIF 0
53#define PIM_MAX_USABLE_VIFS (MAXVIFS - 1)
1865a44a 54
d62a17ae 55struct channel_counts {
56 unsigned long long lastused;
cd333cf9 57 unsigned long origpktcnt;
d62a17ae 58 unsigned long pktcnt;
59 unsigned long oldpktcnt;
cd333cf9 60 unsigned long origbytecnt;
d62a17ae 61 unsigned long bytecnt;
62 unsigned long oldbytecnt;
cd333cf9 63 unsigned long origwrong_if;
d62a17ae 64 unsigned long wrong_if;
65 unsigned long oldwrong_if;
3667e8a0
DS
66};
67
12e41d03
DL
68/*
69 qpim_channel_oil_list holds a list of struct channel_oil.
70
71 Each channel_oil.oil is used to control an (S,G) entry in the Kernel
72 Multicast Forwarding Cache.
bbe598df
SP
73
74 There is a case when we create a channel_oil but don't install in the kernel
75
76 Case where (S, G) entry not installed in the kernel:
77 FRR receives IGMP/PIM (*, G) join and RP is not configured or
78 not-reachable, then create a channel_oil for the group G with the incoming
79 interface(channel_oil.oil.mfcc_parent) as invalid i.e "MAXVIF" and populate
80 the outgoing interface where join is received. Keep this entry in the stack,
81 but don't install in the kernel(channel_oil.installed = 0).
82
83 Case where (S, G) entry installed in the kernel:
84 When RP is configured and is reachable for the group G, and receiving a
85 join if channel_oil is already present then populate the incoming interface
86 and install the entry in the kernel, if channel_oil not present, then create
87 a new_channel oil(channel_oil.installed = 1).
88
89 is_valid: indicate if this entry is valid to get installed in kernel.
90 installed: indicate if this entry is installed in the kernel.
91
12e41d03 92*/
7315ecda 93PREDECL_RBTREE_UNIQ(rb_pim_oil)
12e41d03
DL
94
95struct channel_oil {
856e863f
DS
96 struct pim_instance *pim;
97
7315ecda
DS
98 struct rb_pim_oil_item oil_rb;
99
d62a17ae 100 struct mfcctl oil;
101 int installed;
102 int oil_inherited_rescan;
103 int oil_size;
104 int oil_ref_count;
105 time_t oif_creation[MAXVIFS];
106 uint32_t oif_flags[MAXVIFS];
107 struct channel_counts cc;
108 struct pim_upstream *up;
e7cd85bd 109 time_t mroute_creation;
12e41d03
DL
110};
111
7315ecda
DS
112extern int pim_channel_oil_compare(const struct channel_oil *c1,
113 const struct channel_oil *c2);
114DECLARE_RBTREE_UNIQ(rb_pim_oil, struct channel_oil, oil_rb,
115 pim_channel_oil_compare)
116
117
040d86ad
DS
118extern struct list *pim_channel_oil_list;
119
611925dc
DS
120void pim_oil_init(struct pim_instance *pim);
121void pim_oil_terminate(struct pim_instance *pim);
040d86ad 122
12e41d03 123void pim_channel_oil_free(struct channel_oil *c_oil);
4d9ad5dc
MS
124struct channel_oil *pim_find_channel_oil(struct pim_instance *pim,
125 struct prefix_sg *sg);
611925dc
DS
126struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
127 struct prefix_sg *sg,
7984af18 128 const char *name);
afb2f470
DS
129void pim_channel_oil_change_iif(struct pim_instance *pim,
130 struct channel_oil *c_oil, int input_vif_index,
131 const char *name);
a155fed5
AK
132struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil,
133 const char *name);
12e41d03 134
d62a17ae 135int pim_channel_add_oif(struct channel_oil *c_oil, struct interface *oif,
1b249e70 136 uint32_t proto_mask, const char *caller);
d62a17ae 137int pim_channel_del_oif(struct channel_oil *c_oil, struct interface *oif,
1b249e70 138 uint32_t proto_mask, const char *caller);
1865a44a 139
d62a17ae 140int pim_channel_oil_empty(struct channel_oil *c_oil);
781a1745 141
d62a17ae 142char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size);
5923b739
AK
143
144void pim_channel_update_oif_mute(struct channel_oil *c_oil,
145 struct pim_interface *pim_ifp);
a155fed5
AK
146
147void pim_channel_oil_upstream_deref(struct channel_oil *c_oil);
1537a668
AK
148void pim_channel_del_inherited_oif(struct channel_oil *c_oil,
149 struct interface *oif, const char *caller);
150
12e41d03 151#endif /* PIM_OIL_H */