2 * pim_bsm.h: PIM BSM handling related
4 * Copyright (C) 2018-19 Vmware, Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program 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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
34 #define PIM_GBL_SZ_ID 0 /* global scope zone id set to 0 */
35 #define PIM_BS_TIME 60 /* RFC 5059 - Sec 5 */
36 #define PIM_BSR_DEFAULT_TIMEOUT 130 /* RFC 5059 - Sec 5 */
38 /* These structures are only encoded IPv4 specific */
39 #define PIM_BSM_HDR_LEN sizeof(struct bsm_hdr)
40 #define PIM_BSM_GRP_LEN sizeof(struct bsmmsg_grpinfo)
41 #define PIM_BSM_RP_LEN sizeof(struct bsmmsg_rpinfo)
43 #define PIM_MIN_BSM_LEN \
44 (PIM_HDR_LEN + PIM_BSM_HDR_LEN + PIM_BSM_GRP_LEN + PIM_BSM_RP_LEN)
50 /* Non candidate BSR states */
57 /* BSM scope - bsm processing is per scope */
59 int sz_id
; /* scope zone id */
60 enum ncbsr_state state
; /* non candidate BSR state */
61 bool accept_nofwd_bsm
; /* no fwd bsm accepted for scope */
62 struct in_addr current_bsr
; /* current elected BSR for the sz */
63 uint32_t current_bsr_prio
; /* current BSR priority */
64 int64_t current_bsr_first_ts
; /* current BSR elected time */
65 int64_t current_bsr_last_ts
; /* Last BSM received from E-BSR */
66 uint16_t bsm_frag_tag
; /* Last received frag tag from E-BSR */
67 uint8_t hashMasklen
; /* Mask in hash calc RFC 7761 4.7.2 */
68 struct pim_instance
*pim
; /* Back pointer to pim instance */
69 struct list
*bsm_list
; /* list of bsm frag for frowarding */
70 struct route_table
*bsrp_table
; /* group2rp mapping rcvd from BSR */
71 struct thread
*bs_timer
; /* Boot strap timer */
72 struct thread
*sz_timer
;
75 /* BSM packet - this is stored as list in bsm_list inside scope
76 * This is used for forwarding to new neighbors or restarting mcast routers
79 uint32_t size
; /* size of the packet */
80 unsigned char *bsm
; /* Actual packet */
83 /* This is the group node of the bsrp table in scope.
84 * this node maintains the list of rp for the group.
87 struct prefix group
; /* Group range */
88 struct bsm_scope
*scope
; /* Back ptr to scope */
89 struct list
*bsrp_list
; /* list of RPs adv by BSR */
90 struct list
*partial_bsrp_list
; /* maintained until all RPs received */
91 int pend_rp_cnt
; /* Total RP - Received RP */
92 uint16_t frag_tag
; /* frag tag to identify the fragment */
95 /* This is the list node of bsrp_list and partial bsrp list in
96 * bsgrp_node. Hold info of each RP received for the group
99 uint32_t hash
; /* Hash Value as per RFC 7761 4.7.2 */
100 uint32_t elapse_time
; /* upd at expiry of elected RP node */
101 uint16_t rp_prio
; /* RP priority */
102 uint16_t rp_holdtime
; /* RP holdtime - g2rp timer value */
103 struct in_addr rp_address
; /* RP Address */
104 struct bsgrp_node
*bsgrp_node
; /* Back ptr to bsgrp_node */
105 struct thread
*g2rp_timer
; /* Run only for elected RP node */
108 /* Structures to extract Bootstrap Message header and Grp to RP Mappings
109 * =====================================================================
113 * 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
114 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
115 * |PIM Ver| Type |N| Reserved | Checksum | PIM HDR
116 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
117 * | Fragment Tag | Hash Mask Len | BSR Priority | BS HDR(1)
118 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119 * | BSR Address (Encoded-Unicast format) | BS HDR(2)
120 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
121 * | Group Address 1 (Encoded-Group format) |
122 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
123 * | RP Count 1 | Frag RP Cnt 1 | Reserved |
124 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
125 * | RP Address 1 (Encoded-Unicast format) |
126 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
127 * | RP1 Holdtime | RP1 Priority | Reserved |
128 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129 * | RP Address 2 (Encoded-Unicast format) |
130 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131 * | RP2 Holdtime | RP2 Priority | Reserved |
132 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
135 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
136 * | RP Address m (Encoded-Unicast format) |
137 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
138 * | RPm Holdtime | RPm Priority | Reserved |
139 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 * | Group Address 2 (Encoded-Group format) |
141 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
144 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145 * | Group Address n (Encoded-Group format) |
146 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
147 * | RP Count n | Frag RP Cnt n | Reserved |
148 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
149 * | RP Address 1 (Encoded-Unicast format) |
150 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151 * | RP1 Holdtime | RP1 Priority | Reserved |
152 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
153 * | RP Address 2 (Encoded-Unicast format) |
154 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
155 * | RP2 Holdtime | RP2 Priority | Reserved |
156 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
159 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
160 * | RP Address m (Encoded-Unicast format) |
161 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
162 * | RPm Holdtime | RPm Priority | Reserved |
163 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
169 struct pim_encoded_ipv4_unicast bsr_addr
;
170 } __attribute__((packed
));
172 struct bsmmsg_grpinfo
{
173 struct pim_encoded_group_ipv4 group
;
175 uint8_t frag_rp_count
;
177 } __attribute__((packed
));
179 struct bsmmsg_rpinfo
{
180 struct pim_encoded_ipv4_unicast rpaddr
;
181 uint16_t rp_holdtime
;
184 } __attribute__((packed
));
187 void pim_bsm_proc_init(struct pim_instance
*pim
);
188 void pim_bsm_proc_free(struct pim_instance
*pim
);
189 void pim_bsm_write_config(struct vty
*vty
, struct interface
*ifp
);
190 int pim_bsm_process(struct interface
*ifp
,
195 bool pim_bsm_new_nbr_fwd(struct pim_neighbor
*neigh
, struct interface
*ifp
);
196 struct bsgrp_node
*pim_bsm_get_bsgrp_node(struct bsm_scope
*scope
,