summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_ns.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* all: remove logical-router functionalityIgor Ryzhov2019-08-021-19/+0
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* zebra: move rtadv service from zrouter to zvrfPhilippe Guibert2019-06-041-8/+0
| | | | | | | | | when network namespace is used as vrf backend, there is need to have separate contexts for rtadv contexts. route advertisements have to look for appropriate interface based on zvrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* Revert "zebra: move rtadv service from zrouter to zvrf"Donald Sharp2019-05-161-0/+8
| | | | This reverts commit f20e2a09c8aef399698fa074b36f24becdf49cbb.
* zebra: move rtadv service from zrouter to zvrfPhilippe Guibert2019-04-251-8/+0
| | | | | | | | | when network namespace is used as vrf backend, there is need to have separate contexts for rtadv contexts. route advertisements have to look for appropriate interface based on zvrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: start the netns notification mechanism after ns initialisationPhilippe Guibert2019-01-091-1/+5
| | | | | | | | | | | | | when zebra is run, by using vrf netns backend mode, then the parser detector of netns is run before forcing the default vrf to a possible value. In that case, there is a possibility that the forced '-o' option will create a second vrf with same name, whereas this option should be there to uniquely have a default vrf with a value. To make things consistent, the forced value will be priorised. Then, the notifier will attempt to create vrf contexts. The expectation is that the creation will fail, due to an already present vrf with same name. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: update local ns_id fieldPhilippe Guibert2019-01-081-0/+1
| | | | | | ns_id field must be synced with ns_id from netns service. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: avoid initialising more than one the l3vni hash structurePhilippe Guibert2018-12-171-3/+0
| | | | | | | | | the l3vni structure is allocated only once, since that structure is only used for default netns. For that, move the initialisation part is moved to a proper place, where there is no risk of attempting to initialise it more than once, even when vrf backend is netns. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: separate netlink socket for dataplaneMark Stapp2018-11-211-5/+34
| | | | | | | | | | Use a separate netlink socket for the dataplane's updates, to avoid races between the dataplane pthread and the zebra main pthread. Revise zebra shutdown so that the dataplane netlink socket is cleaned-up later, after all shutdown-time dataplane work has been done. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: Move ipset_hash, ipset_entry_hash and iptable_hash into zrouterDonald Sharp2018-10-241-23/+0
| | | | | | | These three data structures belong in the `zebra_router` structure as that they do not belong in `struct zebra_ns`. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Move rules_hash to zrouterDonald Sharp2018-10-241-7/+3
| | | | | | | | | | Move the rules_hash to the zrouter data structure and provide the additional bit of work needed to lookup the rule based upon the namespace id as well. Make the callers of functions not care about what namespace id we are in. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Start breakup of zns into zrouter and znsDonald Sharp2018-10-241-123/+0
| | | | | | | | | | | | | | | | | | | | | | The `struct zebra_ns` data structure is being used for both router information as well as support for the vrf backend( as appropriate ). This is a confusing state. Start the movement of `struct zebra_ns` into 2 things `struct zebra_router` and `struct zebra_ns`. In this new regime `struct zebra_router` is purely for handling data about the router. It has no knowledge of the underlying representation of the Data Plane. `struct zebra_ns` becomes a linux specific bit of code that allows us to handle the vrf backend and is allowed to have knowledge about underlying data plane constructs. When someone implements a *bsd backend the zebra_vrf data structure will need to be abstracted to take advantage of this instead of relying on zebra_ns. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd, lib, zebra: Wrapper get/set of table->info pointerDonald Sharp2018-09-241-2/+2
| | | | | | | Wrapper the get/set of the table->info pointer so that people are not directly accessing this data. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd isisd zebra: misuse of comma operatorF. Aragon2018-09-141-2/+1
| | | | | | Detected using ./configure CFLAGS=-Wcomma CC=clang Signed-off-by: F. Aragon <paco@voltanet.io>
* zebra: fix includesQuentin Young2018-09-061-1/+0
| | | | | | Add and remove error related includes as necessary. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: use frr_elevate_privs() (1/2: coccinelle)David Lamparter2018-08-141-5/+3
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* *: rename zlog_fer -> flog_errQuentin Young2018-08-141-2/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* bgpd, lib, zebra: Convert LIB_ERR_PRIVILEGESDonald Sharp2018-08-141-2/+3
| | | | | | | For all the places we zlog_err about raising/lowering privileges, use zlog_ferr. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: ns_table list is extended to support multiple NETNSPhilippe Guibert2018-06-011-11/+24
| | | | | | | In the case where vrf backend is netns, then the list of ns tables may be extended. A single list is kept,but an attribute is added: the ns_id. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: rework pbr ipset entryPhilippe Guibert2018-05-251-2/+2
| | | | | | | | Add ns_id into zebra_pbr ipset This is important so that each ipset entry knows on which NETNS the ipset entry must be inkected Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: add IPTABLE_ADD and IPTABLE_DEL commands in zapiPhilippe Guibert2018-04-161-0/+9
| | | | | | | | | | | Those messages permit a remote daemon to configure an iptable entry. A structure is defined that maps to an iptable entry. More specifically, this structure proposes to associate fwmark, and a table ID. Adding to the configuration, the initialisation of iptables hash list is done into zebra netnamespace. Also a hook for notifying the sender that the iptables has been correctly set is done. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: handle entry pointfs for ipset creation/destructionPhilippe Guibert2018-04-161-0/+14
| | | | | | | | IPset and IPset entries structures are introduced. Those entries reflect the ipset structures and ipset hash sets that will be created on the kernel. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: add an indirection table for ns_idPhilippe Guibert2018-04-131-3/+4
| | | | | | | | | | 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>
* zebra: add the handling of table ids from remote daemonsPhilippe Guibert2018-03-291-0/+6
| | | | | | | | | This commit is connecting the table manager with remote daemons by handling the queries. As the function is similar in many points with label allocator, a function has been renamed. 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>
* zebra: move hash rules creation to the vrf_enable placePhilippe Guibert2018-03-231-3/+4
| | | | | | | The vrf netns usage makes a crash, when deleting vrf, due to the hash list of rules not initialised for non default VRF. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: Read in on startup arbitrary tablesDonald Sharp2018-03-161-0/+11
| | | | | | | | | | | | | | | When we receive an arbitrary table over the netlink bus save it for later perusal and sweep any routes that we may have created from an earlier run. The current redistribute code is limited to ZEBRA_KERNEL_TABLE_MAX. I left this alone for the moment because I believe it needs to be converted to a RB tree instead of a flat array. Which is more work for the future. Additionally this proposed change might necessitate some cli changes or rethinks. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Upon client disconnect remove routes from all tablesDonald Sharp2018-03-161-0/+15
| | | | | | | | It is possible for clients to install routes into tables that they desire. Modify the code to delete these routes from these tables as well. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Keep track of rules writtenDonald Sharp2018-03-091-0/+7
| | | | | | | | Keep track of rules written into the kernel. This will allow us to delete them on shutdown if we are not cleaned up properly. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-10/+8
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* zebra: adapt the vrf and logical router initialisationPhilippe Guibert2018-02-271-3/+22
| | | | | | | | The zebra daemon introduces the logical router initialisation. Because right now, the usage of logical router and vrf NETNS is exclusive, then the logical router and VRF are initialised accordingly. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: upon startup, a NSID is assigned to default netnsPhilippe Guibert2018-02-271-1/+11
| | | | | | | | | | | | | | | | | | 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>
* zebra: collect and get netnamespaces informationPhilippe Guibert2018-02-271-0/+3
| | | | | | | | | | | | | | upon zebra initialisation, and upon further netnamespace creation, the the netnamespaces are created and a vrf associated to the netnamespace is created. By convention, the name of the netns will be the same as the VRF. Add a stub routine that returns a fake ns identifier, in case netlink ( linux machines) is not available. Also, upon each newly discovered NETNS, a NSID id being generated, either by relying on kernel NSID feature, or by generating locally the NSID ( see previous commit for more information). Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra: handle the zns init/destroyPhilippe Guibert2018-02-271-2/+15
| | | | | | | | 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-1/+62
| | | | | | | | | | | 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>
* zebra: copy logical-router-command under vrf subnodePhilippe Guibert2018-02-271-0/+8
| | | | | | | | | | | | | | | | | | | 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>
* zebra: Fix up some code formatting issues.Donald Sharp2018-02-231-2/+3
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Fix warning found in CI systemDonald Sharp2018-02-231-3/+2
| | | | | | | | | | The Clang SA system found a new issue: Dead store: Dead assignment. This fixes that issue Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: Make assignment from RB_ROOT in while loop work betterDonald Sharp2018-02-231-5/+6
| | | | | | | Fix up the assignment of the variable = RB_ROOT inside of while loop patter we were using. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Add code to display interesting tablesDonald Sharp2018-02-231-0/+17
| | | | | | | | With the ability of zebra to handle random tables, add code to display those tables via the show <ip|ipv6> route table (1-...) [json] command. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Move zvrf->other_tables into znsDonald Sharp2018-02-231-0/+69
| | | | | | | | | | | | The other_tables data structure does not belong to a vrf. It belongs to the zns. This is because each vrf does not need to have copies of each of other_tables. Additionally move the array into a RB_TREE. This will allow us to sort quickly and easily expand the number of tables we can support to beyond the ZEBRA_KERNEL_TABLE_MAX define. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: Handle VRF configuration when VRF gets inactivated and activatedvivek2018-01-241-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A VRF is active only when the corresponding VRF device is present in the kernel. However, when the kernel VRF device is removed, the VRF container in FRR should go away only if there is no user configuration for it. Otherwise, when the VRF device is created again so that the VRF becomes active, FRR cannot take the correct actions. Example configuration for the VRF includes static routes and EVPN L3 VNI. Note that a VRF is currently considered to be "configured" as soon as the operator has issued the "vrf <name>" command in FRR. Such a configured VRF is not deleted upon VRF device removal, it is only made inactive. A VRF that is "configured" can be deleted only upon operator action and only if the VRF has been deactivated i.e., the VRF device removed from the kernel. This is an existing restriction. To implement this change, the VRF disable and delete actions have been modified. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Mitesh Kanjariya <mkanjariya@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Ticket: CM-18553, CM-18918, CM-10139 Reviewed By: CCR-7022 Testing Done: 1. vrf and pim-vrf automation tests 2. Multiple VRF delete and readd (ifdown, ifup-with-depends) 3. FRR stop, start, restart 4. Networking restart 5. Configuration delete and readd Some of the above tests run in different sequences (manually).
* zebra: replace 0 value on zebra with NS_DEFAULTPhilippe Guibert2018-01-221-1/+1
| | | | | | | On some places, macro NS_DEFAULT was not used. This commit is replacind on some identified places where 0 can be replaced with NS_DEFAULT macro. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* zebra, lib: zebra changes for symmetric routing supportMitesh Kanjariya2017-12-141-0/+3
| | | | Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* zebra: Make zserv.h the true api for zapi northboundDonald Sharp2017-12-131-0/+1
| | | | | | | | zserv.c had a grab bag of function declarations that did not belong in it. Move those to where they better belong. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: static nsVincent JARDIN2017-09-261-1/+1
| | | | it only for local usage, only accessors are used.
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-29/+25
| | | | | | 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>
* zebra/lib: move some code aroundRenato Westphal2016-11-281-10/+0
| | | | | | | | * 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>
* zebra/lib: plug several memleaksRenato Westphal2016-11-281-8/+5
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter2016-09-191-0/+4
| | | | | | | | | | | | | | | | | | | This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [CF: rebased for cmaster-next] Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org>