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 (PIM_HDR_LEN + \
51 /* Non candidate BSR states */
58 /* BSM scope - bsm processing is per scope */
60 int sz_id
; /* scope zone id */
61 enum ncbsr_state state
; /* non candidate BSR state */
62 bool accept_nofwd_bsm
; /* no fwd bsm accepted for scope */
63 struct in_addr current_bsr
; /* current elected BSR for the sz */
64 uint32_t current_bsr_prio
; /* current BSR priority */
65 int64_t current_bsr_first_ts
; /* current BSR elected time */
66 int64_t current_bsr_last_ts
; /* Last BSM received from E-BSR */
67 uint16_t bsm_frag_tag
; /* Last received frag tag from E-BSR */
68 uint8_t hashMasklen
; /* Mask in hash calc RFC 7761 4.7.2 */
69 struct pim_instance
*pim
; /* Back pointer to pim instance */
70 struct list
*bsm_list
; /* list of bsm frag for frowarding */
71 struct route_table
*bsrp_table
; /* group2rp mapping rcvd from BSR */
72 struct thread
*bs_timer
; /* Boot strap timer */
73 struct thread
*sz_timer
;
76 /* BSM packet - this is stored as list in bsm_list inside scope
77 * This is used for forwarding to new neighbors or restarting mcast routers
80 uint32_t size
; /* size of the packet */
81 unsigned char *bsm
; /* Actual packet */
84 /* This is the group node of the bsrp table in scope.
85 * this node maintains the list of rp for the group.
88 struct prefix group
; /* Group range */
89 struct bsm_scope
*scope
; /* Back ptr to scope */
90 struct list
*bsrp_list
; /* list of RPs adv by BSR */
91 struct list
*partial_bsrp_list
; /* maintained until all RPs received */
92 int pend_rp_cnt
; /* Total RP - Received RP */
93 uint16_t frag_tag
; /* frag tag to identify the fragment */
96 /* This is the list node of bsrp_list and partial bsrp list in
97 * bsgrp_node. Hold info of each RP received for the group
100 uint32_t hash
; /* Hash Value as per RFC 7761 4.7.2 */
101 uint32_t elapse_time
; /* upd at expiry of elected RP node */
102 uint16_t rp_prio
; /* RP priority */
103 uint16_t rp_holdtime
; /* RP holdtime - g2rp timer value */
104 struct in_addr rp_address
; /* RP Address */
105 struct bsgrp_node
*bsgrp_node
; /* Back ptr to bsgrp_node */
106 struct thread
*g2rp_timer
; /* Run only for elected RP node */
109 /* Structures to extract Bootstrap Message header and Grp to RP Mappings
110 * =====================================================================
114 * 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
115 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116 * |PIM Ver| Type |N| Reserved | Checksum | PIM HDR
117 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
118 * | Fragment Tag | Hash Mask Len | BSR Priority | BS HDR(1)
119 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120 * | BSR Address (Encoded-Unicast format) | BS HDR(2)
121 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
122 * | Group Address 1 (Encoded-Group format) |
123 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
124 * | RP Count 1 | Frag RP Cnt 1 | Reserved |
125 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126 * | RP Address 1 (Encoded-Unicast format) |
127 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128 * | RP1 Holdtime | RP1 Priority | Reserved |
129 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130 * | RP Address 2 (Encoded-Unicast format) |
131 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132 * | RP2 Holdtime | RP2 Priority | Reserved |
133 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
136 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
137 * | RP Address m (Encoded-Unicast format) |
138 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139 * | RPm Holdtime | RPm Priority | Reserved |
140 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141 * | Group Address 2 (Encoded-Group format) |
142 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
146 * | Group Address n (Encoded-Group format) |
147 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
148 * | RP Count n | Frag RP Cnt n | Reserved |
149 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150 * | RP Address 1 (Encoded-Unicast format) |
151 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 * | RP1 Holdtime | RP1 Priority | Reserved |
153 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 * | RP Address 2 (Encoded-Unicast format) |
155 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
156 * | RP2 Holdtime | RP2 Priority | Reserved |
157 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
160 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
161 * | RP Address m (Encoded-Unicast format) |
162 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
163 * | RPm Holdtime | RPm Priority | Reserved |
164 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
170 struct pim_encoded_ipv4_unicast bsr_addr
;
171 }__attribute__((packed
));
173 struct bsmmsg_grpinfo
{
174 struct pim_encoded_group_ipv4 group
;
176 uint8_t frag_rp_count
;
178 }__attribute__((packed
));
180 struct bsmmsg_rpinfo
{
181 struct pim_encoded_ipv4_unicast rpaddr
;
182 uint16_t rp_holdtime
;
185 }__attribute__((packed
));
188 void pim_bsm_proc_init(struct pim_instance
*pim
);
189 void pim_bsm_proc_free(struct pim_instance
*pim
);