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) )
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 == X[2] * 3 + 2) & match.ip_proto(Match1) & match.ip_dst_prefix(X[1], X[2], Match2) & (Match == Match1 + Match2) & action.bundle_load(NXM_Reg(REG4_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 == X[2] * 3 + 2) & match.ip_proto(Match1) & match.ip_dst_prefix(X[1], X[2], Match2) & (Match == Match1 + Match2) & action.bundle_load( NXM_Reg(REG4_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 == Route[LSR_PREFIX] * 3 + 2) & match.reg_4(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_4(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))
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) )
def init_lrp_ingress_clause(options): init_ecmp_clause(options) # response ICMP packet if receiving ICMP request lrp_pkt_response(LR, Priority, Match, Action, State) <= ( (Priority == 3) & lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) & (State != 0) & match.icmp_proto(Match1) & match.icmp_type(8, Match2) & match.icmp_code(0, Match3) & match.ip_dst(LRP[LRP_IP], Match4) & (Match == Match1 + Match2 + Match3 + Match4) & action.exchange(NXM_Reg(IP_SRC_IDX), NXM_Reg(IP_DST_IDX), Action1) & action.load(0xff, NXM_Reg(IP_TTL_IDX), Action2) & action.load(0, NXM_Reg(ICMP_TYPE_IDX), Action3) & action.move(NXM_Reg(REG_SRC_IDX), NXM_Reg(REG_DST_IDX), Action4) & action.load(1, NXM_Reg(REG_FLAG_IDX, FLAG_LOOPBACK_BIT_IDX, FLAG_LOOPBACK_BIT_IDX), Action5) & action.resubmit_next(Action6) & (Action == Action1 + Action2 + Action3 + Action4 + Action5 + Action6) ) lrp_pkt_response(LR, Priority, Match, Action, State) <= ( (Priority == 0) & lr_array(LR, UUID_LR, State) & (State != 0) & match.ip_proto(Match) & action.resubmit_next(Action)) lrp_drop_unexpect(LR, Priority, Match, Action, State) <= ( (Priority == 2) & lr_array(LR, UUID_LR, State) & (State != 0) & match.ip_proto(Match1) & match.ip_ttl(1, Match2) & (Match == Match1 + Match2) & action.resubmit_table(TABLE_DROP_PACKET, Action) ) lrp_drop_unexpect(LR, Priority, Match, Action, State) <= ( (Priority == 0) & lr_array(LR, UUID_LR, State) & (State != 0) & match.ip_proto(Match) & action.dec_ttl(Action1) & action.resubmit_next(Action2) & (Action == Action1 + Action2) ) lrp_ip_unsnat_stage1(LR, Priority, Match, Action, State) <= ( nat.lunsnat_xlate_stage1(LR, Priority, Match, Action, State)) lrp_ip_unsnat_stage2(LR, Priority, Match, Action, State) <= ( nat.lunsnat_xlate_stage2(LR, Priority, Match, Action, State)) lrp_ip_dnat_stage1(LR, Priority, Match, Action, State) <= ( nat.ldnat_xlate_stage1(LR, Priority, Match, Action, State)) lrp_ip_dnat_stage2(LR, Priority, Match, Action, State) <= ( nat.ldnat_xlate_stage2(LR, Priority, Match, Action, State)) #automatic route lrp_ip_route(LR, Priority, Match, Action, State) <= ( lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) & (State != 0) & (Priority == LRP[LRP_PREFIX] * 3) & match.ip_proto(Match1) & match.ip_dst_prefix(LRP[LRP_IP], LRP[LRP_PREFIX], Match2) & (Match == Match1 + Match2) & action.load(LRP[LRP_PORTID], NXM_Reg(REG_DST_IDX), Action1) & action.load(LRP[LRP_MAC_INT], NXM_Reg(ETH_SRC_IDX), Action2) & action.move(NXM_Reg(IP_DST_IDX), NXM_Reg(REG2_IDX), Action3) & # lrp_handle_unknow_dst_pkt may use it to modify IP to # construct right arp request action.load(LRP[LRP_IP_INT], NXM_Reg(REG3_IDX), Action4) & action.resubmit_next(Action5) & (Action == Action1 + Action2 + Action3 + Action4 + Action5) ) #static route lrp_ip_route(LR, Priority, Match, Action, State) <= ( lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State1) & (lroute_array(Route, UUID_LR, State2)) & (State == State1 + State2) & (State != 0) & (UUID_LR == LR[LR_UUID]) & # only match the first outport (LRP[LRP_UUID] == Route[LSR_OUTPORT]) & (Priority == 1 + Route[LSR_PREFIX] * 3) & match.ip_proto(Match1) & match.ip_dst_prefix(Route[LSR_IP], Route[LSR_PREFIX], Match2) & (Match == Match1 + Match2) & 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) & # lrp_handle_unknow_dst_pkt may use it to modify IP to # construct right arp request action.load(LRP[LRP_IP_INT], NXM_Reg(REG3_IDX), Action4) & action.resubmit_next(Action5) & (Action == Action1 + Action2 + Action3 + Action4 + Action5) ) # gateway chassis no need to consider ecmp if not options.has_key('GATEWAY'): lrp_ip_route(LR, Priority, Match, Action, State) <= ( ecmp_static_route(LR, Priority, Match, Action, State) ) lrp_ecmp_judge(LR, Priority, Match, Action, State) <= ( ecmp_static_route_judge(LR, Priority, Match, Action, State) ) # drop packet if we cannot found route for this packet lrp_ip_route(LR, Priority, Match, Action, State) <= ( (Priority == 0) & lr_array(LR, UUID_LR, State) & (State != 0) & match.match_none(Match) & action.resubmit_table(TABLE_DROP_PACKET, Action) )
def init_lrp_ingress_clause(options): init_ecmp_clause(options) if options.has_key('GATEWAY'): _live_lsp_link_lrp( LSP, LS, UUID_LS, LRP, LR, UUID_LR, None, State) <= (lsp_link_lrp( LSP, LS, UUID_LS, LRP, LR, UUID_LR, None, State)) _live_lsp_link_lrp( LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) <= (lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State1) & chassis_array(PHY_CHASSIS, UUID_LR_CHASSIS, State2) & (State == State1 + State2)) else: _live_lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) <= (lsp_link_lrp( LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State)) # response ICMP packet if receiving ICMP request lrp_pkt_response(LR, Priority, Match, Action, State) <= ( (Priority == 3) & _live_lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) & (State != 0) & match.icmp_proto(Match1) & match.icmp_type(8, Match2) & match.icmp_code(0, Match3) & match.ip_dst(LRP[LRP_IP], Match4) & (Match == Match1 + Match2 + Match3 + Match4) & action.exchange(NXM_Reg(IP_SRC_IDX), NXM_Reg(IP_DST_IDX), Action1) & action.load(0xff, NXM_Reg(IP_TTL_IDX), Action2) & action.load(0, NXM_Reg(ICMP_TYPE_IDX), Action3) & action.move( NXM_Reg(REG_SRC_IDX), NXM_Reg(REG_DST_IDX), Action4) & action.load( 1, NXM_Reg(REG_FLAG_IDX, FLAG_LOOPBACK_BIT_IDX, FLAG_LOOPBACK_BIT_IDX), Action5) & action.resubmit_next(Action6) & (Action == Action1 + Action2 + Action3 + Action4 + Action5 + Action6)) lrp_pkt_response(LR, Priority, Match, Action, State) <= ( (Priority == 0) & lr_array(LR, UUID_LR, State) & (State != 0) & match.ip_proto(Match) & action.resubmit_next(Action)) lrp_drop_unexpect(LR, Priority, Match, Action, State) <= ( (Priority == 2) & lr_array(LR, UUID_LR, State) & (State != 0) & match.ip_proto(Match1) & match.ip_ttl(1, Match2) & (Match == Match1 + Match2) & action.resubmit_table(TABLE_DROP_PACKET, Action)) lrp_drop_unexpect(LR, Priority, Match, Action, State) <= ( (Priority == 0) & lr_array(LR, UUID_LR, State) & (State != 0) & match.ip_proto(Match) & action.dec_ttl(Action1) & action.resubmit_next(Action2) & (Action == Action1 + Action2)) lrp_ip_unsnat_stage1(LR, Priority, Match, Action, State) <= (nat.lunsnat_xlate_stage1( LR, Priority, Match, Action, State)) lrp_ip_unsnat_stage2(LR, Priority, Match, Action, State) <= (nat.lunsnat_xlate_stage2( LR, Priority, Match, Action, State)) lrp_ip_dnat_stage1(LR, Priority, Match, Action, State) <= (nat.ldnat_xlate_stage1( LR, Priority, Match, Action, State)) lrp_ip_dnat_stage2(LR, Priority, Match, Action, State) <= (nat.ldnat_xlate_stage2( LR, Priority, Match, Action, State)) #automatic route lrp_ip_route(LR, Priority, Match, Action, State) <= ( lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) & (State != 0) & (Priority == _cal_priority(LRP[LRP_PREFIX], 0, LRP[LRP_ILK_IDX])) & match.ip_proto(Match1) & match.ip_dst_prefix(LRP[LRP_IP], LRP[LRP_PREFIX], Match2) & (Match == Match1 + Match2) & action.load(LRP[LRP_PORTID], NXM_Reg(REG_DST_IDX), Action1) & action.load(LRP[LRP_MAC_INT], NXM_Reg(ETH_SRC_IDX), Action2) & action.move(NXM_Reg(IP_DST_IDX), NXM_Reg(REG2_IDX), Action3) & # lrp_handle_unknow_dst_pkt may use it to modify IP to # construct right arp request action.load(LRP[LRP_IP_INT], NXM_Reg(REG3_IDX), Action4) & action.resubmit_next(Action5) & (Action == Action1 + Action2 + Action3 + Action4 + Action5)) if options.has_key('GATEWAY'): _static_route_changed(Route, LR, LRP, State) <= ( local_system_id(UUID_CHASSIS) & lroute_array(Route, UUID_LR, State1) & lsp_link_lrp( LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_CHASSIS, State2) & (Route[LSR_OUTPORT] == LRP[LRP_UUID]) & local_patchport(LSP1, LS, State3) & (State == State1 + State2 + State3) & (State != 0)) _next_live_hop_lr(UUID_LRP, LRP, LR, LR_NEXT, State) <= (next_hop_lr(UUID_LRP, LRP, LR, LR_NEXT, State) & (LR_NEXT[LR_CHASSIS_UUID] == None)) # if next LR is pining on a chassis, tuplenet have to verify if the geneve # tunnel port had been create. Otherwise, some packet may deliver to this # LR which has no tunnel port to remote chassis. It cause packet drop once # a gateway chassis was re-add. _next_live_hop_lr(UUID_LRP, LRP, LR, LR_NEXT, State) <= ( next_hop_lr(UUID_LRP, LRP, LR, LR_NEXT, State1) & (LR_NEXT[LR_CHASSIS_UUID] != None) & remote_chassis( LR_NEXT[LR_CHASSIS_UUID], PHY_CHASSIS_WITH_OFPORT, State2) & (State == State1 + State2)) _next_live_hop_lr(UUID_LRP, LRP, LR, LR_NEXT, State) <= (next_hop_lr(UUID_LRP, LRP, LR, LR_NEXT, State) & local_system_id(LR_NEXT[LR_CHASSIS_UUID])) _static_route_changed(Route, LR, LRP, State) <= ( lroute_array(Route, UUID_LR, State1) & _next_live_hop_lr(Route[LSR_OUTPORT], LRP, LR, LR_NEXT, State2) & (State == State1 + State2) & (State != 0)) #static route lrp_ip_route(LR, Priority, Match, Action, State) <= ( _static_route_changed(Route, LR, LRP, State) & (Priority == _cal_priority(Route[LSR_PREFIX], 1, Route[LSR_ILK_IDX])) & match.ip_proto(Match1) & match.ip_dst_prefix(Route[LSR_IP], Route[LSR_PREFIX], Match2) & (Match == Match1 + Match2) & 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) & # lrp_handle_unknow_dst_pkt may use it to modify IP to # construct right arp request action.load(LRP[LRP_IP_INT], NXM_Reg(REG3_IDX), Action4) & action.resubmit_next(Action5) & (Action == Action1 + Action2 + Action3 + Action4 + Action5)) # gateway chassis no need to consider ecmp if not options.has_key('GATEWAY'): lrp_ip_route(LR, Priority, Match, Action, State) <= (ecmp_static_route( LR, Priority, Match, Action, State)) lrp_ecmp_judge(LR, Priority, Match, Action, State) <= (ecmp_static_route_judge( LR, Priority, Match, Action, State)) # drop packet if we cannot found route for this packet lrp_ip_route(LR, Priority, Match, Action, State) <= ((Priority == 0) & lr_array(LR, UUID_LR, State) & (State != 0) & match.match_none(Match) & action.resubmit_table(TABLE_DROP_PACKET, Action))