'Identify egress traffic and send it to egress base'

def _initialize_egress(self, port):

    self._initialize_egress_ipv6_icmp(port)
    allowed_pairs = port.allowed_pairs_v4.union({(port.mac, ip_addr) for ip_addr in port.ipv4_addresses})
    for (mac_addr, ip_addr) in allowed_pairs:
        self._add_flow(table=ovs_consts.BASE_EGRESS_TABLE, priority=95, in_port=port.ofport, reg_port=port.ofport, dl_src=mac_addr, dl_type=constants.ETHERTYPE_ARP, arp_spa=ip_addr, actions='normal')
        self._add_flow(table=ovs_consts.BASE_EGRESS_TABLE, priority=65, reg_port=port.ofport, ct_state=ovsfw_consts.OF_STATE_NOT_TRACKED, dl_type=constants.ETHERTYPE_IP, in_port=port.ofport, dl_src=mac_addr, nw_src=ip_addr, actions='ct(table={:d},zone=NXM_NX_REG{:d}[0..15])'.format(ovs_consts.RULES_EGRESS_TABLE, ovsfw_consts.REG_NET))
    allowed_pairs = port.allowed_pairs_v6.union({(port.mac, ip_addr) for ip_addr in port.ipv6_addresses})
    for (mac_addr, ip_addr) in allowed_pairs:
        self._add_flow(table=ovs_consts.BASE_EGRESS_TABLE, priority=65, reg_port=port.ofport, in_port=port.ofport, ct_state=ovsfw_consts.OF_STATE_NOT_TRACKED, dl_type=constants.ETHERTYPE_IPV6, dl_src=mac_addr, ipv6_src=ip_addr, actions='ct(table={:d},zone=NXM_NX_REG{:d}[0..15])'.format(ovs_consts.RULES_EGRESS_TABLE, ovsfw_consts.REG_NET))
    for (dl_type, src_port, dst_port) in ((constants.ETHERTYPE_IP, 68, 67), (constants.ETHERTYPE_IPV6, 546, 547)):
        self._add_flow(table=ovs_consts.BASE_EGRESS_TABLE, priority=80, reg_port=port.ofport, in_port=port.ofport, dl_type=dl_type, nw_proto=lib_const.PROTO_NUM_UDP, tp_src=src_port, tp_dst=dst_port, actions='resubmit(,{:d})'.format(ovs_consts.ACCEPT_OR_INGRESS_TABLE))
    for (dl_type, src_port, dst_port) in ((constants.ETHERTYPE_IP, 67, 68), (constants.ETHERTYPE_IPV6, 547, 546)):
        self._add_flow(table=ovs_consts.BASE_EGRESS_TABLE, priority=70, in_port=port.ofport, reg_port=port.ofport, dl_type=dl_type, nw_proto=lib_const.PROTO_NUM_UDP, tp_src=src_port, tp_dst=dst_port, actions='drop')
    self._add_flow(table=ovs_consts.BASE_EGRESS_TABLE, priority=70, in_port=port.ofport, reg_port=port.ofport, dl_type=constants.ETHERTYPE_IPV6, nw_proto=lib_const.PROTO_NUM_IPV6_ICMP, icmp_type=lib_const.ICMPV6_TYPE_RA, actions='drop')
    self._add_flow(table=ovs_consts.BASE_EGRESS_TABLE, priority=10, ct_state=ovsfw_consts.OF_STATE_NOT_TRACKED, in_port=port.ofport, reg_port=port.ofport, actions='drop')
    for mac_addr in port.all_allowed_macs:
        self._add_flow(table=ovs_consts.ACCEPT_OR_INGRESS_TABLE, priority=100, dl_dst=mac_addr, reg_net=port.vlan_tag, actions='set_field:{:d}->reg{:d},resubmit(,{:d})'.format(port.ofport, ovsfw_consts.REG_PORT, ovs_consts.BASE_INGRESS_TABLE))
    for ethertype in [constants.ETHERTYPE_IP, constants.ETHERTYPE_IPV6]:
        self._add_flow(table=ovs_consts.ACCEPT_OR_INGRESS_TABLE, priority=90, dl_type=ethertype, reg_port=port.ofport, ct_state=ovsfw_consts.OF_STATE_NEW_NOT_ESTABLISHED, actions='ct(commit,zone=NXM_NX_REG{:d}[0..15]),normal'.format(ovsfw_consts.REG_NET))
    self._add_flow(table=ovs_consts.ACCEPT_OR_INGRESS_TABLE, priority=80, reg_port=port.ofport, actions='normal')
