diff --git a/p4app/controller.py b/p4app/controller.py index d536315..70277b3 100755 --- a/p4app/controller.py +++ b/p4app/controller.py @@ -36,7 +36,8 @@ table_id_fields = { 3: 'TABLE_V6_NETWORKS', 4: 'TABLE_NAT46', 5: 'TABLE_V4_NETWORKS', - 6: 'TABLE_ARP' + 6: 'TABLE_ARP', + 7: 'TABLE_ARP_EGRESS' } table_proto = { @@ -254,6 +255,7 @@ class L2Controller(object): self.controller.table_add("v4_networks", "set_egress_port", [str(v4route['net'])], [str(v4route['port'])]) # ARP support + self.controller.table_add("v4_arp_egress", "set_egress_port", [str(v4route['net'])], [str(v4route['port'])]) router = "{}/32".format(self.ipv4_router(v4route['net'])) self.controller.table_add("v4_arp", "arp_reply", [str(self.info['mac_broadcast']), diff --git a/p4src/headers.p4 b/p4src/headers.p4 index 0b23ae9..1c542ef 100644 --- a/p4src/headers.p4 +++ b/p4src/headers.p4 @@ -23,6 +23,7 @@ const bit<16> TABLE_V6_NETWORKS = 3; const bit<16> TABLE_NAT46 = 4; const bit<16> TABLE_V4_NETWORKS = 5; const bit<16> TABLE_ARP = 6; +const bit<16> TABLE_ARP_EGRESS = 7; const bit<16> TYPE_IPV4 = 0x0800; diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index 9be75e8..35e7de0 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -360,6 +360,19 @@ Echo or Echo Reply Message default_action = controller_debug_table_id(TABLE_ARP); } + table v4_arp_egress { + key = { + hdr.arp.dst_ipv4_addr: lpm; + } + actions = { + controller_debug_table_id; + set_egress_port; + NoAction; + } + size = ICMP6_TABLE_SIZE; + default_action = controller_debug_table_id(TABLE_ARP_EGRESS); + } + /********************** ROUTING (egress definiton) TABLES ***********************************/ @@ -432,7 +445,10 @@ Echo or Echo Reply Message } v4_networks.apply(); /* regular routing, egress */ } else if(hdr.arp.isValid()) { - v4_arp.apply(); + if(v4_arp.apply().hit) { + v4_arp_egress.apply(); + } + } } }