summaryrefslogtreecommitdiff
path: root/lib/if.c
AgeCommit message (Collapse)Author
2019-11-30lib: gcc 4.x workaround v2 for frr_interface_infoDavid Lamparter
The previous workaround only works for -O0, at higher optimization levels gcc reorders the statements in the file global scope which breaks the asm statement :(. Fixes: #4563 Fixes: #5074 Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-26lib: add gcc 4.x workaround for frr_interface_infoDavid Lamparter
gcc 4.x does not properly support structs with variable length array members. Specifically, for global variables, it completely ignores the array, coming up with a size much smaller than what is correct. This is broken for both sizeof() as well as ELF object size. This breaks for frr_interface_info since this variable is in some cases copy relocated by the linker. (The linker does this to make the address of the variable a "constant" for the main program.) This copying uses the ELF object size, thereby copying only the non-array part of the struct. Breakage ensues... (This fix is a bit ugly, but it's limited to very old gcc, and it's better than changing the array to "nodes[1000]" and wasting memory...) Fixes: #4563 Fixes: #5074 Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-02lib, ospfd, zebra: Convert interface_delete to take double pointerDonald Sharp
When free'ing the interface pointer, set it to NULL. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-02*: Convert connected_free to a double pointerDonald Sharp
Set the connected pointer to set the pointer to NULL. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-02*: Convert prefix_free to double pointerDonald Sharp
Have the prefix_free code take a double pointer to free the data. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-29vrrpd: only count ipv4 addresses on check startGhasem Naddaf
Signed-off-by: Ghasem Naddaf <ghasem.naddaf@gmail.com>
2019-10-24lib: vrf lookup may be NULLDonald Sharp
The vrf lookup may be NULL, so let's protect against this. Found in coverity Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-09*: Cleanup interface creation apisStephen Worley
Cleanup the interface creation apis to make it more clear what they are doing. Make it explicit that the creation via name/ifindex will only add it to the appropriate list. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-09lib: Don't add/del from name tree if name isnt setStephen Worley
If the name has not been set yet (we were only passed the ifindex in some cases like with master/slave timings) then do not add/del it from the ifname rb tree on the vrf struct. Doing so causes duplicate entries on the tree and infinte loops can happen when iterating over it. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-09-30Merge pull request #5009 from donaldsharp/interface_deletionRuss White
lib, zebra: Allow for interface deletion when kernel event happens
2019-09-24*: fix missing VRF autocompletionsIgor Ryzhov
Current autocompletion works only for simple "vrf NAME" case. This commit expands it also for the following cases: - "nexthop-vrf NAME" in staticd - usage of $varname in many daemons All daemons are updated to use single varname "$vrf_name". Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-09-19lib: delete interface if you can in upper level protocolDonald Sharp
In an upper level protocol, delete the interface on notification about deletion. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Convert zapi->interface_delete to ifp callbackDonald Sharp
Convert the callback of the interface_delete to the new ifp callback. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Convert interface_down to interface down callbackDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Convert from ->interface_up to the interface callbackDonald Sharp
For all the places we have a zclient->interface_up convert them to use the interface ifp_up callback instead. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Switch all zclient->interface_add to interface create callbackDonald Sharp
Switch the zclient->interface_add functionality to have everyone use the interface create callback in lib/if.c Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19*: Add infrastructure to support zapi interface callbacksDonald Sharp
Start the conversion to allow zapi interface callbacks to be controlled like vrf creation/destruction/change callbacks. This will allow us to consolidate control into the interface.c instead of having each daemon read the stream and react accordingly. This will hopefully reduce a bunch of cut-n-paste stuff Create 4 new callback functions that will be controlled by lib/if.c create -> A upper level protocol receives an interface creation event The ifp is brand spanking newly created in the system. up -> A upper level protocol receives a interface up event This means the interface is up and ready to go. down -> A upper level protocol receives a interface down destroy -> A upper level protocol receives a destroy event This means to delete the pointers associated with it. At this point this is just boilerplate setup for future commits. There is no new functionality. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19lib, zebra: Allow for interface deletion when kernel event happensDonald Sharp
When zebra gets a callback from the kernel that an interface has actually been deleted *and* the end users has not configured the interface, then allow for deletion of the interface from zebra. This is especially important in a docker environment where containers and their veth interfaces are treated as ephermeal. FRR can quickly have an inordinate amount of interfaces sitting around that are not in the kernel and we have no way to clean them up either. My expectation is that this will cause a second order crashes in upper level protocols, but I am not sure how to catch these and fix them now ( suggestions welcome ). There are too many use patterns and order based events that I cannot know for certain that we are going to see any at all, until someone sees this problem as a crash :( I do not recommend that this be put in the current stabilization branch and allow this to soak in master for some time first. Testing: sharpd@donna ~/frr4> sudo ip link add vethdj type veth peer name vethjd sharpd@donna ~/frr4> sudo ip link add vethaa type veth peer name vethab sharpd@donna ~/frr4> sudo vtysh -c "show int brief" Interface Status VRF Addresses --------- ------ --- --------- dummy1 down default enp0s3 up default 10.0.2.15/24 enp0s8 up default 192.168.209.2/24 enp0s9 up default 192.168.210.2/24 enp0s10 up default 192.168.212.4/24 lo up default 10.22.89.38/32 vethaa down default vethab down default vethdj down default vethjd down default virbr0 up default 192.168.122.1/24 virbr0-nic down default sharpd@donna ~/frr4> sudo ip link set vethaa up sharpd@donna ~/frr4> sudo ip link set vethab up sharpd@donna ~/frr4> sudo ip link del vethdj sharpd@donna ~/frr4> sudo vtysh -c "show int brief" Interface Status VRF Addresses --------- ------ --- --------- dummy1 down default enp0s3 up default 10.0.2.15/24 enp0s8 up default 192.168.209.2/24 enp0s9 up default 192.168.210.2/24 enp0s10 up default 192.168.212.4/24 lo up default 10.22.89.38/32 vethaa up default vethab up default virbr0 up default 192.168.122.1/24 virbr0-nic down default sharpd@donna ~/frr4> sudo ip link del vethaa sharpd@donna ~/frr4> sudo vtysh -c "show int brief" Interface Status VRF Addresses --------- ------ --- --------- dummy1 down default enp0s3 up default 10.0.2.15/24 enp0s8 up default 192.168.209.2/24 enp0s9 up default 192.168.210.2/24 enp0s10 up default 192.168.212.4/24 lo up default 10.22.89.38/32 virbr0 up default 192.168.122.1/24 virbr0-nic down default sharpd@donna ~/frr4> sudo ip link add vethaa type veth peer name vethab sharpd@donna ~/frr4> sudo vtysh -c "show int brief" Interface Status VRF Addresses --------- ------ --- --------- dummy1 down default enp0s3 up default 10.0.2.15/24 enp0s8 up default 192.168.209.2/24 enp0s9 up default 192.168.210.2/24 enp0s10 up default 192.168.212.4/24 lo up default 10.22.89.38/32 vethaa down default vethab down default virbr0 up default 192.168.122.1/24 virbr0-nic down default sharpd@donna ~/frr4> sudo vtysh -c "show run" Building configuration... Current configuration: ! frr version 7.2-dev frr defaults datacenter hostname donna.cumulusnetworks.com log stdout no ipv6 forwarding ! ip route 192.168.3.0/24 192.168.209.1 ip route 192.168.4.0/24 blackhole ip route 192.168.5.0/24 192.168.209.1 ip route 192.168.6.0/24 192.168.209.1 ip route 192.168.7.0/24 99.99.99.99 nexthop-vrf EVA ip route 192.168.8.0/24 192.168.209.1 ip route 4.5.6.7/32 12.13.14.15 ! interface dummy1 ip address 12.13.14.15/32 ! interface vethaa description FROO ! line vty ! end sharpd@donna ~/frr4> sudo ip link del vethaa sharpd@donna ~/frr4> sudo vtysh -c "show int brief" Interface Status VRF Addresses --------- ------ --- --------- dummy1 down default enp0s3 up default 10.0.2.15/24 enp0s8 up default 192.168.209.2/24 enp0s9 up default 192.168.210.2/24 enp0s10 up default 192.168.212.4/24 lo up default 10.22.89.38/32 vethaa down default virbr0 up default 192.168.122.1/24 virbr0-nic down default sharpd@donna ~/frr4> sudo vtysh -c "show run" Building configuration... Current configuration: ! frr version 7.2-dev frr defaults datacenter hostname donna.cumulusnetworks.com log stdout no ipv6 forwarding ! ip route 192.168.3.0/24 192.168.209.1 ip route 192.168.4.0/24 blackhole ip route 192.168.5.0/24 192.168.209.1 ip route 192.168.6.0/24 192.168.209.1 ip route 192.168.7.0/24 99.99.99.99 nexthop-vrf EVA ip route 192.168.8.0/24 192.168.209.1 ip route 4.5.6.7/32 12.13.14.15 ! interface dummy1 ip address 12.13.14.15/32 ! interface vethaa description FROO ! line vty ! end Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-18lib: add oper data cbs for ifacesQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-09-18Revert "lib: introduce a read-write lock for northbound configurations"Renato Westphal
Adding a lock to protect the global running configuration doesn't help much since the FRR daemons are not prepared to process configuration changes in a pthread that is not the main one (a whole lot of new protections would be necessary to prevent race conditions). This means the lock added by commit 83981138 only adds more complexity for no benefit. Remove it now to simplify the code. All northbound clients, including the gRPC one, should either run in the main pthread or use synchronization primitives to process configuration transactions in the main pthread. This reverts commit 83981138fe8c1e0a40b8dede74eca65449dda5de.
2019-08-26Merge pull request #4880 from ddutt/masterDonald Sharp
lib: Make if_lookup_by_index understand if VRF is backed by netns or not
2019-08-26lib: Make if_lookup_by_index understand if VRF is backed by netns or notDinesh G Dutt
FRR has two implementations of VRF, one backed by netns and the other by the proper VRF implementation in the Linux kernel. In certain places, the code assumes that a VRF is netns and so lookups fail. One example of this is in IPv6 RA code. This causes functionality such as Unnumbered BGP to fail. To fix this, this patch makes if_lookup_by_index handle the behavior based on the backend, similar to if_get_by_index. For the two places in if.c that were calling if_lookup_by_index to be specific to the VRF, I renamed the existing code, if_lookup_by_ifindex and made it a static function that is never exposed or called by any routine outside of if.c. Signed-off-by: Dinesh G Dutt <5016467+ddutt@users.noreply.github.com>
2019-08-21lib: fix a couple more doc commentsRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-13zebra: Ensure master's ifname is known, even if slave comes up firstDinesh G Dutt
In if_netlink.c, when an interface structure, ifp, is first created, its possible for the master to come up after the slave interface does. This means, the slave interface has no way to display the master's ifname in show outputs. To fix this, we need to allow creation by ifindex instead of by ifname so that this issue is handled. Signed-off-by: Dinesh G Dutt<5016467+ddutt@users.noreply.github.com>
2019-06-23Revert "Ospf missing interface handling 2"Donald Sharp
2019-06-22Merge pull request #3775 from pguibert6WIND/ospf_missing_interface_handling_2Donald Sharp
Ospf missing interface handling 2
2019-06-21lib: use MTYPE_STATICDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-13*: fix northbound initializer warning on OpenBSDDavid Lamparter
For some reason, the compiler on OpenBSD on our CI boxes doesn't like struct initializers with ".a.b = x, .a.c = y", generating a warning about overwritten initializers... Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12*: change interface structure, from vrf_id to vrfPhilippe Guibert
Field vrf_id is replaced by the pointer of the struct vrf *. For that all other code referencing to (interface)->vrf_id is replaced. This work should not change the behaviour. It is just a continuation work toward having an interface API handling vrf pointer only. some new generic functions are created in vrf: vrf_to_id, vrf_to_name, a zebra function is also created: zvrf_info_lookup an ospf function is also created: ospf_lookup_by_vrf it is to be noted that now that interface has a vrf pointer, some more optimisations could be thought through all the rest of the code. as example, many structure store the vrf_id. those structures could get the exact vrf structure if inherited from an interface vrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12lib, bgpd, ospfd, pimd, zebra, rip, ripng, bfd: change ↵Philippe Guibert
if_update_to_new_vrf() api vrf_id parameter is replaced with struct vrf * parameter. It is needed to create vrf structure before entering in the fuction. an error is generated in case the vrf parameter is missing. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12zebra, ifp: on netlink discovery, anticipate the vrf creationPhilippe Guibert
there may be cases where the vrf is yet allocated from the vty, and the discovery process did not make the relationship between the vrf_id and the name of the vrf. For instance, by parsing an interface belonging to vrf-id X, it is not sure that vrf-id X and vrfname XX are talking about the same vrf. For that, lets allocate the vrf, and lets try to detect there is a duplicate case in vrf, so that the merge can be done without any impact for the user. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12zebra, lib: upon entering interface, create vrf contextPhilippe Guibert
the interface search is based on vrfs. As at startup, some interfaces may be configured, there is need to have vrfs contexts present. A macro is being appended with an extra parameter that permits create a vrf and return the context. This macro is also used by some show routines, but will not create vrfs, because that extra parameter will be set to false, on that case. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12lib: create interface upon accessing interface NB API.Philippe Guibert
Upon accessing interface NB API, the interface is created, if the vrf is available. the commit does not change the behaviour, since at this commit, this is not yet possible to have vrf contexts, while zebra did not connect to daemons. However, that commit adds some work, so that it will be possible to work on a vrf context, without having the vrf_id completely resolved. for instance, if we suppose a vrf is created by command 'vrf TOTO' in the starting configuration of a daemon, then 'interface TITI vrf TOTO' will permit to create interface TITI within vrf TOTO. the macro VRF_GET_INSTANCE will return the vrf context, if available or not. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12*: change if_lookup_by_name() api with vrfPhilippe Guibert
the vrf_id parameter is replaced by struct vrf * parameter. this impacts most of the daemons that look for an interface based on the name and the vrf identifier. Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was ignored until now. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11lib, ospfd, pimd, zebra: change if_create() api with vrfPhilippe Guibert
if_create() takes as input a vrf poiter instead of the vrf_id parameter. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11ospf, ospf6d, zebra, lib: change if_get_by_name prototype with vrfPhilippe Guibert
vrf pointer is used as reference when calling if_get_by_name() function. this will permit to create interfaces with an unknown vrf_id, since it is only necessary to get the vrf structure to store the interfaces. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-17lib: add function to get iface link-localQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17vrrpd: add initial macvlan supportQuentin Young
* Search for macvlan interfaces with the appropriate name and MAC address when starting up a new VRRP instance * Split VRRP socket into two; one for Tx, one for Rx * Bind Tx socket to the macvlan subinterface so our VRRP advertisements go out with the correct MAC address * Send ARP requests from this macvlan subinterface * Improve error messaging Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-26lib: introduce a read-write lock for northbound configurationsRenato Westphal
The upcoming gRPC-based northbound plugin will run on a separate pthread, and it will need to have access to the running configuration global variable. Introduce a rw-lock to control concurrent access to the running configuration. Add the lock inside the "nb_config" structure so that it can be used to protect candidate configurations as well (this might be necessary depending on the threading scheme of future northbound plugins). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-22Merge pull request #3786 from mjstapp/dplane_intfDonald Sharp
zebra: async interface address programming
2019-04-22libs: use const in some interface flag accessorsMark Stapp
Use const in several interface struct flag accessors (that just test flags.) Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-18lib: rework management of user pointers in the northbound layerRenato Westphal
Introduce a hash table to keep track of user pointers associated to configuration entries. The previous strategy was to embed the user pointers inside libyang data nodes, but this solution incurred a substantial performance overhead. The user pointers embedded in candidate configurations could be lost while the configuration was being edited, so they needed to be regenerated before the candidate could be committed. This was done by the nb_candidate_restore_priv_pointers() function, which was extremely expensive for large configurations. The new hash table solves this performance problem. The yang_dnode_[gs]et_entry() functions were renamed and moved from yang.[ch] to northbound.[ch], which is a more appropriate place for them. This patch also introduces the nb_running_unset_entry() function, the counterpart of nb_running_set_entry() (unsetting user pointers was done automatically before, now it needs to be done manually). As a consequence of these changes, we shouldn't need support for libyang private pointers anymore (-DENABLE_LYD_PRIV=ON). But it's probably a good idea to keep requiring this feature as we might need it in the future for other things (e.g. disable configuration settings without removing them). Fixes #4136. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-06lib: Fixup IFF_OUT_LOG macro to make SA happyDonald Sharp
The IFF_OUT_LOG macro is using BUFSIZE, which is the sizeof(logbuf) but for some reason 8.0 clang SA is not happy with it. Just make it happy. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-04Merge pull request #3548 from opensourcerouting/rip-vrfDonald Sharp
rip(ng)d: add VRF support
2019-04-03lib: reduce exported var symbolsQuentin Young
Don't need these in our DSO tables Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-03-29lib, ripd, ripngd: rename remaining delete northbound callbacksRenato Westphal
PR #3622 renamed the "delete" northbound callback to "destroy" in order to make the libfrr headers compatible with C++. This commit renames a few functions that still use "delete" instead of "destroy" in their names. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-03-25Merge pull request #3772 from pguibert6WIND/vrf_backend_unknownDonald Sharp
Vrf backend unknown
2019-02-25*: remove null check before XFREEQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-11libs, rip, isis: change northbound operation enum to DESTROYMark Stapp
Change the northbound lib operation from DELETE to DESTROY; make the required changes in the users of the northbound, in the cli, rip, ripng, and isis. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11libs, daemons: changes to permit c++ compilationMark Stapp
Some misc changes to resolve some c++ compilation errors. The goal is only to permit an external module - a plugin, for example - to see frr headers, not to support or encourage contributions in c++. The changes include: avoiding use of keywords like 'new', 'delete'; cleaning up implicit type-casting from 'void *' in several places. Signed-off-by: Mark Stapp <mjs@voltanet.io>