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_lsp_egress_clause(way): lsp_judge_loopback(LS, Priority, Match, Action, State) <= ( (Priority == 2) & ls_array(LS, UUID_LS, State) & (State != 0) & match.reg_flag(FLAG_LOOPBACK, Match) & # load 0xffff(OFPP_NONE) -> inport to avoid dropping loopback packet action.load(st.TP_OFPORT_NONE, NXM_Reg(IN_PORT_IDX), Action1) & action.resubmit_next(Action2) & (Action == Action1 + Action2)) lsp_judge_loopback(LS, Priority, Match, Action, State) <= ( (Priority == 0) & ls_array(LS, UUID_LS, State) & (State != 0) & match.match_none(Match) & action.resubmit_next(Action)) # output packet to local ovs-port lsp_forward_packet(LS, Priority, Match, Action, State) <= ( (Priority == 3) & local_bond_lsp(LSP, LS, State) & (State != 0) & match.reg_dst(LSP[LSP_PORTID], Match) & action.load(1, NXM_Reg(REG5_IDX), Action1) & action.load(LSP[LSP_OFPORT], NXM_Reg(REG_OUTPORT_IDX), Action2) & action.resubmit_next(Action3) & (Action == Action1 + Action2 + Action3)) # set the packet's destination, the destination is next LR's LRP lsp_forward_packet(LS, Priority, Match, Action, State) <= ( (Priority == 2) & lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) & (State != 0) & match.reg_dst(LSP[LSP_PORTID], Match) & # load next LR's ID to reg6, next stage's flow will move reg6 --> DP # load next LR's port to reg7, next stage's flow will move reg7 # --> REG_SRC_IDX action.load(LR[LR_ID], NXM_Reg(REG6_IDX), Action1) & action.load(LRP[LRP_PORTID], NXM_Reg(REG7_IDX), Action2) & action.resubmit_next(Action3) & (Action == Action1 + Action2 + Action3)) # if above flows are not hit, then it means the destination is not # on this host and this packet must be a redirect packet. We should # send it to lsp_lookup_dst_port, then lsp_output_dst_port will use # output action to output packet later. # And we decrease ttl the packet.(we assume all packet comes in lsp # egress should be IP packet). lsp_forward_packet(LS, Priority, Match, Action, State) <= ( (Priority == 0) & ls_array(LS, UUID_LS, State) & (State != 0) & match.ip_proto(Match) & # we set REDIRECT bit again, just try to avoid infinite loop action.load( 1, NXM_Reg(REG_FLAG_IDX, FLAG_REDIRECT_BIT_IDX, FLAG_REDIRECT_BIT_IDX), Action1) & action.resubmit_table(TABLE_LSP_INGRESS_LOOKUP_DST_PORT, Action2) & (Action == Action1 + Action2)) # if above flows are not hit, then it means the destination is not # on this host and this packet must be a redirect packet. We should # convert this arp request into arp response and send it back to # tunnel port which it comes from lsp_forward_packet(LS, Priority, Match, Action, State) <= ( (Priority == 0) & ls_array(LS, UUID_LS, State) & (State != 0) & match.arp_proto(Match1) & match.arp_op(1, Match2) & (Match == Match1 + Match2) & # set REDIRECT bit again to avoid infinite loop action.load( 1, NXM_Reg(REG_FLAG_IDX, FLAG_REDIRECT_BIT_IDX, FLAG_REDIRECT_BIT_IDX), Action1) & action.resubmit_table(TABLE_ARP_FEEDBACK_CONSTRUCT, Action2) & action.resubmit_table(TABLE_LSP_INGRESS_LOOKUP_DST_PORT, Action3) & (Action == Action1 + Action2 + Action3)) lsp_pushout_packet(LS, Priority, Match, Action, State) <= ( (Priority == 2) & ls_array(LS, UUID_LS, State) & (State != 0) & match.reg_5(1, Match) & action.resubmit_table(TABLE_OUTPUT_PKT, Action)) lsp_pushout_packet(LS, Priority, Match, Action, State) <= ( (Priority == 1) & ls_array(LS, UUID_LS, State) & (State != 0) & match.match_none(Match) & action.move( NXM_Reg(REG6_IDX, 0, 23), NXM_Reg(REG_DP_IDX, 0, 23), Action1) & action.move(NXM_Reg(REG7_IDX), NXM_Reg(REG_SRC_IDX), Action2) & # set reg6 back to 0 action.load(0, NXM_Reg(REG6_IDX), Action3) & action.load(0, NXM_Reg(REG7_IDX), Action4) & action.resubmit_table(TABLE_LRP_TRACE_INGRESS_IN, Action5) & (Action == Action1 + Action2 + Action3 + Action4 + Action5))