Skip to content

Commit eebf148

Browse files
authored
Merge pull request #2290 from anarkiwi/master
Stricter checks in proactive learning.
2 parents 03032b2 + 2f2f7a7 commit eebf148

File tree

4 files changed

+51
-25
lines changed

4 files changed

+51
-25
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Faucet
22
======
33

4-
:version: 1.8.13
4+
:version: 1.8.14
55

66
.. image:: https://travis-ci.com/faucetsdn/faucet.svg?branch=master
77
:target: https://travis-ci.com/faucetsdn/faucet

faucet/valve_route.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def _add_faucet_fib_to_vip(self, vlan, priority, faucet_vip, faucet_vip_host):
204204
priority=self.route_priority,
205205
inst=insts))
206206
routed_vlans = self._routed_vlans(vlan)
207+
if self._global_routing():
208+
vlan = self.global_vlan
207209
ofmsgs.append(self.fib_table.flowmod(
208210
self._route_match(vlan, faucet_vip_host),
209211
priority=priority,
@@ -401,17 +403,18 @@ def _resolve_gateway_flows(self, ip_gw, nexthop_cache_entry, vlan, faucet_vip, n
401403
if last_retry_time is None and nexthop_cache_entry.port is not None:
402404
resolve_flows = [self.resolve_gw_on_port(
403405
vlan, nexthop_cache_entry.port, faucet_vip, ip_gw)]
404-
if last_retry_time is None:
405-
self.logger.info(
406-
'resolving %s (%u flows) on VLAN %u' % (ip_gw, len(resolve_flows), vlan.vid))
407-
else:
408-
self.logger.info(
409-
'resolving %s retry %u (last attempt was %us ago; %u flows) on VLAN %u' % (
410-
ip_gw,
411-
nexthop_cache_entry.resolve_retries,
412-
now - last_retry_time,
413-
len(resolve_flows),
414-
vlan.vid))
406+
if resolve_flows:
407+
if last_retry_time is None:
408+
self.logger.info(
409+
'resolving %s (%u flows) on VLAN %u' % (ip_gw, len(resolve_flows), vlan.vid))
410+
else:
411+
self.logger.info(
412+
'resolving %s retry %u (last attempt was %us ago; %u flows) on VLAN %u' % (
413+
ip_gw,
414+
nexthop_cache_entry.resolve_retries,
415+
now - last_retry_time,
416+
len(resolve_flows),
417+
vlan.vid))
415418
return resolve_flows
416419

417420
def _expire_gateway_flows(self, ip_gw, nexthop_cache_entry, vlan, now):
@@ -490,7 +493,7 @@ def _proactive_resolve_neighbor(self, now, vlan, dst_ip):
490493
faucet_vip = vlan.vip_map(dst_ip)
491494
else:
492495
vlan, faucet_vip = router.vip_map(dst_ip)
493-
if vlan and faucet_vip and faucet_vip.ip != dst_ip:
496+
if vlan and vlan.ip_in_vip_subnet(dst_ip, faucet_vip) and faucet_vip.ip != dst_ip:
494497
limit = self._vlan_nexthop_cache_limit(vlan)
495498
if limit is None or len(self._vlan_nexthop_cache(vlan)) < limit:
496499
resolution_in_progress = self._is_host_fib_route(vlan, dst_ip)

faucet/vlan.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,16 @@ def vip_map(self, ipa):
514514
return faucet_vip
515515
return None
516516

517-
def is_faucet_vip(self, ipa):
517+
def is_faucet_vip(self, ipa, faucet_vip=None):
518518
"""Return True if IP is a VIP on this VLAN."""
519-
faucet_vip = self.vip_map(ipa)
519+
if faucet_vip is None:
520+
faucet_vip = self.vip_map(ipa)
520521
return faucet_vip and ipa == faucet_vip.ip
521522

522-
def ip_in_vip_subnet(self, ipa):
523+
def ip_in_vip_subnet(self, ipa, faucet_vip=None):
523524
"""Return faucet_vip if IP in same IP network as a VIP on this VLAN."""
524-
faucet_vip = self.vip_map(ipa)
525+
if faucet_vip is None:
526+
faucet_vip = self.vip_map(ipa)
525527
if faucet_vip:
526528
if ipa not in (
527529
faucet_vip.network.network_address,

tests/integration/mininet_tests.py

+29-8
Original file line numberDiff line numberDiff line change
@@ -3972,15 +3972,19 @@ def _vids():
39723972
proactive_learn_v4: True
39733973
interfaces:
39743974
%s:
3975+
native_vlan: 99
39753976
tagged_vlans: [%s]
39763977
description: "b1"
39773978
%s:
3979+
native_vlan: 99
39783980
tagged_vlans: [%s]
39793981
description: "b2"
39803982
%s:
3983+
native_vlan: 99
39813984
tagged_vlans: [%s]
39823985
description: "b3"
39833986
%s:
3987+
native_vlan: 99
39843988
tagged_vlans: [%s]
39853989
description: "b4"
39863990
""" % ('%(port_1)d', ','.join(STR_VIDS),
@@ -3996,29 +4000,46 @@ def test_tagged(self):
39964000
vlan_int = '%s.%u' % (host.intf_root_name, vid)
39974001
ipa = '192.168.%u.%u' % (vid, i)
39984002
ipg = '192.168.%u.254' % vid
4003+
ipd = '192.168.%u.253' % vid
39994004
setup_commands.extend([
40004005
'ip link add link %s name %s type vlan id %u' % (
40014006
host.intf_root_name, vlan_int, vid),
40024007
'ip link set dev %s up' % vlan_int,
40034008
'ip address add %s/24 brd + dev %s' % (ipa, vlan_int),
4009+
'arp -s %s 0e:00:00:00:00:01' % ipd,
4010+
'fping -c1 -t1 -I%s %s > /dev/null 2> /dev/null' % (vlan_int, ipd),
40044011
'ping -c1 -i0.1 -I%s %s > /dev/null' % (vlan_int, ipg)])
40054012
for j, _ in enumerate(hosts, start=1):
40064013
if j != i:
40074014
other_ip = '192.168.%u.%u/32' % (vid, j)
40084015
setup_commands.append(
40094016
'ip -4 route add %s via %s' % (other_ip, ipg))
40104017
self.quiet_commands(host, setup_commands)
4018+
4019+
# ensure learn ban present for down nexthop
4020+
self.wait_nonzero_packet_count_flow(
4021+
{u'dl_type': 2048, u'dl_vlan': u'2047', u'nw_dst': u'192.168.101.253'},
4022+
table_id=self._IPV4_FIB_TABLE, actions=[])
4023+
40114024
host, other_host = hosts
4012-
host_ip = ipaddress.ip_address(unicode(host.IP())) # pytype: disable=name-error
4013-
other_host_ip = ipaddress.ip_address(unicode(other_host.IP())) # pytype: disable=name-error
4014-
self.verify_iperf_min(
4015-
((host, self.port_map['port_1']),
4016-
(other_host, self.port_map['port_2'])),
4017-
1, host_ip, other_host_ip)
4025+
for ip_pair in (
4026+
(host.IP(), other_host.IP()), # non-routed
4027+
('192.168.%u.1' % self.NEW_VIDS[0], '192.168.%u.2' % self.NEW_VIDS[0])): # non-routed
4028+
host_ip_str, other_ip_str = ip_pair
4029+
host_ip = ipaddress.ip_address(unicode(host_ip_str))
4030+
other_ip = ipaddress.ip_address(unicode(other_ip_str))
4031+
self.verify_iperf_min(
4032+
((host, self.port_map['port_1']),
4033+
(other_host, self.port_map['port_2'])),
4034+
1, host_ip, other_ip)
4035+
40184036
for vid in self.NEW_VIDS:
4037+
host_vlan_int = '%s.%u' % (host.intf_root_name, vid)
4038+
other_vlan_int = '%s.%u' % (other_host.intf_root_name, vid)
4039+
host_ip = '192.168.%u.%u' % (vid, 1)
40194040
other_ip = '192.168.%u.%u' % (vid, 2)
4020-
vlan_int = '%s.%u' % (host.intf_root_name, vid)
4021-
self.one_ipv4_ping(host, other_ip, intf=vlan_int)
4041+
self.one_ipv4_ping(host, other_ip, intf=host_vlan_int)
4042+
self.one_ipv4_ping(other_host, host_ip, intf=other_vlan_int)
40224043

40234044

40244045
class FaucetTaggedScaleTest(FaucetTaggedTest):

0 commit comments

Comments
 (0)