Commit Graph

2013 Commits

Author SHA1 Message Date
Igor Ryzhov
870791a3b5 *: do not send opaque data to zebra by default
Opaque data takes up a lot of memory when there are a lot of routes on
the box. Given that this is just a cosmetic info, I propose to disable
it by default to not shock people who start using FRR for the first time
or upgrades from an old version.

Fixes #10101.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-24 22:18:46 +03:00
Russ White
c2a0f12f78
Merge pull request #10407 from idryzhov/ospf-opaque-crash
ospfd: fix crash on "ospf send-extra-data zebra"
2022-01-24 07:34:30 -05:00
Igor Ryzhov
788a036fdb *: do not print vrf name for interface config when using vrf-lite
VRF name should not be printed in the config since 574445ec. The update
was done for NB config output but I missed it for regular vty output.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-24 14:44:05 +03:00
Russ White
2d9e10d095
Merge pull request #10318 from donaldsharp/redistribution
OSPF Redistribution
2022-01-23 22:30:24 -05:00
Igor Ryzhov
6ae27a4be5 ospfd: fix crash on "ospf send-extra-data zebra"
`ospf->new_table` is NULL if the OSPF instance has no routes.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-23 16:10:55 +03:00
rgirada
a8c22275fe ospfd: Modifying LSID generation algorithm
Description:
	This LSID alogithm added as per rcf2328 Appendex-E recommendation.
	This applies only for AS-external lsas and summary lsas.

	As an example of the algorithm, consider its operation when the
        following sequence of events occurs in a single router (Router A).

        (1) Router A wants to originate an AS-external-LSA for
            [10.0.0.0,255.255.255.0]:

            (a) A Link State ID of 10.0.0.0 is used.

        (2) Router A then wants to originate an AS-external-LSA for
            [10.0.0.0,255.255.0.0]:

            (a) The LSA for [10.0.0,0,255.255.255.0] is reoriginated using a
                new Link State ID of 10.0.0.255.

            (b) A Link State ID of 10.0.0.0 is used for
                [10.0.0.0,255.255.0.0].

        (3) Router A then wants to originate an AS-external-LSA for
            [10.0.0.0,255.0.0.0]:
            (a) The LSA for [10.0.0.0,255.255.0.0] is reoriginated using a
                new Link State ID of 10.0.255.255.

            (b) A Link State ID of 10.0.0.0 is used for
                [10.0.0.0,255.0.0.0].

            (c) The network [10.0.0.0,255.255.255.0] keeps its Link State ID
                of 10.0.0.255.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-01-22 04:07:59 -08:00
Russ White
05786ac774
Merge pull request #9644 from opensourcerouting/ospf-opaque-attrs
OSPF opaque route attributes
2022-01-18 09:08:38 -05:00
Donald Sharp
ffa484b4bd ospfd: Get default-information originate working for ospf instances
The ospf instance code is not properly handling the default route
when using default-information originate.  This is because
the code is looking for the default route to be saved with an
instance of <ospf instance id> but we always save it as a instance
id of 0.  In fact OSPF asks zebra for the default route as a special
case in instance 0, always.

Here is the correct behavior:

eva# show ip ospf data

OSPF Instance: 3

       OSPF Router with ID (192.168.122.1)

                AS External Link States

Link ID         ADV Router      Age  Seq#       CkSum  Route
0.0.0.0        192.168.122.1      8 0x80000001 0xdb08 E2 0.0.0.0/0 [0x0]

eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, 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

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:02:03

Fixes: #10251
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00
Donald Sharp
0fa6d92b90 ospfd: Add counts of lsa types to summary command
Add the ability to know the number of lsa type's we
hold in the database as part of the json output.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00
Rafael Zalamena
4e4c027803
Merge pull request #10183 from idryzhov/rework-vrf-rename
*: rework renaming the default VRF
2022-01-17 08:45:12 -03:00
Renato Westphal
5b5d66c431 lib, ospfd, ospf6d, zebra: add OSPF opaque route attributes
Update ospfd and ospf6d to send opaque route attributes to
zebra. Those attributes are stored in the RIB and can be viewed
using the "show ip[v6] route" commands (other than that, they are
completely ignored by zebra).

Example:
```
debian# show ip route 192.168.1.0/24
Routing entry for 192.168.1.0/24
  Known via "ospf", distance 110, metric 20, best
  Last update 01:57:08 ago
  * 10.0.1.2, via eth-rt2, weight 1
    OSPF path type        : External-2
    OSPF tag              : 0

debian#
debian# show ip route 192.168.1.0/24 json
{
  "192.168.1.0\/24":[
    {
      "prefix":"192.168.1.0\/24",
      "prefixLen":24,
      "protocol":"ospf",
      "vrfId":0,
      "vrfName":"default",
      "selected":true,
      [snip]
      "ospfPathType":"External-2",
      "ospfTag":"0"
    }
  ]
}
```

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2022-01-15 17:22:27 +01:00
David Lamparter
bf2209ec07
Merge pull request #9695 from yyuanam/second_commit 2022-01-15 17:18:34 +01:00
Donatas Abraitis
a38db2fac7 ospfd: Use vty_json() for show_ip_ospf_gr_helper_cmd
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-12 22:51:46 +02:00
anlan_cs
ea3f3df53f ospfd: correct one word of the output message
Signed-off-by: anlan_cs <anlan_cs@tom.com>
2022-01-11 08:54:21 -05:00
anlan_cs
ff5c476dc2 ospfd,ospf6d: make clear the comparison of routemap name
Comparison of the two pointer is confusing, they have no relevance
except the time both of them are empty.

Additionly modify one variable name and correct some comment words, they
are same in both ospfd and ospf6d.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2022-01-10 23:24:24 -05:00
Igor Ryzhov
ac2cb9bf94 *: rework renaming the default VRF
Currently, it is possible to rename the default VRF either by passing
`-o` option to zebra or by creating a file in `/var/run/netns` and
binding it to `/proc/self/ns/net`.

In both cases, only zebra knows about the rename and other daemons learn
about it only after they connect to zebra. This is a problem, because
daemons may read their config before they connect to zebra. To handle
this rename after the config is read, we have some special code in every
single daemon, which is not very bad but not desirable in my opinion.
But things are getting worse when we need to handle this in northbound
layer as we have to manually rewrite the config nodes. This approach is
already hacky, but still works as every daemon handles its own NB
structures. But it is completely incompatible with the central
management daemon architecture we are aiming for, as mgmtd doesn't even
have a connection with zebra to learn from it. And it shouldn't have it,
because operational state changes should never affect configuration.

To solve the problem and simplify the code, I propose to expand the `-o`
option to all daemons. By using the startup option, we let daemons know
about the rename before they read their configs so we don't need any
special code to deal with it. There's an easy way to pass the option to
all daemons by using `frr_global_options` variable.

Unfortunately, the second way of renaming by creating a file in
`/var/run/netns` is incompatible with the new mgmtd architecture.
Theoretically, we could force daemons to read their configs only after
they connect to zebra, but it means adding even more code to handle a
very specific use-case. And anyway this won't work for mgmtd as it
doesn't have a connection with zebra. So I had to remove this option.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-12-21 22:09:29 +03:00
Donald Sharp
9d472a3581
Merge pull request #10098 from opensourcerouting/ospf-gr-topotest-fix
ospfd: fix incorrect detection of topology changes in helper mode
2021-12-21 08:43:32 -05:00
Igor Ryzhov
cb3fa0a612
Merge pull request #10124 from ton31337/feature/vty_json 2021-11-29 02:11:29 +03:00
Donatas Abraitis
c48349e346 *: Remove redundand braces for single statement blocks
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-27 11:20:59 +02:00
Donatas Abraitis
0e57e37925
Merge pull request #10127 from idryzhov/ospf-asbr-instance
ospfd: fix summary-address deletion
2021-11-27 10:20:02 +01:00
Igor Ryzhov
fa42b7d80f ospfd: fix summary-address deletion
When the summary-address is deleted, `ospf_aggr_handle_external_info` is
called for each aggregated route for the cleanup. It needs to find the
corresponding OSPF instance and it does it using the `ei->instance`
which is totally wrong, because it's the instance from which the route
is redistributed, not the local OSPF instance. A pointer to the correct
OSPF instance is already stored in the external_info structure.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-25 21:17:58 +03:00
Donatas Abraitis
92ef007878 ospfd: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:50:30 +02:00
Donatas Abraitis
d63f3ff7cc ospfd: Replace prefix2str for JSON to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:30:21 +02:00
Renato Westphal
225883cf4d ospfd: fix backbone connection check to account for restarting neighbors
An OSPF ABR, while in the process of announcing summary LSAs,
checks whether it's connected to the backbone area. If not, then
all summary LSAs are invalidated and not announced (or flushed)
while the missing backbone connectivity persists.

The backbone connectivity check consists of assessing whether
there's at least one fully formed adjacency in the backbone area. The
problem is that this check can fail unexpectedly if the router is
acting as a helper for a neighbor that is performing a graceful
restart. This is because there's a short interim of time in which
that neighbor's state will oscillate between ExStart and Full during
the LSDB synchronization process.

To address that issue, update ospf_act_bb_connection() to consider
neighbors performing a graceful restart as if they were fully
adjacent (which is what a GR helper should do).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-24 20:21:42 -03:00
Donald Sharp
911b9d7b90
Merge pull request #10100 from rgirada/ospf_nssa
ospfd: ospf routing table update upon Changing area from normal to nssa
2021-11-23 19:52:19 -05:00
Renato Westphal
1bb2674ce4 ospfd: fix incorrect detection of topology changes in helper mode
This commit fixes a rather obscure bug that was causing the GR
topotest to fail on a frequent basis.

RFC 3623 specifies that a router acting as a helper to a restarting
neighbor should monitor topology changes and abort the GR procedures
when one is detected, falling back to normal OSPF operation.

ospfd uses the ospf_lsa_different() function to detect when the
content of an LSA has changed, which is considered as a topology
change. The problem is that ospf_lsa_different() can return true
even when the two LSAs passed as parameters are identical, provided
one LSA has the OSPF_LSA_RECEIVED flag set and the other not.

In the context of the ospf_gr_topo1 test, router rt6 performs
a graceful restart and a few seconds later acts as a helper for
router rt7. When it's acting as a helper for rt7, it still didn't
translate its NSSA Type-7 LSAs, something that happens only after 7
seconds (OSPF_ABR_TASK_DELAY) of the first SPF run. The translated
Type-5 LSAs on its LSDB were learned from the helping neighbors
(rt3 and rt7). It's then possible that the NSSA Type-7 LSAs might
be translated while rt6 is acting as helper for rt7, which causes
the daemon to detect a non-existent topology change only because
the OSPF_LSA_RECEIVED flag is unset in the recently originated
Type-5 LSA.

Fix this problem by ignoring the OSPF_LSA_RECEIVED flag when
comparing LSAs for the purpose of topology change detection.

In short, the bug would only show up when the restarting router
would start acting as a helper immediately after coming back up
(which would be hard to happen in the real world). The topotest
failures became more frequent after commit 6255aad0bc because of
the removal of the 'sleep' calls, which used to give ospfd more time
to converge before start acting as a helper for other routers. The
problem still occurred from time to time though.

Fixes #9983.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 15:31:39 -03:00
Renato Westphal
003d3dbead Revert "ospfd: remove commands for broken GR helper mode"
This reverts commit accef597df.
2021-11-23 15:31:39 -03:00
Igor Ryzhov
096f7609f9 *: cleanup ifp->vrf_id
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-22 20:47:23 +03:00
Donald Sharp
9d5a61264a
Merge pull request #10076 from idryzhov/if-is-loopback-or-vrf
*: unify if_is_loopback/if_is_loopback_or_vrf
2021-11-22 12:02:21 -05:00
Igor Ryzhov
587cf8f170
Merge pull request #9683 from volta-networks/sr-minor-fixes
ospfd, isisd: minor SR fixes
2021-11-20 14:53:09 +03:00
rgirada
bf4b7559a0 ospfd: ospf routing table update upon Changing area from normal to nssa
Description:
	When changing the area from normal to NSSA, previous area's
	ASBR router's type-5 also calculated and added to routing table along
	with Type-7 lsas.
	Made a change in route calculation such that it will not consider Type-5
	lsas in calculation if it is originated from NSSA ASBR router.
	These lsas will be age out at MAX age.

  log:
  frr(config-router)# do show ip route
	Codes: K - kernel route, C - connected, S - static, R - RIP,
         O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
         T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
         f - OpenFabric,
         > - selected route, * - FIB route, q - queued, r - rejected, b - backup
         t - trapped, o - offload failure

	K>* 0.0.0.0/0 [0/0] via 10.112.157.253, ens160, 00:32:47
	C>* 10.112.156.0/23 is directly connected, ens160, 00:32:47
	S>* 22.22.22.2/32 [1/0] is directly connected, ens192, weight 1, 00:20:03
	O>* 33.33.33.0/24 [110/20] via 100.1.1.220, ens192, weight 1, 00:08:55
				   via 100.1.1.220, ens192, weight 1, 00:08:55
	O   100.1.1.0/24 [110/10] is directly connected, ens192, weight 1, 00:21:32
	C>* 100.1.1.0/24 is directly connected, ens192, 00:23:11
  frr(config-router)# do show ip ospf  route
	============ OSPF network routing table ============
	N    100.1.1.0/24          [10] area: 0.0.0.1
                           directly attached to ens192

	============ OSPF router routing table =============
	R    2.2.2.2               [10] area: 0.0.0.1, ASBR
                           via 100.1.1.220, ens192

	============ OSPF external routing table ===========
	N E2 33.33.33.0/24         [10/20] tag: 0
                           via 100.1.1.220, ens192
                           via 100.1.1.220, ens192

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-11-19 00:09:29 -08:00
Donatas Abraitis
4e9a98636f *: Remove unused variables
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:41 +02:00
Donatas Abraitis
20308be317 ospfd: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:39 +02:00
Russ White
c597cd76ea
Merge pull request #10064 from idryzhov/ospf-grace-period
ospfd: fix no-form of "graceful-restart" command
2021-11-16 11:32:45 -05:00
Igor Ryzhov
608c887069 *: unify if_is_loopback/if_is_loopback_or_vrf
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-16 18:07:11 +03:00
Donald Sharp
f22a74fee0
Merge pull request #10063 from idryzhov/ospf-gr-guarded-code
ospfd: fix code being guarded by debug check
2021-11-15 15:08:26 -05:00
Olivier Dugeon
e3db39db57 ospfd: Fix wrong parsing of TE subTLV
Function ospf_te_parse_te() and ospf_te_delete_te() browse TE TLV but also
subTLV. The loop that parse the subTLV check that cummulative read data doesn't
exceed the total size of the TLV. However, the sum variable that counts the
number of read data was wrongly intialize to 0 instead to 4 (i.e. the initial
TLV Header size that is located at the TOP of subTLV).

This patch adjust accordingly the initial value of the counter.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-11-15 18:25:58 +01:00
Donatas Abraitis
67ca5030f7
Merge pull request #10014 from rgirada/ospf_nbr_cov
ospfd: fixing few coverity issues in ospf_vty.c
2021-11-15 17:55:35 +02:00
Igor Ryzhov
9a8c0f2d25 ospfd: fix no-form of "graceful-restart" command
The no-form should use the same arguments as the regular command, hence
replace "period" with "grace-period".

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-15 18:12:55 +03:00
Igor Ryzhov
65bf67b310 ospfd: fix code being guarded by debug check
OSPF_NSM_TIMER_ON must be called regardless of debug configuration.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-15 18:12:40 +03:00
Jafar Al-Gharaibeh
3357afaa74
Merge pull request #10036 from donaldsharp/finally_frr
Finally frr
2021-11-12 21:35:27 -06:00
Donald Sharp
13576f45f8
Merge pull request #9981 from idryzhov/fix-vrf-delete
lib: fix vrf deletion when the last interface is deleted
2021-11-11 18:41:02 -05:00
Donald Sharp
b72aae2e04 *: Cleanup some documentation from quagga->frr
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11 14:41:27 -05:00
Donald Sharp
7cc91e67a3 *: Convert quagga_signal_X to frr_signal_X
Naming functions/data structures more appropriately for
the project we are actually in.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11 14:41:27 -05:00
Donald Sharp
9ffde6e1b0 ospfd: Prevent use after free on shutdown
Running ospf_topo_vrf1 leads us to this valgrind issue:

==2386518== Invalid read of size 8
==2386518==    at 0x4971520: route_top (table.c:401)
==2386518==    by 0x181F08: ospf_interface_bfd_apply (ospf_bfd.c:126)
==2386518==    by 0x182069: ospf_interface_disable_bfd (ospf_bfd.c:158)
==2386518==    by 0x18BF51: ospf_del_if_params (ospf_interface.c:557)
==2386518==    by 0x18C584: ospf_if_delete_hook (ospf_interface.c:712)
==2386518==    by 0x490CA0B: hook_call_if_del (if.c:61)
==2386518==    by 0x490D1F3: if_delete_retain (if.c:286)
==2386518==    by 0x490D337: if_delete (if.c:309)
==2386518==    by 0x490CDED: if_destroy_via_zapi (if.c:200)
==2386518==    by 0x49940A9: zclient_interface_delete (zclient.c:2237)
==2386518==    by 0x4998062: zclient_read (zclient.c:3969)
==2386518==    by 0x4979529: thread_call (thread.c:1908)
==2386518==    by 0x4919918: frr_run (libfrr.c:1164)
==2386518==    by 0x181AC7: main (ospf_main.c:235)
==2386518==  Address 0x5df39a0 is 0 bytes inside a block of size 56 free'd
==2386518==    at 0x48399AB: free (vg_replace_malloc.c:538)
==2386518==    by 0x492A03E: qfree (memory.c:141)
==2386518==    by 0x4970C6F: route_table_free (table.c:141)
==2386518==    by 0x4970A36: route_table_finish (table.c:61)
==2386518==    by 0x18C543: ospf_if_delete_hook (ospf_interface.c:708)
==2386518==    by 0x490CA0B: hook_call_if_del (if.c:61)
==2386518==    by 0x490D1F3: if_delete_retain (if.c:286)
==2386518==    by 0x490D337: if_delete (if.c:309)
==2386518==    by 0x490CDED: if_destroy_via_zapi (if.c:200)
==2386518==    by 0x49940A9: zclient_interface_delete (zclient.c:2237)
==2386518==    by 0x4998062: zclient_read (zclient.c:3969)
==2386518==    by 0x4979529: thread_call (thread.c:1908)
==2386518==    by 0x4919918: frr_run (libfrr.c:1164)
==2386518==    by 0x181AC7: main (ospf_main.c:235)
==2386518==  Block was alloc'd at
==2386518==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==2386518==    by 0x4929EFC: qcalloc (memory.c:116)
==2386518==    by 0x49709F8: route_table_init_with_delegate (table.c:53)
==2386518==    by 0x49717F4: route_table_init (table.c:528)
==2386518==    by 0x18C328: ospf_if_new_hook (ospf_interface.c:659)
==2386518==    by 0x490C97D: hook_call_if_add (if.c:60)
==2386518==    by 0x490CE85: if_create_name (if.c:223)
==2386518==    by 0x490DF32: if_get_by_name (if.c:622)
==2386518==    by 0x4993F73: zclient_interface_add (zclient.c:2186)
==2386518==    by 0x4998062: zclient_read (zclient.c:3969)
==2386518==    by 0x4979529: thread_call (thread.c:1908)
==2386518==    by 0x4919918: frr_run (libfrr.c:1164)
==2386518==    by 0x181AC7: main (ospf_main.c:235)
==2386518==

Fix the ordering to do the individual node tree cleanup after we delete
the data we care about.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11 13:25:35 -05:00
Russ White
b761cb131a
Merge pull request #9864 from ton31337/feature/access_list_autocomplete
lib: Add autocomplete for access-lists
2021-11-11 08:03:33 -05:00
Igor Ryzhov
ce27a13e90 lib: fix vrf deletion when the last interface is deleted
Currently, we automatically delete an inactive VRF when its last
interface is deleted. This code introduces a couple of crashes because
of the following problems:
- vrf_delete is called before calling if_del hook, so daemons may try to
  dereference an ifp->vrf pointer which is freed
- in if_terminate, we continue to use the VRF in the loop condition
  after the last interface is deleted

This check is needed only when the interface is deleted by the user,
because if the interface is deleted by the system, VRF must still exist
in the system. Move the check to appropriate places to fix crashes.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-11 14:57:59 +03:00
Igor Ryzhov
accef597df ospfd: remove commands for broken GR helper mode
Issue #9983 explains what is wrong with the GR helper mode.

To unblock the CI that fails almost all the time on the ospf_gr_topo1
test, remove the commands and disable the test. Also add a reminder to
completely remove the helper mode if no one fixes the code in a month.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-10 19:17:03 +03:00
rgirada
89f472acb4 ospfd: fixing few coverity issues in ospf_vty.c
Description:
	timerval datastructure is being used without initialization.
	Using these uninitialized parameters can lead unexpected results
	so initializing before using it.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-11-09 04:35:12 -08:00
Russ White
438205d540
Merge pull request #9777 from rgirada/ospf_nbr
ospfd: Few modifications in "show ip ospf neighbor" o/p.
2021-11-05 15:15:45 -04:00
Donatas Abraitis
c60dec369a lib: Add autocomplete for access-lists
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-31 20:26:06 +02:00
Igor Ryzhov
a1a8fb4ddd
Merge pull request #9368 from donaldsharp/ospf_ensure_lsa_length
ospfd: Ensure we have some non header lsa data
2021-10-29 13:37:09 +03:00
Donatas Abraitis
1c3f03f79d ospfd: Add autocomplete for area X filter-list prefix
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-28 14:01:13 +03:00
Russ White
f727c6ae8a
Merge pull request #9837 from idryzhov/cleanup-if-by-name-vrf-all
*: fix usage of if_lookup_by_name_all_vrf
2021-10-27 15:29:39 -04:00
Russ White
a2b52cbeb4
Merge pull request #9854 from opensourcerouting/zapi-call-table
*: convert zclient callbacks to table
2021-10-26 11:33:44 -04:00
rgirada
059fd3a48a ospfd: Adding apropriate ism state in ptop neighbors.
Description:
	In PointToPoint networks, There wont be DR and BDR.
	But by default, All neighbours ism state is shown as
	DR_OTHER.

	Changed the nbr state format to <nbrsate>/- (ex : FULL/-)
	to P2pnetworks.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-10-26 05:36:20 -07:00
rgirada
eb4ed6e8c7 ospfd: Few modifications in "show ip ospf neighbor" o/p.
Description:
	1. Adding uptime to the 'show ip ospf neighbor' o/p.
	2. Adding uptime and deadtime in string format for json consumption.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-10-26 05:36:20 -07:00
Mark Stapp
036b746570
Merge pull request #9765 from idryzhov/lib-bool-thread-add
lib: change thread_add_* API
2021-10-22 09:59:54 -04:00
David Lamparter
5a001ddd24
Merge pull request #9855 from donaldsharp/ospf_fini 2021-10-20 19:19:43 +02:00
Igor Ryzhov
ee1455dd98 lib: change thread_add_* API
Do not return pointer to the newly created thread from various thread_add
functions. This should prevent developers from storing a thread pointer
into some variable without letting the lib know that the pointer is
stored. When the lib doesn't know that the pointer is stored, it doesn't
prevent rescheduling and it can lead to hard to find bugs. If someone
wants to store the pointer, they should pass a double pointer as the last
argument.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-20 20:07:15 +03:00
Donald Sharp
e15a935c06 ospfd: Close log files before exiting
When doing a normal exit from ospf we should close
the log file as that we are leaving a bunch of
unterminated logging processes by not doing so.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-20 08:00:02 -04:00
David Lamparter
a243d1db93 *: convert zclient callbacks to table
This removes a giant `switch { }` block from lib/zclient.c and
harmonizes all zclient callback function types to be the same (some had
a subset of the args, some had a void return, now they all have
ZAPI_CALLBACK_ARGS and int return.)

Apart from getting rid of the giant switch, this is a minor security
benefit since the function pointers are now in a `const` array, so they
can't be overwritten by e.g. heap overflows for code execution anymore.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-20 13:28:46 +02:00
Igor Ryzhov
f60a11883c lib: allow to create interfaces in non-existing VRFs
It allows FRR to read the interface config even when the necessary VRFs
are not yet created and interfaces are in "wrong" VRFs. Currently, such
config is rejected.

For VRF-lite backend, we don't care at all about the VRF of the inactive
interface. When the interface is created in the OS and becomes active,
we always use its actual VRF instead of the configured one. So there's
no need to reject the config.

For netns backend, we may have multiple interfaces with the same name in
different VRFs. So we care about the VRF of inactive interfaces. And we
must allow to preconfigure the interface in a VRF even before it is
moved to the corresponding netns. From now on, we allow to create
multiple configs for the same interface name in different VRFs and
the necessary config is applied once the OS interface is moved to the
corresponding netns.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-19 15:29:51 +03:00
Donald Sharp
1afa7d5326
Merge pull request #9813 from opensourcerouting/ospf-gr-fixes
ospfd: more GR fixes
2021-10-15 09:21:40 -04:00
Igor Ryzhov
4030e1867b ospfd: don't use if_lookup_by_name_all_vrf
if_lookup_by_name_all_vrf doesn't work correctly with netns VRF backend
as the same index may be used in multiple netns simultaneously.

Use the appropriate VRF when looking for the interface.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-15 03:44:42 +03:00
Renato Westphal
512901ae53
Merge pull request #9822 from donaldsharp/ospf_testing
Ospf testing
2021-10-13 23:38:44 -03:00
Igor Ryzhov
bb3cd4189a
Merge pull request #9795 from opensourcerouting/ospf_get_name
ospfd: use ospf_get_name() wherever possible
2021-10-14 01:42:29 +03:00
Donald Sharp
3766c36a20 ospfd: Add converged and role json output for neighbor command
The `show ip ospf neighbor json` command was displaying
state:`Full\/DR`

Where state was both the role and whether or not the neigbhor
was converged.  While from a OSPF perspective this is the state.
This state is a combination of two things.

This creates a problem in testing because we have no guarantee
that a particular ospf router will actually have a particular role
given how loaded our topotest systems are.  So add a bit of json
output to display both the converged status as well as the
role this router is playing on this neighbor/interface.

The above becomes:
state:`Full\/DR`
converged:`Full`
role:`DR`

Tests can now be modified to look for `Full` and allow it to
continue.  Most of the tests do not actually care if this
router is the DR or Backup.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-13 12:40:35 -04:00
Renato Westphal
3ebf9d3416 ospfd: fix another DR election issue during graceful restart
Commit 3551ee9e90304 introduced a regression that causes GR to fail
under certain circumstances. In short, while ISM events should
be ignored while acting as a helper for a restarting router, the
DR/BDR fields of the neighbor structure should still be updated
while processing a Hello packet. If that isn't done, it can cause
the helper to elect the wrong DR while exiting from the helper mode,
leading to a situation where there are two DRs for the same network
segment (and a failed GR by consequence). Fix this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-12 17:33:32 -03:00
Renato Westphal
eedc80c1f5 ospfd: introduce additional opaque capability check in the GR code
Before starting the graceful restart procedures, ospf_gr_prepare()
verifies for each configured OSPF instance whether it has the opaque
capability enabled (a pre-requisite for GR). If not, a warning is
emitted and GR isn't performed on that instance.

This PR introduces an additional opaque capability check that will
return a CLI error when the opaque capability isn't enabled. The
idea is to make it easier for the user to identify when the GR
activation has failed, instead of requiring him or her to check
the logs for errors.

The original opaque capability check from ospf_gr_prepare() was
retaining as it's possible that that function might be called from
other contexts in the future.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-12 17:33:32 -03:00
Renato Westphal
4a0167fee5 ospfd: fix flushing of Grace-LSAs on broadcast interfaces
The ospfd opaque LSA infrastruture has an issue where it can't store
different versions of the same Type-9 LSA for different interfaces.

When flushing the self-originated Grace-LSAs upon exiting from the GR
mode, the code was looking up the single self-originated Grace-LSA
from the LSDB, setting its age to MaxAge and sending it out on all
interfaces.

The problem is that Grace-LSAs sent on broadcast interfaces have
their own unique "IP interface address" TLV that is used to identify
the restarting router. That way, just reusing the same Grace-LSA for
all interfaces doesn't work.

Fix this by generating a new Grace-LSA with its age manually set
to MaxAge whenever one needs to be flushed. This will allow the "IP
interface address" TLV to be set correctly and make GR work even in
the presence of multiple broadcast interfaces.

In the long term, the opaque LSA infrastructure should be updated
to support Type-9 link-local LSAs correctly so that we don't need to
resort to hacks like this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-12 17:30:51 -03:00
Russ White
0f96b7e69b
Merge pull request #9763 from ton31337/fix/more_thread_null
More struct thread null
2021-10-12 11:49:46 -04:00
Russ White
effd4c7bdd
Merge pull request #9779 from donaldsharp/gr_repeated
Some GR fixes
2021-10-12 11:00:44 -04:00
Russ White
c5708d0b98
Merge pull request #9781 from opensourcerouting/ospfd-gr-dr-fix
ospfd: preserve DR status across graceful restarts
2021-10-12 10:58:39 -04:00
Renato Westphal
44076f4dc7 ospfd: use ospf_get_name() wherever possible
Small cleanup to reduce code duplication.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-09 20:36:47 -03:00
Russ White
495047b526
Merge pull request #9760 from mobash-rasool/ospfv2-bug-fixes-02
ospfd: ospf nbr in full although mismatch in hello packet contents
2021-10-08 13:55:28 -04:00
Renato Westphal
3e63092b83 ospfd: fix display of plain-text data on "show ... json" commands
Add a 'json' parameter to the 'show_opaque_info' callback definition,
and update all instances of that callback to not display plain-text
data when the user requested JSON data.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-08 10:03:01 -03:00
Renato Westphal
a792fa7b15 ospfd: display detailed information about opaque LSAs in JSON format
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-08 10:03:01 -03:00
Renato Westphal
ab6edbfeef ospfd: preserve DR status across graceful restarts
RFC 3623 says:
 "If the restarting router determines that it was the Designated
 Router on a given segment prior to the restart, it elects
 itself as the Designated Router again.  The restarting router
 knows that it was the Designated Router if, while the
 associated interface is in Waiting state, a Hello packet is
 received from a neighbor listing the router as the Designated
 Router".

Implement that logic when processing Hello messages to ensure DR
interfaces will preserve their DR status across a graceful restart.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-08 09:13:37 -03:00
Donatas Abraitis
30634856b4 ospfd: Do not explicitly set the thread pointer to NULL
FRR should only ever use the appropriate THREAD_ON/THREAD_OFF
semantics.  This is espacially true for the functions we
end up calling the thread for.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-08 08:56:42 +03:00
Russ White
b1003f64b2
Merge pull request #9698 from idryzhov/cleanup-loopback-or-vrf
*: cleanup interface loopback/vrf check
2021-10-06 19:01:52 -04:00
Mobashshera Rasool
874a549d51 ospfd: ospf nbr in full although mismatch in hello packet contents
Issue:
===================
OSPF neighbors are not going down even after 10 mins when
having a mismatch in hello and dead interval.
First neighbors are formed and then a mismatch in the interval
is created, it is observed that the neighbor is not going down.

Root Cause Analysis:
====================
The event HelloReceived defined in RFC 2328 was named as PacketReceived
and this event was scheduled whenever LS Update, LS Ack, LS Request,
DD description packet or Hello packet is received.
Although there is a mismatch in the Hello packet contents, the
event PacketReceived gets triggered due to LS Update received and the
dead timer gets reset and hence the neighbor was never going Down and
remains FULL.

Fix:
==================
As per RFC 2328, the HelloReceived needs to be triggered only when
valid OSPF Hello packet is received and not when other OSPF packets
are received. Modified the function name as well.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-10-06 10:04:10 -07:00
rgirada
89eb4727de ospfd: GR helper functionality change in helper exit
Description:
	As per the RFC 3623 section 3.2,
	OSPF nbr shouldn't be deleted even in unsuccessful helper exit.

	1. Made the changes to keep neighbour even after exit.
	2. Restart the dead timer after expiry in helper. Otherwise, Restarter
	   will be in FULL state in helper forever until it receives the 'hello'.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-10-01 11:59:11 -07:00
Igor Ryzhov
ef322b022f *: cleanup interface loopback/vrf check
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-09-30 12:31:05 +03:00
Yuan Yuan
a1638c7ce5 ospfd: Fix assert related to capability opaque
The capability opaque command can trigger asserts through a rather
round-about mechanism. The command eventually calls
ospf_renegotiate_optional_capabilities, which will call
ospf_flush_self_originated_lsas_now, which has the side effect of
marking the OSPF instance as shutting down. This was causing the
flooding logic to call ospf_write immediately insted of waiting for the
select IO loop every time it was sending a maxage LSA.  This could cause
the list of OSPF interfaces needing to send packets to be drained while
there was a call to ospf_write pending from the IO loop. When the
pending call ran, it would see the empty list of interfaces and assert.

Signed-off-by: Yuan Yuan <yyuanam@amazon.com>
2021-09-29 19:37:33 +00:00
Fredi Raspall
d97e415dd5 ospfd: fix processing of ext prefix in SR
The existing logic was not comparing the prefix of the extended
prefix TLV. As a result, the code was removing all of the prefix
SIDs except the one received on every LSA update.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:33 +02:00
Fredi Raspall
1a41378ecc ospfd: remove duplicate field update
In update_ext_prefix_sid(), the sr_prefix is associated to the
SR node and inherits the adv router ID regardless.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:33 +02:00
Fredi Raspall
152656d8ef ospfd: replace iterator by RO version ..
..since it's used for read-only lookups.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:33 +02:00
Fredi Raspall
d1db7359ad ospfd: fix logic on SR prefix configuration
The logic was broken in some corner cases.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:33 +02:00
Fredi Raspall
6c57d01073 ospfd: validate input SRGB and SRLB
The code was not checking if in these label ranges [a,b], a is
smaller than b, which is assumed in several places, including when
determining the size of the block as b-a+1. As a consequence, the
results of a bad configuration can be unpredictable. Some effects
observed were: 1) segfault 2) de-activation of SR due to label
reservation failure.

The added validation function also checks if the SR blocks are
larger than some minimal size. RFC 8665 mandates that the blocks
be srictly larger than zero. In this patch, the minimum sized is
arbitrarily defined to be 16.

Checking if ranges would fall outside [16,1048575] is omitted
since the vty filtering takes care of that.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
37a331f8c2 ospfd: fix condition to get label from SRLB
The prior condition was wrong since it ended up allowing for
labels past the end of the SRLB. Variable 'current' should be in
range [0, size-1] for labels not to exceed the SRLB upper boundary.

In addition, emit a warning log when all labels in the SRLB have
been used.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
4e10b4dfba ospfd: add util func to detect SR range overlap
Replaces several complex if conditions by a lookup to a utility
to determine if two ranges of numbers overlap.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
daaebd394c ospfd: homogenize reservation of SRGB & SRLB
Homogenize the code dealing with SRGBs and SRLBs by defining the
same set of utility functions for their reservation.

Unify also the logs and don't display function names since the
operations are only performed from the same functions.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
c181efbe14 ospfd: homogenize deletion of SRGB & SRLB
Homogenize the code dealing with SRGBs and SRLBs by defining the
same set of utility functions for the deletion of SR blocks.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:59 +02:00
Fredi Raspall
143661c17f ospfd: remove unnecessary assignment
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:59 +02:00
Fredi Raspall
5403ff15db ospfd: remove unused macro
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:59 +02:00
Fredi Raspall
5bd62f051d ospfd: use existing macro on initialization of SR
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:58 +02:00
Fredi Raspall
2110d03e06 ospfd: remove unused enum case for state of SR ..
In addition, make the relationship among several macros more
explicit.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:58 +02:00
Fredi Raspall
6f609c4980 ospfd: fix display of debug flags
* Some of the debug flags were not shown in show debugging.
* The check for TI-LFA debug was made against the wrong variable.
* Some of the debugs were not cleared with 'no debug ospf'

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:58 +02:00
Renato Westphal
859bce816b ospfd: rename the "graceful-restart helper-only" command
Considering that both the GR helper mode and restarting mode can be
enabled at the same time, the "graceful-restart helper-only" command
can be a bit misleading since it implies that only the helper mode
is enabled. Rename the command to "graceful-restart helper enable"
to clarify what the command does.

Start a deprecation cycle of one year before removing the original
command

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-21 17:42:03 -03:00
Donald Sharp
07a62e585d ospfd: Add some small doc to what each one is for future people
min lsa packet sizes are not always directly corresponding
to the actual LSA.  Add a bit of comments so it's easier
for future people to figure out.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-14 13:13:32 -04:00
Donald Sharp
cf680c38a9 ospfd: Ensure we have some non header lsa data
In some cases FRR is receiving a lsa data packet
with a length set to the length of the header only.
If we are expecting data from a peer in the form
of lsa data.  Let's enforce it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-14 13:07:06 -04:00
Russ White
d79b88c5a1
Merge pull request #9578 from donaldsharp/SLASH_ESCAPE
Slash escape
2021-09-08 20:11:07 -04:00
Russ White
2ca7780ab5
Merge pull request #9533 from mobash-rasool/ospfv3-bug-fixes
ospfd: ASBR Summary LSA is not originated when process is reset
2021-09-07 10:59:33 -04:00
Russ White
12b5b2f9ff
Merge pull request #9551 from mobash-rasool/ospfv2-bug-fixes-04
ospfd: GR Conformance fix in Hello packet DR election
2021-09-07 10:47:09 -04:00
Russ White
91aaac3ac2
Merge pull request #9552 from mobash-rasool/ospfv2-bug-fixes-03
ospfd: ANVL Test case 25.22, 25.23 and 28.11 fixes
2021-09-07 10:46:33 -04:00
Donald Sharp
19d37e54a0 ospfd: Don't allocate json memory unless we have json output
Several functions in ospf_vty.c were allocating json memory
irrelevant if it was needed or not and then at the end of the loop
free'ing it if it was not used.  Clean up the access pattern.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-07 10:10:50 -04:00
Donald Sharp
e77564ccd4 ospfd: Fix usage of JSON_C_TO_STRING_NOSLASHESCAPE
The usage of json_object_to_json_string_ext is meant for
generation of output string and returns a `char *` pointer
to the `formatted` output.  Just calling it does nothing
and it's expensive to boot.

Modify the code in ospfd to just output with the NOSLASHESCAPE
when outputting.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-07 09:36:39 -04:00
Donald Sharp
3702e8577f
Merge pull request #9563 from opensourcerouting/build-strict-prototypes
build: `-Wstrict-prototypes` (+ BSD `sed`)
2021-09-06 12:28:33 -04:00
Igor Ryzhov
038307d88d
Merge pull request #9549 from mobash-rasool/ospfv2-bug-fixes-02
ospfd: Memory Leak seen at show_ip_ospf_neighbor_all_common.
2021-09-03 17:28:59 +03:00
Donald Sharp
3513c6b146
Merge pull request #9077 from idryzhov/ospf-memory-alloc
ospfd: remove unnecessary memory allocation
2021-09-03 10:14:44 -04:00
Mobashshera Rasool
3cb62bb387 ospfd: RFC conformance test case 25.23 issue fix
Problem Statement :
===================
LSA with InitialSequenceNumber is not originated
after MaxSequenceNumber.

ANVL Test case 25.33 states:
============================
As soon as this flooding of a LSA with LS sequence number
MaxSequenceNumber has been acknowledged by all adjacent neighbors,
a new instance can be originated with sequence number of InitialSequenceNumber.

RCA :
=====
DUT did not originated LSA with INITIAL_SEQUENCE number even
after receiving ACK for max sequence LSA.
Code is not present to handle this situation in the lsa ack flow.

Fix :
=====
Add code to originate LSA with initial sequence number in the
LSA ack flow in case of wrap around sequence number.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-03 06:44:56 -07:00
Mobashshera Rasool
44d1115ad6 ospfd: ANVL Test case 25.22, 25.23 and 28.11 fixes
ANVL Test case 28.11
If the database copy has LS age equal to MaxAge and LS sequence number
equal to MaxSequenceNumber, simply discard the received LSA
without acknowledging it.

ANVL Test Case 25.22
When an attempt is made to increment the sequence number past the maximum
value of N - 1 (0x7fffffff; also referred to as MaxSequenceNumber),
the current instance of the LSA must first be flushed from the routing domain.

ANVL Test Case 25.23
As soon as this flooding of a LSA with LS sequence number MaxSequenceNumber
has been acknowledged by all adjacent neighbors, a new instance can be
originated with sequence number of InitialSequenceNumber.

RCA:
When IXIA sent LS Seq num as MAX and LS Age as (MAX - 3),
DUT dropped the packet instead of sending ACK.
In function ospf_ls_upd, at Line 2106 the code is there to drop the LSA.
Hence its failing.

Fix:
LSAs ACK must be sent when received LSA is having max sequence number
but not max-aged.
Considering  /* CVE-2017-3224 */ issue, have corrected the existing
code to prevent attacker from sending LSAs with max sequence number
and higher checksum and blocking the flooding of the Max-sequence numbered LSAs.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-03 06:44:39 -07:00
Mobashshera Rasool
d51715bb44 ospfd: GR Conformance fix for Hello packet DR election
Problem Statement:
===================
DUT selecting itself as DR when RR goes for reload.
Test Case 7.2

DUT (GR Helper) receives the Hello packet from the OSPF GR RESTARTER
(ANVL here) with DR and BDR set to 0.0.0.0 and DUT in its hello
neighbor list. DUT triggers the DR and BDR election although it is
in the Helper mode for that neighbor.

Root Cause Analysis:
====================
When hello packet is received with self router ID in the neighbor list,
there is no check in the code to handle this scenario. Hence the DR/BDR
election happens and it changes the DR although it is helper.

Fix:
===================
As per RFC 3623 Section 3.  Operation of Helper Neighbor, below point,
we need to maintain the DR relationship.
Also, if X was the Designated Router on network segment S when the
helping relationship began, Y maintains X as the Designated Router
until the helping relationship is terminated.

Adding the check when DUT is under neighbor helper mode, we need to avoid
ISM state change when hello packet is received with DR/BDR set to 0.0.0.0.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-03 06:40:14 -07:00
Mobashshera Rasool
6f3e19b736 ospfd: Memory Leak seen at show_ip_ospf_neighbor_all_common.
Problem Statement:
==================
Memory Leak seen at  show_ip_ospf_neighbor_all_common (ospf_vty.c:4635)

RCA:
=================
In function show_ip_ospf_neighbor_all_common, one child json object is not
 added to the parent child object when there is no nbma neighbor. Hence
 the memory leak.

Fix:
=================
Add the child object to the parent json object.

Fixes: #9548

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-03 04:06:15 -07:00
David Lamparter
9fb83ab17d *: fix for -Wstrict-prototypes
Just some "void" missing between empty braces.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-09-02 13:00:35 +02:00
Mobashshera Rasool
8fb693a4cd ospfd: Summary LSA is not originated when process is reset
Problem Statement:
==================
Summary LSA is not originated when router-id is modified or process is reset

Root Cause Analysis:
====================
When router-id is modified or process is cleared, all the external LSAs are
 flushed then LSA is re-originated using ospf_external_lsa_rid_change
When the LSAs are flushed, the aggregate flags are not reset.

Fix:
===============
Reset the aggregation flag when the LSAs
 are flushed.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-01 23:39:00 -07:00
Renato Westphal
cbf4f6f144
Merge pull request #9525 from idryzhov/ospfd-crash
ospfd: correctly cleanup spf data
2021-08-31 17:54:25 -03:00
Igor Ryzhov
57e4c21583 ospfd: correctly cleanup spf data
ospf_spf_cleanup frees the data so we need to reset the stale pointers.

Fixes #9523.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-31 13:41:40 +03:00
Mobashshera Rasool
2c1f2d2ad9 ospfd: add dead-interval 40 if configured in show running
Problem Statement:
==================
When hello-interval is configured as 5, automatically dead interval becomes
4 times of hello i.e 20 seconds. But user wants the dead interval as
40 seconds and hello as 5 seconds. Therefore user configures it.
Now "ip ospf dead-interval 40" is not shown in "show running-config"
Therefore when user restarts the daemon, the dead interval goes back to
20 seconds and the neighbors are down.

Fix:
==================
If user configures dead-interval as 40, show it in show running config.

Fixes: #9401

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-08-30 23:02:39 -07:00
David Lamparter
8268be3d16
Merge pull request #9496 from idryzhov/vrf-cmd-init-unused-arg
lib: remove unused argument from vrf_cmd_init
2021-08-27 10:39:45 +02:00
Christian Hopps
d448e2c5f9
Merge pull request #9331 from idryzhov/explicit-exit
*: explicitly print "exit" at the end of every node config
2021-08-26 11:57:33 -04:00
Igor Ryzhov
cfc369c43a lib: remove unused argument from vrf_cmd_init
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-26 12:01:22 +03:00
Donatas Abraitis
d10bda270e *: Drop break after using frr_help_exit() in switch/case
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-25 10:49:05 +03:00
Russ White
701bb4c692
Merge pull request #9310 from mobash-rasool/ospfv2-bug-fixes-02
ospfd: NSSA area should not exchange Type-4 LSAs in DD
2021-08-24 09:40:59 -04:00
Igor Ryzhov
07679ad98a *: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 22:08:20 +03:00
Igor Ryzhov
2f2372ce9e
Merge pull request #9408 from mobash-rasool/ospfv2-bug-fixes-03
ospfd: Summarised External LSA is not flushed in one scenario
2021-08-18 10:18:32 +03:00
Mobashshera Rasool
d2e8400570 ospfd: Summarised External LSA is not flushed in one scenario
Fix CI Failure test_ospf_type5_summary_tc45_p0

Problem Statement:
==================
Summarised LSA is not flushed in OSPFv2 in below scenario:
1. Configure summary-address in ospfv2
2. redistribute static and connected.
3. Check the LSAs are received on neighbor.
4. Now remove all OSPFv2 configs, so neighbor will still have the summarised LSA.
5. Configure router ospf with redistribute static and connected.
6. Check the DB, summarised LSA is present although the configuration is not present.
7. Now configure the summary-address and remove the configuration after sometime.
8. The summarised LSA will be still present.

RCA:
==================
When self originated LSA is received from the neighbor and that
LSA is summarised one, the LSA is refreshed but a flag is not set
due to which it was not able to remove it later.

Fix:
==================
Set the originated flag when refreshing summarised LSA.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-08-17 02:15:42 -07:00
Igor Ryzhov
5bd78355d1 ospfd: fix initialization when vrf doesn't exist yet
There are a couple of things that are not initialized if the OSPF router
is created in a non-existent VRF:
- ospf_lsa_maxage_walker
- ospf_lsa_refresh_walker
- ospf_opaque_type11_lsa_init

Rearrange some code to always initialize them and make it easier to find
similar problems in the future.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-12 15:49:54 +03:00
Mobashshera Rasool
e474c14373 ospfd: ospf redistribute originating LSA internal connected routes
When OSPF is disabled on interface and enabled again, the IP which is
not matching the prefix-list is getting originated as External LSA.

Fixes: #9362

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-08-10 09:41:14 -07:00
Russ White
ec179bcbba
Merge pull request #9300 from donaldsharp/ospf_header
ospfd: Cleanup ospf_interface.h to work with our standards
2021-08-10 09:50:50 -04:00
Donald Sharp
e8ed9d1548 ospfd: Cleanup ospf_interface.h to work with our standards
When declaring functions we must name the variables as part
of our standard.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-08-06 10:46:48 -04:00
Mobashshera Rasool
d125213c8a ospfd: NSSA area should not exchange Type-4 LSAs in DD
Problem Statement:
==================
OSPF Peer gets stuck in EXSTART with ARISTA Device.

Root Cause:
=================
First peer is form with Arista device in normal area and then
the area type is changed to NSSA. Due to this Type-4 and Type-5
LSAs advertised by Arista router is still present in
the OSPF DB. While DD exchange the Type-5 LSAs are omitted but
the Type-4 LSAs are not omitted due to which Arista device gets
stuck in EXSTART and it keeps moving between EXCHANGE And EXSTART.

Fix:
=================
When the area is NSSA, we should not send Type-4 LSAs in DD
exchange packet.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-08-06 05:15:10 -07:00
anlan_cs
46a8c34324 ospfd: fix coverity warning of one field initialization
Add the initialization of prefixlen field in struct prefix.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-08-04 21:20:20 -04:00
Donald Sharp
761704b370
Merge pull request #9092 from rgirada/rmap
ospfd: OSPF hello packets not sent with configured hello timer
2021-08-03 21:18:21 -04:00
Russ White
f61a950acf
Merge pull request #9239 from idryzhov/ospf-passive-fix
ospfd: fix "no ip ospf passive" command
2021-08-03 09:21:14 -04:00
Igor Ryzhov
82f0277b35 ospfd: fix "no ip ospf passive" command
This command is currently always treated as an "unset" command, assuming
that active is the default type of the interface. In reality, the default
type of the interface can be changed using "passive-interface default"
command. Both "no" and regular commands can be "set" commands, depending
on the default value. They are treated as an "unset" when there's already
a config of the opposite type.

All this logic is in ospf_passive_interface_update.

Fixes #9240.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-30 15:08:08 +03:00
Igor Ryzhov
9da01b0b7b *: cleanup interface node installation
The only difference in daemons' interface node definition is the config
write function. No need to define the node in every daemon, just pass
the callback as an argument to a library function and define the node
there.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-29 21:35:25 +03:00
Donald Sharp
5b1c5bf2d8
Merge pull request #9189 from idryzhov/ospf-dont-exit
ospfd: don't exit when socket is not created
2021-07-28 10:05:58 -04:00
Christian Hopps
1b8049c79f ospfd: remove gratuitous non-ascii quotation marks
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-07-27 17:13:39 +00:00
Igor Ryzhov
95d7a42a1a ospfd: don't exit when socket is not created
Let's be less radical. There's no reason to stop the whole daemon when
there's a socket creation error in a single VRF. The user can always
restart this single VRF to retry to create a socket.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-27 16:10:35 +03:00
rgirada
be418160a7 ospfd: OSPF hello packets not sent with configured hello timer
Description :
	ospf hello timer is not getting refelcted upon
	changing the hello interval.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-07-22 10:22:07 -07:00
David Lamparter
63116a7008 build: fix AM_LDFLAGS usage (and gcov)
like the other automake variables, setting `xyz_LDFLAGS` causes
`AM_LDFLAGS` to be ignored for `xyz`.  For some reason I had in my mind
that automake doesn't do this for LDFLAGS, but... it does.  (Which is
consistent with `_CFLAGS` and co.)

So, all the libraries and modules have been ignoring `AM_LDFLAGS` (which
includes `SAN_FLAGS` too).  Set up new `LIB_LDFLAGS` and
`MODULE_LDFLAGS` to handle all of this correctly (and move these bits to
a central location.)

Fixes: #9034
Fixes: 0c4285d77e ("build: properly split CFLAGS from AC_CFLAGS")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-21 17:10:08 +02:00
Igor Ryzhov
dcaed63d2f ospfd: remove unnecessary memory allocation
ospf_distribute_list_update currently passes two arguments to
ospf_distribute_list_update_timer - pointer to the ospf structure and
protocol type. The protocol type is only used for logging and is not
even correct because if multiple changes happen during one
ospf->min_ls_interval, then only the type of the first change is logged.

It is better to completely remove the protocol type argument to have a
correct log and eliminate the need for memory allocation.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-21 13:49:52 +03:00
rgirada
c88ad8ec5b ospfd: ospfd crash while giving 'clear ip ospf neighbor'
Description:
	Ospf process crashes upon giving 'clear ip ospf neighbor' with
        self routerId. It is asserting if it is a self neighbor in ospf
        neighbour kill event processing.
	Added a check to validate the provided router-id is self
        router-id.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-07-20 04:39:05 -07:00
Russ White
000df71ccd
Merge pull request #8767 from opensourcerouting/ospfd-gr
ospfd: introduce support for Graceful Restart (restarting mode)
2021-07-13 06:39:53 -04:00
Rafael Zalamena
1fe59b44fc lib,ospfd,ospf6d: remove duplicated function
Move `is_default_prefix` variations to `lib/prefix.h` and make the code
use the library version instead of implementing it again.

NOTE
----

The function was split into per family versions to cover all types.
Using `union prefixconstptr` is not possible due to static analyzer
warnings which cause CI to fail.

The specific cases that would cause this failure were:
 - Caller used `struct prefix_ipv4` and called the generic function.
 - `is_default_prefix` with signature using `const struct prefix *` or
   `union prefixconstptr`.

The compiler would complain about reading bytes outside of the memory
bounds even though it did not take into account the `prefix->family`
part.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-07-09 07:55:25 -03:00
Renato Westphal
1051417011 ospfd: introduce support for Graceful Restart (restarting mode)
RFC 3623 specifies the Graceful Restart enhancement to the OSPF
routing protocol. This PR implements support for the restarting mode,
whereas the helper mode was implemented by #6811.

This work is based on #6782, which implemented the pre-restart part
and settled the foundations for the post-restart part (behavioral
changes, GR exit conditions, and on-exit actions).

Here's a quick summary of how the GR restarting mode works:
* GR can be enabled on a per-instance basis using the `graceful-restart
  [grace-period (1-1800)]` command;
* To perform a graceful shutdown, the `graceful-restart prepare ospf`
  EXEC-level command needs to be issued before restarting the ospfd
  daemon (there's no specific requirement on how the daemon should
  be restarted);
* `graceful-restart prepare ospf` will initiate the graceful restart
  for all GR-enabled instances by taking the following actions:
  o Flooding Grace-LSAs over all interfaces
  o Freezing the OSPF routes in the RIB
  o Saving the end of the grace period in non-volatile memory (a JSON
    file stored in `$frr_statedir`)
* Once ospfd is started again, it will follow the procedures
  described in RFC 3623 until it detects it's time to exit the graceful
  restart (either successfully or unsuccessfully).

Testing done:
* New topotest featuring a multi-area OSPF topology (including stub
  and NSSA areas);
* Successful interop tests against IOS-XR routers acting as helpers.

Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-07-05 11:43:02 -03:00
Renato Westphal
cd52c44c00 ospfd: rename the graceful restart header
Both the GR helper code and the upcoming GR restarting code are going
to share a lot of definitions. As such, rename ospf_gr_helper.h to
ospf_gr.h, which will be the central point of all GR definitions
and prototypes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-07-05 11:43:02 -03:00
GalaxyGorilla
3f87e1d8b3 ospfd: adjust log config for GR
Remove previous log config

	debug ospf graceful-restart helper

and just use

	debug ospf graceful-restart

for everything related to OSPF GR.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-07-05 11:43:02 -03:00