| 921 | } |
| 922 | |
| 923 | static void |
| 924 | bstp_update_roles(struct bstp_state *bs, struct bstp_port *bp) |
| 925 | { |
| 926 | switch (bp->bp_role) { |
| 927 | case BSTP_ROLE_DISABLED: |
| 928 | /* Clear any flags if set */ |
| 929 | if (bp->bp_sync || !bp->bp_synced || bp->bp_reroot) { |
| 930 | bp->bp_sync = 0; |
| 931 | bp->bp_synced = 1; |
| 932 | bp->bp_reroot = 0; |
| 933 | } |
| 934 | break; |
| 935 | |
| 936 | case BSTP_ROLE_ALTERNATE: |
| 937 | case BSTP_ROLE_BACKUP: |
| 938 | if ((bs->bs_allsynced && !bp->bp_agree) || |
| 939 | (bp->bp_proposed && bp->bp_agree)) { |
| 940 | bp->bp_proposed = 0; |
| 941 | bp->bp_agree = 1; |
| 942 | bp->bp_flags |= BSTP_PORT_NEWINFO; |
| 943 | DPRINTF("%s -> ALTERNATE_AGREED\n", |
| 944 | bp->bp_ifp->if_xname); |
| 945 | } |
| 946 | |
| 947 | if (bp->bp_proposed && !bp->bp_agree) { |
| 948 | bstp_set_all_sync(bs); |
| 949 | bp->bp_proposed = 0; |
| 950 | DPRINTF("%s -> ALTERNATE_PROPOSED\n", |
| 951 | bp->bp_ifp->if_xname); |
| 952 | } |
| 953 | |
| 954 | /* Clear any flags if set */ |
| 955 | if (bp->bp_sync || !bp->bp_synced || bp->bp_reroot) { |
| 956 | bp->bp_sync = 0; |
| 957 | bp->bp_synced = 1; |
| 958 | bp->bp_reroot = 0; |
| 959 | DPRINTF("%s -> ALTERNATE_PORT\n", bp->bp_ifp->if_xname); |
| 960 | } |
| 961 | break; |
| 962 | |
| 963 | case BSTP_ROLE_ROOT: |
| 964 | if (bp->bp_state != BSTP_IFSTATE_FORWARDING && !bp->bp_reroot) { |
| 965 | bstp_set_all_reroot(bs); |
| 966 | DPRINTF("%s -> ROOT_REROOT\n", bp->bp_ifp->if_xname); |
| 967 | } |
| 968 | |
| 969 | if ((bs->bs_allsynced && !bp->bp_agree) || |
| 970 | (bp->bp_proposed && bp->bp_agree)) { |
| 971 | bp->bp_proposed = 0; |
| 972 | bp->bp_sync = 0; |
| 973 | bp->bp_agree = 1; |
| 974 | bp->bp_flags |= BSTP_PORT_NEWINFO; |
| 975 | DPRINTF("%s -> ROOT_AGREED\n", bp->bp_ifp->if_xname); |
| 976 | } |
| 977 | |
| 978 | if (bp->bp_proposed && !bp->bp_agree) { |
| 979 | bstp_set_all_sync(bs); |
| 980 | bp->bp_proposed = 0; |
no test coverage detected