summaryrefslogtreecommitdiff
path: root/zebra/rtadv.c
AgeCommit message (Collapse)Author
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-12-17zebra: Notice Optional Router Advertisement types that are not handledDonald Sharp
Currently when zebra receives a RA with optional types, note the optional types that we are ignoring. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-26build, vtysh: extract vtysh commands from .xrefDavid Lamparter
Rather than running selected source files through the preprocessor and a bunch of perl regex'ing to get the list of all DEFUNs, use the data collected in frr.xref. This not only eliminates issues we've been having with preprocessor failures due to nonexistent header files, but is also much faster. Where extract.pl would take 5s, this now finishes in 0.2s. And since this is a non-parallelizable build step towards the end of the build (dependent on a lot of other things being done already), the speedup is actually noticeable. Also files containing CLI no longer need to be listed in `vtysh_scan` since the .xref data covers everything. `#ifndef VTYSH_EXTRACT_PL` checks are equally obsolete. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-04zebra: ignore unspec RetransTimer in RA validationTrey Aspelund
Section 6.2.7 of RFC 4861 states that a router SHOULD log inconsistencies in RA information detected on a given link: ``` - Cur Hop Limit values (except for the unspecified value of zero other inconsistencies SHOULD be logged to system network management). - Values of the M or O flags. - Reachable Time values (except for the unspecified value of zero). - Retrans Timer values (except for the unspecified value of zero). - Values in the MTU options. - Preferred and Valid Lifetimes for the same prefix. If AdvPreferredLifetime and/or AdvValidLifetime decrement in real time as specified in Section 6.2.1 then the comparison of the lifetimes cannot compare the content of the fields in the Router Advertisement, but must instead compare the time at which the prefix will become deprecated and invalidated, respectively. Due to link propagation delays and potentially poorly synchronized clocks between the routers such comparison SHOULD allow some time skew. ``` We were not logging inconsistencies if "the unspecified value of zero" was used for Reachable Time but were logging them for Retrans Timer. This updates the validation check to also skip the logging of Retrans Timer inconsistencies if either local/rx value is 0. Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-10-04zebra: show local/rx values in RA mismatch debugsTrey Aspelund
When we process a received Router Advertisement we have some logic in place to detect and log mismatches in a handful of flags/values. However, these logs do not include what the actual values are, which means it's up to the operator to grab a packet capture and compare that against the local configuration... So let's make life a little easier by including those in the log itself. Before: ``` 2022/09/30 20:37:16 ZEBRA: [KV2V1-7GM7G][EC 4043309149] enp1s0(2): Rx RA - our AdvCurHopLimit doesn't agree with fe80::5054:ff:feca:b085 2022/09/30 20:37:16 ZEBRA: [KS0BP-4GR8K][EC 4043309149] enp1s0(2): Rx RA - our AdvManagedFlag doesn't agree with fe80::5054:ff:feca:b085 2022/09/30 20:37:16 ZEBRA: [RE4EC-VYEJ2][EC 4043309149] enp1s0(2): Rx RA - our AdvOtherConfigFlag doesn't agree with fe80::5054:ff:feca:b085 2022/09/30 20:37:16 ZEBRA: [X6794-9MW18][EC 4043309149] enp1s0(2): Rx RA - our AdvReachableTime doesn't agree with fe80::5054:ff:feca:b085 2022/09/30 20:37:16 ZEBRA: [S1KXC-H8F4W][EC 4043309149] enp1s0(2): Rx RA - our AdvRetransTimer doesn't agree with fe80::5054:ff:feca:b085 ``` After: ``` Sep 30 20:45:18 ub20-2 zebra[47487]: [GSW5Z-V7DZN][EC 4043309149] enp1s0(2): Rx RA - our AdvCurHopLimit (14) doesn't agree with fe80::5054:ff:fe9a:e2ca (64) Sep 30 20:45:18 ub20-2 zebra[47487]: [RHHTS-F96DR][EC 4043309149] enp1s0(2): Rx RA - our AdvManagedFlag (0) doesn't agree with fe80::5054:ff:fe9a:e2ca (1) Sep 30 20:45:18 ub20-2 zebra[47487]: [MNBY3-FTN6W][EC 4043309149] enp1s0(2): Rx RA - our AdvOtherConfigFlag (0) doesn't agree with fe80::5054:ff:fe9a:e2ca (1) Sep 30 20:45:18 ub20-2 zebra[47487]: [GG62B-XXWR0][EC 4043309149] enp1s0(2): Rx RA - our AdvReachableTime (20) doesn't agree with fe80::5054:ff:fe9a:e2ca (777) Sep 30 20:45:18 ub20-2 zebra[47487]: [YG220-D6B4H][EC 4043309149] enp1s0(2): Rx RA - our AdvRetransTimer (13) doesn't agree with fe80::5054:ff:fe9a:e2ca (0) ``` Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-09-23zebra: changes for code maintainabilitysri-mohan1
these changes are for improving the code maintainability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-07-19zebra: Add some more data to rtadv socket failuresDonald Sharp
The creation of the rtadv socket can fail but there is very very little data associated with this event to let the operator know something has gone terribly wrong. Please note if this socket fails to create or fails the setsockopt's rtadv is basically just really really messed up. I am not sure what can be done here. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-24zebra: Fix rtadv startup when config read in is before interface upDonald Sharp
When a interface is configured with this: int eva ipv6 nd ra-interval 5 no ipv6 nd suppress-ra ! And then subsuquently the interface is created and brought up, FRR would both error on joining the RA multicast address and never properly work in this state. Delay the startup of the join and start of the Router Advertisements until after the ifindex has actually been found. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-21zebra: clean up rtadv integrationDavid Lamparter
Move a few things into places they actually belong, and reduce the number of places we have `#ifdev HAVE_RTADV`. Just overall code prettification. ... I had actually done this quite a while ago while doing some other random hacking and thought it more useful to not be sitting on it on my disk... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-31zebra: don't send RAs w/o LLv6 or on bridge-portsTrey Aspelund
It's confusing for a user to see 'Tx RA failed' in the logs when they've enabled RAs (either through interface config or BGP unnumbered) on an interface that can't send them. Let's avoid sending RAs on interfaces that are bridge_slaves or don't have a link-local address, since they are the two of the most common reasons for RA Tx failures. Signed-off-by: Trey Aspelund <taspelund@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-04Merge pull request #10501 from donaldsharp/more_zebra_showJafar Al-Gharaibeh
More zebra show
2022-02-04zebra: Add knowledge about RA and RFC 5549 to `show zebra`Donald Sharp
Add to `show zebra` whether or not RA is compiled into FRR and whether or not BGP is using RFC 5549 at the moment. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-28zebra: Make Router Advertisement warnings show up once every 6 hoursDonald Sharp
RA packets are pretty chatty and when there is a warning from a missconfiguration on the network, the log file gets filed up with warnings. Modify the code in rtadv.c to only spit out the warning in these cases at most every 6 hours. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-22*: cleanup ifp->vrf_idIgor Ryzhov
Since f60a1188 we store a pointer to the VRF in the interface structure. There's no need anymore to store a separate vrf_id field. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-16*: unify if_is_loopback/if_is_loopback_or_vrfIgor Ryzhov
We should always treat the VRF interface as a loopback. Currently, this is not the case, because in some old pre-VRF code we use if_is_loopback instead of if_is_loopback_or_vrf. To avoid any future problems, the proposal is to rename if_is_loopback_or_vrf to if_is_loopback and use it everywhere. if_is_loopback is renamed to if_is_loopback_exact in case it's ever needed, but currently it's not used anywhere. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-05zebar: Fix the RA sent fail in netns modeLEI BAO
Make the code more explicit. Signed-off-by: LEI BAO <bali.baolei@cn.ibm.com>
2021-11-05zebra: Fix the RA send failed in netns modeLEI BAO
In the rtadv_timer(), it always uses the zvrf's socket to send RA packets. In the vrf-lite mode, it's righ since it uses the default vrf to send the RA packets. But in the netns mode, it uses socket in each netns. So the issue only happens in the netns mode because the zvrf's socket may not be in the same netns as the interface's netns. In order to compatible with both vrf-lite and netns mode, the fix uses the if_lookup_by_index() to check whether interfaces can use the zvrf's socket. Signed-off-by: LEI BAO <bali.baolei@cn.ibm.com>
2021-11-02zebra: Fix the RA packets can not sent outLEI BAO
Skip the interfaces which not belong to the same VRF as the current thread's zvrf. Signed-off-by: LEI BAO <bali.baolei@cn.ibm.com>
2021-09-30*: cleanup interface loopback/vrf checkIgor Ryzhov
There's a helper function to check whether the interface is loopback or VRF - if_is_loopback_or_vrf. Let's use it whenever we need to check that. There's no functional change in this commit. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-01*: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLENDonatas Abraitis
Just drop IPV6_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-08zebra: print adv_if count with %zuStephen Worley
Use the %zu formatter for adv_if count printing for portability. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2021-06-08zebra: add show command for RA interface listsStephen Worley
Add a show command so we can easily get info on what interfaces are turned on per ver and in which list. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2021-06-08zebra: rework RA handling for vrf-liteStephen Worley
Rework RA handling for vrf-lite scenarios. Before we were using a single FD descriptor for polling across multiple zvrf's. This would cause us to hit this assert() in some bgp unnumbered and vrrp configs: ``` /* * What happens if we have a thread already * created for this event? */ if (thread_array[fd]) assert(!"Thread already scheduled for file descriptor"); ``` We were scheduling a thread_read on the same FD for every zvrf. With vrf-lite, RAs and ARPs are not vrf-bound, so we can just use one rtadv instance to manage them for all VRFs. We will choose the default VRF for this. This patch removes the rtadv_sock altogether for zrouter and moves the functionality this represented to the default VRF. All RAs will be handled in the default VRF under vrf-lite configs with only one poll thread started for it. This patch also extends how we track subscribed interfaces (s or msec) to use an actual sorted list by interface names rather than just a counter. With multiple daemons turning interfaces/on/off these counters can get very wrong during ifup/down events. Making them a sorted list prevents this from happening by preventing duplicates. With netns-vrf's nothing should change other than the interface list. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2021-04-28lib, bgpd, zebra: RA interval is unsignedQuentin Young
Use unsigned value for all RA requests to Zebra - encoding signed int as unsigned is bad practice - RA interval is never, and should never be, negative Signed-off-by: Quentin Young <qlyoung@nvidia.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>
2020-10-22:* Convert prefix2str to %pFXDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@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-05-21zebra: Allow zebra to gracefully handle rtadv when not configuredDonald Sharp
Currently zebra when you compile without router advertisements will just say something like `cannot handle message 42`. Which is not terribly useful to an end user. Add some smarts to the zapi message handling to just do nothing and output a debug if someone has it turned on. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-21zebra: allow rtadv.c to compile with `--enable-rtadv=no`Donald Sharp
The rtadv.c code was not properly compiling if you turned off router advertisements in zebra. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08zebra: Remove enum around ipv6_nd_suppress_ra_statusDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-29zebra: add ability to set retransmit timer for IPv6 RAsDon Slice
Reported by testing agency that rfc 4861 section 6.2.1 states that all implementations must have a configuration knob to change the setting of the advertised retransmit timer sent in RA packets. This fix adds that capability. Ticket: CM-29199 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2020-04-15zebra: add ability to set hoplimit for IPv6 RAsDon Slice
Reported by testing agency that rfc 4861 section 6.2.1 states that all implementations must have a configuration knob to change the setting of the advertised hop limit. This fix adds that capability. Ticket: CM-29200 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2020-04-02zebra: Add some vrf information to RA logsDonald Sharp
Add some data about what vrf we are operating on in the RA logs. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-02zebra: Don't kill the global rtadv socket when a vrf is deletedDonald Sharp
The rtadv code has two types of sockets: a) namespace -> Where each zvrf get's it's own socket b) vrf lite -> Where we get 1 socket for everything When we were terminating a vrf we were *always* killing the (b) socket. This is a mistake in that other vrf's may need to be communicating. Modify the code on vrf shutdown to only disable that vrf's event processing and when we actually terminate we shut the socket. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-10zebra: delete ipv6 RA prefix entries when zebra is killedDon Slice
Memory leak found where ipv6 global prefixes added to the router advertisement prefix lists were not deleted when the process was killed. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
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-18zebra: fix missing rtadv stub functionsMark Stapp
Add in a few missing stub route-advert functions; these are needed to build frr with v6 route adverts disabled. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-14zebra: add all ipv6 global addresses to RA messagesDon Slice
RFC 4861 states that ipv6 RA messages sent out an interface should contain all global ipv6 addresses on that interface. This fix adds that capability. To override the default flags and timer settings for a particular prefix, the existing "ipv6 nd prefix ..." command should be used via vtysh under the appropriate interface. Ticket: CM-20363 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2020-01-03zebra: disallow negative rtadv intvl, fix overflowQuentin Young
- Disallow RA interval < 0 - Fix integer overflow issue converting interval to seconds from milliseconds - Add missing "m" to "ms" Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-03zebra: send RA lifetime of 0 before ceasing to advertise RAsDon Slice
Problem reported by testing agency that RFC4861 section 6.2.5 states that a router should send an RA with a lifetime of 0 before ceasing to send RAs on the interface, or when the interace is shutdown, or the router is shutdown. This fix adds that capability. Ticket: CM-27061 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-12-02*: generously apply constDavid Lamparter
const const const your boat, merrily down the stream... Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-22zebra: knob to make ra retransmit interval rfc compliantDon Slice
Problem reported by testing facility that our sending of Router Advertisements more frequently than once very three seconds is not compliant with rfc4861. Added a knob to turn off fast retransmits in order to meet the requirement of the RFC. Ticket: CM-27063 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>