Add icmp handling / replying
This commit is contained in:
parent
79a46f42c2
commit
d87b897069
5 changed files with 58 additions and 11 deletions
|
|
@ -37,7 +37,8 @@ table_id_fields = {
|
|||
4: 'TABLE_NAT46',
|
||||
5: 'TABLE_V4_NETWORKS',
|
||||
6: 'TABLE_ARP',
|
||||
7: 'TABLE_ARP_EGRESS'
|
||||
7: 'TABLE_ARP_EGRESS',
|
||||
8: 'TABLE_ICMP'
|
||||
}
|
||||
|
||||
table_proto = {
|
||||
|
|
@ -224,7 +225,7 @@ class L2Controller(object):
|
|||
def init_ndp_in_switch(self, addr):
|
||||
icmp6_addr = self.gen_ndp_multicast_addr(addr)
|
||||
icmp6_net = "{}/128".format(icmp6_addr)
|
||||
icmp6_type = 135
|
||||
icmp6_type = table_proto['ICMP_NS']
|
||||
mac_addr = self.info['mac_addr']
|
||||
|
||||
self.controller.table_add("icmp6",
|
||||
|
|
@ -233,13 +234,21 @@ class L2Controller(object):
|
|||
|
||||
def init_icmp6_echo_in_switch(self, addr):
|
||||
icmp6_addr = addr
|
||||
icmp6_type = 128
|
||||
icmp6_type = table_proto['ICMP6_ECHO_REQUEST']
|
||||
icmp6_net = "{}/128".format(icmp6_addr)
|
||||
|
||||
self.controller.table_add("icmp6",
|
||||
"icmp6_echo_reply",
|
||||
[str(icmp6_net), str(icmp6_type)], [])
|
||||
|
||||
def init_icmp_echo_in_switch(self, addr):
|
||||
icmp_addr = addr
|
||||
icmp_type = table_proto['ICMP_ECHO_REQUEST']
|
||||
icmp_net = "{}/32".format(icmp_addr)
|
||||
|
||||
self.controller.table_add("icmp",
|
||||
"icmp_echo_reply",
|
||||
[str(icmp_net), str(icmp_type)], [])
|
||||
|
||||
def ipv4_router(self, net):
|
||||
return net[self.info['switch_suffix']]
|
||||
|
|
@ -251,6 +260,7 @@ class L2Controller(object):
|
|||
|
||||
self.controller.table_clear("v4_networks")
|
||||
self.controller.table_clear("v4_arp")
|
||||
self.controller.table_clear("v4_arp_egress")
|
||||
for v4route in self.v4_routes[self.mode]:
|
||||
self.controller.table_add("v4_networks", "set_egress_port", [str(v4route['net'])], [str(v4route['port'])])
|
||||
|
||||
|
|
@ -267,11 +277,17 @@ class L2Controller(object):
|
|||
if self.args.multicast_to_controller:
|
||||
self.listen_to_icmp6_multicast()
|
||||
|
||||
# icmp6 echo request + NDP
|
||||
self.controller.table_clear("icmp6")
|
||||
for v6addr in self.v6_addresses[self.mode]:
|
||||
self.init_ndp_in_switch(v6addr)
|
||||
self.init_icmp6_echo_in_switch(v6addr)
|
||||
|
||||
# icmp echo request
|
||||
self.controller.table_clear("icmp")
|
||||
for addr in self.v4_addresses[self.mode]:
|
||||
self.init_icmp_echo_in_switch(addr)
|
||||
|
||||
self.controller.table_clear("nat64")
|
||||
self.controller.table_clear("nat46")
|
||||
for nat64map in self.nat64_map[self.mode]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue