summaryrefslogtreecommitdiff
path: root/zebra/kernel_socket.c
AgeCommit message (Collapse)Author
2020-08-10zebra: remove old kernel one-update-at-a-time apiJakub Urbańczyk
The old one is replaced by the api that is suitable for the batching. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10zebra: prepare dplane for batchingJakub Urbańczyk
Extend kernel interface to allow the data plane to send many kernel updates at once. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-07-14*: un-split strings across linesDavid Lamparter
Remove mid-string line breaks, cf. workflow doc: .. [#tool_style_conflicts] For example, lines over 80 characters are allowed for text strings to make it possible to search the code for them: please see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-24*: remove line breaks from log messagesDavid Lamparter
Line break at the end of the message is implicit for zlog_* and flog_*, don't put it in the string. Mid-message line breaks are currently unsupported. (LF is "end of message" in syslog.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-03-08*: Replace `sizeof something` to sizeof(something)Donatas Abraitis
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis) Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-04zebra: Use shorthand operator in ifm_read()Donatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-10-25zebra: Use nexthop object id on route deleteStephen Worley
When we receive a route delete from the kernel and it contains a nexthop object id, use that to match against route gateways with instead of explicit nexthops. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Update rib_add to take a nexthop IDStephen Worley
Add a parameter to the rib_add function so that it takes a nexthop ID from the kernel if one is passed along with the route. Signed-off-by: Stephen Worley <sworley@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-09-03*: frr_elevate_privs -> frr_with_privsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-23Revert "Ospf missing interface handling 2"Donald Sharp
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-29zebra: fix maybe-uninitialized pointerQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29zebra: fix unused variable on OmniOSQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-06zebra: Be consistent in how we call rib_add( and rib_delete( with tableidDonald Sharp
The rib_add( and rib_delete( functions are there to allow kernel interactions with the creation of routes. Fixup the code to be consistent in the passup of the tableid. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-03lib, pbrd, zebra: Fix size_t type printf warnings on obscure platformsDonald Sharp
Use the correct printf formater for those obscure platforms that we build against. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-02zebra: conditionalize RTM_RESOLVE flagMark Stapp
RTM_RESOLVE may not be present; conditionalize zebra's reference to it. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-03-14*: remove trailing newlines from zlog messagesQuentin Young
Zlog puts its own newlines on, and doing this makes logs look nasty. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-01-31zebra: Move the master thread handler to the zrouter structureDonald Sharp
The master thread handler is really part of the zrouter structure. So let's move it over to that. Eventually zserv.h will only be used for zapi messages. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-25zebra: set connected route metric based on the devaddr metricAnuradha Karuppiah
MACVLAN devices are typically used for applications such as VRR/VRRP that require a second MAC address (virtual). These devices have a corresponding SVI/VLAN device - root@TORC11:~# ip addr show vlan1002 39: vlan1002@bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9152 qdisc noqueue master vrf1 state UP group default link/ether 00:02:00:00:00:2e brd ff:ff:ff:ff:ff:ff inet6 2001:aa:1::2/64 scope global valid_lft forever preferred_lft forever root@TORC11:~# ip addr show vlan1002-v0 40: vlan1002-v0@vlan1002: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9152 qdisc noqueue master vrf1 state UP group default link/ether 00:00:5e:00:01:01 brd ff:ff:ff:ff:ff:ff inet6 2001:aa:1::a/64 metric 1024 scope global valid_lft forever preferred_lft forever root@TORC11:~# The macvlan device is used primarily for RX (VR-IP/VR-MAC). And TX is via the SVI. To acheive that functionality the macvlan network's metric is set to a higher value. Zebra currently ignores the devaddr metric sent by the kernel and hardcodes it to 0. This commit eliminates that hardcoding. If the devaddr metric is available (METRIC_MAX) it is used for setting up the connected route otherwise we fallback to the dev/interface metric. Setting the macvlan metric to a higher value ensures that zebra will always select the connected route on the SVI (and subsequently use it for next hop resolution etc.) - root@TORC11:~# vtysh -c "show ip route vrf vrf1 2001:aa:1::/64" Routing entry for 2001:aa:1::/64 Known via "connected", distance 0, metric 1024, vrf vrf1 Last update 11:30:56 ago * directly connected, vlan1002-v0 Routing entry for 2001:aa:1::/64 Known via "connected", distance 0, metric 0, vrf vrf1, best Last update 11:30:56 ago * directly connected, vlan1002 root@TORC11:~# Ticket: CM-23511 Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-01-22zebra: use rta_getattr for NETMASKRafael Zalamena
IPv6 uses AF_LINK to represent netmasks, this commit unbreaks `rtm_read_mesg` that was broke on the `rta_get*` refactory. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org> (cherry picked from commit 7a163a7c59bd1a7e94da356ea033040ae17cef29)
2019-01-22zebra: fix routing socket AF_LINK handling on NETMASKRafael Zalamena
IPv6 netmasks use AF_LINK family type and puts the correct amount of set bits in the data structure. If we only copy the SDL header we won't get all IPv6 address length, we must copy the whole extension of the `sockaddr_in6` struct (which is provided in `destlen` parameter). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org> (cherry picked from commit 691e903879bcf88c872d74f6317784bd2187f3ca)
2019-01-21zebra: make routing socket debug user friendlierRafael Zalamena
Implement a addrs RTA to string translator to provide more useful debug output. Example: ifam_read_mesg: ifindex 2, ifname em1, ifam_addrs NETMASK,IFP,IFA ifam_flags 0x4, addr 2001:db8:1::1/64 broad (unspec) dst (unspec) gateway (unspec) Instead of: ifam_read_mesg: ifindex 2, ifname em1, ifam_addrs 0x34 ifam_flags 0x4, addr 2001:db8:1::1/64 broad (unspec) dst (unspec) gateway (unspec) Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-01-21zebra: fix debug messages in ifam_read_mesgRafael Zalamena
Use the proper address family to convert binary address to string. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-01-08zebra: fix another FreeBSD warning messageRafael Zalamena
When an empty netmask a wrong end size is calculated, lets handle this corner case to avoid spurious warning messages. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-01-08zebra: fix FreeBSD warning on fresh OS bootRafael Zalamena
Handle corner case where a warning log message is issued on interface address netmask handling with sockaddr type AF_LINK: it may come empty or with match all (all 0xFF). In the first case all lengths are zero and we only need to copy the first bytes, second case it comes with a zero index and all 0xFF bytes. In any case we only need to figure out a few of the first bytes instead of all data. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-01-08zebra: implement FreeBSD route attr handlingRafael Zalamena
When porting routing socket macro data handling to functions, the attribute function was forgotten. The only difference between the attribute and address handler is the family type check. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-12-21zebra: fix compilation on OpenBSDRafael Zalamena
OpenBSD doesn't define RTM_LOCK anymore: https://marc.info/?l=openbsd-tech&m=153018811429193&w=2 Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-12-13Merge pull request #3467 from donaldsharp/kernel_socket_cleanupRuss White
Kernel socket cleanup
2018-12-12lib, zebra: Remove ZEBRA_FLAG_STATICDonald Sharp
We never used this information and it was merely stored. Additionally this is not something that is a flag, it's a status. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-12zebra: Make v4 and v6 code paths for rib_XXX calls in kernel_socket the sameDonald Sharp
Make the v4 and v6 code paths for rib_XXX calls in kernel_socket as similiar as we can possibly make them. There is no need for code duplication at this point in time. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-12zebra: Remove rib_lookup_ipv4_routeDonald Sharp
The rib_lookup_ipv4_route function is only used in a debug path. Is only used for v4 and only checks to make sure that the rib and fib are in sync( which is not needed/used/supported on other platforms ). So let's just remove it. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-05zebra: refactor route socket message handlingRafael Zalamena
Some address types were not being skipped triggering a warning log message, so lets refactor this code to properly handle known and unknown types. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-12-05zebra: always define ROUNDUP and ROUND_TYPERafael Zalamena
Move the declaration of ROUNDUP and ROUND_TYPE to outside of `ifdef SA_SIZE`. We'll use these definitions in the next commit. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-11-21zebra: add dataplane routing socketMark Stapp
To avoid conflicts between the zebra main pthread and the dataplane pthread, use a separate routing socket (on non-netlink platforms) for dataplane route updates to the OS. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-11-21zebra: separate netlink socket for dataplaneMark Stapp
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>
2018-10-31Merge pull request #2705 from opensourcerouting/northbound-yang-v2Donald Sharp
Northbound API
2018-10-28Merge pull request #2946 from mjstapp/dplane_2Donald Sharp
Zebra: async dataplane, phase 1
2018-10-27lib: retrofit interface commands to the new northbound modelRenato Westphal
The frr-interface YANG module models interfaces using a YANG list keyed by the interface name and the interface VRF. Interfaces can't be keyed only by their name since interface names might not be globally unique when the netns VRF backend is in use. When using the VRF-Lite backend, however, interface names *must* be globally unique. In this case, we need to validate the uniqueness of interface names inside the appropriate northbound callback since this constraint can't be expressed in the YANG language. We must also ensure that only inactive interfaces can be removed, among other things we need to validate in the northbound layer. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-25*: spelchekDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-25zebra: update routing socket pathMark Stapp
Update route-socket path for route updates using the async dplane module. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-09-13*: style for EC replacementsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13*: LIB_[ERR|WARN] -> EC_LIBQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRAQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06zebra: flog_warn conversionQuentin Young
Convert Zebra to user error subsystem. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14*: use frr_elevate_privs() (2/2: manual)David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14zebra: add missing includeQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>