Skip to content

Commit

Permalink
Merge pull request #3548 from anarkiwi/l2l2
Browse files Browse the repository at this point in the history
Add stack info to learn message.
  • Loading branch information
gizmoguy authored May 4, 2020
2 parents 8d38635 + bcd4f59 commit 33c7399
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
26 changes: 15 additions & 11 deletions faucet/valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,8 +1293,10 @@ def learn_host(self, now, pkt_meta, other_valves):
pkt_meta.reparse_ip()
learn_log = 'L2 learned on %s %s (%u hosts total)' % (
learn_port, pkt_meta.log(), pkt_meta.vlan.hosts_count())
stack_descr = None
if pkt_meta.port.stack:
learn_log += ' from %s' % pkt_meta.port.stack_descr()
stack_descr = pkt_meta.port.stack_descr()
learn_log += ' from %s' % stack_descr
previous_port_no = None
if previous_port is not None:
previous_port_no = previous_port.number
Expand All @@ -1306,16 +1308,18 @@ def learn_host(self, now, pkt_meta, other_valves):
learn_labels = dict(self.dp.base_prom_labels(), vid=pkt_meta.vlan.vid,
eth_src=pkt_meta.eth_src)
self._set_var('learned_l2_port', learn_port.number, labels=learn_labels)
self.notify(
{'L2_LEARN': {
'port_no': learn_port.number,
'previous_port_no': previous_port_no,
'vid': pkt_meta.vlan.vid,
'eth_src': pkt_meta.eth_src,
'eth_dst': pkt_meta.eth_dst,
'eth_type': pkt_meta.eth_type,
'l3_src_ip': str(pkt_meta.l3_src),
'l3_dst_ip': str(pkt_meta.l3_dst)}})
l2_learn_msg = {
'port_no': learn_port.number,
'previous_port_no': previous_port_no,
'vid': pkt_meta.vlan.vid,
'eth_src': pkt_meta.eth_src,
'eth_dst': pkt_meta.eth_dst,
'eth_type': pkt_meta.eth_type,
'l3_src_ip': str(pkt_meta.l3_src),
'l3_dst_ip': str(pkt_meta.l3_dst)}
if stack_descr:
l2_learn_msg.update({'stack_descr': stack_descr})
self.notify({'L2_LEARN': l2_learn_msg})
return learn_flows
return []

Expand Down
12 changes: 12 additions & 0 deletions tests/integration/mininet_multidp_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import json
import os
import time
import networkx
Expand Down Expand Up @@ -269,12 +270,23 @@ class FaucetStackStringOfDPUntaggedTest(FaucetMultiDPTest):
NUM_HOSTS = 2
SOFTWARE_ONLY = True

def verify_events_log(self, event_log):
with open(event_log, 'r') as event_log_file:
events = [json.loads(event_log_line.strip()) for event_log_line in event_log_file]
l2_learns = [event['L2_LEARN'] for event in events if 'L2_LEARN' in event]
for event in l2_learns:
if event.get('stack_descr', None):
return
self.fail('stack_descr not in events: %s' % l2_learns)

def test_untagged(self):
"""All untagged hosts in stack topology can reach each other."""
self.set_up(
stack=True, n_dps=self.NUM_DPS, n_untagged=self.NUM_HOSTS,
switch_to_switch_links=2, hw_dpid=self.hw_dpid)
self._enable_event_log()
self.verify_stack_hosts()
self.verify_events_log(self.event_log)


class FaucetSingleStackStringOfDPExtLoopProtUntaggedTest(FaucetMultiDPTest):
Expand Down

0 comments on commit 33c7399

Please sign in to comment.