| 1237 | } |
| 1238 | |
| 1239 | static void |
| 1240 | bstp_set_port_role(struct bstp_port *bp, int role) |
| 1241 | { |
| 1242 | struct bstp_state *bs = bp->bp_bs; |
| 1243 | |
| 1244 | if (bp->bp_role == role) |
| 1245 | return; |
| 1246 | |
| 1247 | /* perform pre-change tasks */ |
| 1248 | switch (bp->bp_role) { |
| 1249 | case BSTP_ROLE_DISABLED: |
| 1250 | bstp_timer_start(&bp->bp_forward_delay_timer, |
| 1251 | bp->bp_desg_max_age); |
| 1252 | break; |
| 1253 | |
| 1254 | case BSTP_ROLE_BACKUP: |
| 1255 | bstp_timer_start(&bp->bp_recent_backup_timer, |
| 1256 | bp->bp_desg_htime * 2); |
| 1257 | /* fall through */ |
| 1258 | case BSTP_ROLE_ALTERNATE: |
| 1259 | bstp_timer_start(&bp->bp_forward_delay_timer, |
| 1260 | bp->bp_desg_fdelay); |
| 1261 | bp->bp_sync = 0; |
| 1262 | bp->bp_synced = 1; |
| 1263 | bp->bp_reroot = 0; |
| 1264 | break; |
| 1265 | |
| 1266 | case BSTP_ROLE_ROOT: |
| 1267 | bstp_timer_start(&bp->bp_recent_root_timer, |
| 1268 | BSTP_DEFAULT_FORWARD_DELAY); |
| 1269 | break; |
| 1270 | } |
| 1271 | |
| 1272 | bp->bp_role = role; |
| 1273 | /* clear values not carried between roles */ |
| 1274 | bp->bp_proposing = 0; |
| 1275 | bs->bs_allsynced = 0; |
| 1276 | |
| 1277 | /* initialise the new role */ |
| 1278 | switch (bp->bp_role) { |
| 1279 | case BSTP_ROLE_DISABLED: |
| 1280 | case BSTP_ROLE_ALTERNATE: |
| 1281 | case BSTP_ROLE_BACKUP: |
| 1282 | DPRINTF("%s role -> ALT/BACK/DISABLED\n", |
| 1283 | bp->bp_ifp->if_xname); |
| 1284 | bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); |
| 1285 | bstp_timer_stop(&bp->bp_recent_root_timer); |
| 1286 | bstp_timer_latch(&bp->bp_forward_delay_timer); |
| 1287 | bp->bp_sync = 0; |
| 1288 | bp->bp_synced = 1; |
| 1289 | bp->bp_reroot = 0; |
| 1290 | break; |
| 1291 | |
| 1292 | case BSTP_ROLE_ROOT: |
| 1293 | DPRINTF("%s role -> ROOT\n", |
| 1294 | bp->bp_ifp->if_xname); |
| 1295 | bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); |
| 1296 | bstp_timer_latch(&bp->bp_recent_root_timer); |
no test coverage detected