Skip to content

Commit

Permalink
[minigraph] Enhanced parser to parse interface name for static route …
Browse files Browse the repository at this point in the history
…nexthop (sonic-net#9707)

What I did:-

Enhanced minigraph parser to parse interface name associated with static route nexthop

Why I did:-

One of the use case to support interface name is Chassis Packet. For Chassis Packet we have Static Routes configured to route traffic across line-card. If the FRR programs static route without the interface name then in case if the ip interface that is associated with the nexthop goes down FRR resolves static route nexthop over the default route as we have FRR config ip nht-resolve-via-default which causes undesired behavior. Having interface name with Static Route prevents recursive lookup on default route.

How I verify:

Updated unit-test cases
Manual verification
  • Loading branch information
abdosi authored Jan 13, 2022
1 parent 945278f commit 649e6c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,11 @@ def parse_dpg(dpg, hname):
elif ":" in ipnhaddr:
port_nhipv6_map[ipnhfmbr] = ipnhaddr
elif ipnh.find(str(QName(ns, "Type"))).text == 'StaticRoute':
prefix = ipnh.find(str(QName(ns, "AttachTo"))).text
prefix = ipnh.find(str(QName(ns, "AssociatedTo"))).text
ifname = ipnh.find(str(QName(ns, "AttachTo"))).text
nexthop = ipnh.find(str(QName(ns, "Address"))).text
advertise = ipnh.find(str(QName(ns, "Advertise"))).text
static_routes[prefix] = {'nexthop': nexthop, 'advertise': advertise}
static_routes[prefix] = {'nexthop': nexthop, 'ifname': ifname, 'advertise': advertise}

if port_nhipv4_map and port_nhipv6_map:
subnet_check_ip = list(port_nhipv4_map.values())[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@
<IPNextHop>
<ElementType>IPNextHop</ElementType>
<Name i:nil="true"/>
<AttachTo>8.0.0.1/32</AttachTo>
<AssociatedTo>8.0.0.1/32</AssociatedTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AttachTo>PortChannel40,PortChannel50</AttachTo>
<Type>StaticRoute</Type>
<Advertise>false</Advertise>
</IPNextHop>
Expand Down Expand Up @@ -212,8 +213,9 @@
<IPNextHop>
<ElementType>IPNextHop</ElementType>
<Name i:nil="true"/>
<AttachTo>8.0.0.1/32</AttachTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AssociatedTo>8.0.0.1/32</AssociatedTo>
<Address>192.168.1.2,192.168.2.2</Address>
<AttachTo>PortChannel40,PortChannel50</AttachTo>
<Type>StaticRoute</Type>
<Advertise>false</Advertise>
</IPNextHop>
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,14 +904,14 @@ def test_minigraph_bgp_packet_chassis_static_route(self):
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'advertise':'false'}}")
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}")
)

argument = '-m "' + self.packet_chassis_graph + '" -p "' + self.packet_chassis_port_ini + '" -n "' + "asic1" + '" -v "STATIC_ROUTE"'
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'advertise':'false'}}")
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}")
)

def test_minigraph_bgp_packet_chassis_vlan_subintf(self):
Expand Down

0 comments on commit 649e6c7

Please sign in to comment.