summaryrefslogtreecommitdiff
path: root/zebra/kernel_netlink.c
AgeCommit message (Collapse)Author
2017-06-21*: simplify log message lookupQuentin Young
log.c provides functionality for associating a constant (typically a protocol constant) with a string and finding the string given the constant. However this is highly delicate code that is extremely prone to stack overflows and off-by-one's due to requiring the developer to always remember to update the array size constant and to do so correctly which, as shown by example, is never a good idea.b The original goal of this code was to try to implement lookups in O(1) time without a linear search through the message array. Since this code is used 99% of the time for debugs, it's worth the 5-6 additional cmp's worst case if it means we avoid explitable bugs due to oversights... Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-25zebra: Store commonly used values instead of regeneratingDonald Sharp
the ipv4_ll address used for 5549 routes does not need to be figured out every single time that we attempt to install/remove a route of that type. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-25zebra: Format netlink requests correctlyvivek
When zebra issues read (GET) requests to the kernel using the netlink interface, it is incorrect to format all of them in a generic manner using 'struct ifinfomsg' or 'struct rtgenmsg'. Rather, messages for a particular entity (e.g., routes) should use the corresponding structure for encoding (e.g., 'struct rtmsg'). Of course, this has to correlate with what the kernel expects. In the absence of this, there is the possibility of sending extraneous information in the request which the kernel wouldn't like. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: David Ahern <dsa@cumulusnetworks.com>
2017-05-25zebra: Set nlmsg_pid in netlink_talk()vivek
While it is not essential to set this, it seems a good thing to do. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-05-25zebra: New API for filling netlink attributevivek
Define addattr16(). Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
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>
2017-05-11zebra: Fix kernel netlink hex dump of informationDonald Sharp
1) Fix the kernel send and recv hex dump of what we are sending to the kernel 2) When configuring the debugs under 'conf t' display it too. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-09*: update thread_add_* callsQuentin Young
Pass pointer to pointer instead of assigning by return value. See previous commit message. To ensure that the behavior stays functionally correct, any assignments with the result of a thread_add* function have been transformed to set the pointer to null before passing it. These can be removed wherever the pointer is known to already be null. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09*: remove THREAD_ON macros, add nullity checkQuentin Young
The way thread.c is written, a caller who wishes to be able to cancel a thread or avoid scheduling it twice must keep a reference to the thread. Typically this is done with a long lived pointer whose value is checked for null in order to know if the thread is currently scheduled. The check-and-schedule idiom is so common that several wrapper macros in thread.h existed solely to provide it. This patch removes those macros and adds a new parameter to all thread_add_* functions which is a pointer to the struct thread * to store the result of a scheduling call. If the value passed is non-null, the thread will only be scheduled if the value is null. This helps with consistency. A Coccinelle spatch has been used to transform code of the form: if (t == NULL) t = thread_add_* (...) to the form thread_add_* (..., &t) The THREAD_ON macros have also been transformed to the underlying thread.c calls. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-04-20Add source of route as protocol string in ip route pushed into kernelDinesh G Dutt
Ticket: CM-14313 Reviewed By: Testing Done: bgpmin, ospfmin, bgp_kitchen_sink_test 'ip route show' displays all routes as belonging to protocol zebra. The user has to run an additional command (in vtysh) to get the actual source of a route (bgp/ospf/static etc.). This patch addresses that by pushing the appropriate protocol string into the protocol field of the netlink route update message. Now you can see routes with the correct origin as well as filter on them (ip route show proto ospf). 'ospf' is used for both IPv4 and IPv6 routes, even though the OSPF version is different in both cases. Sample output (old): 9.9.12.13 via 69.254.2.38 dev swp3.2 proto zebra metric 20 9.9.13.3 proto zebra metric 20 nexthop via 69.254.2.30 dev swp1.2 weight 1 nexthop via 69.254.2.34 dev swp2.2 weight 1 nexthop via 69.254.2.38 dev swp3.2 weight 1 Sample output (new): 9.9.12.13 via 69.254.2.38 dev swp3.2 proto bgp metric 20 9.9.13.3 proto bgp metric 20 nexthop via 69.254.2.30 dev swp1.2 weight 1 nexthop via 69.254.2.34 dev swp2.2 weight 1 nexthop via 69.254.2.38 dev swp3.2 weight 1
2017-03-08*: get rid of zlog(*, LOG_LEVEL, ...)David Lamparter
Result of running the following Coccinelle patch + fixups: <<EOF /* long-forms: zlog(NULL, <level>, ...) * => zlog_level(...) */ @@ expression list args; @@ - zlog(NULL, LOG_DEBUG, args) + zlog_debug(args) @@ expression list args; @@ - zlog(NULL, LOG_NOTICE, args) + zlog_notice(args) @@ expression list args; @@ - zlog(NULL, LOG_INFO, args) + zlog_info(args) @@ expression list args; @@ - zlog(NULL, LOG_WARNING, args) + zlog_warn(args) @@ expression list args; @@ - zlog(NULL, LOG_ERR, args) + zlog_err(args) /* long-forms: zlog(base->log, <level>, ...) * => zlog_level(...) */ @@ expression base; expression list args; @@ - zlog(base->log, LOG_DEBUG, args) + zlog_debug(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_NOTICE, args) + zlog_notice(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_INFO, args) + zlog_info(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_WARNING, args) + zlog_warn(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_ERR, args) + zlog_err(args) EOF Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-01zebra: Add knowledge of whether or not we are acting under startup conditionsDonald Sharp
The reading if unicast routes from the kernel acts subtly differently between reading in the routes from the kernel on startup and reading a new route or getting a response for a route. Add startup flag(currently ignored) so that we can start consolidating the functionality. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-01zebra: fix wrong asserts in netlink codeRenato Westphal
These new asserts were causing zebra to abort when trying to install MPLS labeled routes. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-01-17zebra: Fix compiles for non-linux based systemsDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-17zebra: Cleanup zebra_static CLANG/SA issues.Donald Sharp
When compiling using CLANG's SA, cleanup the SA issues found. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-17zebra: Fully decode mcast messagesDonald Sharp
Fully decode mcast messages from the kernel. We are not doing anything with this at the moment, but that will change. Additionally convert over to using lookup for displaying the route type. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-17zebra: Allow netlink_talk to choose the filter function to callDonald Sharp
The netlink_talk call sends a message to the kernel, which with netlink_talk_filter only waits for the ACK. It would be nice to have the ability to specify what the handler function would be for when we send queries about mcast S,G routes so that we can gather the data returned from the kernel. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-17zebra: Remove unused variable.Donald Sharp
Remove the rtnh variable since it is unused. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-11-28zebra/lib: move some code aroundRenato Westphal
* 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>
2016-10-21Merge remote-tracking branch 'origin/cmaster' into cmaster-nextDonald Sharp
2016-10-18zebra: use unsigned args for *addattrDavid Lamparter
[based on a patch by Paul Jakma changing it to size_t] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-17zebra: Refactor netlink interactionsvivek
Separate core netlink functions and library functions from route-related interactions and interface-related interactions. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Ticket: CM-13199 Reviewed By: CCR-5254 Testing Done: bgp-min, ospf-min
2002-12-13Initial revisionpaul