summaryrefslogtreecommitdiff
path: root/zebra/interface.c
AgeCommit message (Collapse)Author
2018-09-12Merge remote-tracking branch 'frr/master' into warningsDavid Lamparter
Conflicts: zebra/if_ioctl_solaris.c zebra/rtread_getmsg.c Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-11Merge pull request #2944 from thbtcllt/masterRuss White
fix zebra crash when a vrf interface changes with netns implementation for vrf
2018-09-06zebra: flog_warn conversionQuentin Young
Convert Zebra to user error subsystem. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06zebra/lib: code cleaningThibaut Collet
Remove useless parenthesis and explicit cast. Remove redundant code. Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
2018-08-30zebra: fix crash when interface vrf changesThibaut Collet
This crash occurs only with netns implementation. vrf meaning is different regarging its implementation (netns or vrf-lite) - With vrf-lite implementation vrf is a property of the interface that can be changed as the speed or the state (iproute2 command: "ip link set dev IF_NAME master VRF_NAME"). All interfaces of the system are in the same netns and so interface name is unique. - With netns implementation vrf is a characteristic of the interface that CANNOT be changed: it is the id of the netns where the interface is located. To change the vrf of an interface (iproute2 command to move an interface "ip netns exec VRF_NAME1 ip link set dev IF_NAME netns VRF_NAME2") the interface is deleted from the old vrf and created in the new vrf. Interface name is not unique, the same name can be present in the different netns (typically the lo interface) and search of interface must be done by the tuple (interface name, netns id). Current tests on the vrf implementation (vrf-lite or netns) are not sufficient. In some cases (for example when an interface is moved from a vrf X to the default vrf and then move back to VRF X) we can have a corruption message and then a crash of zebra. To avoid this corruption test on the vrf implementation, needed when an interface changes, has been rewritten: - For all interface changes except deletion the if_get_by_name function, that checks if an interface exists and creates or updates it if needed, is changed: * The vrf-lite implementation is unchanged: search of the interface is based only on the name and update the vrf-id if needed. * The netns implementation search of the interface is based on the (name, vrf-id) tuple and interface is created if not found, the vrf-id is never updated. - deletion of an interface (reception of a RTM_DELLINK netlink message): * The vrf-lite implementation is unchanged: the interface information are cleared and the interface is moved to the default vrf if it does not belong to (to allow vrf deletion) * The netns implementation is changed: only the interface information are cleared and the interface stays in its vrf to avoid conflict with interface with the same name in the default vrf. This implementation reverts (partially or totally): commit 393ec5424e35 ("zebra: fix missing node attribute set in ifp") commit e9e9b1150f0c ("lib: create interface even if name is the same") commit 9373219c67e1 ("zebra: improve logs when replacing interface to an other netns") Fixes: b53686c52a59 ("zebra: delete interface that disappeared") Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-29zebra: do not update link if interface is veth interfacePhilippe Guibert
when interface is a virtual ethernet interface, then there is no need to update link pointer of interface. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-27zebra: when veth link is used across vrf, the link may not be goodPhilippe Guibert
This function is changed so that the interface index is searched across the correct namespace. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14lib, zebra: Add LIB_ERR_INTERFACEDonald Sharp
Add a error type that allows us to track bad interface states. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29zebra: Remove zebra_static.c and .hDonald Sharp
These are no longer needed so remove. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29staticd: Start the addition of a staticdDonald Sharp
This is the start of separating out the static handling code from zebra -> staticd. This will help simplify the zebra code and isolate static route handling to it's own code base. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-27lib,zebra: fix json output when vrf1 when not activeNathan Van Gheem
When I did a show ip route with `json` on a vrf when it didn't exist, frr would output invalid json. Signed-off-by: Nathan Van Gheem <nathan@cumulusnetworks.com>
2018-06-18zebra: re-install static routes needed vrf when the vrf intf comes upDon Slice
Problem reported that if the vrf device is taken down and then brought back up, any static route referencing that vrf device was not re-installed. This fix runs back thru the static routes that reference the vrf device coming up and re-install them. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-05-12Merge pull request #2171 from pguibert6WIND/misc_crashes_moving_ifp_from_netnsRuss White
Misc crashes moving ifp from netns
2018-05-08zebra: Fixup crash with vlan interfaces attempted to be usedDonald Sharp
When zebra starts up it receives from the kernel a full dump of interface information. Unfortunately it is in no particular order. As such we sometimes receive data from the kernel about interfaces we do not know about yet. In this bug, we are attempting to use the interface pointer(->link) for a vlan interface that we have not properly resolved. This fix ensures that we will not attempt to call zvni_map_svi if we have a NULL pointer. There are other places in the code we are already checking for the fact that the ->link pointer is valid before calling this function, so I believe that this is correct. We do need to come back and resolve all ->link pointers after we have received the full table. This can be done in another commit. Ticket: CM-17041 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-04zebra: avoid inactivating twice an interfacePhilippe Guibert
This code is a sanity check to avoid double unlink of interface. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-05-04zebra: fix missing node attribute set in ifpPhilippe Guibert
There are cases when switching from one netns to an other one, where the if_table registration by index has not been flushed. This fix mitigates the potential crashes, in case the ifp->node pointer is null, the value is overwritten by the route_node obtained. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-09zebra: Notice when our neighbor entry is removed and fight backDonald Sharp
Notice when someone deletes a neighbor entry we've put in for rfc-5549 gets deleted by some evil evil person. When this happens notice and push it back in, immediately. Ticket: CM-18612 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-03Merge pull request #1927 from pguibert6WIND/issue_1926Renato Westphal
zebra: delete interface that disappeared
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
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>
2018-03-26zebra: delete interface that disappearedPhilippe Guibert
When moving interfaces to an other place, like other netns, the remaining interface is still present, with inactive status. Now, that interface is deleted from the list, if the interface appears on an other netns. If not, the interface is kept. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-23zebra: fix misc changes related to link updates with correct znsPhilippe Guibert
Because vrf with netns backend may be used, the correct zns must be found prior any modifications. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-06*: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2018-02-27zebra: retrieve zns context from zvrf when netlink discoveryPhilippe Guibert
So as to get the correct NETNS where some discovery must be done and populated, the zns pointer is directly retrieved from zvrf, instead of checking that the VRF is a backend NETNS or not. In the case where the interfaces are discovered before the VRF is enabled ( VRF-lite populate), then the default NS is retrieved. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27zebra: fix initialised vrf_id value never readPhilippe Guibert
this is a static analysis performed by c-lang scan-build tool that demonstrated this issue. This commit is handling the fix. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27zebra: ipv6 operations stick to namespacePhilippe Guibert
All ipv6 operations stick to namespace. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27zebra: socket operations stick to namespace if necessaryPhilippe Guibert
Upon following calls: interface poll, address poll, route poll, and ICMPv6 handling, each new Namespace is being parsed. For that, the socket operations need to switch from one NS to one other, to get the necessary information. As of now, there is a crash when dumping interfaces, through show running-config. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-01-21zebra: Install connected routes during VRF change only if interface is upvivek
During VRF change handling, the connected route for the interface should be installed only if the interface is up. Otherwise, we end up with duplicate connected routes which can lead to other problems. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Ticket: CM-19364 Reviewed By: CCR-7099 Testing Done: Manual verification
2018-01-11zebra: Add one-shot thread to recheck speedDonald Sharp
There are certain interfaces that when brought up and we receive the netlink notification about it, the speed of the interface is not set correctly. This creates a one-shot thread that will wait 15 seconds and then requery the speed and if it is different it will renotify the running daemons. The kernel should notify us on speed changes, unfortunately this is not done currently via a netlink message as you would think. As I understand it there is some in-fighting about the proper way to approach this issue and due to the way the kernel release cycle works we are a ways off from getting this fixed. This is a `hack` to make us work correctly while we wait for the true answer. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-14zebra: Remove possible NULL dereference in if_delete_connectedDonald Sharp
It is technically possible to attempt to use a NULL pointer. Remove this from happening. Additionally cleanup code indentation a small bit. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-24*: add missing \n in some help stringsRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10*: use the FOR_ALL_INTERFACES abstraction from babeldRenato Westphal
This improves code readability and also future-proofs our codebase against new changes in the data structure used to store interfaces. The FOR_ALL_INTERFACES_ADDRESSES macro was also moved to lib/ but for now only babeld is using it. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10*: introduce new rb-tree to optimize interface lookup by ifindexRenato Westphal
Performance tests showed that, when running on a system with a large number of interfaces, some daemons would spend a considerable amount of time in the if_lookup_by_index() function. Introduce a new rb-tree to solve this problem. With this change, we need to use the if_set_index() function whenever we want to change the ifindex of an interface. This is necessary to ensure that the 'ifaces_by_index' rb-tree is updated accordingly. The return value of all insert/remove operations in the interface rb-trees is checked to ensure that an error is logged if a corruption is detected. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10*: use rb-trees to store interfaces instead of sorted linked-listsRenato Westphal
This is an important optimization for users running FRR on systems with a large number of interfaces (e.g. thousands of tunnels). Red-black trees scale much better than sorted linked-lists and also store the elements in an ordered way (contrary to hash tables). This is a big patch but the interesting bits are all in lib/if.[ch]. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-05*: Convert list_free usage to list_deleteDonald Sharp
list_free is occassionally being used to delete the list and accidently not deleting all the nodes. We keep running across this usage pattern. Let's remove the temptation and only allow list_delete to handle list deletion. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05*: Convert list_delete(struct list *) to ** to allow nullingDonald Sharp
Convert the list_delete(struct list *) function to use struct list **. This is to allow the list pointer to be nulled. I keep running into uses of this list_delete function where we forget to set the returned pointer to NULL and attempt to use it and then experience a crash, usually after the developer has long since left the building. Let's make the api explicit in it setting the list pointer to null. Cynical Prediction: This code will expose a attempt to use the NULL'ed list pointer in some obscure bit of code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-15*: use clang's 'ForEachMacros' format style optionRenato Westphal
This fixes the broken indentation of several foreach loops throughout the code. From clang's documentation[1]: ForEachMacros: A vector of macros that should be interpreted as foreach loops instead of as function calls. [1] http://clang.llvm.org/docs/ClangFormatStyleOptions.html Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-11Merge pull request #1084 from donaldsharp/zebra_frameDavid Lamparter
zebra: Fix vty_frame usage in zebra
2017-08-31zebra: Refactor connected_down_ipv[4|6]Donald Sharp
The connected_down_ipv[4|6] functions are basically identical. Refactor into one common interface. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-31zebra: Refactor connected_up_ipv[4|6]Donald Sharp
The connected_up_ipv[4|6] functions were almost identical. Combine the forces for the goodness of mankind Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-31Merge pull request #1079 from qlyoung/fix-style-aRenato Westphal
*: fix style
2017-08-31Merge pull request #1044 from donaldsharp/combinationJafar Al-Gharaibeh
Coverity Cleanup of Stuff
2017-08-31zebra: Fix vty_frame usage in zebraDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-30*: fix styleQuentin Young
Fixes style nits introduced by recent pull requests. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-29Merge pull request #1059 from opensourcerouting/oldbits-1Donald Sharp
zebra: PtP address configuration support
2017-08-29Merge pull request #1056 from opensourcerouting/oldbits-0Donald Sharp
"pathspace" options, vtysh-suid-cleanups, "vty_frame()"
2017-08-29*: remove empty "interface XYZ" config blocksDavid Lamparter
Using the previously-added vty_frame() support, this gets rid of all the pointless empty "interface XYZ" blocks that get added for any interface that shows up in the system (e.g. dummys, tunnels, etc.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28Merge branch 'master' into dev-masterMitesh Kanjariya
2017-08-27zebra: add '[no] ip address A.B.C.D peer A.B.C.D/M'David Lamparter
introduce a new command to configure a Point-to-Point address on an interface. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-27zebra: fix interface deletion bug introduced by ptp address supportDavid Lamparter
meh. forgot to even look at the interface deletion path. this doesn't really work well when looking for the local address in the subnet list which has the connected prefix in it... loop ensues. fix by using the connected prefix when looking at the list of connected prefixes. duh. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>