Пример #1
0
def init_lsp_ingress_clause(options):

    if options.has_key('GATEWAY'):
        # push RARP to controller, only Edge node should consider receiving rarp
        lsp_arp_controller(LS, Priority, Match, Action, State) <= (
            (Priority == 2) &
            ls_array(LS, UUID_LS, State) & (State != 0) &
            match.arp_proto(Match1) &
            match.arp_op(2, Match2) &
            (Match == Match1 + Match2) &
            action.upload_arp(Action)
            )

    if not options.has_key('ONDEMAND'):
        # maybe gratuitous ARP, push to controller.
        # maybe a unknow dst arp
        lsp_arp_controller(LS, Priority, Match, Action, State) <= (
            (Priority == 1) &
            ls_array(LS, UUID_LS, State) & (State != 0) &
            match.arp_proto(Match1) &
            match.arp_op(1, Match2) &
            (Match == Match1 + Match2) &
            action.upload_arp(Action1) &
            action.resubmit_next(Action2) &
            (Action == Action1 + Action2)
            )

    lsp_arp_controller(LS, Priority, Match, Action, State) <= (
        (Priority == 0) &
        ls_array(LS, UUID_LS, State) & (State != 0) &
        (match.match_none(Match)) &
        action.resubmit_next(Action)
        )

    lsp_arp_response(LS, Priority, Match, Action, State) <= (
        (Priority == 2) &
        ls_array(LS, UUID_LS, State) & (State != 0) &
        match.arp_proto(Match1) &
        match.arp_op(1, Match2) &
        (Match == Match1 + Match2) &
        action.resubmit_table(TABLE_ARP_FEEDBACK_CONSTRUCT, Action1) &
        action.resubmit_next(Action2) &
        (Action == Action1 + Action2)
        )

    lsp_arp_response(LS, Priority, Match, Action, State) <= (
        (Priority == 0) &
        ls_array(LS, UUID_LS, State) & (State != 0) &
        (match.match_none(Match)) &
        action.resubmit_next(Action)
        )


    if options.has_key('ENABLE_UNTUNNEL') and options.has_key('dsrport'):
        # NOTE: it helps reduce time-cost
        _lsp_lrp_ls_changed(LS, LRP, State) <= (
            ls_array(LS, UUID_LS, State1) &
            lsp_link_lrp(LSP, LS1, UUID_LS1, LRP, LR,
                         UUID_LR, UUID_LR_CHASSIS, State2) &
            (State == State1 + State2) & (State != 0)
        )
        lsp_untunnel_deliver(LS, Priority, Match, Action, State) <= (
             _lsp_lrp_ls_changed(LS, LRP, State) &
            (Priority == _cal_priority(LRP[LRP_PREFIX], 2, LRP[LRP_ILK_IDX])) &
            match.ip_proto(Match1) &
            match.ip_dst_prefix(LRP[LRP_IP], LRP[LRP_PREFIX], Match2) &
            (Match == Match1 + Match2) &
            action.resubmit_next(Action)
        )

        lsp_untunnel_deliver(LS, Priority, Match, Action, State) <= (
            (Priority == 1) &
            ls_array(LS, UUID_LS, State) & (State != 0) &
            match.ip_proto(Match) &
            # output packet to local port which is an internal port.
            # packet goes into tcpip stack
            action.mod_dl_dst(options['dsrport']['mac'], Action1) &
            action.output(options['dsrport']['ofport'], Action2) &
            (Action == Action1 + Action2)
            )


    lsp_untunnel_deliver(LS, Priority, Match, Action, State) <= (
        (Priority == 0) &
        ls_array(LS, UUID_LS, State) & (State != 0) &
        (match.match_none(Match)) &
        action.resubmit_next(Action)
        )

    # deliver to LR which has snat/dnat
    lsp_lookup_dst_port(LS, Priority, Match, Action, State) <= (
        (Priority == 5) &
        # TODO optimize it
        lnat_data(LNAT, LR, XLATE_TYPE, UUID_LR, State1) &
        lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR,
                     UUID_LR, UUID_LR_CHASSIS, State2) &
        (State == State1 + State2) & (State != 0) &
        match.eth_dst(LNAT[LNAT_XLATE_MAC], Match) &
        action.load(LSP[LSP_PORTID], NXM_Reg(REG_DST_IDX), Action1) &
        action.resubmit_next(Action2) &
        (Action == Action1 + Action2)
        )

    # deliver to another lsp on local chassis
    lsp_lookup_dst_port(LS, Priority, Match, Action, State) <= (
        (Priority == 4) &
        local_lsp(LSP, LS, State) & (State != 0) &
        match.eth_dst(LSP[LSP_MAC], Match) &
        action.load(LSP[LSP_PORTID],
                    NXM_Reg(REG_DST_IDX), Action1) &
        action.resubmit_next(Action2) &
        (Action == Action1 + Action2)
        )

    # it helps reduce time-cost
    _lsp_remote_lsp_changed(LSP, LS, PHY_CHASSIS, State) <= (
                    remote_lsp(LSP, LS, PHY_CHASSIS, State) & (State != 0))

    if options.has_key('ENABLE_REDIRECT'):
        # output deliver to another remote chassis.
        # use bundle_load to check if dst chassis is dead or live.
        lsp_lookup_dst_port(LS, Priority, Match, Action, State) <= (
            (Priority == 3) &
            _lsp_remote_lsp_changed(LSP, LS, PHY_CHASSIS, State) &
            match.eth_dst(LSP[LSP_MAC], Match) &
            action.load(LSP[LSP_PORTID],
                        NXM_Reg(REG_DST_IDX), Action1) &
            action.bundle_load(NXM_Reg(REG_OUTPORT_IDX),
                               [PHY_CHASSIS[PCH_OFPORT]], Action2) &
            # if we want output this packet in next step, we set 1->reg5
            # in next step flow, no need to clean this reg5, because
            # it should output a port means the end of packet process
            action.load(1, NXM_Reg(REG5_IDX), Action3) &
            action.resubmit_next(Action4) &
            (Action == Action1 + Action2 + Action3 + Action4)
            )
    else:
        # deliver to remote chassis by using output,(set outport to reg4)
        lsp_lookup_dst_port(LS, Priority, Match, Action, State) <= (
            (Priority == 3) &
            _lsp_remote_lsp_changed(LSP, LS, PHY_CHASSIS, State) &
            match.eth_dst(LSP[LSP_MAC], Match) &
            action.load(LSP[LSP_PORTID],
                        NXM_Reg(REG_DST_IDX), Action1) &
            action.load(PHY_CHASSIS[PCH_OFPORT],
                        NXM_Reg(REG_OUTPORT_IDX), Action2) &
            # if we want output this packet in next step, we set 1->reg5
            # in next step flow, no need to clean this reg5, because
            # it should output a a port means the end of packet process
            action.load(1, NXM_Reg(REG5_IDX), Action3) &
            action.resubmit_next(Action4) &
            (Action == Action1 + Action2 + Action3 + Action4)
            )

    # deliver the packet which not match above flow to the patchport
    # patch port's ip address should be 255.255.255.255
    lsp_lookup_dst_port(LS, Priority, Match, Action, State) <= (
        (Priority == 2) &
        local_patchport(LSP, LS, State) & (State != 0) &
        match.match_none(Match) &
        action.load(LSP[LSP_PORTID],
                    NXM_Reg(REG_DST_IDX), Action1) &
        action.resubmit_table(TABLE_LSP_EGRESS_FIRST, Action2) &
        (Action == Action1 + Action2)
        )

    if options.has_key('ONDEMAND'):
        # ovs must upload this packet to controller if cannot found the
        # destination. controller will tell tuplenet to generate more flows
        lsp_lookup_dst_port(LS, Priority, Match, Action, State) <= (
            (Priority == 0) &
            ls_array(LS, UUID_LS, State) & (State != 0) &
            match.match_none(Match) &
            action.upload_unknow_dst(Action1) &
            # resubmit this packet to next stage, gateway host can
            # do delivering if gateway enable redirect feature
            action.load(st.TP_OFPORT_NONE, NXM_Reg(REG_OUTPORT_IDX), Action2) &
            action.load(1, NXM_Reg(REG5_IDX), Action3) &
            action.resubmit_next(Action4) &
            (Action == Action1 + Action2 + Action3 + Action4)
            )

    else:
        # deliver packet to drop table if this packet cannot
        # found the destination.
        lsp_lookup_dst_port(LS, Priority, Match, Action, State) <= (
            (Priority == 0) &
            ls_array(LS, UUID_LS, State) & (State != 0) &
            match.match_none(Match) &
            action.resubmit_table(TABLE_DROP_PACKET, Action)
            )

    if options.has_key('ENABLE_REDIRECT'):
        # if it is a redirectd packet and reg4 is 0xffff, then we should drop
        # it, because we don't want cause infinite loop
        lsp_output_dst_port(LS, Priority, Match, Action, State) <= (
            (Priority == 4) &
            ls_array(LS, UUID_LS, State) & (State != 0) &
            match.reg_5(1, Match1) &
            match.reg_flag(FLAG_REDIRECT, Match2) &
            match.reg_outport(st.TP_OFPORT_NONE, Match3) &
            (Match == Match1 + Match2 + Match3) &
            action.resubmit_table(TABLE_DROP_PACKET, Action)
            )

        # if this packet was failed to deliver to remote chassis, we send it to
        # other gateway to help forwarding
        lsp_output_dst_port(LS, Priority, Match, Action, State) <= (
            (Priority == 3) &
            ls_array(LS, UUID_LS, State) & (State != 0) &
            match.reg_5(1, Match1) &
            match.reg_outport(st.TP_OFPORT_NONE, Match2) &
            (Match == Match1 + Match2) &
            action.resubmit_table(TABLE_REDIRECT_CHASSIS, Action)
            )

    # output to a port base on reg4's value
    lsp_output_dst_port(LS, Priority, Match, Action, State) <= (
        (Priority == 2) &
        ls_array(LS, UUID_LS, State) &  (State != 0) &
        match.reg_5(1, Match) &
        action.resubmit_table(TABLE_EMBED2_METADATA, Action1) &
        action.resubmit_table(TABLE_OUTPUT_PKT, Action2) &
        (Action == Action1 + Action2)
        )

    # just deliver to next stage
    lsp_output_dst_port(LS, Priority, Match, Action, State) <= (
        (Priority == 1) &
        ls_array(LS, UUID_LS, State) & (State != 0) &
        match.match_none(Match) &
        action.resubmit_table(TABLE_LSP_EGRESS_FIRST, Action)
        )
Пример #2
0
def init_ecmp_clause(options):
    # for adding
    # NOTE: this clause is consumed by ecmp_static_route.
    # There is NO circumstances that ecmp_static_route's LR's state is not zero, but
    # ecmp_aggregate_outport's state is zero. Because next_hop_ovsport need LR's state.
    # If you try to update ecmp_static_route, we should consider it!
    (ecmp_aggregate_outport[X] == tuple_(Y, order_by=Z)) <= (
        lroute_array(Route1, UUID_LR, State1) &
        lroute_array(Route2, UUID_LR, State2) &
        (State1 + State2 >= 0) &
        (Route1[LSR_UUID] != Route2[LSR_UUID]) &
        (Route1[LSR_IP] == Route2[LSR_IP]) &
        (Route1[LSR_PREFIX] == Route2[LSR_PREFIX]) &
        (Route1[LSR_NEXT_HOP] == Route2[LSR_NEXT_HOP]) &
        (Route1[LSR_OUTPORT] != Route2[LSR_OUTPORT]) &
        next_hop_ovsport(Route1[LSR_OUTPORT], OFPORT1, State3) &
        next_hop_ovsport(Route2[LSR_OUTPORT], OFPORT2, State4) &
        (State1 + State2 + State3 + State4 > 0) &
        (X == (UUID_LR, Route1[LSR_IP], Route1[LSR_PREFIX],
               State_ADD, 'adding')) &
        (Y == OFPORT1) & (Z == Route1[LSR_UUID])
        )

    # for readding slave port, deletion delete the whole flow,
    # but some ports should stay in bundle slave as well,
    # we should add those ports back
    (ecmp_aggregate_outport_readd[X] == tuple_(Y, order_by=Z)) <= (
        lroute_array(Route1, UUID_LR, State1) &
        lroute_array(Route2, UUID_LR, State2) &
        (State_COMBIND1 == State1 + State2) & (State_COMBIND1 >= 0) &
        (Route1[LSR_UUID] != Route2[LSR_UUID]) &
        (Route1[LSR_IP] == Route2[LSR_IP]) &
        (Route1[LSR_PREFIX] == Route2[LSR_PREFIX]) &
        (Route1[LSR_NEXT_HOP] == Route2[LSR_NEXT_HOP]) &
        (Route1[LSR_OUTPORT] != Route2[LSR_OUTPORT]) &
        next_hop_ovsport(Route1[LSR_OUTPORT], OFPORT1, State3) &
        next_hop_ovsport(Route2[LSR_OUTPORT], OFPORT2, State4) &
        (State_COMBIND2 == State1 + State2 + State3 + State4) & (State_COMBIND2 >= 0) &
        (ecmp_aggregate_outport[A] == B) &
        (A[0] == UUID_LR) & (A[1] == Route1[LSR_IP]) &
        (A[2] == Route1[LSR_PREFIX]) & (A[4] == 'deleting') &
        (X == (UUID_LR, Route1[LSR_IP], Route1[LSR_PREFIX],
               State_ADD, 'readding')) &
        (Y == OFPORT1) & (Z == Route1[LSR_UUID])
        )

    # for deleting
    (ecmp_aggregate_outport[X] == tuple_(Y, order_by=Y)) <= (
        lroute_array(Route1, UUID_LR, State1) &
        lroute_array(Route2, UUID_LR, State2) &
        (Route1[LSR_UUID] != Route2[LSR_UUID]) &
        (Route1[LSR_LR_UUID] == Route2[LSR_LR_UUID]) &
        (Route1[LSR_IP] == Route2[LSR_IP]) &
        (Route1[LSR_PREFIX] == Route2[LSR_PREFIX]) &
        (Route1[LSR_NEXT_HOP] == Route2[LSR_NEXT_HOP]) &
        (Route1[LSR_OUTPORT] != Route2[LSR_OUTPORT]) &
        next_hop_ovsport(Route1[LSR_OUTPORT], OFPORT, State3) &
        (State1 + State2 + State3 < 0) &
        (X == (Route1[LSR_LR_UUID], Route1[LSR_IP], Route1[LSR_PREFIX],
               State_DEL, 'deleting')) &
        (Y == OFPORT)
        )

    # adding and readding may generate same flow, it is ok.
    ecmp_static_route(LR, Priority, Match, Action, State) <= (
        lr_array(LR, UUID_LR, State1) &
        (ecmp_aggregate_outport[X] == Y) &
        (State == State1 + X[3]) & (State != 0) &
        (X[0] == UUID_LR) &
        (Priority == _cal_priority(X[2], 2, 0)) &
        match.ip_proto(Match1) &
        match.ip_dst_prefix(X[1], X[2], Match2) &
        (Match == Match1 + Match2) &
        action.bundle_load(NXM_Reg(REG_OUTPORT_IDX), Y, Action1) &
        action.resubmit_next(Action2) &
        (Action == Action1 + Action2)
        )

    ecmp_static_route(LR, Priority, Match, Action, State) <= (
        lr_array(LR, UUID_LR, State1) &
        (ecmp_aggregate_outport_readd[X] == Y) &
        (State == State1 + X[3]) & (State != 0) &
        (X[0] == UUID_LR) &
        (Priority == _cal_priority(X[2], 2, 0)) &
        match.ip_proto(Match1) &
        match.ip_dst_prefix(X[1], X[2], Match2) &
        (Match == Match1 + Match2) &
        action.bundle_load(NXM_Reg(REG_OUTPORT_IDX), Y, Action1) &
        action.resubmit_next(Action2) &
        (Action == Action1 + Action2)
        )

    # gateway chassis no need to consider ecmp
    if not options.has_key('GATEWAY'):
        # after hitting bundle_load action, flows should be add to forward packet
        # to different port base on value of reg4
        ecmp_static_route_judge(LR, Priority, Match, Action, State) <= (
            lroute_array(Route, UUID_LR, State1) &
            next_hop_ovsport(Route[LSR_OUTPORT], OFPORT, State2) &
            lr_array(LR, UUID_LR, State3) &
            lrp_array(Route[LSR_OUTPORT], LRP, UUID_LR, UUID_LSP, State4) &
            (State == State1 + State2 + State3 + State4) & (State != 0) &
            (Priority == _cal_priority(Route[LSR_PREFIX], 2, 0)) &
            match.reg_outport(OFPORT, Match1) &
            match.ip_proto(Match2) &
            match.ip_dst_prefix(Route[LSR_IP], Route[LSR_PREFIX], Match3) &
            (Match == Match1 + Match2 + Match3) &
            action.load(LRP[LRP_PORTID], NXM_Reg(REG_DST_IDX), Action1) &
            action.load(LRP[LRP_MAC_INT], NXM_Reg(ETH_SRC_IDX), Action2) &
            action.load(Route[LSR_NEXT_HOP_INT], NXM_Reg(REG2_IDX), Action3) &
            action.load(LRP[LRP_IP_INT], NXM_Reg(REG3_IDX), Action4) &
            action.resubmit_next(Action5) &
            (Action == Action1 + Action2 + Action3 + Action4 + Action5)
            )

        # drop packets if all bundle slave ports are not in 'up' status
        # TODO if we should ignore failure and deliver packet to
        # one of output ports
        ecmp_static_route_judge(LR, Priority, Match, Action, State) <= (
            lr_array(LR, UUID_LR, State) & (State != 0) &
            (Priority == 1) &
            match.reg_outport(st.TP_OFPORT_NONE, Match) &
            action.resubmit_table(TABLE_DROP_PACKET, Action)
            )

    # resubmit next stage without hitting any flows above
    ecmp_static_route_judge(LR, Priority, Match, Action, State) <= (
        lr_array(LR, UUID_LR, State) & (State != 0) &
        (Priority == 0) &
        match.match_none(Match) &
        action.resubmit_next(Action)
        )

    if options.has_key('GATEWAY'):
        # gateway chassis should set all tunnel port's bfd to true, unless the
        # chassis was deleted
        ecmp_bfd_port(PORT_NAME, State) <= (
            ovsport_chassis(PORT_NAME, UUID_CHASSIS, OFPORT, State1) &
            # we only enable ovsport that exist
            (State1 >= 0) & (UUID_CHASSIS != st.TP_FLOW_TUNNEL_NAME) &
            chassis_array(PHY_CHASSIS, UUID_CHASSIS, State2) &
            (State == State1 + State2) & (State != 0)
            )
        # disable all tunnel port bfd if we found our chassis was deleted
        ecmp_bfd_port(PORT_NAME, State) <= (
            local_system_id(UUID_CHASSIS) &
            chassis_array(PHY_CHASSIS1, UUID_CHASSIS, State1) &
            # prevent event like chassis tick update,
            # ecmp_bfd_port will grep out PORT_NAME with state above 0.
            # In the same time, it also grep out PORT_NAME with state has negative
            # value. But config_tunnel_bfd help us eliminate negative part
            # NOTE: it can grep out (State1=1) (State2=1) (State=1),
            # (State1=1) (State2=-1)(State=-1),(State1=-1) (State2=-1)(State=-1)
            # but config_tunnel_bfd will keep (State=1) only
            chassis_array(PHY_CHASSIS2, UUID_CHASSIS, State2) &
            (State == State1 + State2) & (State != 0) &
            # figure out all tunnel port
            ovsport_chassis(PORT_NAME, UUID_CHASSIS1, OFPORT, State3) & (State3 >= 0) &
            (UUID_CHASSIS1 != st.TP_FLOW_TUNNEL_NAME)
            )
    else:
        ecmp_bfd_port(PORT_NAME, State) <= (
            lroute_array(Route, UUID_LR, State1) &
            next_hop_ovsport(Route[LSR_OUTPORT], OFPORT, State2) &
            # we only enable/disable ovsport that exist
            ovsport_chassis(PORT_NAME, UUID_CHASSIS, OFPORT, State3) & (State3 >= 0) &
            chassis_array(PHY_CHASSIS, UUID_CHASSIS, State4) &
            (UUID_CHASSIS != st.TP_FLOW_TUNNEL_NAME) &
            (State == State1 + State2 + State3 + State4)
            )
Пример #3
0
def init_physical_flow_clause(options):

    # handle tunnel port ingress traffic
    convert_phy_logical(Priority, Match, Action, State) <= (
        (Priority == 2) & remote_chassis(UUID_CHASSIS, PHY_CHASSIS, State) &
        (State != 0) & match.in_port(PHY_CHASSIS[PCH_OFPORT], Match)
        & action.resubmit_table(TABLE_EXTRACT_METADATA, Action1) & action.load(
            1,
            NXM_Reg(REG_FLAG_IDX, FLAG_LOOPBACK_BIT_IDX,
                    FLAG_LOOPBACK_BIT_IDX), Action2)
        & action.resubmit_table(TABLE_PIPELINE_FORWARD, Action3) &
        (Action == Action1 + Action2 + Action3))

    # handle regular port ingress traffic
    convert_phy_logical(Priority, Match, Action, State) <= (
        (Priority == 2) & local_bond_lsp(LSP, LS, State) &
        (State != 0) & match.in_port(LSP[LSP_OFPORT], Match)
        & action.load(LSP[LSP_PORTID], NXM_Reg(REG_SRC_IDX), Action1)
        & action.load(LS[LS_ID], NXM_Reg(REG_DP_IDX), Action2)
        & action.resubmit_next(Action3) &
        (Action == Action1 + Action2 + Action3))

    # it helps reduce time-cost
    _arp_ip_mac(IP, IP_INT, MAC, MAC_INT, LS,
                State) <= (active_lsp(LSP, LS, UUID_LS, State) & (State != 0) &
                           (IP == LSP[LSP_IP]) & (IP_INT == LSP[LSP_IP_INT]) &
                           (MAC == LSP[LSP_MAC]) &
                           (MAC_INT == LSP[LSP_MAC_INT]))

    _arp_ip_mac(IP, IP_INT, MAC, MAC_INT, LS, State) <= (
        lnat_data(LNAT, LR, XLATE_TYPE, UUID_LR, State1) & lsp_link_lrp(
            LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State2) &
        (State == State1 + State2) & (State != 0) &
        (IP == LNAT[LNAT_XLATE_IP]) & (IP_INT == LNAT[LNAT_XLATE_IP_INT]) &
        (MAC == LNAT[LNAT_XLATE_MAC]) & (MAC_INT == LNAT[LNAT_XLATE_MAC_INT]))
    # regular lsp arp feedback
    arp_feedback_construct(LS, Priority, Match, Action, State) <= (
        (Priority == 0) & _arp_ip_mac(IP, IP_INT, MAC, MAC_INT, LS, State)
        & match.arp_proto(Match1) & match.arp_tpa(IP, Match2)
        & match.arp_op(1, Match3) &
        (Match == Match1 + Match2 + Match3) & action.load(
            1,
            NXM_Reg(REG_FLAG_IDX, FLAG_LOOPBACK_BIT_IDX,
                    FLAG_LOOPBACK_BIT_IDX), Action1)
        & action.move(NXM_Reg(ETH_SRC_IDX), NXM_Reg(ETH_DST_IDX), Action2)
        & action.mod_dl_src(MAC, Action3)
        & action.load(2, NXM_Reg(ARP_OP_IDX), Action4)
        & action.move(NXM_Reg(ARP_SHA_IDX), NXM_Reg(ARP_THA_IDX), Action5)
        & action.load(MAC_INT, NXM_Reg(ARP_SHA_IDX), Action6)
        & action.move(NXM_Reg(ARP_SPA_IDX), NXM_Reg(ARP_TPA_IDX), Action7)
        & action.load(IP_INT, NXM_Reg(ARP_SPA_IDX), Action8)
        & action.move(NXM_Reg(REG_SRC_IDX), NXM_Reg(REG_DST_IDX), Action9) &
        (Action == Action1 + Action2 + Action3 + Action4 + Action5 + Action6 +
         Action7 + Action8 + Action9))

    output_pkt_by_reg(Priority, Match, Action) <= (
        (Priority == 1) & match.reg_outport(st.TP_OFPORT_NONE, Match)
        & action.resubmit_table(TABLE_DROP_PACKET, Action))

    output_pkt_by_reg(Priority, Match, Action) <= (
        (Priority == 0) & match.match_none(Match)
        & action.output_reg(NXM_Reg(REG_OUTPORT_IDX), Action))
Пример #4
0
def init_ecmp_clause(options):
    # for adding
    # NOTE: this clause is consumed by ecmp_static_route.
    # There is NO circumstances that ecmp_static_route's LR's state is not zero, but
    # ecmp_aggregate_outport's state is zero. Because next_hop_ovsport need LR's state.
    # If you try to update ecmp_static_route, we should consider it!
    (ecmp_aggregate_outport[X] == tuple_(Y, order_by=Z)) <= (
        lroute_array(Route1, UUID_LR, State1) &
        lroute_array(Route2, UUID_LR, State2) &
        (State1 + State2 >= 0) &
        (Route1[LSR_UUID] != Route2[LSR_UUID]) &
        (Route1[LSR_IP] == Route2[LSR_IP]) &
        (Route1[LSR_PREFIX] == Route2[LSR_PREFIX]) &
        (Route1[LSR_NEXT_HOP] == Route2[LSR_NEXT_HOP]) &
        (Route1[LSR_OUTPORT] != Route2[LSR_OUTPORT]) &
        next_hop_ovsport(Route1[LSR_OUTPORT], OFPORT1, State3) &
        next_hop_ovsport(Route2[LSR_OUTPORT], OFPORT2, State4) &
        (State1 + State2 + State3 + State4 > 0) &
        (X == (UUID_LR, Route1[LSR_IP], Route1[LSR_PREFIX],
               State_ADD, 'adding')) &
        (Y == OFPORT1) & (Z == Route1[LSR_UUID])
        )

    # for readding slave port, deletion delete the whole flow,
    # but some ports should stay in bundle slave as well,
    # we should add those ports back
    (ecmp_aggregate_outport_readd[X] == tuple_(Y, order_by=Z)) <= (
        lroute_array(Route1, UUID_LR, State1) &
        lroute_array(Route2, UUID_LR, State2) &
        (State_COMBIND1 == State1 + State2) & (State_COMBIND1 >= 0) &
        (Route1[LSR_UUID] != Route2[LSR_UUID]) &
        (Route1[LSR_IP] == Route2[LSR_IP]) &
        (Route1[LSR_PREFIX] == Route2[LSR_PREFIX]) &
        (Route1[LSR_NEXT_HOP] == Route2[LSR_NEXT_HOP]) &
        (Route1[LSR_OUTPORT] != Route2[LSR_OUTPORT]) &
        next_hop_ovsport(Route1[LSR_OUTPORT], OFPORT1, State3) &
        next_hop_ovsport(Route2[LSR_OUTPORT], OFPORT2, State4) &
        (State_COMBIND2 == State1 + State2 + State3 + State4) & (State_COMBIND2 >= 0) &
        (ecmp_aggregate_outport[A] == B) &
        (A[0] == UUID_LR) & (A[1] == Route1[LSR_IP]) &
        (A[2] == Route1[LSR_PREFIX]) & (A[4] == 'deleting') &
        (X == (UUID_LR, Route1[LSR_IP], Route1[LSR_PREFIX],
               State_ADD, 'readding')) &
        (Y == OFPORT1) & (Z == Route1[LSR_UUID])
        )

    # for deleting
    (ecmp_aggregate_outport[X] == tuple_(Y, order_by=Y)) <= (
        lroute_array(Route1, UUID_LR, State1) &
        lroute_array(Route2, UUID_LR, State2) &
        (Route1[LSR_UUID] != Route2[LSR_UUID]) &
        (Route1[LSR_LR_UUID] == Route2[LSR_LR_UUID]) &
        (Route1[LSR_IP] == Route2[LSR_IP]) &
        (Route1[LSR_PREFIX] == Route2[LSR_PREFIX]) &
        (Route1[LSR_NEXT_HOP] == Route2[LSR_NEXT_HOP]) &
        (Route1[LSR_OUTPORT] != Route2[LSR_OUTPORT]) &
        next_hop_ovsport(Route1[LSR_OUTPORT], OFPORT, State3) &
        (State1 + State2 + State3 < 0) &
        (X == (Route1[LSR_LR_UUID], Route1[LSR_IP], Route1[LSR_PREFIX],
               State_DEL, 'deleting')) &
        (Y == OFPORT)
        )

    ecmp_static_route(LR, Priority, Match, Action, State) <= (
        lr_array(LR, UUID_LR, State1) &
        (ecmp_aggregate_outport[X] == Y) &
        (State == State1 + X[3]) & (State != 0) &
        (X[0] == UUID_LR) &
        (Priority == _cal_priority(X[2], 2, 0)) &
        match.ip_proto(Match1) &
        match.ip_dst_prefix(X[1], X[2], Match2) &
        (Match == Match1 + Match2) &
        action.bundle_load(NXM_Reg(REG_OUTPORT_IDX), Y, Action1) &
        action.resubmit_next(Action2) &
        (Action == Action1 + Action2)
        )

    ecmp_static_route(LR, Priority, Match, Action, State) <= (
        lr_array(LR, UUID_LR, State1) &
        (ecmp_aggregate_outport_readd[X] == Y) &
        (State == State1 + X[3]) & (State != 0) &
        (X[0] == UUID_LR) &
        (Priority == _cal_priority(X[2], 2, 0)) &
        match.ip_proto(Match1) &
        match.ip_dst_prefix(X[1], X[2], Match2) &
        (Match == Match1 + Match2) &
        action.bundle_load(NXM_Reg(REG_OUTPORT_IDX), Y, Action1) &
        action.resubmit_next(Action2) &
        (Action == Action1 + Action2)
        )

    # gateway chassis no need to consider ecmp
    if not options.has_key('GATEWAY'):
        # after hitting bundle_load action, flows should be add to forward packet
        # to different port base on value of reg4
        ecmp_static_route_judge(LR, Priority, Match, Action, State) <= (
            lroute_array(Route, UUID_LR, State1) &
            next_hop_ovsport(Route[LSR_OUTPORT], OFPORT, State2) &
            lr_array(LR, UUID_LR, State3) &
            lrp_array(Route[LSR_OUTPORT], LRP, UUID_LR, UUID_LSP, State4) &
            (State == State1 + State2 + State3 + State4) & (State != 0) &
            (Priority == _cal_priority(Route[LSR_PREFIX], 2, 0)) &
            match.reg_outport(OFPORT, Match1) &
            match.ip_proto(Match2) &
            match.ip_dst_prefix(Route[LSR_IP], Route[LSR_PREFIX], Match3) &
            (Match == Match1 + Match2 + Match3) &
            action.load(LRP[LRP_PORTID], NXM_Reg(REG_DST_IDX), Action1) &
            action.load(LRP[LRP_MAC_INT], NXM_Reg(ETH_SRC_IDX), Action2) &
            action.load(Route[LSR_NEXT_HOP_INT], NXM_Reg(REG2_IDX), Action3) &
            action.load(LRP[LRP_IP_INT], NXM_Reg(REG3_IDX), Action4) &
            action.resubmit_next(Action5) &
            (Action == Action1 + Action2 + Action3 + Action4 + Action5)
            )

        # drop packets if all bundle slave ports are not in 'up' status
        # TODO if we should ignore failure and deliver packet to
        # one of output ports
        ecmp_static_route_judge(LR, Priority, Match, Action, State) <= (
            lr_array(LR, UUID_LR, State) & (State != 0) &
            (Priority == 1) &
            match.reg_outport(0xffff, Match) &
            action.resubmit_table(TABLE_DROP_PACKET, Action)
            )

    # resubmit next stage without hitting any flows above
    ecmp_static_route_judge(LR, Priority, Match, Action, State) <= (
        lr_array(LR, UUID_LR, State) & (State != 0) &
        (Priority == 0) &
        match.match_none(Match) &
        action.resubmit_next(Action)
        )

    ecmp_bfd_port(PORT_NAME, State) <= (
        lroute_array(Route, UUID_LR, State1) &
        next_hop_ovsport(Route[LSR_OUTPORT], OFPORT, State2) &
        # we only enable/disable ovsport that exist
        ovsport_chassis(PORT_NAME, UUID_CHASSIS, OFPORT, State3) & (State3 >= 0) &
        chassis_array(PHY_CHASSIS, UUID_CHASSIS, State4) &
        (State == State1 + State2 + State3 + State4)
        )