]>
Commit | Line | Data |
---|---|---|
b583b035 AK |
1 | /* PIM support for VxLAN BUM flooding |
2 | * | |
3 | * Copyright (C) 2019 Cumulus Networks, Inc. | |
4 | * | |
5 | * This file is part of FRR. | |
6 | * | |
7 | * FRR is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * FRR is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * This program is free software; you can redistribute it and/or modify | |
17 | * it under the terms of the GNU General Public License as published by | |
18 | * the Free Software Foundation; either version 2 of the License, or | |
19 | * (at your option) any later version. | |
20 | */ | |
21 | ||
22 | #ifndef PIM_VXLAN_H | |
23 | #define PIM_VXLAN_H | |
24 | ||
d889ab75 AK |
25 | /* global timer used for miscellaneous staggered processing */ |
26 | #define PIM_VXLAN_WORK_TIME 1 | |
27 | /* number of SG entries processed at one shot */ | |
28 | #define PIM_VXLAN_WORK_MAX 500 | |
29 | /* frequency of periodic NULL registers */ | |
30 | #define PIM_VXLAN_NULL_REG_INTERVAL 60 /* seconds */ | |
31 | ||
32 | #define vxlan_mlag (vxlan_info.mlag) | |
33 | ||
62429d84 AK |
34 | enum pim_vxlan_sg_flags { |
35 | PIM_VXLAN_SGF_NONE = 0, | |
36 | PIM_VXLAN_SGF_DEL_IN_PROG = (1 << 0), | |
37 | PIM_VXLAN_SGF_OIF_INSTALLED = (1 << 1) | |
38 | }; | |
39 | ||
b583b035 AK |
40 | struct pim_vxlan_sg { |
41 | struct pim_instance *pim; | |
42 | ||
43 | /* key */ | |
44 | struct prefix_sg sg; | |
45 | char sg_str[PIM_SG_LEN]; | |
62429d84 AK |
46 | |
47 | enum pim_vxlan_sg_flags flags; | |
48 | struct pim_upstream *up; | |
d889ab75 | 49 | struct listnode *work_node; /* to pim_vxlan.work_list */ |
62429d84 AK |
50 | |
51 | /* termination info (only applicable to termination XG mroutes) | |
52 | * term_if - termination device ipmr-lo is added to the OIL | |
53 | * as local/IGMP membership to allow termination of vxlan traffic | |
54 | */ | |
55 | struct interface *term_oif; | |
56 | ||
57 | /* origination info | |
58 | * iif - lo/vrf or peerlink (on MLAG setups) | |
59 | * peerlink_oif - added to the OIL to send encapsulated BUM traffic to | |
60 | * the MLAG peer switch | |
61 | */ | |
62 | struct interface *iif; | |
63 | /* on a MLAG setup the peerlink is added as a static OIF */ | |
64 | struct interface *orig_oif; | |
b583b035 AK |
65 | }; |
66 | ||
1595f9bb AK |
67 | enum pim_vxlan_mlag_flags { |
68 | PIM_VXLAN_MLAGF_NONE = 0, | |
0309c55d AK |
69 | PIM_VXLAN_MLAGF_ENABLED = (1 << 0), |
70 | PIM_VXLAN_MLAGF_DO_REG = (1 << 1) | |
1595f9bb AK |
71 | }; |
72 | ||
73 | enum pim_vxlan_mlag_role { | |
74 | PIM_VXLAN_MLAG_ROLE_SECONDARY = 0, | |
75 | PIM_VXLAN_MLAG_ROLE_PRIMARY | |
76 | }; | |
77 | ||
78 | struct pim_vxlan_mlag { | |
79 | enum pim_vxlan_mlag_flags flags; | |
80 | enum pim_vxlan_mlag_role role; | |
81 | bool peer_state; | |
82 | /* routed interface setup on top of MLAG peerlink */ | |
83 | struct interface *peerlink_rif; | |
84 | struct in_addr reg_addr; | |
85 | }; | |
86 | ||
d889ab75 AK |
87 | enum pim_vxlan_flags { |
88 | PIM_VXLANF_NONE = 0, | |
89 | PIM_VXLANF_WORK_INITED = (1 << 0) | |
90 | }; | |
91 | ||
1595f9bb | 92 | struct pim_vxlan { |
d889ab75 AK |
93 | enum pim_vxlan_flags flags; |
94 | ||
95 | struct thread *work_timer; | |
96 | struct list *work_list; | |
97 | struct listnode *next_work; | |
98 | int max_work_cnt; | |
99 | ||
1595f9bb AK |
100 | struct pim_vxlan_mlag mlag; |
101 | }; | |
102 | ||
a513da36 AK |
103 | /* zebra adds- |
104 | * 1. one (S, G) entry where S=local-VTEP-IP and G==BUM-mcast-grp for | |
105 | * each BUM MDT. This is the origination entry. | |
106 | * 2. and one (*, G) entry each MDT. This is the termination place holder. | |
107 | * | |
108 | * Note: This doesn't mean that only (*, G) mroutes are used for tunnel | |
109 | * termination. (S, G) mroutes with ipmr-lo in the OIL can also be | |
110 | * used for tunnel termiation if SPT switchover happens; however such | |
111 | * SG entries are created by traffic and will NOT be a part of the vxlan SG | |
112 | * database. | |
113 | */ | |
114 | static inline bool pim_vxlan_is_orig_mroute(struct pim_vxlan_sg *vxlan_sg) | |
115 | { | |
116 | return (vxlan_sg->sg.src.s_addr != 0); | |
117 | } | |
118 | ||
a155fed5 AK |
119 | static inline bool pim_vxlan_is_local_sip(struct pim_upstream *up) |
120 | { | |
121 | return (up->sg.src.s_addr != INADDR_ANY) && | |
122 | up->rpf.source_nexthop.interface && | |
123 | if_is_loopback_or_vrf(up->rpf.source_nexthop.interface); | |
124 | } | |
125 | ||
f1e2901a | 126 | extern struct pim_vxlan *pim_vxlan_p; |
b583b035 AK |
127 | extern struct pim_vxlan_sg *pim_vxlan_sg_find(struct pim_instance *pim, |
128 | struct prefix_sg *sg); | |
129 | extern struct pim_vxlan_sg *pim_vxlan_sg_add(struct pim_instance *pim, | |
130 | struct prefix_sg *sg); | |
131 | extern void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg); | |
b9f3a51c AK |
132 | extern void pim_vxlan_update_sg_reg_state(struct pim_instance *pim, |
133 | struct pim_upstream *up, bool reg_join); | |
332087df | 134 | extern struct pim_interface *pim_vxlan_get_term_ifp(struct pim_instance *pim); |
269c1fe1 AK |
135 | extern void pim_vxlan_add_vif(struct interface *ifp); |
136 | extern void pim_vxlan_del_vif(struct interface *ifp); | |
0a2dcc1c AK |
137 | extern void pim_vxlan_add_term_dev(struct pim_instance *pim, |
138 | struct interface *ifp); | |
139 | extern void pim_vxlan_del_term_dev(struct pim_instance *pim); | |
48b33862 AK |
140 | extern bool pim_vxlan_get_register_src(struct pim_instance *pim, |
141 | struct pim_upstream *up, struct in_addr *src_p); | |
142 | extern void pim_vxlan_mlag_update(bool enable, bool peer_state, uint32_t role, | |
143 | struct interface *peerlink_rif, | |
144 | struct in_addr *reg_addr); | |
7c85225c | 145 | extern void pim_vxlan_config_write(struct vty *vty, char *spaces, int *writes); |
0309c55d | 146 | extern bool pim_vxlan_do_mlag_reg(void); |
b583b035 AK |
147 | |
148 | #endif /* PIM_VXLAN_H */ |