Reformat controller processing
This commit is contained in:
parent
1c1eeaf46e
commit
b0cd39d82c
1 changed files with 33 additions and 24 deletions
|
@ -431,15 +431,18 @@ class L2Controller(object):
|
||||||
def recv_msg_cpu(self, pkg):
|
def recv_msg_cpu(self, pkg):
|
||||||
packet = Ether(str(pkg))
|
packet = Ether(str(pkg))
|
||||||
|
|
||||||
|
cpu_header = ""
|
||||||
|
ether_orig = ""
|
||||||
|
orig_packet = ""
|
||||||
|
|
||||||
if packet.type == 0x0800:
|
if packet.type == 0x0800:
|
||||||
log.debug("Received raw (untagged) packet - BUG")
|
log.debug("Received raw (untagged) IPv4 packet - BUG")
|
||||||
self.debug_print_pkg(pkg)
|
self.debug_print_pkg(pkg)
|
||||||
|
|
||||||
elif packet.type == 0x86dd:
|
elif packet.type == 0x86dd:
|
||||||
|
log.debug("Received raw (untagged) IPv6 packet - BUG")
|
||||||
self.debug_print_pkg(pkg)
|
self.debug_print_pkg(pkg)
|
||||||
cpu_header = CpuHeader(packet.payload)
|
|
||||||
ether_orig = Ether(src=packet.src, dst=packet.dst, type=cpu_header.type)
|
|
||||||
orig_packet = ether_orig / IP(cpu_header.load)
|
|
||||||
log.debug("cpu = {}".format(cpu_header.__repr__()))
|
log.debug("cpu = {}".format(cpu_header.__repr__()))
|
||||||
log.debug("v4 reassambled={}".format(orig_packet.__repr__()))
|
log.debug("v4 reassambled={}".format(orig_packet.__repr__()))
|
||||||
|
|
||||||
|
@ -451,30 +454,36 @@ class L2Controller(object):
|
||||||
|
|
||||||
ether_orig = Ether(src=packet.src, dst=packet.dst, type=cpu_header.type)
|
ether_orig = Ether(src=packet.src, dst=packet.dst, type=cpu_header.type)
|
||||||
|
|
||||||
# Bug? This might be IPv4 as well later!
|
if cpu_header.type == 0x0800:
|
||||||
orig_packet = ether_orig / IPv6(cpu_header.load)
|
orig_packet = ether_orig / IP(cpu_header.load)
|
||||||
|
elif cpu_header.type == 0x86dd:
|
||||||
if ICMPv6ND_NS in orig_packet and orig_packet['IPv6'].src == '::':
|
orig_packet = ether_orig / IPv6(cpu_header.load)
|
||||||
log.debug("Neighbor solicitation for checking her own IP address")
|
else:
|
||||||
elif ICMPv6MLReport2 in orig_packet and orig_packet['IPv6'].dst == 'ff02::16':
|
print("Broken pkg: {}".format(pkg.__repr__()))
|
||||||
mc_group = orig_packet['ICMPv6MLDMultAddrRec'].dst
|
return
|
||||||
log.debug("Multicast registration for {} port {} -- should probably handle this".format(mc_group, cpu_header.ingress_port))
|
|
||||||
elif ICMPv6ND_RS in orig_packet and orig_packet['IPv6'].dst == 'ff02::2':
|
|
||||||
src = orig_packet['IPv6'].src
|
|
||||||
log.debug("Router solicitation from {} -- should probably handle this?".format(src))
|
|
||||||
elif cpu_header.task == self.task['DEBUG']:
|
|
||||||
log.debug("[debug] v6 reassambled={}".format(orig_packet.__repr__()))
|
|
||||||
elif cpu_header.task == self.task['ICMP6_NS']:
|
|
||||||
log.info("Doing neighbor solicitation for the switch in the controller")
|
|
||||||
self.handle_icmp6_ns(orig_packet)
|
|
||||||
elif cpu_header.task == self.task['ICMP6_GENERAL']:
|
|
||||||
if ICMPv6EchoRequest in orig_packet:
|
|
||||||
self.handle_icmp6_echo_request(orig_packet)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Broken pkg: {}".format(pkg.__repr__()))
|
print("Broken pkg: {}".format(pkg.__repr__()))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Process parsed
|
||||||
|
if ICMPv6ND_NS in orig_packet and orig_packet['IPv6'].src == '::':
|
||||||
|
log.debug("Neighbor solicitation for checking her own IP address")
|
||||||
|
elif ICMPv6MLReport2 in orig_packet and orig_packet['IPv6'].dst == 'ff02::16':
|
||||||
|
mc_group = orig_packet['ICMPv6MLDMultAddrRec'].dst
|
||||||
|
log.debug("Multicast registration for {} port {} -- should probably handle this".format(mc_group, cpu_header.ingress_port))
|
||||||
|
elif ICMPv6ND_RS in orig_packet and orig_packet['IPv6'].dst == 'ff02::2':
|
||||||
|
src = orig_packet['IPv6'].src
|
||||||
|
log.debug("Router solicitation from {} -- should probably handle this?".format(src))
|
||||||
|
elif cpu_header.task == self.task['ICMP6_NS']:
|
||||||
|
log.info("Doing neighbor solicitation for the switch in the controller")
|
||||||
|
self.handle_icmp6_ns(orig_packet)
|
||||||
|
elif cpu_header.task == self.task['ICMP6_GENERAL']:
|
||||||
|
if ICMPv6EchoRequest in orig_packet:
|
||||||
|
self.handle_icmp6_echo_request(orig_packet)
|
||||||
|
else:
|
||||||
|
log.debug("unhandled reassambled={} from table {}".format(orig_packet.__repr__(), cpu_header.table_id))
|
||||||
|
|
||||||
|
|
||||||
def run_cpu_port_loop(self):
|
def run_cpu_port_loop(self):
|
||||||
sniff(iface=self.intf, prn=self.recv_msg_cpu)
|
sniff(iface=self.intf, prn=self.recv_msg_cpu)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue