log syslog all;
router id ${node.metadata.get('bird/my_ip')};
debug protocols all;

ipv4 table master4;

protocol device {
}

protocol kernel {
    scan time 30;
    ipv4 {
        export where source != RTS_STATIC;
    };
}
% if node.metadata.get('bird/static_routes', set()):

protocol static {
    ipv4;

% for route in sorted(node.metadata.get('bird/static_routes', set())):
%  for name, config in sorted(node.metadata.get('bird/bgp_neighbors', {}).items()):
    route ${route} via ${config['local_ip']};
%  endfor
% endfor
}
% endif
% for name, config in sorted(node.metadata.get('bird/bgp_neighbors', {}).items()):

protocol bgp '${name}' {
    local ${config['local_ip']} as ${config['local_as']};
    neighbor ${config['neighbor_ip']} as ${config['neighbor_as']};
    hold time ${config.get('hold_time', 15)};
    error wait time 5, 10;
    direct;

    ipv4 {
        next hop self;
        import all;
        export all;
    };
}
% endfor