summaryrefslogtreecommitdiffstats
path: root/lib/ns.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* vrf: VRF_DEFAULT must be 0, remove useless codeChristophe Gouault2020-09-211-4/+1
| | | | | | | | | | Code was added in the past to support a value of VRF_DEFAULT different from 0. This option was abandoned, the default vrf id is always 0. Remove this code, this will simplify the code and improve performance (use a constant value instead of a function that performs tests). Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
* lib, zebra: reuse and adapt ns_list walk functionalityPhilippe Guibert2020-09-111-3/+8
| | | | | | | | | the walk routine is used by vxlan service to identify some contexts in each specific network namespace, when vrf netns backend is used. that walk mechanism is extended with some additional paramters to the walk routine. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra, lib: new API to get absolute netns val from relative netns valPhilippe Guibert2020-08-181-0/+1
| | | | | | | | | | | | | when receiving a netlink API for an interface in a namespace, this interface may come with LINK_NSID value, which means that the interface has its link in an other namespace. Unfortunately, the link_nsid value is self to that namespace, and there is a need to know what is its associated nsid value from the default namespace point of view. The information collected previously on each namespace, can then be compared with that value to check if the link belongs to the default namespace or not. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra, lib: store relative default ns id in each namespacePhilippe Guibert2020-08-181-0/+5
| | | | | | | | to be able to retrieve the network namespace identifier for each namespace, the ns id is stored in each ns context. For default namespace, the netns id is the same as that value. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra, lib: add an internal API to get relative default nsid in other nsPhilippe Guibert2020-08-181-0/+1
| | | | | | | | | | | | | | | | | | | as remind, the netns identifiers are local to a namespace. that is to say that for instance, a vrf <vrfx> will have a netns id value in one netns, and have an other netns id value in one other netns. There is a need for zebra daemon to collect some cross information, like the LINK_NETNSID information from interfaces having link layer in an other network namespace. For that, it is needed to have a global overview instead of a relative overview per namespace. The first brick of this change is an API that sticks to netlink API, that uses NETNSA_TARGET_NSID. from a given vrf vrfX, and a new vrf created vrfY, the API returns the value of nsID from vrfX, inside the new vrf vrfY. The brick also gets the ns id value of default namespace in each other namespace. An additional value in ns.h is offered, that permits to retrieve the default namespace context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: importation of bgp evpn rt5 from vni with other netnsPhilippe Guibert2020-08-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | With vrf-lite mechanisms, it is possible to create layer 3 vnis by creating a bridge interface in default vr, by creating a vxlan interface that is attached to that bridge interface, then by moving the vxlan interface to the wished vrf. With vrf-netns mechanism, it is slightly different since bridged interfaces can not be separated in different network namespaces. To make it work, the setup consists in : - creating a vxlan interface on default vrf. - move the vxlan interface to the wished vrf ( with an other netns) - create a bridge interface in the wished vrf - attach the vxlan interface to that bridged interface from that point, if BGP is enabled to advertise vnis in default vrf, then vxlan interfaces are discovered appropriately in other vrfs, provided that the link interface still resides in the vrf where l2vpn is advertised. to import ipv4 entries from a separate vrf, into the l2vpn, the configuration of vni in the dedicated vrf + the advertisement of ipv4 entries in bgp vrf will import the entries in the bgp l2vpn. the modification consists in parsing the vxlan interfaces in all network namespaces, where the link resides in the same network namespace as the bgp core instance where bgp l2vpn is enabled. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* evpn-netns: Revert PR5077, has been re-worked post-refactorPat Ruddy2020-08-051-15/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revert "zebra: support for macvlan interfaces" This reverts commit bf69e212fd053af3298fc3cba38458b396467849. Revert "doc: add some documentation about bgp evpn netns support" This reverts commit 89b97c33d7a6d9dc427d56fea52fa27334dde81d. Revert "zebra: dynamically detect vxlan link interfaces in other netns" This reverts commit de0ebb25404fe984f084a0d57b7f873618423876. Revert "bgpd: sanity check when updating nexthop from bgp to zebra" This reverts commit ee9633ed87f0ff5da1373a42d6c044f0a682c8d3. Revert "lib, zebra: reuse and adapt ns_list walk functionality" This reverts commit c4d466c830083e8ba58881d7ad03a90f6baf0754. Revert "zebra: local mac entries populated in correct netnamespace" This reverts commit 40424548910887f3bbbf544ce964d3b736048ae5. Revert "zebra: when parsing local entry against dad, retrieve config" This reverts commit 3acc394bc5e5c225e9258fd0d57a6cebea0c0ccd. Revert "bgpd: evpn nexthop can be changed by default" This reverts commit a2342a241253c41b798845cae155b4caab4bcda5. Revert "zebra: zvni_map_to_vlan() adaptation for all namespaces" This reverts commit db81d18647bbd81a2c335620c9a03e32e4a5b2be. Revert "zebra: add ns_id attribute to mac structure" This reverts commit 388d5b438e22cddc6740e362763c0922edbb242a. Revert "zebra: bridge layer2 information records ns_id where bridge is" This reverts commit b5b453a2d6af58692bee0e256fe1dffe99824801. Revert "zebra, lib: new API to get absolute netns val from relative netns val" This reverts commit b6ebab34f664ba1cc9479fc1287f127c12077509. Revert "zebra, lib: store relative default ns id in each namespace" This reverts commit 9d3555e06ccc68fe37e0a00100029ac4bad8dee2. Revert "zebra, lib: add an internal API to get relative default nsid in other ns" This reverts commit 97c9e7533bd22029ac19838c043cfca82d2f6eb3. Revert "zebra: map vxlan interface to bridge interface with correct ns id" This reverts commit 7c990878f20efff335c1211deda3ec50071ae2b5. Revert "zebra: fdb and neighbor table are read for all zns" This reverts commit f8ed2c5420106314a940cb67264494e0110fc4c0. Revert "zebra: zvni_map_to_svi() adaptation for other network namespaces" This reverts commit 2a9dccb6475bfc11af2b855c4c8ff9e500ba21f4. Revert "zebra: display interface slave type" This reverts commit fc3141393ad95651d31fccd144b5c029d00e5f3a. Revert "zebra: zvni_from_svi() adaptation for other network namespaces" This reverts commit 6fe516bd4b85569b3b8b4bcc2910afc5569aa026. Revert "zebra: importation of bgp evpn rt5 from vni with other netns" This reverts commit 28254125d06f65cc4344b6156eec76a37ec6aede. Revert "lib, zebra: update interface name at netlink creation" This reverts commit 1f7a68a2ff0ba1424131f30112e0cc1572f0bee3. Signed-off-by: Pat Ruddy <pat@voltanet.io>
* lib, zebra: reuse and adapt ns_list walk functionalityPhilippe Guibert2020-05-181-3/+8
| | | | | | | | | the walk routine is used by vxlan service to identify some contexts in each specific network namespace, when vrf netns backend is used. that walk mechanism is extended with some additional paramters to the walk routine. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra, lib: new API to get absolute netns val from relative netns valPhilippe Guibert2020-05-181-0/+1
| | | | | | | | | | | | | when receiving a netlink API for an interface in a namespace, this interface may come with LINK_NSID value, which means that the interface has its link in an other namespace. Unfortunately, the link_nsid value is self to that namespace, and there is a need to know what is its associated nsid value from the default namespace point of view. The information collected previously on each namespace, can then be compared with that value to check if the link belongs to the default namespace or not. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra, lib: store relative default ns id in each namespacePhilippe Guibert2020-05-181-0/+5
| | | | | | | | to be able to retrieve the network namespace identifier for each namespace, the ns id is stored in each ns context. For default namespace, the netns id is the same as that value. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra, lib: add an internal API to get relative default nsid in other nsPhilippe Guibert2020-05-181-0/+1
| | | | | | | | | | | | | | | | | | | as remind, the netns identifiers are local to a namespace. that is to say that for instance, a vrf <vrfx> will have a netns id value in one netns, and have an other netns id value in one other netns. There is a need for zebra daemon to collect some cross information, like the LINK_NETNSID information from interfaces having link layer in an other network namespace. For that, it is needed to have a global overview instead of a relative overview per namespace. The first brick of this change is an API that sticks to netlink API, that uses NETNSA_TARGET_NSID. from a given vrf vrfX, and a new vrf created vrfY, the API returns the value of nsID from vrfX, inside the new vrf vrfY. The brick also gets the ns id value of default namespace in each other namespace. An additional value in ns.h is offered, that permits to retrieve the default namespace context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: importation of bgp evpn rt5 from vni with other netnsPhilippe Guibert2020-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | With vrf-lite mechanisms, it is possible to create layer 3 vnis by creating a bridge interface in default vr, by creating a vxlan interface that is attached to that bridge interface, then by moving the vxlan interface to the wished vrf. With vrf-netns mechanism, it is slightly different since bridged interfaces can not be separated in different network namespaces. To make it work, the setup consists in : - creating a vxlan interface on default vrf. - move the vxlan interface to the wished vrf ( with an other netns) - create a bridge interface in the wished vrf - attach the vxlan interface to that bridged interface from that point, if BGP is enabled to advertise vnis in default vrf, then vxlan interfaces are discovered appropriately in other vrfs, provided that the link interface still resides in the vrf where l2vpn is advertised. to import ipv4 entries from a separate vrf, into the l2vpn, the configuration of vni in the dedicated vrf + the advertisement of ipv4 entries in bgp vrf will import the entries in the bgp l2vpn. the modification consists in parsing the vxlan interfaces in all network namespaces, where the link resides in the same network namespace as the bgp core instance where bgp l2vpn is enabled. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* lib: make some variables staticDavid Lamparter2019-12-131-2/+0
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* all: remove logical-router functionalityIgor Ryzhov2019-08-021-6/+6
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* lib: add extern "C" {} blocks to all libfrr headersRenato Westphal2019-02-121-0/+8
| | | | | | | These are necessary to use functions defined in these headers from C++. Signed-off-by: David Lamparter <equinox@diac24.net> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: rename parameter for netns functionPhilippe Guibert2018-04-131-1/+1
| | | | Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: add an indirection table for ns_idPhilippe Guibert2018-04-131-1/+9
| | | | | | | | | | This list "table" is created in the case the netns backend for VRF is used. This contains the mapping between the NSID value read from the 'ip netns list' and the ns id external used to create the VRF value from vrf context. This mapping is necessary in order to reserve default 0 value for vrf_default. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: split logicalrouter and vrf netns featurePhilippe Guibert2018-02-271-13/+62
| | | | | | | | | | | | | | | | | | | | | | | | This split is introducing logicalrouter.[ch] as the file that contains the vty commands to configure logical router feature. The split has as consequence that the backend of logical router is linux_netns.c formerly called ns.c. The same relationship exists between VRF and its backend which may be linux_netns.c file. The split is adapting ns and vrf fiels so as to : - clarify header - ensure that the daemon persepctive, the feature VRF or logical router is called instead of calling directly ns. - this implies that VRF will call NS apis, as logical router does. Also, like it is done for default NS and default VRF, the associated VRF is enabled first, before NETNS is enabled, so that zvrf->zns pointer is valid when NETNS discovery applies. Also, other_netns.c file is a stub handler that will be used for non linux systems. As NETNS feature is only used by Linux, some BSD systems may want to use the same backend API to benefit from NETNS. This is what that file has been done. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: upon startup, a NSID is assigned to default netnsPhilippe Guibert2018-02-271-2/+12
| | | | | | | | | | | | | | | | | | when the netns backend is selected for VRF, the default VRF is being assigned a NSID. This avoids the need to handle the case where if the incoming NSID was 0 for a non default VRF, then a specific handling had to be done to keep 0 value for default VRF. In most cases, as the first NETNS to get a NSID will be the default VRF, most probably the default VRF will be assigned to 0, while the other ones will have their value incremented. On some cases, where the NSID is already assigned for NETNS, including default VRF, then the default VRF value will be the one derived from the NSID of default VRF, thus keeping consistency between VRF IDs and NETNS IDs. Default NS is attempted to be created. Actually, some VMs may have the netns feature, but the NS initialisation fails because that folder is not present. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* lib: provide an API to switch from one netns to an otherPhilippe Guibert2018-02-271-0/+6
| | | | | | | | | Two apis are provided so that the switch from one netns to an other one is taken care. Also an other API to know if the VRF has a NETNS backend or a VRF Lite backend. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: enhance show vrf for netns and fixingPhilippe Guibert2018-02-271-0/+1
| | | | | | | | | | | Show vrf command displays information on the vrf, if it is related to vrf kernel or if it is related to netns. When a vrf from kernel is detected, before creating a new vrf, a check is done against an already present vrf, and if that vrf is not a vrf mapped with a netns. If that is that case, then the creation is rejected. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: handle the zns init/destroyPhilippe Guibert2018-02-271-0/+2
| | | | | | | | The zebra netnamespace contexts are initialised, based on the callback coming from the NS. Reversely, the list of ns is parsed to disable the ns contexts. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: add the registration mechanism for netnsPhilippe Guibert2018-02-271-3/+2
| | | | | | | | | | | If vrf backend is netns, then the zebra will create its own zebra_ns context for each new netns discovered. As consequence, a routing table, and other contexts will be created for each new namespace discovered. When it is enabled, a populate process will be done, consisting in learning new interfaces and routes, and addresses from other NETNS. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* lib: externalise vrf and ns creationPhilippe Guibert2018-02-271-0/+5
| | | | | | | | | | | | | | | | In addition to have the possibility to create from vty vrf based on a netns backend, the API will be made accessible from external, especially for zebra that will handle the netns discovery part. This commit is externalising following functions: - netns_pathname - ns_handler_create - vrf_handler_create Also, the VRF initialisation case when under NETNS backend is changed, since the NS identifier may not be known at the configuration time,but may be known later, under discovery process. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: copy logical-router-command under vrf subnodePhilippe Guibert2018-02-271-0/+4
| | | | | | | | | | | | | | | | | | | a vty command is added: in addition to this command ( kept for future usage): - [no] logical-router-id <ID> netns <NETNSNAME> a new command is being placed under vrf subnode - vrf <NAME> [no] netns <NETNSNAME> exit This command permits to map a VRF with a Netnamespace. The commit only handles the relationship between vrf and ns structures. It adds 2 attributes to vrf structure: - one defines the kind of vrf ( mapped under netns or vrf from kernel) - the other is the opaque pointer to ns The show running-config is handled by zebra daemon. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* lib: ns_id_t changed to 32 bitPhilippe Guibert2018-01-221-2/+3
| | | | | | | | | | | Because the VRF_ID is mapped into 32 bit, and because when NETNS will be the backend of VRF, then the NS identifier must also be encoded as 32 bit. Also, the NS_UNKNOWN value is changed accordingly to UINT32_MAX. Also, the NS_UNKNOWN and NS_DEFAULT values are removed from zebra_ns.h and kept on ns.h header file. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-20/+18
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: convert namespace code to use red-black treesRenato Westphal2016-11-281-0/+9
| | | | | | | | We definitely need to stop abusing the route table data structure when it's not necessary. Convert the namespace code to use red-black trees instead. This greatly improves code readability. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* zebra/lib: move some code aroundRenato Westphal2016-11-281-0/+16
| | | | | | | | * move netlink code from zebra_nc.c to kernel_netlink.c; * move vrf CLI commands from if.c/interface.c to vrf.c/zebra_vrf.c; * move declaration of the 'ns' structure to a header file. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: remove unused ns codeRenato Westphal2016-11-281-73/+1
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib, vtysh: support multiple VRFs by using linux netnsFeng Lu2016-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | We realize VRFs with linux netns by default. The main job is to associate a VRF with a netns. Currently this is done by the configuration: [no] vrf N netns <netns-name> This command is also available in vtysh and goes to only zebra, because presently only zebra supports multiple VRF. A file descriptor is added to "struct vrf". This is for the associated netns file. Once the command "vrf N netns NAME" is executed, the specified file is opened and the file descriptor is stored in the VRF N. In this way the association is formed. In vrf_socket(), we first switch to the specified VRF by using the stored file descriptor, and then can allocate a socket which is working in the associated netns. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> (cherry picked from commit 55cfa2f190620f7c711944637659bc208970324d)
* lib: Create ns.cDonald Sharp2016-09-091-0/+142
Create the ns.c files from the original vrf.c code to allow us to create the 'logical-router' command to work within namespaces. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>