summaryrefslogtreecommitdiff
path: root/zebra/kernel_socket.c
AgeCommit message (Collapse)Author
2017-12-14zebra: Add ability to support tags -> realms in linuxKaloyan Kovachev
Linux has the ability to support a concept of 'realms'. This concept allows you to mark routes with a realm id value of 1-255. If you have marked the realm of a route then you can use the tc program to apply policy to the routes. This commit adds the ability of FRR to interpret a tag from (1-255) as a realm when installing into the kernel. Please note that at this point in time there is no way to set policy from within FRR. This must be done outside of it. The normal methodology for setting tags is valid here via a route-map. Finally this is only applied if the --enable-realms configure option is applied. Signed-off-by: Kaloyan Kovachev <kkovachev@varna.net>
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-10lib: nuke the if_*_by_name_len() functionsRenato Westphal
Make use of strnlen() and strlcpy() so we can get rid of these convoluted if_*_by_name_len() functions. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-25zebra: Do not allow delete of route from kernel in non-startup caseDonald Sharp
This is a continuation of 915902cb82cfd. Basically the netlink read of messages up from the kernel is now noticing the proper owner of the route. As such when rib_delete was being called as part of the upcall from the kernel we were not noticing that we were the originator and not diss-allowing the rib_delete from happening. This restores this behavior that we were getting pre-915902cb82cfd 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-28zebra: kernel_socket: read extra attributesDavid Lamparter
This is just to silence the "didn't read all data" warning. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28zebra: drop IPv6 "broadcast" and "peer" addr codeDavid Lamparter
There is no such thing as an IPv6 "broadcast" or "peer" address. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28zebra: cleanup blackhole supportDavid Lamparter
blackhole support was horribly broken. cleanup by removing blackhole stuff from ZEBRA_FLAG_* introduces support for "prohibit" routes (Linux/netlink only) also clean up blackhole options on "ip route" vty commands. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28zebra: rib: use nexthop ptr in rib_add/deleteDavid Lamparter
This simplifies the API for the following blackhole rework. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-26zebra: remove RT_ROUNDUP warningDavid Lamparter
This warning is at odds with how the world works. Also, the code is correct on all platforms we care about. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-09zebra: Pay attention to metric from kernelDonald Sharp
When the linux kernel adds/deletes routes, the metric is important, but our routing protocols add/delete in a slightly different manner, so allow kernel metrics to match so that our rib matches the kernel's fib. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-09zebra: fetch interface speed on *BSDRenato Westphal
Fixes #407 for FreeBSD and NetBSD. OpenBSD uses ioctl to fetch interface information on startup and the SIOCGIFMEDIA command is just too cumbersome to use. The best way to fix the problem for OpenBSD is probably to stop treating it differently from the other BSDs for no apparent reason. There should be nothing preventing us to make OpenBSD use the routing socket to fetch interface information on startup (we already do it to detect runtime changes). This is something that should be done in a separate commit after a careful analysis. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-31build: zebra: remove *_method Makefile hacksDavid Lamparter
replace with preprocessor checks in source files. Much simpler... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22Revert "*: reindent pt. 2"David Lamparter
This reverts commit c14777c6bfd0a446c85243d3a9835054a259c276. clang 5 is not widely available enough for people to indent with. This is particularly problematic when rebasing/adjusting branches. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindent pt. 2whitespace / reindent
w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
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-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-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-03-15lib: Refactor if_get_by_name_len to be VRF awareDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15*: Refactor if_lookup_by_name to be VRF awareDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15lib, ospfd, pimd: Convert to using VRF based interface creationDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15*: Remove non-vrf based ifindex lookupDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
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-01-30zebra: receive ZAPI IPv6 source prefixDavid Lamparter
Check and read the IPv6 source prefix on ZAPI messages, and pass it down to the RIB functions (which do nothing with it yet.) Since the RIB functions now all have a new extra argument, this also updates the kernel route read functions to supply NULL. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-18zebra: Fix compile warnings under freebsdDonald Sharp
Compiling under clang we see compiler warnings Fix them. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-13frr: Remove HAVE_IPV6 from code baseDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-11-15lib: replace strlcpy & strlcat with glibc versionsDavid Lamparter
It seems these two were at some point copied in from rsync; replace with more recent versions that will hopefully become available in glibc as well. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-18zebra: kernel interface simplificationTimo Teräs
[DL: picked out from: "atomic FIB updates"] This simplifies the OS-specific route update API into a single entry point, kernel_route_rib(), which dispatches the various operations internally. Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2016-09-23zebra: check at startup if the kernel supports MPLSRenato Westphal
Replace all HAVE_MPLS #ifdef's by a run-time check if MPLS is supported by the kernel or not. This way we don't need to create multiple packages for each OS distribution. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-23mpls: add support to the OpenBSD kernelRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-19*: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter
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>
2016-09-03lib, zebra: unify link layer type and hardware address handlingTimo Teräs
This removes the BSD specific usage of struct sockaddr_dl hardware address. This unifies to use explict hw_addr member for the address, and zebra specific enumeration for the link layer type. Additionally the zapi is updated to never send platform specific structures over the wire, but the ll_type along with hw_addr_len and hw_addr are now sent for all platforms. Based on initial work by Paul Jakma. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # Author: Timo Teräs <timo.teras@iki.fi> # # rebase in progress; onto 9c2f85d # You are currently editing a commit while rebasing branch 'renato' on '9c2f85d'. # # Changes to be committed: # modified: isisd/isis_circuit.c # modified: lib/if.c # modified: lib/if.h # modified: lib/zclient.c # modified: zebra/interface.c # modified: zebra/interface.h # modified: zebra/kernel_socket.c # modified: zebra/rt_netlink.c # modified: zebra/rtadv.c # modified: zebra/zserv.c # # Untracked files: # "\033\033OA\033OB\033" # 0001-bgpd-fix-build-on-Solaris.patch # ldpd/ # redhat/ldpd.init # redhat/ldpd.service # tags #
2016-09-01zebra: Refactor rib_add_ipv[4|6] to a common functionDonald Sharp
rib_add_ipv[4|6] both were essentially the same function combine and refactor everywhere. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01zebra: Refactor rib_delete_ipv[4|6]Donald Sharp
These two functions are essentially the same. Refactor. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-08-21zebra: implement per-route mtu handlingTimo Teräs
This commits allow overriding MTU using netlink attributes on per-route basis. This is useful for routing protocols that can advertice prefix specific MTUs between routers (e.g. NHRP). Signed-off-by: Timo Teräs <timo.teras@iki.fi> (cherry picked from commit b11f3b54c842117e22e2f5cf1561ea34eee8dfcc)
2016-08-18*: use an ifindex_t type, defined in lib/if.h, for ifindex valuesPaul Jakma
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-08-07*: fix trivial build errors on *BSDRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-08-07zebra: fix build on OpenBSD >= 5.9Renato Westphal
RTF_XRESOLVE was removed from the OpenBSD tree recently. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-06-09zebra: fix VRF code for *BSDDavid Lamparter
There seems to be no rtm_table in struct rt_msghdr, at least on the systems I have access to... Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit d6cf5134c05a7890738411852d9357ee5bb322f3)
2016-06-09zebra: use prefix2str for logging where possibleTimo Teräs
This makes code more robust, consice and readable. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit be6335d682c5ee1b6930345193eda875705fbab2)
2016-05-26zebra: make RTF_LLINFO optional to fix FreeBSDLou Berger
Signed-off-by: Lou Berger <lberger@labn.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit b05c6ca57130f079f8a8a6686d9d4ffa5ff440f0)
2016-05-26solaris: more warnings fixedDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit da1b7eaa0ac5d590818e1cde92a9807a2f0e07f2)
2016-05-26solaris: no ROUNDUPDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit a2b503131b188292ede08df99309bcbef4bd1a52)
2016-05-26zebra: static int inline -> static inline intDavid Lamparter
The BSD socket kernel interface had some weird ordering of function attribute keywords. ("static int inline foobar()") Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 3e9e2c9fb66895df42159b98a3743e25399760df)
2016-05-26zebra: use SA_SIZE for RT_ROUNDUP on FreeBSDDavid Lamparter
FreeBSD provides SA_SIZE (and none of the other options to infer padded size of a struct sockaddr). Just define SAROUNDUP to SA_SIZE if it is available. This also drops a superfluous-looking extra macro branch which would require ROUNDUP. It seemed redundant to my eyes, but I have no idea what odd things might have triggered addition of this in the first place... Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 7e92322cfcc6c062acae3b550f90d36fe40763f1)
2016-05-26Fix alignment assumptions on non-RT_ROUNDUP platforms.Greg Troxel
The comment said that apple uses int and BSD traditionally used long, but the code was backwards. This fixes apple to be int, and otherwise long. That should make FreeBSD, which aligns to long, work correctly, even without using SA_SIZE. (cherry picked from commit 941789e470199df4f612368f669ecc0fd096fb9a)
2016-05-26zebra/kernel_socket.c: Use platform alignmentGreg Troxel
Use the platform-provided RT_ROUNDUP macro to align sockaddrs on the routing socket, rather than using hard-coded assumptions about alignment. Emit a warning if the OS doesn't define alignment macros. Resolves failure of ripngd on NetBSD 6 i386, which changed alignment to uint64_t from long. (cherry picked from commit 273b1bd341afff86ba571e0be296d88dba627136)
2016-04-14zebra: Refactor struct zebra_tDonald Sharp
We were including 'extern struct zebra_t zebrad;' all over the place. This made no sense. Refactor into zserv.h where the definition was and remove resulting unnecessary code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>