diff --git a/dockers/docker-fpm-quagga/zebra.conf.j2 b/dockers/docker-fpm-quagga/zebra.conf.j2
index 8b967f98671c..e4586e72dd62 100644
--- a/dockers/docker-fpm-quagga/zebra.conf.j2
+++ b/dockers/docker-fpm-quagga/zebra.conf.j2
@@ -40,11 +40,13 @@ ip route 0.0.0.0/0 {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} 200
{% set lo_ipv6_addrs = [] %}
{% if LOOPBACK_INTERFACE %}
{% for (name, prefix) in LOOPBACK_INTERFACE %}
-{% if prefix | ipv6 %}
-{% if lo_ipv6_addrs.append(prefix) %}
-{% endif %}
-{% else %}
-{% if lo_ipv4_addrs.append(prefix) %}
+{% if name == 'Loopback0' %}
+{% if prefix | ipv6 %}
+{% if lo_ipv6_addrs.append(prefix) %}
+{% endif %}
+{% else %}
+{% if lo_ipv4_addrs.append(prefix) %}
+{% endif %}
{% endif %}
{% endif %}
{% endfor %}
diff --git a/dockers/docker-orchagent/ipinip.json.j2 b/dockers/docker-orchagent/ipinip.json.j2
index bee97f45b8ae..36fccddc237a 100644
--- a/dockers/docker-orchagent/ipinip.json.j2
+++ b/dockers/docker-orchagent/ipinip.json.j2
@@ -1,7 +1,7 @@
{# only IPv4 decapsulation is supported #}
{% set ipv4_loopback_addresses = [] %}
{% for (name, prefix) in LOOPBACK_INTERFACE %}
- {%- if prefix | ipv4 %}
+ {%- if prefix | ipv4 and name == 'Loopback0' %}
{%- set ipv4_loopback_addresses = ipv4_loopback_addresses.append(prefix) %}
{%- endif %}
{% endfor %}
diff --git a/src/sonic-config-engine/tests/sample_output/bgpd.conf b/src/sonic-config-engine/tests/sample_output/bgpd.conf
new file mode 100644
index 000000000000..4416b4628569
--- /dev/null
+++ b/src/sonic-config-engine/tests/sample_output/bgpd.conf
@@ -0,0 +1,91 @@
+!
+! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
+! generated by templates/quagga/bgpd.conf.j2 with config DB data
+! file: bgpd.conf
+!
+!
+hostname switch-t0
+password zebra
+log syslog informational
+log facility local4
+! enable password !
+!
+! bgp multiple-instance
+!
+route-map FROM_BGP_SPEAKER_V4 permit 10
+!
+route-map TO_BGP_SPEAKER_V4 deny 10
+!
+router bgp 65100
+ bgp log-neighbor-changes
+ bgp bestpath as-path multipath-relax
+ no bgp default ipv4-unicast
+ bgp graceful-restart
+ bgp router-id 10.1.0.32
+ network 10.1.0.32/32
+ address-family ipv6
+ network fc00:1::32/64
+ exit-address-family
+ network 192.168.0.1/27
+ neighbor 10.0.0.57 remote-as 64600
+ neighbor 10.0.0.57 description ARISTA01T1
+ address-family ipv4
+ neighbor 10.0.0.57 allowas-in 1
+ neighbor 10.0.0.57 activate
+ maximum-paths 64
+ exit-address-family
+ neighbor 10.0.0.59 remote-as 64600
+ neighbor 10.0.0.59 description ARISTA02T1
+ address-family ipv4
+ neighbor 10.0.0.59 allowas-in 1
+ neighbor 10.0.0.59 activate
+ maximum-paths 64
+ exit-address-family
+ neighbor 10.0.0.61 remote-as 64600
+ neighbor 10.0.0.61 description ARISTA03T1
+ address-family ipv4
+ neighbor 10.0.0.61 allowas-in 1
+ neighbor 10.0.0.61 activate
+ maximum-paths 64
+ exit-address-family
+ neighbor 10.0.0.63 remote-as 64600
+ neighbor 10.0.0.63 description ARISTA04T1
+ address-family ipv4
+ neighbor 10.0.0.63 allowas-in 1
+ neighbor 10.0.0.63 activate
+ maximum-paths 64
+ exit-address-family
+ neighbor fc00::7a remote-as 64600
+ neighbor fc00::7a description ARISTA03T1
+ address-family ipv6
+ neighbor fc00::7a allowas-in 1
+ neighbor fc00::7a activate
+ maximum-paths 64
+ exit-address-family
+ neighbor fc00::7e remote-as 64600
+ neighbor fc00::7e description ARISTA04T1
+ address-family ipv6
+ neighbor fc00::7e allowas-in 1
+ neighbor fc00::7e activate
+ maximum-paths 64
+ exit-address-family
+ neighbor fc00::72 remote-as 64600
+ neighbor fc00::72 description ARISTA01T1
+ address-family ipv6
+ neighbor fc00::72 allowas-in 1
+ neighbor fc00::72 activate
+ maximum-paths 64
+ exit-address-family
+ neighbor fc00::76 remote-as 64600
+ neighbor fc00::76 description ARISTA02T1
+ address-family ipv6
+ neighbor fc00::76 allowas-in 1
+ neighbor fc00::76 activate
+ maximum-paths 64
+ exit-address-family
+!
+maximum-paths 64
+!
+route-map ISOLATE permit 10
+set as-path prepend 65100
+!
diff --git a/src/sonic-config-engine/tests/sample_output/interfaces b/src/sonic-config-engine/tests/sample_output/interfaces
index c8da2fee8f76..96dc577ffe8b 100644
--- a/src/sonic-config-engine/tests/sample_output/interfaces
+++ b/src/sonic-config-engine/tests/sample_output/interfaces
@@ -15,6 +15,10 @@ iface lo inet6 static
address fc00:1::32
netmask 128
#
+iface lo inet static
+ address 10.10.0.99
+ netmask 255.255.255.255
+#
# The management network interface
auto eth0
iface eth0 inet static
diff --git a/src/sonic-config-engine/tests/sample_output/zebra.conf b/src/sonic-config-engine/tests/sample_output/zebra.conf
new file mode 100644
index 000000000000..aa3486b0163a
--- /dev/null
+++ b/src/sonic-config-engine/tests/sample_output/zebra.conf
@@ -0,0 +1,44 @@
+!
+! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
+! generated by templates/quagga/zebra.conf.j2 using config DB data
+! file: zebra.conf
+!
+!
+hostname switch-t0
+password zebra
+enable password zebra
+!
+! Enable link-detect (default disabled)
+interface PortChannel01
+link-detect
+!
+interface PortChannel02
+link-detect
+!
+interface PortChannel03
+link-detect
+!
+interface PortChannel04
+link-detect
+!
+!
+! set static default route to mgmt gateway as a backup to learned default
+ip route 0.0.0.0/0 10.0.0.1 200
+!
+! Set ip source to loopback for bgp learned routes
+route-map RM_SET_SRC permit 10
+ set src 10.1.0.32
+!
+
+route-map RM_SET_SRC6 permit 10
+ set src fc00:1::32
+!
+ip protocol bgp route-map RM_SET_SRC
+!
+ipv6 protocol bgp route-map RM_SET_SRC6
+!
+!
+log syslog informational
+log facility local4
+!
+
diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml
index bda5517771e5..ce0177d4c158 100644
--- a/src/sonic-config-engine/tests/t0-sample-graph.xml
+++ b/src/sonic-config-engine/tests/t0-sample-graph.xml
@@ -153,7 +153,15 @@
FC00:1::32/128
-
+
+ LoopbackIP1
+ Loopback1
+
+ 10.10.0.99/32
+
+ 10.10.0.99/32
+
+
HostIP
diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py
index 8ff974c1eb10..bda3a20dbdfb 100644
--- a/src/sonic-config-engine/tests/test_j2files.py
+++ b/src/sonic-config-engine/tests/test_j2files.py
@@ -20,6 +20,9 @@ def setUp(self):
def run_script(self, argument):
print 'CMD: sonic-cfggen ' + argument
return subprocess.check_output(self.script_file + ' ' + argument, shell=True)
+
+ def run_diff(self, file1, file2, diff):
+ return subprocess.check_output('diff {} {} >{}'.format(file1, file2, diff), shell=True)
def test_interfaces(self):
interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2')
@@ -59,6 +62,18 @@ def test_lldp(self):
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'lldpd.conf'), self.output_file))
+ def test_bgpd(self):
+ conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'bgpd.conf.j2')
+ argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
+ self.run_script(argument)
+ self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'bgpd.conf'), self.output_file))
+
+ def test_zebra(self):
+ conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'zebra.conf.j2')
+ argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
+ self.run_script(argument)
+ self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'zebra.conf'), self.output_file))
+
def test_teamd(self):
def test_render_teamd(self, pc, minigraph, sample_output):
@@ -94,7 +109,6 @@ def test_ipinip(self):
self.run_script(argument)
sample_output_file = os.path.join(self.test_dir, 'sample_output', 'ipinip.json')
-
assert filecmp.cmp(sample_output_file, self.output_file)
def test_msn27xx_32ports_buffers(self):