#
# IP{{ proto }} Bird configuration (Salt managed)
#
{%- set node_config = salt['pillar.get']('nodes:' ~ grains['id'], {}) %}

define AS_OWN  = 65132;
define LO_IP = {{ salt['ffho_net.get_primary_ip'](node_config, proto).ip }};

router id {{ salt['ffho_net.get_router_id'](node_config, grains['id']) }};


# this pseudo-protocol watches all interface up/down events
protocol device {
	scan time 10;
};

# This pseudo-protocol performs synchronization between BIRD's routing
# tables and the kernel. If your kernel supports multiple routing tables
# (as Linux 2.2.x does), you can run multiple instances of the kernel
# protocol and synchronize different kernel tables with different BIRD tables.
protocol kernel {
	scan time 20;           # Scan kernel routing table every 20 seconds

	import none;
	export filter {
		# Do NOT export local unreachable routes for TE purposes
		if proto = "ffho_te" then
			reject;

		# Export routes with source address set to loopback IP
		krt_prefsrc = LO_IP;
		accept;
	};
}


#
# Load additiional configuration (IGP, FFRL, ICVPN, 'n stuff)
{%- if proto == "v4" %}
include "/etc/bird/ff-policy.conf";
include "/etc/bird/bird.d/*.conf";
{%- else %}
include "/etc/bird/ff-policy6.conf";
include "/etc/bird/bird6.d/*.conf";
{%- endif %}