예제 #1
0
 def add_next_routing(self, next_id, egress_port, smac, dmac):
     egress_port_ = stringify(egress_port, 2)
     smac_ = mac_to_binary(smac)
     dmac_ = mac_to_binary(dmac)
     self.add_next_hashed_indirect_action(next_id, "next.routing_hashed",
                                          [("port_num", egress_port_),
                                           ("smac", smac_),
                                           ("dmac", dmac_)])
예제 #2
0
 def add_l2_ternary_entry(self, eth_dst, eth_dst_mask, mcast_group_id):
     mc_group_id_ = stringify(mcast_group_id, 2)
     eth_dst_ = mac_to_binary(eth_dst)
     eth_dst_mask_ = mac_to_binary(eth_dst_mask)
     mk = [self.Ternary("hdr.ethernet.dst_addr", eth_dst_, eth_dst_mask_)]
     self.send_request_add_entry_to_action(
         "FabricIngress.l2_ternary_table", mk,
         "FabricIngress.set_multicast_group", [("gid", mc_group_id_)],
         DEFAULT_PRIORITY)
예제 #3
0
 def add_next_hop_L3(self, next_id, egress_port, smac, dmac):
     next_id_ = stringify(next_id, 4)
     egress_port_ = stringify(egress_port, 2)
     smac_ = mac_to_binary(smac)
     dmac_ = mac_to_binary(dmac)
     self.send_request_add_entry_to_action(
         "next.simple", [self.Exact("fabric_metadata.next_id", next_id_)],
         "next.l3_routing", [("port_num", egress_port_), ("smac", smac_),
                             ("dmac", dmac_)])
예제 #4
0
 def add_next_hop_mpls_v4(self, next_id, egress_port, smac, dmac, label):
     next_id_ = stringify(next_id, 4)
     egress_port_ = stringify(egress_port, 2)
     smac_ = mac_to_binary(smac)
     dmac_ = mac_to_binary(dmac)
     label_ = stringify(label, 3)
     self.send_request_add_entry_to_action(
         "next.simple", [self.Exact("fabric_metadata.next_id", next_id_)],
         "next.mpls_routing_v4", [("port_num", egress_port_),
                                  ("smac", smac_), ("dmac", dmac_),
                                  ("label", label_)])
예제 #5
0
 def add_bridging_entry(self, vlan_id, eth_dstAddr, eth_dstAddr_mask,
                        next_id):
     vlan_id_ = stringify(vlan_id, 2)
     eth_dstAddr_ = mac_to_binary(eth_dstAddr)
     eth_dstAddr_mask_ = mac_to_binary(eth_dstAddr_mask)
     next_id_ = stringify(next_id, 4)
     self.send_request_add_entry_to_action("forwarding.bridging", [
         self.Exact("hdr.vlan_tag.vlan_id", vlan_id_),
         self.Ternary("hdr.ethernet.dst_addr", eth_dstAddr_,
                      eth_dstAddr_mask_)
     ], "forwarding.set_next_id", [("next_id", next_id_)], DEFAULT_PRIORITY)
예제 #6
0
 def add_bridging_entry(self, vlan_id, eth_dstAddr, eth_dstAddr_mask,
                        next_id):
     vlan_id_ = stringify(vlan_id, 2)
     mk = [self.Exact("vlan_id", vlan_id_)]
     if eth_dstAddr is not None:
         eth_dstAddr_ = mac_to_binary(eth_dstAddr)
         eth_dstAddr_mask_ = mac_to_binary(eth_dstAddr_mask)
         mk.append(self.Ternary("eth_dst", eth_dstAddr_, eth_dstAddr_mask_))
     next_id_ = stringify(next_id, 4)
     self.send_request_add_entry_to_action(
         "forwarding.bridging", mk, "forwarding.set_next_id_bridging",
         [("next_id", next_id_)], DEFAULT_PRIORITY)
예제 #7
0
 def add_next_routing_group(self, next_id, grp_id, next_hops=None):
     actions = []
     if next_hops is not None:
         for (egress_port, smac, dmac) in next_hops:
             egress_port_ = stringify(egress_port, 2)
             smac_ = mac_to_binary(smac)
             dmac_ = mac_to_binary(dmac)
             actions.append([
                 "next.routing_hashed",
                 [("port_num", egress_port_), ("smac", smac_), ("dmac", dmac_)]
             ])
     self.add_next_hashed_group_action(next_id, grp_id, actions)
예제 #8
0
 def set_forwarding_type(self, ingress_port, eth_dstAddr, ethertype=ETH_TYPE_IPV4,
                         fwd_type=FORWARDING_TYPE_UNICAST_IPV4):
     ingress_port_ = stringify(ingress_port, 2)
     eth_dstAddr_ = mac_to_binary(eth_dstAddr)
     eth_mask_ = mac_to_binary(MAC_MASK)
     ethertype_ = stringify(ethertype, 2)
     fwd_type_ = stringify(fwd_type, 1)
     self.send_request_add_entry_to_action(
         "filtering.fwd_classifier",
         [self.Exact("ig_port", ingress_port_),
          self.Ternary("eth_dst", eth_dstAddr_, eth_mask_),
          self.Exact("eth_type", ethertype_)],
         "filtering.set_forwarding_type", [("fwd_type", fwd_type_)],
         priority=DEFAULT_PRIORITY)
예제 #9
0
 def add_ndp_reply_entry(self, target_addr, target_mac):
     target_addr = inet_pton(socket.AF_INET6, target_addr)
     target_mac = mac_to_binary(target_mac)
     mk = [self.Exact("hdr.ndp.target_addr", target_addr)]
     self.send_request_add_entry_to_action(
         "FabricIngress.ndp_reply", mk, "FabricIngress.ndp_advertisement",
         [("router_mac", target_mac)])
예제 #10
0
 def add_l3_ecmp_entry(self, dstAddr, prefix_len, next_hop_macs):
     members = []
     for mac in next_hop_macs:
         mac_ = mac_to_binary(mac)
         members.append(("FabricIngress.set_l2_next_hop", [("dmac", mac_)]))
     grp_id = self.get_next_grp_id()
     self.add_l3_group_with_members(grp_id, members)
     self.add_l3_entry(dstAddr, prefix_len, grp_id)
예제 #11
0
 def add_l2_exact_entry(self, eth_dst, out_port):
     out_port_ = stringify(out_port, 2)
     eth_dst_ = mac_to_binary(eth_dst)
     mk = [self.Exact("hdr.ethernet.dst_addr", eth_dst_)]
     self.send_request_add_entry_to_action("FabricIngress.l2_exact_table",
                                           mk,
                                           "FabricIngress.set_output_port",
                                           [("port_num", out_port_)])
예제 #12
0
 def add_next_hop_L3_group(self, next_id, grp_id, next_hops=None):
     next_id_ = stringify(next_id, 4)
     if next_hops is not None:
         for mbr_id, params in next_hops.items():
             egress_port, smac, dmac = params
             egress_port_ = stringify(egress_port, 2)
             smac_ = mac_to_binary(smac)
             dmac_ = mac_to_binary(dmac)
             self.send_request_add_member(
                 "next.ecmp_selector", mbr_id, "next.l3_routing_hashed",
                 [("port_num", egress_port_), ("smac", smac_), ("dmac", dmac_)])
     self.send_request_add_group("next.ecmp_selector", grp_id,
                                 grp_size=32, mbr_ids=next_hops.keys())
     self.send_request_add_entry_to_group(
         "next.hashed",
         [self.Exact("fabric_metadata.next_id", next_id_)],
         grp_id)
예제 #13
0
 def set_forwarding_type(self, ingress_port, eth_dstAddr, ethertype=0x800,
                         fwd_type=FORWARDING_TYPE_UNICAST_IPV4):
     ingress_port_ = stringify(ingress_port, 2)
     eth_dstAddr_ = mac_to_binary(eth_dstAddr)
     ethertype_ = stringify(ethertype, 2)
     fwd_type_ = stringify(fwd_type, 1)
     self.send_request_add_entry_to_action(
         "filtering.fwd_classifier",
         [self.Exact("standard_metadata.ingress_port", ingress_port_),
          self.Exact("hdr.ethernet.dst_addr", eth_dstAddr_),
          self.Exact("fabric_metadata.original_ether_type", ethertype_)],
         "filtering.set_forwarding_type", [("fwd_type", fwd_type_)])
예제 #14
0
 def add_l2_my_station_entry(self, eth_dst):
     eth_dst_ = mac_to_binary(eth_dst)
     mk = [self.Exact("hdr.ethernet.dst_addr", eth_dst_)]
     self.send_request_add_entry_to_action("FabricIngress.l2_my_station",
                                           mk, "NoAction", [])