]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_oil.h
pim6d: IPv6-adjust mroute code
[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
e34e07e6
DL
23struct pim_interface;
24
12e41d03
DL
25#include "pim_mroute.h"
26
0fba6e63
DS
27/*
28 * Where did we get this (S,G) from?
29 *
30 * IGMP - Learned from IGMP
31 * PIM - Learned from PIM
32 * SOURCE - Learned from Source multicast packet received
781a1745 33 * STAR - Inherited
0fba6e63
DS
34 */
35#define PIM_OIF_FLAG_PROTO_IGMP (1 << 0)
36#define PIM_OIF_FLAG_PROTO_PIM (1 << 1)
11e0acfb
DS
37#define PIM_OIF_FLAG_PROTO_STAR (1 << 2)
38#define PIM_OIF_FLAG_PROTO_VXLAN (1 << 3)
d45432cd
AK
39#define PIM_OIF_FLAG_PROTO_ANY \
40 (PIM_OIF_FLAG_PROTO_IGMP | PIM_OIF_FLAG_PROTO_PIM \
11e0acfb 41 | PIM_OIF_FLAG_PROTO_STAR | PIM_OIF_FLAG_PROTO_VXLAN)
12e41d03 42
5923b739
AK
43/* OIF is present in the OIL but must not be used for forwarding traffic */
44#define PIM_OIF_FLAG_MUTE (1 << 4)
1865a44a
DS
45/*
46 * We need a pimreg vif id from the kernel.
47 * Since ifindex == vif id for most cases and the number
48 * of expected interfaces is at most 100, using MAXVIFS -1
49 * is probably ok.
50 * Don't come running to me if this assumption is bad,
51 * fix it.
52 */
e34a317a
DS
53#define PIM_OIF_PIM_REGISTER_VIF 0
54#define PIM_MAX_USABLE_VIFS (MAXVIFS - 1)
1865a44a 55
d62a17ae 56struct channel_counts {
57 unsigned long long lastused;
cd333cf9 58 unsigned long origpktcnt;
d62a17ae 59 unsigned long pktcnt;
60 unsigned long oldpktcnt;
cd333cf9 61 unsigned long origbytecnt;
d62a17ae 62 unsigned long bytecnt;
63 unsigned long oldbytecnt;
cd333cf9 64 unsigned long origwrong_if;
d62a17ae 65 unsigned long wrong_if;
66 unsigned long oldwrong_if;
3667e8a0
DS
67};
68
12e41d03
DL
69/*
70 qpim_channel_oil_list holds a list of struct channel_oil.
71
72 Each channel_oil.oil is used to control an (S,G) entry in the Kernel
73 Multicast Forwarding Cache.
bbe598df
SP
74
75 There is a case when we create a channel_oil but don't install in the kernel
76
77 Case where (S, G) entry not installed in the kernel:
78 FRR receives IGMP/PIM (*, G) join and RP is not configured or
79 not-reachable, then create a channel_oil for the group G with the incoming
80 interface(channel_oil.oil.mfcc_parent) as invalid i.e "MAXVIF" and populate
81 the outgoing interface where join is received. Keep this entry in the stack,
82 but don't install in the kernel(channel_oil.installed = 0).
83
84 Case where (S, G) entry installed in the kernel:
85 When RP is configured and is reachable for the group G, and receiving a
86 join if channel_oil is already present then populate the incoming interface
87 and install the entry in the kernel, if channel_oil not present, then create
88 a new_channel oil(channel_oil.installed = 1).
89
90 is_valid: indicate if this entry is valid to get installed in kernel.
91 installed: indicate if this entry is installed in the kernel.
92
12e41d03 93*/
960b9a53 94PREDECL_RBTREE_UNIQ(rb_pim_oil);
12e41d03
DL
95
96struct channel_oil {
856e863f
DS
97 struct pim_instance *pim;
98
7315ecda
DS
99 struct rb_pim_oil_item oil_rb;
100
a9338fa4 101 pim_mfcctl oil;
d62a17ae 102 int installed;
103 int oil_inherited_rescan;
104 int oil_size;
105 int oil_ref_count;
106 time_t oif_creation[MAXVIFS];
107 uint32_t oif_flags[MAXVIFS];
108 struct channel_counts cc;
109 struct pim_upstream *up;
e7cd85bd 110 time_t mroute_creation;
12e41d03
DL
111};
112
a9338fa4
DL
113#if PIM_IPV == 4
114static inline pim_addr *oil_origin(struct channel_oil *c_oil)
115{
116 return &c_oil->oil.mfcc_origin;
117}
118
119static inline pim_addr *oil_mcastgrp(struct channel_oil *c_oil)
120{
121 return &c_oil->oil.mfcc_mcastgrp;
122}
123
124static inline vifi_t *oil_parent(struct channel_oil *c_oil)
125{
126 return &c_oil->oil.mfcc_parent;
127}
128
129static inline uint8_t oil_if_has(struct channel_oil *c_oil, vifi_t ifi)
130{
131 return c_oil->oil.mfcc_ttls[ifi];
132}
133
134static inline void oil_if_set(struct channel_oil *c_oil, vifi_t ifi, uint8_t set)
135{
136 c_oil->oil.mfcc_ttls[ifi] = set;
137}
138#else
139static inline pim_addr *oil_origin(struct channel_oil *c_oil)
140{
141 return &c_oil->oil.mf6cc_origin.sin6_addr;
142}
143
144static inline pim_addr *oil_mcastgrp(struct channel_oil *c_oil)
145{
146 return &c_oil->oil.mf6cc_mcastgrp.sin6_addr;
147}
148
149static inline mifi_t *oil_parent(struct channel_oil *c_oil)
150{
151 return &c_oil->oil.mf6cc_parent;
152}
153
154static inline bool oil_if_has(struct channel_oil *c_oil, mifi_t ifi)
155{
156 return !!IF_ISSET(ifi, &c_oil->oil.mf6cc_ifset);
157}
158
159static inline void oil_if_set(struct channel_oil *c_oil, mifi_t ifi, bool set)
160{
161 if (set)
162 IF_SET(ifi, &c_oil->oil.mf6cc_ifset);
163 else
164 IF_CLR(ifi, &c_oil->oil.mf6cc_ifset);
165}
166#endif
167
7315ecda
DS
168extern int pim_channel_oil_compare(const struct channel_oil *c1,
169 const struct channel_oil *c2);
170DECLARE_RBTREE_UNIQ(rb_pim_oil, struct channel_oil, oil_rb,
960b9a53 171 pim_channel_oil_compare);
7315ecda
DS
172
173
040d86ad
DS
174extern struct list *pim_channel_oil_list;
175
611925dc
DS
176void pim_oil_init(struct pim_instance *pim);
177void pim_oil_terminate(struct pim_instance *pim);
040d86ad 178
12e41d03 179void pim_channel_oil_free(struct channel_oil *c_oil);
4d9ad5dc 180struct channel_oil *pim_find_channel_oil(struct pim_instance *pim,
6fff2cc6 181 pim_sgaddr *sg);
611925dc 182struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
6fff2cc6 183 pim_sgaddr *sg, const char *name);
afb2f470
DS
184void pim_channel_oil_change_iif(struct pim_instance *pim,
185 struct channel_oil *c_oil, int input_vif_index,
186 const char *name);
a155fed5 187struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil,
17823cdd 188 const char *name);
12e41d03 189
d62a17ae 190int pim_channel_add_oif(struct channel_oil *c_oil, struct interface *oif,
1b249e70 191 uint32_t proto_mask, const char *caller);
d62a17ae 192int pim_channel_del_oif(struct channel_oil *c_oil, struct interface *oif,
1b249e70 193 uint32_t proto_mask, const char *caller);
1865a44a 194
d62a17ae 195int pim_channel_oil_empty(struct channel_oil *c_oil);
781a1745 196
d62a17ae 197char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size);
5923b739
AK
198
199void pim_channel_update_oif_mute(struct channel_oil *c_oil,
200 struct pim_interface *pim_ifp);
a155fed5
AK
201
202void pim_channel_oil_upstream_deref(struct channel_oil *c_oil);
1537a668 203void pim_channel_del_inherited_oif(struct channel_oil *c_oil,
17823cdd 204 struct interface *oif, const char *caller);
1537a668 205
12e41d03 206#endif /* PIM_OIL_H */