From e87c2419c4f1c73c7e7b76d34ba909b7b0f962d6 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 4 Jan 2013 17:59:29 -0800 Subject: Allow pinging own float when using fixed gateway When pinging your own floating ip, the snat rule is not hit if dnsmasq is set up to give out an external gateway. Fixes bug 1096259 Change-Id: Ib71312bf37b3a890567cf6212acabb5821846ab8 --- nova/network/linux_net.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index a1c03bc51..bab523ee8 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -649,12 +649,18 @@ def remove_floating_forward(floating_ip, fixed_ip, device): def floating_forward_rules(floating_ip, fixed_ip, device): + rules = [] rule = '-s %s -j SNAT --to %s' % (fixed_ip, floating_ip) if device: - rule += ' -o %s' % device - return [('PREROUTING', '-d %s -j DNAT --to %s' % (floating_ip, fixed_ip)), - ('OUTPUT', '-d %s -j DNAT --to %s' % (floating_ip, fixed_ip)), - ('float-snat', rule)] + rules.append(('float-snat', rule + ' -d %s' % fixed_ip)) + rules.append(('float-snat', rule + ' -o %s' % device)) + else: + rules.append(('float-snat', rule)) + rules.append( + ('PREROUTING', '-d %s -j DNAT --to %s' % (floating_ip, fixed_ip))) + rules.append( + ('OUTPUT', '-d %s -j DNAT --to %s' % (floating_ip, fixed_ip))) + return rules def initialize_gateway_device(dev, network_ref): -- cgit