Hello everyone.
š
I'd like to share some (beta-quality) patches permitting to create BGP protocol instances dynamically, based on templates.
Main purpose is to get feedback and make them good enough to be integrated into main tree.
š
Similar feature was implemented by major vendors yeas ago.
Juniper:
http://www.juniper.net/techpubs/en_US/junos11.4/topics/usage-guidelines/routing-configuring-bgp-groups-and-peers.html
Cisco IOS:šhttp://www.cisco.com/c/en/us/td/docs/ios/12_2sr/12_2srb/feature/guide/tbgp_c/brbpeer.html#wp1128937
š
Typically it is used in peering setups.
š
Patches still have some rough edges (see below) but should work^Wnot make bird crash every 5 minutes.
š
Example setup:
š
# Set up template with ALL info except and IP address
# In this case we don't have any option to specify interface, so it is specified in
# neighbor part
template bgp bgg {
š š š š debug all;
š š š š local as 4444;
š š š š neighbor fe80::1%em0 as 4443;
š š š š import all;
š š š š export all;
};
š
# Set up dynamic template with ranges and neighbor mask
# Accepted format (%) values:
# 1..4 - octets in IPv4 address
# 1..8 - hex groups in IPv6 address
# I - full addressš
# format values can be specified more than once in format string
# e.g. "b_x_%4_%I_%4"
dynamic template bgp bgp_int from bgg {
š š š š dynamic template name "b_s%4-%8-%8";
š š š š dynamic allow fe80::f000/112, fe80::f00/116;
};
š
# You need to have at least one "normal" bgp peer to get listen socket opened
# That's all
š
# Example from working system:
# š using šseveral { dynamic template name "b_Vrf1_s%8";šdynamic allow fe80::/64; }
# štemplates
š
bird> show protocols
name š š proto š štable š šstate šsince š š š info
direct1 šDirect š master š up š š 22:06:05
kernel1 šKernel š master š up š š 22:06:05
device1 šDevice š master š up š š 22:06:05
ospf3 š šOSPF š š master š up š š 22:06:05 š šRunning
..
b_Vrf2_dc1_c1 BGP š š šVrf2 š š up š š 22:06:06 š šEstablished
b_Vrf1_se48 BGP š š šVrf1 š up š š 22:06:05 š šEstablished
b_Vrf1_se10 BGP š š šVrf1 š up š š 22:06:06 š šEstablished
b_Vrf1_se45 BGP š š šVrf1 š up š š 22:06:06 š šEstablished
b_Vrf1_se60 BGP š š šVrf1 š up š š 22:06:07 š šEstablished
b_Vrf2_se91 BGP š š šVrf2 š š up š š 22:06:08 š šEstablished
..
š
Comments on individual patches:
0001 is basic LPM for the f_trie šand is part of aggregator patch
0002 decouples get-proto-from-address function from incoming connection handling. This makes hacking here much simpler (for example, implementing IP hash lookup)
0003 just movesšSYM_MAX_LEN definition to header
0004 moves sizeof(XXX_proto) info inside protocol structure permitting anyone to call proto_config_init() without knowing details
0005 tries to isolate/limit global new_config/cfg_mem variables usage to absolute minimum. Despite the fact that actual BGP patch does not require much more than config_start_edit() / config_stop_edit() implementation, I (after hours of debugging cores) decided to make things more transparent here.
0006 is the actual patch.
Basically, it
* adds SYM_TEMPLATE class
* adds dyn_parent proto_config field to specify parent template
* adds condition-check and copy-dynamic protocol callbacks
* adds runtime config/protocol creation functions to nest
* adds bgp-specific structure to struct config allocated on demandš
š
Rough edges:
* non-optimized case for IPv6 LL prefixes
* non-optimized peer lookup for existing sessions
* dynamic expire not implemented (next version)
* no docs (next version)
* some bugs, definitely