[PATCH] Dynamic BGP templates

Alexander V. Chernikov melifaro at ipfw.ru
Sun Feb 15 11:44:29 CET 2015


New version.
Changelog:
* Split nest API and bgp implementation
* Simplify new nest code a bit
* Fix crash on CLI lookups (forgot to fill in sym->def) 
* Remove protocols on dynamic templates renaming
* Permit deleting dynamic instances via removal of disabled protos on reconfigure
* Do not create new dynamic protocols on shutdown
* Permit using table names (%T) in templates
* Allow to inherit allow list from common templates (handy in link-local setups)


12.02.2015, 03:48, "Alexander V. Chernikov" <melifaro at ipfw.ru>:
> I'm sorry, previous posting was in html, duplicating as plain-text
>
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-LPM-support-for-trie.patch
Type: text/x-diff
Size: 7469 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Make-BGP-protocol-instance-search-separate-function.patch
Type: text/x-diff
Size: 4614 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Move-SYM_MAX_LEN-definition-to-conf.h.patch
Type: text/x-diff
Size: 945 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Store-protocol-instance-size-inside-protocol-structu.patch
Type: text/x-diff
Size: 10761 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment-0003.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Limit-scope-of-new_config-and-cfg_mem-variables.patch
Type: text/x-diff
Size: 30383 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment-0004.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Pass-struct-config-to-cfg_copy_list-to-specify-where.patch
Type: text/x-diff
Size: 3110 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment-0005.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-Add-api-for-dynamic-protocol-creation-based-on-dynam.patch
Type: text/x-diff
Size: 9046 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment-0006.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-Implement-dynamic-BGP-protocols-creation-based-on-in.patch
Type: text/x-diff
Size: 15437 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20150215/bbc89b0b/attachment-0007.patch>


More information about the Bird-users mailing list