Packet looping between two routers


#1

I have requirement of following topoligy and that is causing packet looping.
n1----A------B–C--n2.
There is tunnel between two vyos instances A and B and they are exchanges routes using BGP. C is also a vyos instance that is working as a normal router. Now default gateway for B is address of C and I am manually adding static routes in C for all the cidrs that is learned through bgp in B with next hop as B(That is next of for cidr n1 in C is B).
For example:
A will distribute network n1 via BGP.
I am adding static route for n1 with next hop is B in router C.
I am adding static route for n2 with next hop is C in B so that it can distribute it to A.
Now n1 and n2 is connected.

The problem is when vti goes down or bgp is down static routes will still be there. In that case when n2 sends packets to n1 via C, C will send it to B because of static route and since vti is down and bgp is down instead of sending that packet to vti it will send it to default gateway which is C and again C will send it to B and this way packet will continue looping till TTL expires. Is there a way I can prevent this looping ?