Commit Graph

142 Commits

Author SHA1 Message Date
Donald Sharp
effee18744 ospfd: Fix quick interface down up event handling in ospf
When we get this sequence of events:

- zebra receives interface up, sends to ospf
- ospf receives intf up, processes( including neighbor formation and spf )
  and sends route to zebra for installation.
- zebra receives route for processing, schedules it too happen in the future
- zebra receives interface down event, sends to ospf
- zebra processes route X and marks it inactive because nexthop
  interface is down
- zebra receives interface up event, sends to ospf
- ospf receives both events and processes the change and decides
  that nothing has changed so it does not send any route change for X to zebra.

At this point zebra has a route from ospf that is marked as inactive, while
ospf believes that the route should be installed properly.

Modify the code such that on an interface down event, ospf marks the routes
as changed if the ifindex is being used for a nexthop, so that when ospf
is deciding if routes have changed post spf that it can just automatically
send that route down again if it still exists.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-25 14:43:40 -04:00
Jafar Al-Gharaibeh
d75213d260
Merge pull request #8153 from reubendowle/nhrp-multicast
nhrp, ospf: add nhrp multicast for OSPF DMVPN
2021-04-13 12:49:28 -05:00
Rafael Zalamena
e2134a79ee ospfd: fix crash on interface/vrf removal
The interface parameters deletion must be called before
`route_table_finish` due to the usage of the route data structures to
search neighbors in the same interface. If the route info is removed
before that we get the following crash:

```
 6  0x00007f5c6ed50394 in core_handler at lib/sigevent.c:255
 7  <signal handler called>
 8  ospf_interface_bfd_apply (ifp=<optimized out>) at ospfd/ospf_bfd.c:130
 9  0x000055d4c306d076 in ospf_interface_disable_bfd at ospfd/ospf_bfd.c:159
 10 0x000055d4c3071781 in ospf_del_if_params at ospfd/ospf_interface.c:553
 11 0x000055d4c3071900 in ospf_if_delete_hook at ospfd/ospf_interface.c:704
 12 0x00007f5c6ed17935 in hook_call_if_del at lib/if.c:59
 13 if_delete_retain at lib/if.c:290
 14 0x00007f5c6ed19bc5 in if_delete at lib/if.c:313
 15 0x00007f5c6ed19d88 in if_terminate at lib/if.c:1067
 16 0x00007f5c6ed63a04 in vrf_delete at lib/vrf.c:297
 17 0x00007f5c6ed76784 in zclient_vrf_delete at lib/zclient.c:1974
 18 zclient_read at lib/zclient.c:3686
 19 0x00007f5c6ed60f85 in thread_call at lib/thread.c:1815
 20 0x00007f5c6ed20228 in frr_run at lib/libfrr.c:1149
 21 0x000055d4c306bc70 in main at ospfd/ospf_main.c:233
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-04-09 10:54:23 -03:00
Amol Lad
bc97889b39 ospfd: Support use of ospf with DMVPN
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:22:59 +12:00
Igor Ryzhov
cbf32f74ef ospfd: fix counting of "ip ospf area" commands
Instead of trying to maintain if_ospf_cli_count, let's directly count
the number of configured interfaces when it is needed. Current approach
sometimes leads to an incorrect counter.

Fixes #8321.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-30 11:51:21 +03:00
Rafael Zalamena
659f4e40dd ospfd: rework BFD integration
Use new BFD API to integrate with OSPFv2.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-03-23 10:18:42 -03:00
David Lamparter
96244aca23 *: require semicolon after DEFINE_QOBJ & co.
Again, see previous commits.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:37 +01:00
David Lamparter
8451921b70 *: require semicolon after DEFINE_HOOK & co.
See previous commit.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
Donald Sharp
2655301da7 ospfd: Set Curr_mtu to when we get the mtu
Currently if you start ospfd, bring up neighbors and then issue
a tcpdump on a interface ospf is peering over, this causes the neighbor
relationship to be restarted:

root@spectrum301(mlx-4600c-01):mgmt:~# tcpdump -i vlan402
2020-11-13T21:25:38.059671+00:00 spectrum301 ospfd[29953]: AdjChg: Nbr 202.0.0.3(default) on vlan402:200.0.3.1: Full -> Deleted (KillNbr)
2020-11-13T21:25:38.065520+00:00 spectrum301 ospfd[29953]: ospfTrapNbrStateChange: trap sent: 200.0.3.2 now Deleted/DROther
2020-11-13T21:25:38.065922+00:00 spectrum301 ospfd[29953]: ospfTrapIfStateChange: trap sent: 200.0.3.1 now Down
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on vlan402, link-type EN10MB (Ethernet), capture size 262144 bytes
21:25:38.072330 IP 200.0.3.1 > igmp.mcast.net: igmp v3 report, 1 group record(s)
2020-11-13T21:25:38.080430+00:00 spectrum301 ospfd[29953]: ospfTrapIfStateChange: trap sent: 200.0.3.1 now Point-To-Point
2020-11-13T21:25:38.080654+00:00 spectrum301 ospfd[29953]: SPF Processing Time(usecs): 9734
2020-11-13T21:25:38.080829+00:00 spectrum301 ospfd[29953]:             SPF Time: 6422
2020-11-13T21:25:38.080991+00:00 spectrum301 ospfd[29953]:            InterArea: 1572
2020-11-13T21:25:38.081152+00:00 spectrum301 ospfd[29953]:                Prune: 67
2020-11-13T21:25:38.081329+00:00 spectrum301 ospfd[29953]:         RouteInstall: 1396
2020-11-13T21:25:38.081548+00:00 spectrum301 ospfd[29953]: Reason(s) for SPF: N, S, ABR, ASBR
21:25:38.092510 IP 200.0.3.1 > ospf-all.mcast.net: OSPFv2, Hello, length 44

This is happening because the curr_mtu is not being properly stored.  It was being set
on interface creation( but we have not actually read in the mtu part of the interface data, so
it is still 0 ).

Modify the code to store the curr_mtu at a point in interface creation *After* we have read
in interface data.

Ticket: CM-32276
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-02 06:55:31 -05:00
Santosh P K
5a066545da
Merge pull request #7301 from idryzhov/ospf-fixes
many ospfd fixes
2020-10-28 20:26:02 +05:30
Mark Stapp
96b663a381 ospfd: replace inet_ntoa
Stop using inet_ntoa, use %pI4 etc or inet_ntop instead

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 13:37:25 -04:00
Igor Ryzhov
cbf1568110 ospfd: correctly process interface creation/destruction
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-14 02:22:16 +03:00
Igor Ryzhov
bf617538be ospfd: fix missing initialization and check for if_area param
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-13 22:53:02 +03:00
Igor Ryzhov
2917d36bf9 ospfd: fix freeing of if_params struct
Freeing of configuration structure should not depend on operational
variable.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-13 22:52:12 +03:00
rgirada
df074ec33a ospfd: GR helper exit scenarios
Description:
	The follwoing helper exit scenarios are handled.
	1. Recv Max age grace LSA from RESTARTER.
	2. Grace timer expiry.
	3. Due to topo change if lsa check is enabled.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2020-09-22 00:02:37 -07:00
Kaushik
182d6bdc16 ospfd : Fix for ospf dead interval and hello due.
1. Ospf dead-interval will be set as 4 times of hello-interval, incase
if it is not set by using "ip ospf dead-interval <dead-val>".
2. On resetting hello-interval using "no ip ospf hello-interval" the
dead interval and hello due will be changed accordingly.

Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-09-19 00:29:25 -07:00
Renato Westphal
beb91114ec
Merge pull request #6789 from volta-networks/feat_ldp_igp_sync
ldpd: Add support for LDP-IGP Synchronization
2020-09-11 15:55:04 -03:00
lynne
132a782eb8 ospfd: ldp-igp-sync feature: adding ospf support
Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-09-09 14:38:44 -04:00
GalaxyGorilla
1d376ff539 ospfd: introduce a 'dry run' into SPF code
in OSPF interface data is used for the nexthop resolution
during the SPF algorithm, see RFC2328 16.1.1. However, for
certain technologies like TI-LFA it is desirable to be able
to calculate SPFs for arbitrary root nodes, not just the
calculating node. Since interface data is not available for
other nodes it is necessary to remove this dependency and
make its usage optional, depending on the intent of
changing the RIB with the generated tree (or not).

To signal that a SPF run is used without the intent to
change the RIB an additional flag `spf_dry_run` is
introduced to the ospf_area struct. This flag is currently
only used within the pure SPF code but will be extended
to the SPF postprocessing later on.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-08-18 10:58:45 +00:00
David Lamparter
3efd0893d0 *: un-split strings across lines
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-07-14 10:37:25 +02:00
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Donatas Abraitis
975a328e2e *: Replace s_addr 0 => INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06 09:00:12 +02:00
Quentin Young
b3ba5dc7fe *: don't null after XFREE; XFREE does this itself
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03 11:22:13 -05:00
Donald Sharp
7a004ccfd6 ospfd: Prevent use after free on shutdown
Address Sanitizer is reporting this issue:

==26177==ERROR: AddressSanitizer: heap-use-after-free on address 0x6120000238d8 at pc 0x7f88f7c4fa93 bp 0x7fff9a641830 sp 0x7fff9a641820
READ of size 8 at 0x6120000238d8 thread T0
    #0 0x7f88f7c4fa92 in if_delete lib/if.c:290
    #1 0x42192e in ospf_vl_if_delete ospfd/ospf_interface.c:912
    #2 0x42192e in ospf_vl_delete ospfd/ospf_interface.c:990
    #3 0x4a6208 in no_ospf_area_vlink ospfd/ospf_vty.c:1227
    #4 0x7f88f7c1553d in cmd_execute_command_real lib/command.c:1073
    #5 0x7f88f7c19b1e in cmd_execute_command lib/command.c:1132
    #6 0x7f88f7c19e8e in cmd_execute lib/command.c:1288
    #7 0x7f88f7cd7523 in vty_command lib/vty.c:516
    #8 0x7f88f7cd79ff in vty_execute lib/vty.c:1285
    #9 0x7f88f7cde4f9 in vtysh_read lib/vty.c:2119
    #10 0x7f88f7ccb845 in thread_call lib/thread.c:1549
    #11 0x7f88f7c5d6a7 in frr_run lib/libfrr.c:1093
    #12 0x412976 in main ospfd/ospf_main.c:221
    #13 0x7f88f73b082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #14 0x413c78 in _start (/usr/local/master/sbin/ospfd+0x413c78)

Effectively we are in a shutdown phase and as part of shutdown we delete the
ospf interface pointer ( ifp->info ).  The interface deletion code
was modified in the past year to pass in the address of operator
to allow us to NULL out the holding pointer.  The catch here
is that we free the oi and then delete the interface passing
in the address of the oi->ifp pointer, causing a use after free.

Fixes: #5555
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-18 09:27:34 -05:00
Donald Sharp
85d25587bf eigrpd, ospfd, pimd: Fix assumption that interface may not be up
Commit: ddbf3e6060

This commit modified the interface up handling code in
ZAPI such that the zclient handled the decoding for you.
Prior to this commit ospf assumed that it could use the
old ifp pointer to know state before reading the stream.
This lead to a situation where ospf would `smartly` track
and do the right thing in this situation.  This commit
changed this assumption and in certain scenarios, say
a interface was changed after it was already up would
lead to situations where ospf would not properly handle
the new interface up.

Modify ospf to track data that is important to it in
it's interface->info pointer.

This code pattern was followed in both eigrp and pim.
In eigrp's case it was just behaving weirdly in any event
so fixing this pattern is not a big deal.  In pim's
case it was not properly using this so it's a no-op
to fix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-04 14:23:20 -05:00
Donald Sharp
868a0861d2 ospfd: Add/fix some debugs to handle vrf
This commit has:
The received packet path in ospf, had absolutely no debugs associated with
it.  This makes it extremely hard to know when we receive packets for
consumption.  Add some breadcrumbs to this end.

Large chunks of commands have no ability to debug what is happening
in what vrf.  With ip overlap X vrf this becomes a bit of a problem
Add some breadcrumbs here.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-19 07:47:19 -05:00
Donald Sharp
f609709a58 lib, ospfd, zebra: Convert interface_delete to take double pointer
When free'ing the interface pointer, set it to NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-02 16:13:44 -04:00
Stephen Worley
d5c65bf1a2 *: Cleanup interface creation apis
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-10-09 20:24:31 -04:00
Donald Sharp
3c3c325203 *: Convert zapi->interface_delete to ifp callback
Convert the callback of the interface_delete to the new
ifp callback.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
b0b69e59f4 *: Convert interface_down to interface down callback
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
ddbf3e6060 *: Convert from ->interface_up to the interface callback
For all the places we have a zclient->interface_up convert
them to use the interface ifp_up callback instead.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
ef7bd2a3d5 *: Switch all zclient->interface_add to interface create callback
Switch the zclient->interface_add functionality to have everyone
use the interface create callback in lib/if.c

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
138c5a7450 *: Add infrastructure to support zapi interface callbacks
Start the conversion to allow zapi interface callbacks to be
controlled like vrf creation/destruction/change callbacks.

This will allow us to consolidate control into the interface.c
instead of having each daemon read the stream and react accordingly.
This will hopefully reduce a bunch of cut-n-paste stuff

Create 4 new callback functions that will be controlled by
lib/if.c

create -> A upper level protocol receives an interface creation event
The ifp is brand spanking newly created in the system.
up -> A upper level protocol receives a interface up event
This means the interface is up and ready to go.
down -> A upper level protocol receives a interface down
destroy -> A upper level protocol receives a destroy event
This means to delete the pointers associated with it.

At this point this is just boilerplate setup for future commits.
There is no new functionality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
36a106e0e4 ospfd: Cleanup oi->obuf to always be created
This looks like a finish up of the partial cleanup that
ocurred at some point in time in the past.  When we
alloc oi also always alloc the oi->obuf.  When we delete
oi always delete the oi->obuf right before.

This cleans up a bunch of code to be simpler and hopefully
easier to follow.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-08-30 16:48:07 -04:00
Donald Sharp
a36898e755
Revert "Ospf missing interface handling 2" 2019-06-23 19:46:39 -04:00
Philippe Guibert
a41c4e1b1f *: change interface structure, from vrf_id to vrf
Field vrf_id is replaced by the pointer of the struct vrf *.
For that all other code referencing to (interface)->vrf_id is replaced.
This work should not change the behaviour.
It is just a continuation work toward having an interface API handling
vrf pointer only.

some new generic functions are created in vrf:
vrf_to_id, vrf_to_name,

a zebra function is also created:
zvrf_info_lookup

an ospf function is also created:
ospf_lookup_by_vrf

it is to be noted that now that interface has a vrf pointer, some more
optimisations could be thought through all the rest of the code. as
example, many structure store the vrf_id. those structures could get
the exact vrf structure if inherited from an interface vrf context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 14:10:28 +02:00
Philippe Guibert
e9c199a6c1 lib, ospfd, pimd, zebra: change if_create() api with vrf
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-11 17:10:47 +02:00
Ruben Kerkhof
4d762f2607 Treewide: use ANSI function definitions
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2019-01-24 11:21:59 +01:00
Philippe Guibert
19ce7d5eb7 ospfd: do not remove area structure, while vls are configured
when adding/removing virtual links per interface, sometimes, the ospf
virtual link can not be removed, whereas the associated area is already
removed. Do not remove the area while a virtual link is yet configured.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-10-25 09:04:15 +02:00
David Lamparter
6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
Donald Sharp
266469ebab ospfd: Cleanup some warnings that were not warnings
1) stream allocation cannot fail
2) some warnings were removed when functions safely ignored
the calling parameters being wrong.
3) some warnings were removed when functions did not consider
the state as an error since we did not return an error code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06 20:50:58 +00:00
Donald Sharp
0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
paco
2ec42b858c
babeld, lib, ospfd, tests: fmt fixes (cppcheck)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-18 17:52:56 +02:00
Chirag Shah
4fc8a85288 ospfd: packet fifo init in interface create
Currently, interface packet transmit queue is created/deleted
as part of Interface UP/Down event. This results in
a rare condition where port came up but queue
was not created. The creation of queue occupies only few bytes.

Moving fifo queue creation to interface create
would add few bytes of fifo creation but at least it guaranteed
to be available during Up/down -->Up event.

Initialize ospf packet fifo queue during ospf
interface creation.

Drain queue during interface down event.

Drained and free the queue as part of the interface
delete/cleanup.

Ticket:CM-20744
Testing Done:

Bring up ospfv2 topology with multiple neighbors.
1) Trigger multiple shut/no shut events and validate
all queues are freed.
2) configure/deconfigure router ospf and validate
all ospf instance and interface underneath are freed.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-05-10 17:45:43 -07:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Chirag Shah
0c74bbe03e ospfd: Treat vrf interface as loopback type
Ticket:CM-19914

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-03-08 13:15:58 -08:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Chirag Shah
2bc7673f11 ospfd: show ip ospf neighbor json output format
Current json output does not differentiate start of
neighbor ip object. Adding "neighbors" keyword at the
beginning of neighbor list. This is useful when
displaying vrf level output along with neighbors
list.

Ticket:CM-19097
Testing Done:
show ip ospf neighbor json
show ip ospf vrf all neighbor json

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-20 19:30:59 -08:00
Chirag Shah
85c8ef0663 ospfd: reset ospf interface protocol stats
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-10-23 14:48:22 -07:00
Renato Westphal
bcc245799b lib: nuke the if_*_by_name_len() functions
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-10-10 09:01:24 -03:00