]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_vxlan.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pimd / pim_vxlan.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
b583b035
AK
2/* PIM support for VxLAN BUM flooding
3 *
4 * Copyright (C) 2019 Cumulus Networks, Inc.
b583b035
AK
5 */
6
7#ifndef PIM_VXLAN_H
8#define PIM_VXLAN_H
9
993e3d8e
DL
10#include "pim_instance.h"
11
d889ab75
AK
12/* global timer used for miscellaneous staggered processing */
13#define PIM_VXLAN_WORK_TIME 1
14/* number of SG entries processed at one shot */
15#define PIM_VXLAN_WORK_MAX 500
16/* frequency of periodic NULL registers */
17#define PIM_VXLAN_NULL_REG_INTERVAL 60 /* seconds */
18
19#define vxlan_mlag (vxlan_info.mlag)
20
62429d84
AK
21enum pim_vxlan_sg_flags {
22 PIM_VXLAN_SGF_NONE = 0,
23 PIM_VXLAN_SGF_DEL_IN_PROG = (1 << 0),
24 PIM_VXLAN_SGF_OIF_INSTALLED = (1 << 1)
25};
26
b583b035
AK
27struct pim_vxlan_sg {
28 struct pim_instance *pim;
29
30 /* key */
6fff2cc6 31 pim_sgaddr sg;
b583b035 32 char sg_str[PIM_SG_LEN];
62429d84
AK
33
34 enum pim_vxlan_sg_flags flags;
35 struct pim_upstream *up;
d889ab75 36 struct listnode *work_node; /* to pim_vxlan.work_list */
62429d84
AK
37
38 /* termination info (only applicable to termination XG mroutes)
39 * term_if - termination device ipmr-lo is added to the OIL
40 * as local/IGMP membership to allow termination of vxlan traffic
41 */
42 struct interface *term_oif;
43
44 /* origination info
45 * iif - lo/vrf or peerlink (on MLAG setups)
46 * peerlink_oif - added to the OIL to send encapsulated BUM traffic to
47 * the MLAG peer switch
48 */
49 struct interface *iif;
50 /* on a MLAG setup the peerlink is added as a static OIF */
51 struct interface *orig_oif;
b583b035
AK
52};
53
1595f9bb
AK
54enum pim_vxlan_mlag_flags {
55 PIM_VXLAN_MLAGF_NONE = 0,
0309c55d
AK
56 PIM_VXLAN_MLAGF_ENABLED = (1 << 0),
57 PIM_VXLAN_MLAGF_DO_REG = (1 << 1)
1595f9bb
AK
58};
59
1595f9bb
AK
60struct pim_vxlan_mlag {
61 enum pim_vxlan_mlag_flags flags;
05ca004b
AK
62 /* XXX - remove this variable from here */
63 int role;
1595f9bb
AK
64 bool peer_state;
65 /* routed interface setup on top of MLAG peerlink */
66 struct interface *peerlink_rif;
67 struct in_addr reg_addr;
68};
69
d889ab75
AK
70enum pim_vxlan_flags {
71 PIM_VXLANF_NONE = 0,
72 PIM_VXLANF_WORK_INITED = (1 << 0)
73};
74
1595f9bb 75struct pim_vxlan {
d889ab75
AK
76 enum pim_vxlan_flags flags;
77
78 struct thread *work_timer;
79 struct list *work_list;
80 struct listnode *next_work;
81 int max_work_cnt;
82
1595f9bb
AK
83 struct pim_vxlan_mlag mlag;
84};
85
a513da36
AK
86/* zebra adds-
87 * 1. one (S, G) entry where S=local-VTEP-IP and G==BUM-mcast-grp for
88 * each BUM MDT. This is the origination entry.
89 * 2. and one (*, G) entry each MDT. This is the termination place holder.
90 *
91 * Note: This doesn't mean that only (*, G) mroutes are used for tunnel
92 * termination. (S, G) mroutes with ipmr-lo in the OIL can also be
93 * used for tunnel termiation if SPT switchover happens; however such
94 * SG entries are created by traffic and will NOT be a part of the vxlan SG
95 * database.
96 */
97static inline bool pim_vxlan_is_orig_mroute(struct pim_vxlan_sg *vxlan_sg)
98{
2a27f13b 99 return !pim_addr_is_any(vxlan_sg->sg.src);
a513da36
AK
100}
101
a155fed5
AK
102static inline bool pim_vxlan_is_local_sip(struct pim_upstream *up)
103{
2a27f13b
DL
104 return !pim_addr_is_any(up->sg.src) &&
105 up->rpf.source_nexthop.interface &&
106 if_is_loopback(up->rpf.source_nexthop.interface);
a155fed5
AK
107}
108
650d9ad1
AK
109static inline bool pim_vxlan_is_term_dev_cfg(struct pim_instance *pim,
110 struct interface *ifp)
111{
112 return pim->vxlan.term_if_cfg == ifp;
113}
114
f1e2901a 115extern struct pim_vxlan *pim_vxlan_p;
b583b035 116extern struct pim_vxlan_sg *pim_vxlan_sg_find(struct pim_instance *pim,
6fff2cc6 117 pim_sgaddr *sg);
b583b035 118extern struct pim_vxlan_sg *pim_vxlan_sg_add(struct pim_instance *pim,
6fff2cc6
DL
119 pim_sgaddr *sg);
120extern void pim_vxlan_sg_del(struct pim_instance *pim, pim_sgaddr *sg);
b9f3a51c
AK
121extern void pim_vxlan_update_sg_reg_state(struct pim_instance *pim,
122 struct pim_upstream *up, bool reg_join);
332087df 123extern struct pim_interface *pim_vxlan_get_term_ifp(struct pim_instance *pim);
269c1fe1
AK
124extern void pim_vxlan_add_vif(struct interface *ifp);
125extern void pim_vxlan_del_vif(struct interface *ifp);
0a2dcc1c
AK
126extern void pim_vxlan_add_term_dev(struct pim_instance *pim,
127 struct interface *ifp);
128extern void pim_vxlan_del_term_dev(struct pim_instance *pim);
48b33862
AK
129extern bool pim_vxlan_get_register_src(struct pim_instance *pim,
130 struct pim_upstream *up, struct in_addr *src_p);
131extern void pim_vxlan_mlag_update(bool enable, bool peer_state, uint32_t role,
132 struct interface *peerlink_rif,
133 struct in_addr *reg_addr);
0309c55d 134extern bool pim_vxlan_do_mlag_reg(void);
95586137
AK
135extern void pim_vxlan_inherit_mlag_flags(struct pim_instance *pim,
136 struct pim_upstream *up, bool inherit);
b583b035 137
3c582f62
DS
138/* Shutdown of PIM stop the thread */
139extern void pim_vxlan_terminate(void);
b583b035 140#endif /* PIM_VXLAN_H */