summaryrefslogtreecommitdiff
path: root/zebra/kernel_netlink.c
AgeCommit message (Collapse)Author
2023-01-23zebra: use typesafe lib lists in zebra dplaneMark Stapp
Replace some of the old queue/DLIST macros with typesafe dlists. Signed-off-by: Mark Stapp <mjs@labn.net>
2022-11-22zebra: traffic control state managementSiger Yang
This allows Zebra to manage QDISC, TCLASS, TFILTER in kernel and do cleaning jobs when it starts up. Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-09-08zebra: fix broken evpnanlan_cs
To resolve link dependencies of unordered interfaces, the commit `520ebf72b27c2462ce8b0dc5a1d4cb83956df69c` has separated assignment of `zif->link_ifindex` and `zif->link` from `netlink_interface()` during startup. The fixup stage of `zebra_if_update_all_links()` goes into the last of `interface_lookup_netlink()`, it can't be executed in the case of error in above `netlink_parse_info()`s. `RTM_GETTUNNEL` is not supported in linux kernel until 5.18, so `netlink_parse_info()` will throw error with the previous versions. If two conditions are met, (it is a common case) 1. Interfaces are created before frr restart/start 2. Linux kernel version < 5.18 the link dependencies will not be done, then evpn feature will be broken. IMO we should just ignore this error. Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-08-11zebra: add tc netlink and dplane opsSiger Yang
This commit implements necessary netlink encoders for traffic control including QDISC, TCLASS and TFILTER, and adds basic dplane operations. Co-authored-by: Stephen Worley <sworley@nvidia.com> Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-08-08zebra: Add a `mpls enable` interface node commandDonald Sharp
Allow individual interfaces to turn on/off the mpls subsystem for it in linux. sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls net.mpls.conf.enp39s0.input = 0 sharpd@eva:~/frr9$ vtysh -c "conf" -c "int enp39s0" -c "mpls enable" sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls net.mpls.conf.enp39s0.input = 1 sharpd@eva:~/frr9$ vtysh -c "conf" -c "int enp39s0" -c "no mpls enable" sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls net.mpls.conf.enp39s0.input = 0 sharpd@eva:~/frr9$ Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21zebra: Convert thread_cancel to THREAD_OFFDonald Sharp
Just convert all uses of thread_cancel to THREAD_OFF Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-30zebra: Realign SOL_NETLINK to warn when FRR does not have itDonald Sharp
There exists a possibility that an end operator has choosen to compile FRR on an extremely old KERNEL that does not support the SOL_NETLINK sockopt call. If so let's note it for them instead of stuff silently not working. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-30zebra: Correct implication of SOL_NETLINK NETLINK_ADD_MEMBERSHIP usageDonald Sharp
The usage of SOL_NETLINK for adding memberships of interest is 1 group per call. The netink_socket function implied that the call could be a bitfield of values. This is not correct at all. This will trip someone else up in the future when a new value is needed. Let's get it right `now` before it becomes a problem. Let's also add a bit of extra code to give operator a better understanding of what went wrong when a kernel does not support the option. Finally as a point of future reference should FRR just switch over to a loop to add the required loops instead of having this bastardized approach of some going in one way and some going in another way? Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-24zebra: netlink rtm tunnel msg parsingChirag Shah
'bridge vni add vni <id> dev <vxlan device>' generates new RTM_NEWTUNNEL and RTM_DELTUNNEL to add or remove vni to l3vxlan device. Register new RTNLGRP_TUNNEL group to receive new netlink notification. Callback for the new RTM_xxxTUNNEL. kernel patches: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/ linux.git/commit/?h=v5.18-rc7&id=7b8135f4df98b155b23754b6065c157861e268f1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/ linux.git/commit/?h=v5.18-rc7&id=f9c4bb0b245cee35ef66f75bf409c9573d934cf9 Ticket:#3073812 Testing Done: Signed-off-by: Donald Sharp <sharpd@nvidia.com> Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-31zebra: add error check condition to sock optionChirag Shah
Adding error checking condition which was missed in PR-11216. *** CID 1517953: Error handling issues (CHECKED_RETURN) /zebra/kernel_netlink.c: 313 in netlink_socket() 307 memset(&snl, 0, sizeof(snl)); 308 snl.nl_family = AF_NETLINK; 309 snl.nl_groups = groups; 310 311 #if defined SOL_NETLINK 312 if (ext_groups) >>> CID 1517953: Error handling issues (CHECKED_RETURN) >>> Calling "setsockopt(sock, 270, 1, &ext_groups, 8U)" without checking return value. This library function may fail and return an error code. 313 setsockopt(sock, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, 314 &ext_groups, sizeof(ext_groups)); 315 #endif 316 317 /* Bind the socket to the netlink structure for anything. */ 318 ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl)); Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-19Merge pull request #11216 from chiragshah6/fdev2Sri Mohana Singamsetty
zebra: netlink registry of rtm tunnel notification
2022-05-18zebra: Fix newline in log messageDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-18zebra: netlink registry rtm tunnel notifChirag Shah
The kernel supports l3vxlan device to have (l3vni) vni filter similar to vlan filtering on bridge device. To receive netlink notification, FRR to register for new netlink RTNLGRP_TUNNEL message. This message required to register via additional socket option as it's beyond bitmap size. kernel patches: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/ linux.git/commit/?h=v5.18-rc7&id=7b8135f4df98b155b23754b6065c157861e268f1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/ linux.git/commit/?h=v5.18-rc7&id=f9c4bb0b245cee35ef66f75bf409c9573d934cf9 Ticket:#3073812 Testing Done: Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-05-16zebra: new netlink parse utility for rtaChirag Shah
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-03-25zebra: Note when the netlink DUMP command is interruptedDonald Sharp
There exists code paths in the linux kernel where a dump command will be interrupted( I am not sure I understand what this really means ) and the data sent back from the kernel is wrong or incomplete. At this point in time I am not 100% certain what should be done, but let's start noticing that this has happened so we can formulate a plan or allow the end operator to know bad stuff is a foot at the circle K. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-09zebra: add command for setting protodown bitStephen Worley
Add command for use to set protodown via frr.conf in the case our default conflicts with another application they are using. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: add support for protodown reason codeStephen Worley
Add support for setting the protodown reason code. https://github.com/torvalds/linux/commit/829eb208e80d6db95c0201cb8fa00c2f9ad87faf These patches handle all our netlink code for setting the reason. For protodown reason we only set `frr` as the reason externally but internally we have more descriptive reasoning available via `show interface IFNAME`. The kernel only provides a bitwidth of 32 that all userspace programs have to share so this makes the most sense. Since this is new functionality, it needs to be added to the dplane pthread instead. So these patches, also move the protodown setting we were doing before into the dplane pthread. For this, we abstract it a bit more to make it a general interface LINK update dplane API. This API can be expanded to support gernal link creation/updating when/if someone ever adds that code. We also move a more common entrypoint for evpn-mh and from zapi clients like vrrpd. They both call common code now to set our internal flags for protodown and protodown reason. Also add debugging code for dumping netlink packets with protodown/protodown_reason. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-02-27zebra: Allow *BSD to specify a receive buffer sizeDonald Sharp
End operator is reporting that they are receiving buffer overruns when attempting to read from the kernel receive socket. It is possible to adjust this size to more modern levels especially for when the system is under load. Modify the code base so that *BSD operators can use the zebra `-s XXX` option to specify a read buffer. Additionally setup the default receive buffer size on *BSD to be 128k instead of the 8k so that FRR does not run into this issue again. Fixes: #10666 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-25zebra: use dataplane to read interface NETCONF infoMark Stapp
Use the dataplane to query and read interface NETCONF data; add netconf-oriented data to the dplane context object, and add accessors for it. Add handler for incoming update processing. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25zebra: add dplane type for NETCONF dataMark Stapp
Add a new dplane op for interface NETCONF data; add the new enum value to several switch statements. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25zebra: add xxxNETCONF messages to the netlink BPF filterMark Stapp
Allow self-produced xxxNETCONF netlink messages through the BPF filter we use. Just like address-configuration actions, we'll process NETCONF changes in one path, whether the changes were generated by zebra or by something else in the host OS. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25zebra: Start of work to get data about mpls from kernelDonald Sharp
a) We'll need to pass the info up via some dataplane control method (This way bsd and linux can both be zebra agnostic of each other) b) We'll need to modify `struct interface *` to track this data and when it changes to notify upper level protocols about it. c) Work is needed to dump the entire mpls state at the start so we can gather interface state. This should be done after interface data gathering from the kernel. Signed-off-by: Donald Sharp <sharpd@nvidia.com> Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-23*: Change thread->func to return void instead of intDonald Sharp
The int return value is never used. Modify the code base to just return a void instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-16Merge pull request #10561 from mjstapp/nlsock_hash_lockJafar Al-Gharaibeh
zebra: make netlink object hash threadsafe
2022-02-14zebra: Fix spelling mistakeDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-11zebra: make netlink object hash threadsafeMark Stapp
The recently-added hashtable of nlsock objects needs to be thread-safe: it's accessed from the main and dplane pthreads. Add a mutex for it, use wrapper apis when accessing it. Add a per-OS init/terminate api so we can do init that's not per-vrf or per-namespace. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-08zebra: Make netlink buffer reads resizeable when neededDonald Sharp
Currently when the kernel sends netlink messages to FRR the buffers to receive this data is of fixed length. The kernel, with certain configurations, will send netlink messages that are larger than this fixed length. This leads to situations where, on startup, zebra gets really confused about the state of the kernel. Effectively the current algorithm is this: read up to buffer in size while (data to parse) get netlink message header, look at size parse if you can The problem is that there is a 32k buffer we read. We get the first message that is say 1k in size, subtract that 1k to 31k left to parse. We then get the next header and notice that the length of the message is 33k. Which is obviously larger than what we read in. FRR has no recover mechanism nor is there a way to know, a priori, what the maximum size the kernel will send us. Modify FRR to look at the kernel message and see if the buffer is large enough, if not, make it large enough to read in the message. This code has to be per netlink socket because of the usage of pthreads. So add to `struct nlsock` the buffer and current buffer length. Growing it as necessary. Fixes: #10404 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-08zebra: Remove `struct nlsock` from dataplane information and use `int fd`Donald Sharp
Store the fd that corresponds to the appropriate `struct nlsock` and pass that around in the dplane context instead of the pointer to the nlsock. Modify the kernel_netlink.c code to store in a hash the `struct nlsock` with the socket fd as the key. Why do this? The dataplane context is used to pass around the `struct nlsock` but the zebra code has a bug where the received buffer for kernel netlink messages from the kernel is not big enough. So we need to dynamically grow the receive buffer per socket, instead of having a non-dynamic buffer that we read into. By passing around the fd we can look up the `struct nlsock` that will soon have the associated buffer and not have to worry about `const` issues that will arise. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-08zebra: Store the sequence number to use as part of the dp_infoDonald Sharp
Store and use the sequence number instead of using what is in the `struct nlsock`. Future commits are going away from storing the `struct nlsock` and the copy of the nlsock was guaranteeing unique sequence numbers per message. So let's store the sequence number to use instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-04Merge pull request #9926 from donaldsharp/update_issuesJafar Al-Gharaibeh
zebra: Fix v6 route replace failure turned into success
2022-02-04zebra: Fix v6 route replace failure turned into successDonald Sharp
Currently when we have a route replace operation for v6 routes with a new nexthop group the order of kernel installation is this: a) New nexthop group insertion seq 1 b) Route delete operation seq 3 c) Route insertion operation seq 2 Currently the code in nl_batch_read_resp is attempting to handle this situation by skipping the delete operation. *BUT* it is enqueuing the context into the zebra dplane queue before we read the response. Since we create the ctx with an implied success, success is being reported to the upper level dplane and the zebra rib thinks the route has been properly handled. This is showing up in the zebra_seg6_route test code because the test code is installing a seg6 route w/ sharpd and it is failing to install because the route's nexthop is rejected: First installation: 2021/10/29 09:28:10.218 ZEBRA: [JGWSB-SMNVE] dplane: incoming new work counter: 2 2021/10/29 09:28:10.218 ZEBRA: [Q52A7-211QJ] dplane enqueues 2 new work to provider 'Kernel' 2021/10/29 09:28:10.218 ZEBRA: [JVY1P-93VFY] dplane provider 'Kernel': processing 2021/10/29 09:28:10.218 ZEBRA: [TX9N0-9JKDF] ID (9) Dplane nexthop update ctx 0x56125390a820 op NH_INSTALL 2021/10/29 09:28:10.218 ZEBRA: [PM9ZJ-07RCP] 0:1::1/128 Dplane route update ctx 0x56125390add0 op ROUTE_INSTALL 2021/10/29 09:28:10.218 ZEBRA: [TJ327-ET8HE] netlink_send_msg: >> netlink message dump [sent] 2021/10/29 09:28:10.218 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=104 type=(104) NEWNEXTHOP flags=(0x0501) {REQUEST,DUMP,(ROOT|REPLACE|CAPPED),(ATOMIC|CREATE)} seq=9 pid=3539131282] 2021/10/29 09:28:10.218 ZEBRA: [WCX94-SW894] nhm [family=(10) AF_INET6 scope=(0) UNIVERSE protocol=(11) ZEBRA flags=0x00000000 {}] 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(1) ID] 2021/10/29 09:28:10.218 ZEBRA: [Z4E9C-GD9EP] 9 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=20 (payload=16) type=(6) GATEWAY] 2021/10/29 09:28:10.218 ZEBRA: [STTSM-27M81] 2001::1 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(5) OIF] 2021/10/29 09:28:10.218 ZEBRA: [JR4EA-BKPTA] 6 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=6 (payload=2) type=(7) ENCAP_TYPE] 2021/10/29 09:28:10.218 ZEBRA: [JR4EA-BKPTA] 5 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=36 (payload=32) type=(32776) UNKNOWN] 2021/10/29 09:28:10.218 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=64 type=(24) NEWROUTE flags=(0x0401) {REQUEST,(ATOMIC|CREATE)} seq=10 pid=3539131282] 2021/10/29 09:28:10.218 ZEBRA: [GCEGC-W8YBF] rtmsg [family=(10) AF_INET6 dstlen=128 srclen=0 tos=0 table=254 protocol=(194) UNKNOWN scope=(0) UNIVERSE type=(1) UNICAST flags=0x0000 {}] 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=20 (payload=16) type=(1) DST] 2021/10/29 09:28:10.218 ZEBRA: [STTSM-27M81] 1::1 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(6) PRIORITY] 2021/10/29 09:28:10.218 ZEBRA: [Z4E9C-GD9EP] 20 2021/10/29 09:28:10.218 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(30) NH_ID] 2021/10/29 09:28:10.218 ZEBRA: [Z4E9C-GD9EP] 9 2021/10/29 09:28:10.218 ZEBRA: [V8KNF-8EXH8] netlink_recv_msg: << netlink message dump [recv] 2021/10/29 09:28:10.218 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=76 type=(2) ERROR flags=(0x0300) {DUMP,(ROOT|REPLACE|CAPPED),(MATCH|EXCLUDE|ACK_TLVS)} seq=9 pid=3539131282] 2021/10/29 09:28:10.218 ZEBRA: [KWP1C-6CSXF] nlmsgerr [error=(-22) Invalid argument] 2021/10/29 09:28:10.218 ZEBRA: [HSYZM-HV7HF] Extended Error: Gateway can not be a local address 2021/10/29 09:28:10.218 ZEBRA: [WVJCK-PPMGD][EC 4043309093] netlink-dp (NS 0) error: Invalid argument, type=RTM_NEWNEXTHOP(104), seq=9, pid=3539131282 2021/10/29 09:28:10.218 ZEBRA: [V8KNF-8EXH8] netlink_recv_msg: << netlink message dump [recv] 2021/10/29 09:28:10.218 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=68 type=(2) ERROR flags=(0x0300) {DUMP,(ROOT|REPLACE|CAPPED),(MATCH|EXCLUDE|ACK_TLVS)} seq=10 pid=3539131282] 2021/10/29 09:28:10.218 ZEBRA: [KWP1C-6CSXF] nlmsgerr [error=(-22) Invalid argument] 2021/10/29 09:28:10.218 ZEBRA: [HSYZM-HV7HF] Extended Error: Nexthop id does not exist 2021/10/29 09:28:10.218 ZEBRA: [WVJCK-PPMGD][EC 4043309093] netlink-dp (NS 0) error: Invalid argument, type=RTM_NEWROUTE(24), seq=10, pid=3539131282 2021/10/29 09:28:10.218 ZEBRA: [VCDW6-A7ZF1] dplane dequeues 2 completed work from provider Kernel 2021/10/29 09:28:10.218 ZEBRA: [JTWAB-1MH4Y] dplane has 2 completed, 0 errors, for zebra main 2021/10/29 09:28:10.218 ZEBRA: [J7K9Z-9M7DT] Nexthop dplane ctx 0x56125390a820, op NH_INSTALL, nexthop ID (9), result FAILURE 2021/10/29 09:28:10.218 ZEBRA: [P2XBZ-RAFQ5][EC 4043309074] Failed to install Nexthop ID (9) into the kernel 2021/10/29 09:28:10.218 ZEBRA: [RMK34-61HV5] default(0:254):1::1/128 Processing dplane result ctx 0x56125390add0, op ROUTE_INSTALL result FAILURE Note the last line `op ROUTE_INSTALL result FAILURE` because we are attempting to use a a gw nexthop that is local. This is the result. Then the test code was installing the route again: 2021/10/29 09:30:00.493 ZEBRA: [JGWSB-SMNVE] dplane: incoming new work counter: 2 2021/10/29 09:30:00.493 ZEBRA: [Q52A7-211QJ] dplane enqueues 2 new work to provider 'Kernel' 2021/10/29 09:30:00.493 ZEBRA: [JVY1P-93VFY] dplane provider 'Kernel': processing 2021/10/29 09:30:00.493 ZEBRA: [TX9N0-9JKDF] ID (9) Dplane nexthop update ctx 0x561253916a00 op NH_INSTALL 2021/10/29 09:30:00.493 ZEBRA: [PM9ZJ-07RCP] 0:1::1/128 Dplane route update ctx 0x561253915f40 op ROUTE_UPDATE 2021/10/29 09:30:00.493 ZEBRA: [TJ327-ET8HE] netlink_send_msg: >> netlink message dump [sent] 2021/10/29 09:30:00.493 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=104 type=(104) NEWNEXTHOP flags=(0x0501) {REQUEST,DUMP,(ROOT|REPLACE|CAPPED),(ATOMIC|CREATE)} seq=11 pid=3539131282] 2021/10/29 09:30:00.493 ZEBRA: [WCX94-SW894] nhm [family=(10) AF_INET6 scope=(0) UNIVERSE protocol=(11) ZEBRA flags=0x00000000 {}] 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(1) ID] 2021/10/29 09:30:00.493 ZEBRA: [Z4E9C-GD9EP] 9 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=20 (payload=16) type=(6) GATEWAY] 2021/10/29 09:30:00.493 ZEBRA: [STTSM-27M81] 2001::1 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(5) OIF] 2021/10/29 09:30:00.493 ZEBRA: [JR4EA-BKPTA] 6 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=6 (payload=2) type=(7) ENCAP_TYPE] 2021/10/29 09:30:00.493 ZEBRA: [JR4EA-BKPTA] 5 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=36 (payload=32) type=(32776) UNKNOWN] 2021/10/29 09:30:00.493 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=56 type=(25) DELROUTE flags=(0x0401) {REQUEST,(ATOMIC|CREATE)} seq=13 pid=3539131282] 2021/10/29 09:30:00.493 ZEBRA: [GCEGC-W8YBF] rtmsg [family=(10) AF_INET6 dstlen=128 srclen=0 tos=0 table=254 protocol=(194) UNKNOWN scope=(0) UNIVERSE type=(0) UNSPEC flags=0x0000 {}] 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=20 (payload=16) type=(1) DST] 2021/10/29 09:30:00.493 ZEBRA: [STTSM-27M81] 1::1 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(6) PRIORITY] 2021/10/29 09:30:00.493 ZEBRA: [Z4E9C-GD9EP] 20 2021/10/29 09:30:00.493 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=64 type=(24) NEWROUTE flags=(0x0401) {REQUEST,(ATOMIC|CREATE)} seq=12 pid=3539131282] 2021/10/29 09:30:00.493 ZEBRA: [GCEGC-W8YBF] rtmsg [family=(10) AF_INET6 dstlen=128 srclen=0 tos=0 table=254 protocol=(194) UNKNOWN scope=(0) UNIVERSE type=(1) UNICAST flags=0x0000 {}] 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=20 (payload=16) type=(1) DST] 2021/10/29 09:30:00.493 ZEBRA: [STTSM-27M81] 1::1 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(6) PRIORITY] 2021/10/29 09:30:00.493 ZEBRA: [Z4E9C-GD9EP] 20 2021/10/29 09:30:00.493 ZEBRA: [KFBSR-XYJV1] rta [len=8 (payload=4) type=(30) NH_ID] 2021/10/29 09:30:00.493 ZEBRA: [Z4E9C-GD9EP] 9 2021/10/29 09:30:00.493 ZEBRA: [V8KNF-8EXH8] netlink_recv_msg: << netlink message dump [recv] 2021/10/29 09:30:00.493 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=76 type=(2) ERROR flags=(0x0300) {DUMP,(ROOT|REPLACE|CAPPED),(MATCH|EXCLUDE|ACK_TLVS)} seq=11 pid=3539131282] 2021/10/29 09:30:00.493 ZEBRA: [KWP1C-6CSXF] nlmsgerr [error=(-22) Invalid argument] 2021/10/29 09:30:00.493 ZEBRA: [HSYZM-HV7HF] Extended Error: Gateway can not be a local address 2021/10/29 09:30:00.493 ZEBRA: [WVJCK-PPMGD][EC 4043309093] netlink-dp (NS 0) error: Invalid argument, type=RTM_NEWNEXTHOP(104), seq=11, pid=3539131282 2021/10/29 09:30:00.493 ZEBRA: [V8KNF-8EXH8] netlink_recv_msg: << netlink message dump [recv] 2021/10/29 09:30:00.493 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=36 type=(2) ERROR flags=(0x0100) {DUMP,(ROOT|REPLACE|CAPPED)} seq=13 pid=3539131282] 2021/10/29 09:30:00.493 ZEBRA: [KWP1C-6CSXF] nlmsgerr [error=(-3) No such process] 2021/10/29 09:30:00.493 ZEBRA: [V8KNF-8EXH8] netlink_recv_msg: << netlink message dump [recv] 2021/10/29 09:30:00.493 ZEBRA: [JAS4D-NCWGP] nlmsghdr [len=68 type=(2) ERROR flags=(0x0300) {DUMP,(ROOT|REPLACE|CAPPED),(MATCH|EXCLUDE|ACK_TLVS)} seq=12 pid=3539131282] 2021/10/29 09:30:00.493 ZEBRA: [KWP1C-6CSXF] nlmsgerr [error=(-22) Invalid argument] 2021/10/29 09:30:00.493 ZEBRA: [VCDW6-A7ZF1] dplane dequeues 2 completed work from provider Kernel 2021/10/29 09:30:00.493 ZEBRA: [JTWAB-1MH4Y] dplane has 2 completed, 0 errors, for zebra main 2021/10/29 09:30:00.493 ZEBRA: [J7K9Z-9M7DT] Nexthop dplane ctx 0x561253916a00, op NH_INSTALL, nexthop ID (9), result FAILURE 2021/10/29 09:30:00.493 ZEBRA: [P2XBZ-RAFQ5][EC 4043309074] Failed to install Nexthop ID (9) into the kernel 2021/10/29 09:30:00.493 ZEBRA: [RMK34-61HV5] default(0:254):1::1/128 Processing dplane result ctx 0x561253915f40, op ROUTE_UPDATE result SUCCESS Note that this time we do these three operations a) nexthop installation seq 11 b) route delete seq 13 c) route add seq 12 Note the last line, we report the install as a success but it clearly failed from the seq=12 decode. When we look at the v6 rib it thinks it is installed: unet> r1 show ipv6 route Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure D>* 1::1/128 [150/0] via 2001::1, dum0, seg6local unspec unknown(seg6local_context2str), seg6 a::, weight 1, 00:00:17 So let's modify nl_batch_read_resp to not dequeue/enqueue the context until we are sure we have the right one. This fixes the test code to do the right thing on the second installation. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-04zebra: When we get an implicit or ack or full failure mark statusDonald Sharp
When nl_batch_read_resp gets a full on failure -1 or an implicit ack 0 from the kernel for a batch of code. Let's immediately mark all of those in the batch pass/fail as needed. Instead of having them marked else where. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-01zebra: reduce incoming netlink messages for dplane threadMark Stapp
The dataplane pthread only processes a limited set of incoming netlink notifications: only register for that set of events, reducing duplicate incoming netlink messages. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-01-17zebra: remove netlink buffer size log messageDavid Lamparter
... really not much point in printing this. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-04zebra: Use a bool for startup indicationsDonald Sharp
Let's not pass around an int startup when all we are doing is true/falsing it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-14zebra: use the dataplane to read netlink intf addr changesMark Stapp
Read incoming interface address change notifications in the dplane pthread; enqueue the events to the main pthread for processing. This is netlink-only for now - the bsd kernel socket path remains unchanged. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-14zebra: add new dplane op codes for interface addr eventsMark Stapp
Add new dplane op values for incoming interface address add and delete events. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-14zebra: use uint32_t instead of __u32Mark Stapp
Use more consistent int type. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-14zebra: add inbound netlink socket for dataplaneMark Stapp
Add a new netlink socket for events coming in from the host OS to the dataplane system for processing. Rename the existing outbound dplane socket. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-08-17zebra: RTM_GETNEIGH messages may be used by nhrpPhilippe Guibert
When NHRP registers to zebra to receive link layer events related to gre interfaces, then it is interested in receiving also RTM_GETNEIGH messages. Fixes ("b3b751046495") nhrpd: link layer registration to notifications Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-07-08zebra: Add nl_attr_put8 so we can put uint8_t in netlink messagesDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-11zebra: memset the `struct rtattr *tb[SIZE]` in setting functionDonald Sharp
In order to parse the netlink message into the `struct rtattr *tb[size]` it is assumed that the buffer is memset to 0 before the parsing. As such if you attempt to read a value that was not returned in the message you will not crash when you test for it. The code has places were we memset it and places where we don't. This *will* lead to crashes when the kernel changes. In our parsing routines let's have them memset instead of having to remember to do it pre pass in to the parser. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-30zebra: new dplane action to set gre link interfacePhilippe Guibert
This action is initiated by nhrp and has been stubbed when moving to zebra. Now, a netlink request is forged to set the link interface of a gre interface if that gre interface does not have already a link interface. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09zebra: move neighbor table configuration to dplane contextsPhilippe Guibert
Instead of directly configuring the neighbor table after read from zapi interface, a zebra dplane context is prepared to host the interface and the family where the neighbor table is updated. Also, some other fields are hosted: app_probes, ucast_probes, and mcast_probes. More information on those fields can be found on ip-ntable configuration. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09zebra, lib: handle NEIGH_ADD/DELETE to zebra dataplane frameworkPhilippe Guibert
EVPN neighbor operations were already done in the zebra dataplane framework. Now that NHRP is able to use zebra to perform neighbor IP operations (by programming link IP operations), handle this operation under dataplane framework: - assign two new operations NEIGH_IP_INSTALL and NEIGH_IP_DELETE; this is reserved for GRE like interfaces: example: ip neigh add A.B.C.D lladdr E.F.G.H - use 'struct ipaddr' to store and encode the link ip address - reuse dplane_neigh_info, and create an union with mac address - reuse the protocol type and use it for neighbor operations; this permits to store the daemon originating this neighbor operation. a new route type is created: ZEBRA_ROUTE_NEIGH. - the netlink level functions will handle a pointer, and a type; the type indicates the family of the pointer: AF_INET or AF_INET6 if the link type is an ip address, mac address otherwise. - to keep backward compatibility with old queries, as no extension was done, an option NEIGH_NO_EXTENSION has been put in place - also, 2 new state flags are used: NUD_PERMANENT and NUD_FAILED. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-03-22zebra: kill zebra_memory.h, use MTYPE_STATICDavid Lamparter
This one also needed a bit of shuffling around, but MTYPE_RE is the only one left used across file boundaries now. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-10zebra: move ipset and ipset_entry to zebra dplane contextsPhilippe Guibert
like it has been done for iptable contexts, a zebra dplane context is created for each ipset/ipset entry event. The zebra_dplane_ctx job is then enqueued and processed by separate thread. Like it has been done for zebra_pbr_iptable context, the ipset and ipset entry contexts are encapsulated into an union of structures in zebra_dplane_ctx. There is a specificity in that when storing ipset_entry structure, there was a backpointer pointer to the ipset structure that is necessary to get some complementary information before calling the hook. The proposal is to use an ipset_entry_info structure next to the ipset_entry, in the zebra_dplane context. That information is used for ipset_entry processing. The ipset name and the ipset type are the only fields necessary. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-03-04zebra: move iptable handling in zebra_dplanePhilippe Guibert
The iptable processing was not handled in remote dataplane, and was directly processed by the thread in charge of zapi calls. Now that call can be handled in the zebra_dplane separate thread. once a zebra_dplane_ctx is allocated for iptable handling, the hook call is performed later. Subsequently, a return code may be triggered to zclient interface if any problem occurs when calling the hook call. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-02-14*: remove tabs & newlines from log messagesDavid Lamparter
Neither tabs nor newlines are acceptable in syslog messages. They also break line-based parsing of file logs. Signed-off-by: David Lamparter <equinox@diac24.net>