Commit graph

1400 commits

Author SHA1 Message Date
Donatas Abraitis 93bae5f81f ospf6d: Show if the interface is passive for show ipv6 ospf6 interface
donatas-pc# sh ipv6 ospf6 interface enp3s0
enp3s0 is up, type BROADCAST
  Interface ID: 2
  Internet Address:
    inet : 192.168.10.17/24
    inet6: fe80::ca5d:fd0d:cd8:1bb7/64
  Instance ID 0, Interface MTU 1500 (autodetect: 1500)
  MTU mismatch detection: enabled
  Area ID 0.0.0.0, Cost 1000
  State Waiting, Transmit Delay 1 sec, Priority 1
  Timer intervals configured:
   Hello 10(8.149), Dead 40, Retransmit 5
  DR: 0.0.0.0 BDR: 0.0.0.0
  Number of I/F scoped LSAs is 1
    0 Pending LSAs for LSUpdate in Time 00:00:00 [thread off]
    0 Pending LSAs for LSAck in Time 00:00:00 [thread off]
  Authentication Trailer is disabled
donatas-pc# con
donatas-pc(config)# int enp3s0
donatas-pc(config-if)# ipv6 ospf6 passive
donatas-pc(config-if)# do sh ipv6 ospf6 interface enp3s0
enp3s0 is up, type BROADCAST
  Interface ID: 2
  Internet Address:
    inet : 192.168.10.17/24
    inet6: fe80::ca5d:fd0d:cd8:1bb7/64
  Instance ID 0, Interface MTU 1500 (autodetect: 1500)
  MTU mismatch detection: enabled
  Area ID 0.0.0.0, Cost 1000
  State Waiting, Transmit Delay 1 sec, Priority 1
  Timer intervals configured:
   No Hellos (Passive interface)
  DR: 0.0.0.0 BDR: 0.0.0.0
  Number of I/F scoped LSAs is 1
    0 Pending LSAs for LSUpdate in Time 00:00:00 [thread off]
    0 Pending LSAs for LSAck in Time 00:00:00 [thread off]
  Authentication Trailer is disabled
donatas-pc(config-if)#

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-08 09:37:19 +02:00
Donald Sharp d7cde18c63
Merge pull request #12196 from opensourcerouting/xref-vtysh
*: rewrite `extract.pl` using `xref` infra
2022-11-03 08:54:09 -04:00
Jafar Al-Gharaibeh e3c117e19a
Merge pull request #12201 from donaldsharp/clang-16-robots
Clang 16 robots
2022-10-26 23:07:05 -05:00
David Lamparter e53dac2fb3 ospfd, ospf6d: align CLI help strings
ospfd and ospf6d define the same metric-type route-map commands.  Make
them have the same help string too.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
David Lamparter 89cb86aeb0 build, vtysh: extract vtysh commands from .xref
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-26 17:12:34 +01:00
Donald Sharp b6ce3356d9 ospf6d: Make ospf6d happy with clang-16
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-26 07:41:03 -04:00
Manoj Naragund 0022611fb7 ospf6d: Fix for memory leak issues in ospf6.
Problem:
Multiple memory leaks in ospf6.

 260 ==6637== 32 bytes in 1 blocks are definitely lost in loss record 5 of 24
 261 ==6637==    at 0x4C31FAC: calloc (vg_replace_malloc.c:762)
 262 ==6637==    by 0x4E8A1BF: qcalloc (memory.c:111)
 263 ==6637==    by 0x11EE27: ospf6_summary_add_aggr_route_and_blackhole (ospf6_asbr.c:2779)
 264 ==6637==    by 0x11EEBA: ospf6_originate_new_aggr_lsa (ospf6_asbr.c:2811)
 265 ==6637==    by 0x4E7C6A7: hash_clean (hash.c:325)
 266 ==6637==    by 0x11FA93: ospf6_handle_external_aggr_update (ospf6_asbr.c:3164)
 267 ==6637==    by 0x11FA93: ospf6_asbr_summary_process (ospf6_asbr.c:3386)
 268 ==6637==    by 0x4EB739B: thread_call (thread.c:1692)
 269 ==6637==    by 0x4E85B17: frr_run (libfrr.c:1068)
 270 ==6637==    by 0x119535: main (ospf6_main.c:228)

 356 ==6637== 240 bytes in 12 blocks are indirectly lost in loss record 13 of 24
 357 ==6637==    at 0x4C2FE96: malloc (vg_replace_malloc.c:309)
 358 ==6637==    by 0x4E8A0DA: qmalloc (memory.c:106)
 359 ==6637==    by 0x13545C: ospf6_lsa_alloc (ospf6_lsa.c:724)
 360 ==6637==    by 0x1354E3: ospf6_lsa_create_headeronly (ospf6_lsa.c:756)
 361 ==6637==    by 0x1355F2: ospf6_lsa_copy (ospf6_lsa.c:790)
 362 ==6637==    by 0x13B58B: ospf6_dbdesc_recv_slave (ospf6_message.c:976)
 363 ==6637==    by 0x13B58B: ospf6_dbdesc_recv (ospf6_message.c:1038)
 364 ==6637==    by 0x13B58B: ospf6_read_helper (ospf6_message.c:1838)
 365 ==6637==    by 0x13B58B: ospf6_receive (ospf6_message.c:1875)
 366 ==6637==    by 0x4EB739B: thread_call (thread.c:1692)
 367 ==6637==    by 0x4E85B17: frr_run (libfrr.c:1068)
 368 ==6637==    by 0x119535: main (ospf6_main.c:228)

RCA:
1. when the ospf6 area is being deleted, the neighbor related information
   was not being cleaned up.
2. when aggr route gets deleted from rt_aggr_tbl the corrsponding summary
   route attched to the aggr route was not being deleted.

Fix:
Added the ospf6_neighbor_delete in ospf6_area_delete to free the
neighbor related information and added ospf6_route_delete while
freeing external aggr route to free the summary route.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-10-25 00:43:10 -07:00
Donatas Abraitis d2e0ef18b3
Merge pull request #12146 from rgirada/frr_gr
ospf6d: adding missing json fields
2022-10-19 10:10:50 +03:00
rgirada 239ccb07f2 ospf6d: adding missing json fields
Description:
	Active GR count field is missing in json o/p
	of 'show ipv6 ospf gr helper' command.

Issue: #12100

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-10-18 05:51:18 +00:00
Donald Sharp cf00164b69 *: Create and use infrastructure to show debugs in lib
There are lib debugs being set but never show up in
`show debug` commands because there was no way to show
that they were being used.  Add a bit of infrastructure
to allow this and then use it for `debug route-map`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-07 12:39:05 -04:00
Xiaodong Xu 4ef96a7015 ospf6d: Don't remove summary route if it is a range
Fix issue #11839.

When the user defines a range in an area other than the backbone area, the
summary route will be announced to the backbone area as an inter-area LSA.
However, if the prefix defined in the range is the same prefix as a connected
route in that area, the LSA won't be announced to the backbone area.

This is because when ospf6d is originating the summary route for the
intra-area route, it finds the range configured by the user and tries to
suppress the route by deleting the existing summary route, which happens to be
the one created by the range.

Although the range definition is not necessary in this case, it should not
fail this use case. So let's just keep the summary route there if it is
created from the user defined range.

Signed-off-by: Xiaodong Xu <stid.smth@gmail.com>
2022-08-19 23:26:06 -07:00
Donatas Abraitis 17667be0a3
Merge pull request #11781 from donaldsharp/ospf_packet_helper
Ospf packet helper
2022-08-15 20:43:49 +03:00
Donald Sharp 0b368b50dd
Merge pull request #11785 from opensourcerouting/fix/remove_ospf6Enabled_from_JSON
ospf6d: Remove ospf6Enabled from JSON output
2022-08-12 20:29:47 -04:00
Donald Sharp 4e5c95be91 ospf6d: Remove unused variable
last_serviced_oi is always NULL.  Remove

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-11 13:40:50 -04:00
Donatas Abraitis 97b4474de1 ospf6d: Remove ospf6Enabled from JSON output
Time to deprecate it.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-11 17:32:24 +03:00
anlan_cs 4f0d3f3e8a ospf6d: fix missing cost change
After all needed interfaces ( for example: interface "a1", vrf "vrf1", and
"a1" is binded to "vrf1" ) are ready/created, then restart/start frr. zebra
at startup will call `netlink_interface()` to process all interfaces and notify
all clients, but its calling `get_iflink_speed()` maybe fails for unexpected
order of the coming interfaces: when processing "a1", "vrf1" maybe is unknown
at that time. `if_zebra_speed_update()` timer is introduced to deal with this
order problem.

Currently only ospfd and ospf6d deal with this speed change to recalculated
route cost. ospfd can deal with this change, but ospf6d will wrongly missed it.

Since both `ipv6 ospf6 cost COST` and `auto-cost reference-bandwidth COST` are
not set, cost of this ospf6 interface should be calculated with interface
speed, but it is wrongly kept to `10`, which is based on interface speed being
`0` for it missed speed change. Further, ECMP function becomes invalid after
restart frr, beacuse some ospf6 interfaces of one ECMP are wrongly with cost
`10`.

To avoid missing, recalculate cost for ospf6 interfaces based on potentially
changed speed.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-08-11 08:12:30 -04:00
anlan_cs 22ce5803e4 ospf6d: combine two conditions for lsa prefix
For both router and network LSAs, combine the two conditions and process lsa
prefix uniformly.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-08-02 21:09:33 -04:00
sri-mohan1 abc14fa02b ospf6d: corrected the debug string
Corrected the gramatical error for debug string

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-07-27 22:29:02 +05:30
Punith Kumar S f3e93dc535 ospf6d: fix test_ospf6_gr_topo1 topotest
1. topo test failure seen in below mentioned step of execution with
routes not synced with ABR
ospf6_gr_topo1/test_ospf6_gr_topo1.py::test_gr_rt3 - AssertionError:
"rt1" JSON output mismatches the expected result.

2. as experimental, increasing the sleep interval(21),
cleared the above step but failed in the step
FAILED ospf6_gr_topo1/test_ospf6_gr_topo1.py::test_gr_rt5 -
AssertionError: "rt2" JSON output mismatches the expected result

fix:
tuning retry parameter in check_routers cleared the topotest.
so, changing default value of ospf6 ABR task delay to 5 seconds.

Signed-off-by: Punith Kumar S <punith.shivakumar@sophos.com>
2022-07-13 10:01:11 +00:00
Punith Kumar S a7c1a27f0e ospf6d: routes are not synced by ABR.
topology: C1--R1---R2---R3--C2
client C1 connected to router node R1
client C2 connected to router node R3
router nodes R1,R2 and R3 are back to back connected

area 0 configured between R1 and R2
R1: all routes of area 0 are learnt successfully
R2: all routes of area 0 are learnt successfully

area 1 configured between R2 and R3
R2: all routes are learnt from R3
R3: routes learnt from C1 on ABR router R2 does not get forward to R3

root cause: on interface start, ABR schedule task is missing.

fix: handle ABR schedule during interface start event

Signed-off-by: Punith Kumar S <punith.shivakumar@sophos.com>
2022-07-13 09:51:16 +00:00
mobash-rasool 8771cdcb94
Merge pull request #11462 from donaldsharp/random_stuff_right
Random stuff right
2022-06-24 17:23:31 +05:30
Rafael Zalamena aaa331923d
Merge pull request #11430 from mjstapp/fix_ospf6_zebra_del
ospf6: permit route delete without nexthops
2022-06-24 08:21:48 -03:00
Donald Sharp d9529c9fb1 ospf6d: Ensure that ospf6d does not memcpy beyond end of data
Ensure that received data size can fit into temp variable
that is used to dump data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 13:43:25 -04:00
Mark Stapp 0f9e2c918b ospf6: permit route delete without nexthops
It's possible for ospf6 to decide to delete a route after it's
removed all of the route's nexthops. It's ok to delete a prefix
alone - be a little more forgiving when preparing a route delete.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-06-17 11:47:55 -04:00
Donald Sharp 7aa77e557b ospf6d: cost is uint32_t so it cannot be greater than UINT32_MAX
Remove the extra test.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 16:31:35 -04:00
Donatas Abraitis 70dd370f5a *: Use autocomplete for route-maps under commands that require it
For example:

```
donatas-laptop# show bgp ipv4 unicast neighbors 127.0.0.2 advertised-routes route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas

donatas-laptop(config)# router bgp
donatas-laptop(config-router)# address-family ipv4
donatas-laptop(config-router-af)# redistribute connected route-map ?
  RMAP_NAME  Pointer to route-map entries
       testas2 testas

donatas-laptop(config-router-af)# network 192.168.0.0/23 route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-13 21:00:51 +03:00
David Lamparter c047b50638 ospf6d: fix rx/tx buffer sizes
OSPFv3 packets can be fragmented and up to 64k long, regardless of
interface MTU.  Trying to size these buffers to MTU is just plain wrong.
To not make this a super intrusive change during the 8.3 release freeze,
just code this into ospf6_iobuf_size().

Since the buffer is now always 64k, don't waste time zeroing the entire
thing in receive;  instead just zero kind of a "sled" of 128 bytes after
the buffer as a security precaution.

Fixes: #11298
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-06-01 17:10:11 +02:00
Donald Sharp c905f04c7c ospf6d: Clean up thread interface
a) Remove setting of thread pointer to NULL after
thread invocation, this is already done.

b) Use thread_is_scheduled()

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-20 09:52:16 -04:00
Donald Sharp 23b11ab185 ospf6d: Remove double check of default prefix
The ospf6_is_valid_summary_addr function is checking
to see if a prefix is the default and also then double
comparing it against the v6 prefix part.  No need to do this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-20 09:52:16 -04:00
Donald Sharp 578e092a04 ospf6d: Ensure the ospf6 interface hello timer pops in all cases
If a end users does something like this:

int enp39s0
  ipv6 ospf6 hello-interval 65535

And then the timer pops and we send the hello and immediately
if the end user does this:

  ipv6 ospf6 hello-interval 5

The timer is not being reset and FRR waits the full 65k seconds
before sending the hello again, which then immediately sets
the next hello to go out in 5 seconds.

When FRR receives the new timer value, look at how much time
is left on the timer in seconds.  If this value is greater
than the new hello timer, stop the timer and set it too that
value.

This should fix a CI system test failure found, where the
system is testing setting timer from things like 12 seconds
to 65k seconds then back down to 12 and that the ospf6 neighbor
relationship stays up.

The code was also changed from thread_add_event to thread_add_timer
in all cases.  I am not sure what would happen if a show command
comes in for a thread timer remaining with an event instead of a timer
just make it consistent.

This was chased down because the support bundle showed this:
r0# show ipv6 ospf6 vrf all interface
r0-r1-eth0 is up, type BROADCAST
  Interface ID: 6
  Internet Address:
    inet6: fe80::a4ea:d3ff:fe35:cef1/64
    inet6: fd00::1/64
  Instance ID 0, Interface MTU 1500 (autodetect: 1500)
  MTU mismatch detection: enabled
  Area ID 0.0.0.0, Cost 10
  State DR, Transmit Delay 1 sec, Priority 1
  Timer intervals configured:
   Hello 12(65480.960), Dead 48, Retransmit 5

And looking at the test code is doing stuff like this:
2022/05/16 17:08:15 OSPF6: [M7Q4P-46WDR] vty[5]@(config)# interface r1-r0-eth0

2022/05/16 17:08:15 OSPF6: [M7Q4P-46WDR] vty[5]@(config-if)# ipv6 ospf6 hello-interval 65535

2022/05/16 17:08:15 OSPF6: [M7Q4P-46WDR] vty[5]@(config-if)# no ipv6 ospf6 hello-interval
2022/05/16 17:08:16 OSPF6: [M7Q4P-46WDR] vty[5]@(config-if)# ipv6 ospf6 hello-interval 1
2022/05/16 17:08:16 OSPF6: [M7Q4P-46WDR] vty[5]@(config-if)# ipv6 ospf6 hello-interval 12

If the old timer value pops, the hello interval is set to 65k and never reset again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-16 17:52:10 -04:00
Donald Sharp 6290bec97e ospf6d: Give time left in hello timer for show ipv6 ospf6 int
When running `show ipv6 ospf6 interface` the hello timer period
is shown, but there is no indication on how much time is left
on the timer.  Add a clue:

sharpd@eva ~/frr5 (master)> vtysh -c "show ipv6 ospf6 int"
enp39s0 is up, type BROADCAST
  Interface ID: 2
  Internet Address:
    inet : 192.168.119.224/24
    inet6: 2603:6080:602:509e:9a14:998:b154:9e9/64
  Instance ID 0, Interface MTU 1500 (autodetect: 1500)
  MTU mismatch detection: enabled
  Area ID 0.0.0.0, Cost 1000
  State DR, Transmit Delay 1 sec, Priority 1
  Timer intervals configured:
   Hello 10(2.652), Dead 40, Retransmit 5
  DR: 192.168.122.1 BDR: 0.0.0.0
  Number of I/F scoped LSAs is 1
    0 Pending LSAs for LSUpdate in Time 00:00:00 [thread off]
    0 Pending LSAs for LSAck in Time 00:00:00 [thread off]
  Authentication Trailer is disabled

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-16 11:06:29 -04:00
Donald Sharp f205a2309c
Merge pull request #11177 from opensourcerouting/fix/memset_memcpy
*: memcpy/memset zeroing
2022-05-13 07:40:58 -04:00
Donatas Abraitis 6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
anlan_cs 905b12b263 ospf6d: add header size check for LSA
Add header size check for safe. If the check fails, just jump out of current
function.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-10 10:03:57 -04:00
Igor Ryzhov 2a3807c3ce
Merge pull request #11163 from opensourcerouting/fix/same_type_casting
*: Avoid casting to the same type as on the left
2022-05-10 00:16:30 +03:00
Donatas Abraitis 8998807f69 *: Avoid casting to the same type as on the left
Just not necessary.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-08 16:07:42 +03:00
Donatas Abraitis 432ee88c21 zebra, ospf6d: Do not check if NULL for XCALLOC()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-08 15:43:21 +03:00
anlan_cs 8e3aae66ce *: remove the checking returned value for hash_get()
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-03 00:41:48 +08:00
Donatas Abraitis 3d3c38b1d4
Merge pull request #11051 from donaldsharp/speell_more
Speell more
2022-04-20 11:04:14 +03:00
Donald Sharp 4667220e3a *: Fix spelling of accidently
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:31:30 -04:00
Donald Sharp bd4f51b10f *: Fix spelling of specifed
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:12:43 -04:00
Yash Ranjan ec58bf6f24 ospf6d: Check for MinLSInterval timer when adding to LSUpdate list
A router has some static routes and redistributes turned on.
"clear ipv6 ospf process" command is applied. Then static routes
are deleted. In 1 in 5 runs, AS-External LSAs are not getting removed
from the neighbors even though it gets removed from its own LSDB.

Because of the clear process command, MAX_AGE LSAs are advertised and
fresh LSAs are installed in the LSDB. When the MAX_LSAs are advertised
back to the same router as part of the flooding process, it gets added
to the LSUpdate list even though it comes inside the MinLSArrival time.
When the static routes get deleted, it removed the LSA from the
LSRetrans list but not from LSUpdate list. The LSAs present in the
LSUpdate list gets advertised when sending LS Updates.

When an old copy of an LSA is more recent than the new LSA, check if it
has come inside the MinLSArrival time before adding to the LSUpdate
list.

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2022-04-17 21:55:22 -07:00
Donald Sharp 17be83bf99 *: Fix spelling of Gracefull
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:46:19 -04:00
Igor Ryzhov 68618ebca8 ospf6d: fix crash when applying a route-map on a temporary route
ospf6_routemap_rule_match_interface uses route->ospf6 field for matching
so we must fill the field in our temporary variable.

Fixes #10911.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-03-29 18:09:53 +03:00
Russ White c845d58d6f
Merge pull request #10158 from ckishimo/ospf6d_norefresh
ospf6d: stop refreshing type-5 from NSSA
2022-03-29 08:36:05 -04:00
ckishimo 3cd5108d82 ospf6d: fix NSSA area-range command
When an area-range command is applied in an ABR, the more specific prefixes
need to be removed.

r2# sh ipv6 ospf database

        AS Scoped Link State Database

Type LSId           AdvRouter       Age   SeqNum                        Payload
ASE  0.0.0.1        10.254.254.2     53 80000001                             ::
ASE  0.0.0.2        10.254.254.2     51 80000001                2001:db8:1::/64
ASE  0.0.0.3        10.254.254.2     51 80000001                2001:db8:3::/64
ASE  0.0.0.4        10.254.254.2     51 80000001                2001:db8:2::/64
ASE  0.0.0.5        10.254.254.2     46 80000001                2001:db8:1::/64
ASE  0.0.0.6        10.254.254.2     46 80000001                2001:db8:3::/64
ASE  0.0.0.7        10.254.254.2     46 80000001                2001:db8:2::/64
ASE  0.0.0.8        10.254.254.2     41 80000001                2001:db8:3::/64
ASE  0.0.0.9        10.254.254.2     41 80000001           2001:db8:1000::1/128  <-- **
ASE  0.0.0.10       10.254.254.2     41 80000001           2001:db8:1000::2/128  <-- **
ASE  0.0.0.12       10.254.254.2     24 80000001             2001:db8:1000::/64
ASE  0.0.0.1        10.254.254.3     52 80000001                2001:db8:2::/64

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-03-28 22:19:27 +02:00
David Lamparter eb3c9d9774 *: add SAFI argument to zclient_send_rnh
Just pushing that SAFI_UNICAST up 1 level to the caller.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27 14:57:22 +02:00
Manoj Naragund 7c20ee06d3 ospf6d: crash in ospf6_decrement_retrans_count.
Problem:
ospf6d crash is observed when lsack is received from the neighbour for
AS External LSA.

RCA:
The crash is observed in ospf6_decrement_retrans_count while decrementing
retransmit counter for the LSA when lsack is recived. This is because in
ospf6_flood_interace when new LSA is being added to the neighbour's list
the incrementing is happening on the received LSA instead of the already
present LSA in scope DB which is already carrying counters.

when this new LSA replaces the old one, the already present counters are
not copied on the new LSA this creates counter mismatch which results in
a crash when lsack is recevied due to counter going to negative.

Fix:
The fix involves following changes.
   1. In ospf6_flood_interace when LSA is being added to retrans list
      check if there is alreday lsa in the scoped db and increment
      the counter on that if present.
   2. In ospf6_lsdb_add copy the retrans counter from old to new lsa
      when its being replaced.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-03-17 16:58:02 +05:30
Donald Sharp 7baebfb715
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
*: Fix JSON keys with whitespaces and PascalCase
2022-03-13 18:19:33 -04:00
Donald Sharp 06e4e90132 *: When matching against a nexthop send and process what it matched against
Currently the nexthop tracking code is only sending to the requestor
what it was requested to match against.  When the nexthop tracking
code was simplified to not need an import check and a nexthop check
in b8210849b8 for bgpd.  It was not
noticed that a longer prefix could match but it would be seen
as a match because FRR was not sending up both the resolved
route prefix and the route FRR was asked to match against.

This code change causes the nexthop tracking code to pass
back up the matched requested route (so that the calling
protocol can figure out which one it is being told about )
as well as the actual prefix that was matched to.

Fixes: #10766
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-12 11:18:45 -05:00
Donatas Abraitis 4a3c92de3c ospfd,ospf6d: Add missing newline for graceful-restart prepare CLI
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-09 22:56:53 +02:00
Donald Sharp cc9f21da22 *: Change thread->func to return void instead of int
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-23 19:56:04 -05:00
Russ White c07cfc5494
Merge pull request #10571 from rameshabhinay/ospf6_auth_trailer
ospf6d: fix coverity issues.
2022-02-15 13:19:48 -05:00
Donald Sharp bbf5104c5b ospf6d: Fix spelling mistakes
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-14 12:52:05 -05:00
Abhinay Ramesh 42bfee18c2 ospf6d: fix coverity issues.
Fixed below coverity issues
________________________________________________________________________________________________________
*** CID 1511366:    (TAINTED_SCALAR)
/ospf6d/ospf6_message.c: 2631 in ospf6_make_lsupdate_list()
2625                          + OSPF6_HEADER_SIZE)
2626                         > ospf6_packet_max(on->ospf6_if)) {
2627                             ospf6_fill_header(on->ospf6_if, (*op)->s,
2628                                               length + OSPF6_HEADER_SIZE);
2629                             (*op)->length = length + OSPF6_HEADER_SIZE;
2630                             ospf6_fill_lsupdate_header((*op)->s, *lsa_cnt);
>>>     CID 1511366:    (TAINTED_SCALAR)
>>>     Passing tainted variable "(*op)->length" to a tainted sink.
2631                             ospf6_send_lsupdate(on, NULL, *op);
2632
2633                             /* refresh packet */
2634                             *op = ospf6_packet_new(on->ospf6_if->ifmtu);
2635                             length = OSPF6_LS_UPD_MIN_SIZE;
2636                             *lsa_cnt = 0;
/ospf6d/ospf6_message.c: 2631 in ospf6_make_lsupdate_list()
2625                          + OSPF6_HEADER_SIZE)
2626                         > ospf6_packet_max(on->ospf6_if)) {
2627                             ospf6_fill_header(on->ospf6_if, (*op)->s,
2628                                               length + OSPF6_HEADER_SIZE);
2629                             (*op)->length = length + OSPF6_HEADER_SIZE;
2630                             ospf6_fill_lsupdate_header((*op)->s, *lsa_cnt);
>>>     CID 1511366:    (TAINTED_SCALAR)
>>>     Passing tainted variable "(*op)->length" to a tainted sink.
2631                             ospf6_send_lsupdate(on, NULL, *op);

________________________________________________________________________________________________________
*** CID 1511365:    (TAINTED_SCALAR)
/ospf6d/ospf6_message.c: 2674 in ospf6_make_ls_retrans_list()
2669                             if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT)
2670                                     (*op)->dst = allspfrouters6;
2671                             else
2672                                     (*op)->dst = on->linklocal_addr;
2673
>>>     CID 1511365:    (TAINTED_SCALAR)
>>>     Passing tainted variable "(*op)->length" to a tainted sink.
2674                             ospf6_fill_hdr_checksum(on->ospf6_if, *op);
2675                             ospf6_packet_add(on->ospf6_if, *op);
2676                             OSPF6_MESSAGE_WRITE_ON(on->ospf6_if);
/ospf6d/ospf6_message.c: 2674 in ospf6_make_ls_retrans_list()
2669                             if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT)
2670                                     (*op)->dst = allspfrouters6;
2671                             else
2672                                     (*op)->dst = on->linklocal_addr;
2673
>>>     CID 1511365:    (TAINTED_SCALAR)
>>>     Passing tainted variable "(*op)->length" to a tainted sink.
2674                             ospf6_fill_hdr_checksum(on->ospf6_if, *op);
2675                             ospf6_packet_add(on->ospf6_if, *op);
2676                             OSPF6_MESSAGE_WRITE_ON(on->ospf6_if);
/ospf6d/ospf6_message.c: 2674 in ospf6_make_ls_retrans_list()
2668                             ospf6_fill_lsupdate_header((*op)->s, *lsa_cnt);
2669                             if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT)
2670                                     (*op)->dst = allspfrouters6;
2671                             else
2672                                     (*op)->dst = on->linklocal_addr;
2673
>>>     CID 1511365:    (TAINTED_SCALAR)
>>>     Passing tainted variable "(*op)->length" to a tainted sink.
2674                             ospf6_fill_hdr_checksum(on->ospf6_if, *op);
2675                             ospf6_packet_add(on->ospf6_if, *op);
2676                             OSPF6_MESSAGE_WRITE_ON(on->ospf6_if);

________________________________________________________________________________________________________
*** CID 1511364:  Insecure data handling  (TAINTED_SCALAR)
/ospf6d/ospf6_message.c: 2125 in ospf6_write()
2120                     if (oi->at_data.flags != 0) {
2121                             at_len = ospf6_auth_len_get(oi);
2122                             if (at_len) {
2123                                     iovector[0].iov_len =
2124                                             ntohs(oh->length) + at_len;
>>>     CID 1511364:  Insecure data handling  (TAINTED_SCALAR)
>>>     Passing tainted variable "iovector[0].iov_len" to a tainted sink.
2125                                     ospf6_auth_digest_send(oi->linklocal_addr, oi,
2126                                                            oh, at_len,
2127                                                            iovector[0].iov_len);
2128                             } else {
2129                                     iovector[0].iov_len = ntohs(oh->length);
2130                             }

________________________________________________________________________________________________________
*** CID 1511363:    (DEADCODE)
/ospf6d/ospf6_auth_trailer.c: 275 in ospf6_hash_hmac_sha_digest()
269      case KEYCHAIN_ALGO_HMAC_SHA512:
270     #ifdef CRYPTO_OPENSSL
271              sha512_digest(mes, len, digest);
272     #endif
273              break;
274      case KEYCHAIN_ALGO_NULL:
>>>     CID 1511363:    (DEADCODE)
>>>     Execution cannot reach this statement: "case KEYCHAIN_ALGO_MAX:".
275      case KEYCHAIN_ALGO_MAX:
276      default:

/ospf6d/ospf6_auth_trailer.c: 274 in ospf6_hash_hmac_sha_digest()
269      case KEYCHAIN_ALGO_HMAC_SHA512:
270     #ifdef CRYPTO_OPENSSL
271              sha512_digest(mes, len, digest);
272     #endif
273              break;
>>>     CID 1511363:    (DEADCODE)
>>>     Execution cannot reach this statement: "case KEYCHAIN_ALGO_NULL:".
274      case KEYCHAIN_ALGO_NULL:
275      case KEYCHAIN_ALGO_MAX:
276      default:

________________________________________________________________________________________________________
*** CID 1511362:  Insecure data handling  (TAINTED_SCALAR)
/ospf6d/ospf6_auth_trailer.c: 541 in ospf6_auth_check_digest()
535
536      auth_len = ntohs(ospf6_auth->length);
537
538      memcpy(temp_hash, ospf6_auth->data, hash_len);
539      memcpy(ospf6_auth->data, apad, hash_len);
540
>>>     CID 1511362:  Insecure data handling  (TAINTED_SCALAR)
>>>     Passing tainted variable "oh_len + auth_len + lls_block_len" to a tainted sink.
541      ospf6_auth_update_digest(oi, oh, ospf6_auth, auth_str,
542                               (oh_len + auth_len + lls_block_len),
543                               hash_algo);

________________________________________________________________________________________________________
*** CID 1511361:  Insecure data handling  (TAINTED_SCALAR)
/ospf6d/ospf6_auth_trailer.c: 124 in ospf6_auth_hdr_dump_recv()
118      at_len = length - (oh_len + lls_len);
119      if (at_len > 0) {
120              ospf6_at_hdr =
121                      (struct ospf6_auth_hdr *)((uint8_t *)ospfh + oh_len);
122              at_hdr_len = ntohs(ospf6_at_hdr->length);
123              hash_len = at_hdr_len - OSPF6_AUTH_HDR_MIN_SIZE;
>>>     CID 1511361:  Insecure data handling  (TAINTED_SCALAR)
>>>     Passing tainted variable "hash_len" to a tainted sink.
124              memcpy(temp, ospf6_at_hdr->data, hash_len);
125              temp[hash_len] = '\0';

________________________________________________________________________________________________________
*** CID 1482146:  Insecure data handling  (TAINTED_SCALAR)
/ospf6d/ospf6_message.c: 2787 in ospf6_lsupdate_send_neighbor_now()
2781
2782             if (IS_OSPF6_DEBUG_FLOODING
2783                 || IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND_HDR))
2784                     zlog_debug("%s: Send lsupdate with lsa %s (age %u)", __func__,
2785                                lsa->name, ntohs(lsa->header->age));
2786
>>>     CID 1482146:  Insecure data handling  (TAINTED_SCALAR)
>>>     Passing tainted variable "op->length" to a tainted sink.
2787             ospf6_send_lsupdate(on, NULL, op);

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-14 06:36:02 +00:00
Abhinay Ramesh 6fc7e0c3d1 ospf6d: Enable the feature using configure.ac
Problem Statement:
=================
The feature is not enabled, needs to be enabled by doing required
initialization.

RCA:
====
Changes to support the feature is present, but the feature macro
needs to be enabled.

Fix:
====
This commit has changes to enable the code.

Risk:
=====
Medium

Need to ensure all existing ospf6 related topotests pass. to ensure
packet processing is not impacted.

Tests Executed:
===============
Have tested the functionality with enabling openssl and also disabling
openssl.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-09 01:57:08 +00:00
Abhinay Ramesh 6cb85350df ospf6d: Stitching the auth trailer code with rest of ospf6.
Problem Statement:
==================
RFC 7166 support for OSPF6 in FRR code.

RCA:
====
This feature is newly supported in FRR

Fix:
====
Core functionality implemented in previous commit is
stitched with rest of ospf6 code as part of this commit.

Risk:
=====
Low risk

Tests Executed:
===============
Have executed the combination of commands.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-09 01:57:08 +00:00
Abhinay Ramesh b592ec5ad0 ospf6d: Core functionality of auth trailer implementation..
Problem Statement:
==================
Implement RFC 7166 support for OSPF6 in FRR code.

RCA:
====
This feature is newly supported in FRR.

Fix:
====
Changes are done to implement ospf6 ingress and egress
packet processing.
This commit has the core functionality.

It supports below debugability commands:
---------------------------------------
debug ospf6 authentication [<tx|rx>]

It supports below clear command:
--------------------------------
clear ipv6 ospf6 auth-counters interface [IFNAME]

It supports below show commands:
--------------------------------
frr# show ipv6 ospf6 interface ens192
ens192 is up, type BROADCAST
  Interface ID: 5
  Number of I/F scoped LSAs is 2
    0 Pending LSAs for LSUpdate in Time 00:00:00 [thread off]
    0 Pending LSAs for LSAck in Time 00:00:00 [thread off]
  Authentication trailer is enabled with manual key         ==> new info added
    Packet drop Tx 0, Packet drop Rx 0			    ==> drop counters

frr# show ipv6 ospf6 neighbor 2.2.2.2 detail
 Neighbor 2.2.2.2%ens192
    Area 1 via interface ens192 (ifindex 3)
    0 Pending LSAs for LSUpdate in Time 00:00:00 [thread off]
    0 Pending LSAs for LSAck in Time 00:00:00 [thread off]
    Authentication header present                           ==> new info added
                         hello        DBDesc       LSReq        LSUpd        LSAck
      Higher sequence no 0x0          0x0          0x0          0x0          0x0
      Lower sequence no  0x242E       0x1DC4       0x1DC3       0x23CC       0x1DDA

frr# show ipv6 ospf6
 OSPFv3 Routing Process (0) with Router-ID 2.2.2.2
 Number of areas in this router is 1
 Authentication Sequence number info                       ==> new info added
  Higher sequence no 3, Lower sequence no 1656

Risk:
=====
Low risk

Tests Executed:
===============
Have executed the combination of commands.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-09 01:57:08 +00:00
Abhinay Ramesh 1a5607eab9 ospf6d: Auth trailer CLI implementation.
Problem Statement:
==================
RFC 7166 support for OSPF6 in FRR code.

RCA:
====
This feature is newly supported in FRR

Fix:
====
Changes are done to add support for two new CLIs to configure
ospf6 authentication trailer feature.
One CLI is to support manual key configuration.
Other CLI is to configure key using keychain.

below CLIs are implemented as part of this commit. this configuration
is applied on interface level.

Without openssl:
ipv6 ospf6 authentication key-id (1-65535) hash-algo <md5|hmac-sha-256> key WORD

With openssl:
ipv6 ospf6 authentication key-id (1-65535) hash-algo <md5|hmac-sha-256|hmac-sha-1|hmac-sha-384|hmac-sha-512> key WORD

With keychain support:
ipv6 ospf6 authentication keychain KEYCHAIN_NAME

Running config for these command:

frr# show running-config
Building configuration...

Current configuration:
!
interface ens192
 ipv6 address 2001:DB8:1::2/64
 ipv6 ospf6 authentication key-id 10 hash-algo hmac-sha-256 key abhinay
!
interface ens224
 ipv6 address 2001:DB8:2::2/64
 ipv6 ospf6 authentication keychain abhinay
!

Risk:
=====
Low risk

Tests Executed:
===============
Have executed the combination of commands.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-09 01:57:08 +00:00
Abhinay Ramesh b25bd2ad6e ospf6d: support keychain for ospf6 authentication
Problem Statement:
==================
As of now there is no support for ospf6 authentication.
To support ospf6 authentication need to have keychain support for
managing the auth key. 
 
RCA:
====
New support
 
Fix:
====
Enabling keychain for ospf6 authentication feature.
 
Risk:
=====
Low risk
 
Tests Executed:
===============
Have verified the support for ospf6 auth trailer feature.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-09 01:56:38 +00:00
Igor Ryzhov 88386db620
Merge pull request #10323 from opensourcerouting/ospf6-lsa-stats
ospf6d: LSA statistics
2022-02-06 21:46:13 +03:00
Donatas Abraitis 77a2f8e592 *: Add camelCase JSON keys in addition to PascalCase
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-03 10:48:06 +02:00
Donatas Abraitis 08d79bce3d ospfd,ospf6d: Add JSON additional keys with no whitespaces inside
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-03 10:48:06 +02:00
Igor Ryzhov 0624c3cfcc
Merge pull request #10373 from anlancs/ospf-add-asbr
ospfd: fix missing "aggregation timer" in running configuration
2022-02-01 19:04:33 +03:00
Igor Ryzhov 8ccce75009
Merge pull request #10435 from ckishimo/ospf6d_distance
ospf6d: fix distance not applied
2022-02-01 13:28:44 +03:00
Donatas Abraitis 8b3f1d41fe ospf6d: Fix memory leak for show ipv6 ospf6 zebra json
$ for x in $(seq 1 10000); do vtysh -c 'show ipv6 ospf6 zebra json' >/dev/null; done

Before:
```
$ vtysh -c 'show memory ospf6d' | grep 'Total heap allocated'
  Total heap allocated:  26 MiB
```

After:
```
$ vtysh -c 'show memory ospf6d' | grep 'Total heap allocated'
  Total heap allocated:  2256 KiB
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-31 16:53:23 +02:00
anlan_cs 74e8311eb3 ospf6d: adjust type of "aggr_delay_interval"
Adjust type of "aggr_delay_interval":
Just replace `unsigned int` with `uint16_t` for range is (50..1800).

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-01-28 20:11:30 -05:00
ckishimo 94c78d3b6d ospf6d: print administrative distance in show ipv6 ospf
Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-28 14:20:14 +01:00
ckishimo fcd45026a2 ospf6d: restart spf when distance is updated
if r1 has a route received from a neighbor and the same route
configured as static, the administrative distance will determine
which route to use

r1(config)# ipv6 route 1:1::1/128 Null0 70

r1# sh ipv6 route
Codes: K - kernel route, C - connected, S - static, R - RIPng,
       O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table,
       v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

S>* 1:1::1/128 [70/0] unreachable (blackhole), weight 1, 00:00:12
O   1:1::1/128 [110/20] via fe80::1833:c9ff:fe7b:3e43, r1-r2-eth0, weight 1, 00:00:49

The static route is selected. If we now change the administrative distance
in ospf6, the OSPF route should be selected

r1(config)# router ospf6
r1(config-ospf6)# distance 50

r1# sh ipv6 route
Codes: K - kernel route, C - connected, S - static, R - RIPng,
       O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table,
       v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

S>* 1:1::1/128 [70/0] unreachable (blackhole), weight 1, 00:00:39
O   1:1::1/128 [110/20] via fe80::1833:c9ff:fe7b:3e43, r1-r2-eth0, weight 1, 00:01:16

However the distance is not applied as there are no changes in the routing table

This commit will force the update of the routing table with the new configured distance

r1# sh ipv6 route
Codes: K - kernel route, C - connected, S - static, R - RIPng,
       O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table,
       v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

O>* 1:1::1/128 [50/20] via fe80::8cb7:e6ff:fef5:2344, r1-r2-eth0, weight 1, 00:00:03
S   1:1::1/128 [70/0] unreachable (blackhole), weight 1, 00:00:19

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-28 14:18:54 +01:00
Donatas Abraitis 7a90d91586
Merge pull request #10408 from idryzhov/no-opaque-by-default
*: do not send opaque data to zebra by default
2022-01-28 12:54:16 +02:00
Donatas Abraitis 636da186ae
Merge pull request #10389 from gromit1811/bugfix_9720_ecmp_inter_area
ospf6d: Fix ECMP inter-area route nexthop update
2022-01-28 09:09:51 +02:00
ckishimo cfc5d4746d ospf6d: show if area is NSSA
This PR will include if the area is NSSA in the output of "show ipv6 ospf"

    r2# show ipv6 ospf
     ...
     Area 0.0.0.0
         Number of Area scoped LSAs is 8
         Interface attached to this area: r2-eth1
         SPF last executed 20.46717s ago
     Area 0.0.0.1[Stub]
         Number of Area scoped LSAs is 9
         Interface attached to this area: r2-eth0
         SPF last executed 20.46911s ago
     Area 0.0.0.2[NSSA]
         Number of Area scoped LSAs is 14
         Interface attached to this area: r2-eth2
         SPF last executed 20.46801s ago

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-25 18:49:29 +01:00
ckishimo fb5a450fe7 ospf6d: fix indentation in show ipv6 ospf area
Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-25 18:47:47 +01:00
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
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
Martin Buck b74e965142 ospf6d: Fix ECMP inter-area route nexthop update
Fixes #9720. When updating an ECMP inter-area route, we compute
a new route and check whether that already exists. If so, we keep the old
route and only update its nexthops. Previously, we merged the new route's
nexthops into the old one's, but this way, it's impossible to remove
nexthops from the old route, resulting in stale nexthops.

This commit fixes this by first removing all nexthops from the old route and
then copying all nexthops from the new route into it. If the new route has
fewer nexthops, the old one will have as well afterwards.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
2022-01-20 15:18:32 +01: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
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
Donald Sharp ab0cc8a3f8
Merge pull request #10314 from ckishimo/ospf6d_extstub
ospf6d: do not send Type-5 into stub area
2022-01-13 09:04:35 -05:00
Igor Ryzhov 499841d123
Merge pull request #10315 from ckishimo/ospf6d_cleaning
ospf6d: some cleaning
2022-01-12 14:35:44 +03:00
David Schweizer 0b11b56abd
ospf6d: add LSA stats to show area json output
Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2022-01-12 12:32:33 +01:00
David Schweizer 8935a149e5
ospf6d: add LSA statistics to LSA database
Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2022-01-12 12:30:59 +01:00
Igor Ryzhov eb900ab56c
Merge pull request #9285 from anlancs/fix-ospf6d-cli-with-nonexist-vrf
ospf6d: add prompt for commands with non-exist vrf
2022-01-12 14:26:28 +03:00
Igor Ryzhov 9a809258aa
Merge pull request #9292 from mobash-rasool/ospfv3-bug2
ospfv3 is showing enabled on loopback interface although it is not
2022-01-12 14:25:17 +03:00
ckishimo bc36c05277 ospf6d: add missing htons
Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-11 11:03:30 +01:00
ckishimo 416721d942 ospf6d: fix typos
Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-11 11:03:30 +01:00
ckishimo d8da8a4afc ospf6d: use __func__
Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-11 11:03:21 +01:00
anlan_cs d6b901ac78 ospf6d: give error information for commands with non-exist vrfs
Currently the ospf6d's commands with non-exist vrfs can't give the error
informations to users.

This commit adds a macro "OSPF6_CMD_CHECK_VRF" to give error information
if with non-exist vrfs. As usual, skip the checking process in the case
of json.

So one command can call this macro to do the checking process in its
end. At that time it need know json style or not, so add "json" parameter for
several related functions.

BTW, suppress the build warning of the macro `OSPF6_FIND_VRF_ARGS`:
"Macros starting with if should be enclosed by a do - while loop to avoid
possible if/else logic defects."

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2022-01-11 04:21:05 -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
ckishimo 3a53b2ac31 ospf6d: remove duplicated code
The OSPF6_LSA_UNAPPROVED flag is set in the function above
ospf6_lsa_translated_nssa_new, so there is no need to set
the flag again

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-10 17:58:26 +01:00
ckishimo 18529688e6 ospf6d: remove double htons
Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-10 17:57:58 +01:00
ckishimo b80cebb3b4 ospf6d: remove duplicated log
When running topotest ospf6_topo2 we can see a log message with wrong lsa id

2021/12/20 23:14:40.330 OSPF6: [V8P0C-HB5Z2] ASBR[default:Status:3]: Update
2021/12/20 23:14:40.330 OSPF6: [Z489N-JAJ6P] ASBR[default:Status:3]: Already ASBR
2021/12/20 23:14:40.330 OSPF6: [Z9D0B-12SBJ] Redistribute 2001:db8:2::/64 (connected)
2021/12/20 23:14:40.330 OSPF6: [N66XP-ANN4G] Advertise as AS-External Id:8.70.41.177 prefix 2001:db8:2::/64 metric 2   (**)
2021/12/20 23:14:40.330 OSPF6: [K4Y9R-C22T6] Advertise new AS-External Id:0.0.0.3 prefix 2001:db8:2::/64 metric 2
2021/12/20 23:14:40.330 OSPF6: [PKX0N-KNRQR] Originate AS-External-LSA for 2001:db8:2::/64

This PR removes the log (instead of fixing it) as same information is printed
in the following entry

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-10 14:47:07 +01:00
ckishimo 0c988f96c8 ospf6d: do not send Type-5 into stub area
When running the topotest ospf6_topo2, we see the ABR r2 sending type 5 LSA into
    the stub area 0.0.0.1 which are not acknowledged and the ABR keeps trying forever

    2022/01/07 15:51:57.953 LSUpdate to neighbor 10.254.254.1%r2-eth0
    2022/01/07 15:51:57.953 LSUpdate send on r2-eth0
    2022/01/07 15:51:57.953     src: fe80::5808:2aff:fe79:bb63
    2022/01/07 15:51:57.953     dst: fe80::785f:7aff:feee:82d6
    2022/01/07 15:51:57.953     OSPFv3 Type:4 Len:156 Router-ID:10.254.254.2
    2022/01/07 15:51:57.953     Area-ID:0.0.0.1 Cksum:0 Instance-ID:0
    2022/01/07 15:51:57.953     Number of LSA: 4
    2022/01/07 15:51:57.953     [AS-External Id:0.0.0.1 Adv:10.254.254.2]
    2022/01/07 15:51:57.953     Age:  198 SeqNum: 0x80000001 Cksum: 3959 Len: 28
    2022/01/07 15:51:57.953     [AS-External Id:0.0.0.2 Adv:10.254.254.2]
    2022/01/07 15:51:57.953     Age:  197 SeqNum: 0x80000001 Cksum: d5f2 Len: 36
    2022/01/07 15:51:57.953     [AS-External Id:0.0.0.3 Adv:10.254.254.2]
    2022/01/07 15:51:57.953     Age:  197 SeqNum: 0x80000001 Cksum: ebd9 Len: 36
    2022/01/07 15:51:57.953     [AS-External Id:0.0.0.4 Adv:10.254.254.2]
    2022/01/07 15:51:57.953     Age:  196 SeqNum: 0x80000001 Cksum: d1f3 Len: 36

    2022/01/07 15:52:02.953 LSUpdate to neighbor 10.254.254.1%r2-eth0
    2022/01/07 15:52:02.953 LSUpdate send on r2-eth0
    2022/01/07 15:52:02.953     src: fe80::5808:2aff:fe79:bb63
    2022/01/07 15:52:02.953     dst: fe80::785f:7aff:feee:82d6
    2022/01/07 15:52:02.953     OSPFv3 Type:4 Len:156 Router-ID:10.254.254.2
    2022/01/07 15:52:02.953     Area-ID:0.0.0.1 Cksum:0 Instance-ID:0
    2022/01/07 15:52:02.953     Number of LSA: 4
    2022/01/07 15:52:02.953     [AS-External Id:0.0.0.1 Adv:10.254.254.2]
    2022/01/07 15:52:02.953     Age:  203 SeqNum: 0x80000001 Cksum: 3959 Len: 28
    2022/01/07 15:52:02.954     [AS-External Id:0.0.0.2 Adv:10.254.254.2]
    2022/01/07 15:52:02.954     Age:  202 SeqNum: 0x80000001 Cksum: d5f2 Len: 36
    2022/01/07 15:52:02.954     [AS-External Id:0.0.0.3 Adv:10.254.254.2]
    2022/01/07 15:52:02.954     Age:  202 SeqNum: 0x80000001 Cksum: ebd9 Len: 36
    2022/01/07 15:52:02.954     [AS-External Id:0.0.0.4 Adv:10.254.254.2]
    2022/01/07 15:52:02.954     Age:  201 SeqNum: 0x80000001 Cksum: d1f3 Len: 36

    This PR prevents the ABR of sending type 5 lsa into a stub area

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-10 14:22:31 +01:00
Mobashshera Rasool 40a0880941 ospf6d: remove ospf6Enabled from json output after deprecation cycle
Since ospf6Enabled and attachedToArea are denoting the same thing.
It is decided to remove ospf6Enabled from json output to make
CLI and json output similar.

Fixes: #9286

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-01-10 03:50:16 -08:00
ckishimo 35ee59fb57 ospf6d: stop refreshing type-5 from NSSA
With the current code, in a topology like this:
         r1 ---- 0.0.0.0 ---- r2(ABR) ---- 1.1.1.1 -----r3(ASBR)
                                             NSSA

where r3 is redistributing statics within the NSSA area, the ABR (r2)
is translating type-7 lsa to type-5.

Everytime the function ospf6_abr_nssa_task() is executed all translated
type-5 are aged out and refreshed for no reason. So for instance having 3
lsas already advertised:

r1# sh ipv6 os database
        AS Scoped Link State Database
Type LSId           AdvRouter       Age   SeqNum                        Payload
ASE  0.0.0.1        2.2.2.2          39 80000001                     3:3::3/128
ASE  0.0.0.2        2.2.2.2          39 80000001                     4:4::4/128
ASE  0.0.0.3        2.2.2.2          39 80000001                     5:5::5/128

Adversting a new route from r3:

r3(config)# ipv6 route 6:6::6/128 Null0

r1# sh ipv6 os database
        AS Scoped Link State Database
Type LSId           AdvRouter       Age   SeqNum                        Payload
ASE  0.0.0.1        2.2.2.2         124 80000001                     3:3::3/128
ASE  0.0.0.2        2.2.2.2         124 80000001                     4:4::4/128
ASE  0.0.0.3        2.2.2.2         124 80000001                     5:5::5/128
ASE  0.0.0.4        2.2.2.2           8 80000001                     6:6::6/128

That seems okay, however a few seconds later we see all prefixes refreshed

r1# sh ipv6 os database
        AS Scoped Link State Database
Type LSId           AdvRouter       Age   SeqNum                        Payload
ASE  0.0.0.1        2.2.2.2        3600 80000001                     3:3::3/128
ASE  0.0.0.2        2.2.2.2        3600 80000001                     4:4::4/128
ASE  0.0.0.3        2.2.2.2        3600 80000001                     5:5::5/128
ASE  0.0.0.4        2.2.2.2        3600 80000001                     6:6::6/128
ASE  0.0.0.5        2.2.2.2           3 80000001                     3:3::3/128
ASE  0.0.0.6        2.2.2.2           3 80000001                     4:4::4/128
ASE  0.0.0.7        2.2.2.2           3 80000001                     5:5::5/128
ASE  0.0.0.8        2.2.2.2           3 80000001                     6:6::6/128

This PR prevents the LSA of being refreshed by unsetting the OSPF6_LSA_UNAPPROVED
flag so advertising the last prefix will not refresh all of them:

r1# sh ipv6 os database
        AS Scoped Link State Database
Type LSId           AdvRouter       Age   SeqNum                        Payload
ASE  0.0.0.1        2.2.2.2          90 80000001                     3:3::3/128
ASE  0.0.0.2        2.2.2.2          47 80000001                     4:4::4/128
ASE  0.0.0.3        2.2.2.2          35 80000001                     5:5::5/128
ASE  0.0.0.4        2.2.2.2           7 80000001                     6:6::6/128

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2022-01-05 18:19:32 +01:00
anlan_cs e146082ddc ospf6d: clean coverity warning of possible null pointer
Add assert to protect it.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-12-22 21:52:30 -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
Russ White 6e3a134e09
Merge pull request #10081 from ckishimo/ospf6d_type4
ospf6d: do not originate Type-4 lsa when NSSA
2021-12-07 06:39:00 -05:00
Russ White 85d1d680ab
Merge pull request #10018 from ckishimo/ospf6d_bitN
ospf6d: check N-bit in Hello packet
2021-11-29 11:05:11 -05: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 5a6c232bf8 ospf6d: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:50:37 +02:00
ckishimo a581473fbd ospf6d: check N-bit set in Hello packet
RFC 3101 states both E-bit and N-bit need to be checked when receiving a Hello packet.

"To support the NSSA option an additional check must be made in the function
that handles the receiving of the Hello packet to verify that both the N-bit
and the E-bit found in the Hello packet's option field match the area type and
ExternalRoutingCapability of the area of the receiving interface."

This PR adds the check for the N-bit

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2021-11-25 12:59:09 +01:00
Donald Sharp 62fcbf073e ospf6d: Remove ospf6->external_id_table
The external_id_table was only ever used to store pointers to data
and was never used for lookup during the course of normal operations.
However it did lead to crashes because somewhere along the way
external routes stored in the external_table never had their
id associated into the external_id_table and we would assert
on the node lookup failing.

Since this code was never used for anything other than
storing data and it was never retrieved for anything useful
let's just remove it from ospf6d.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-23 19:49:28 -05:00
Renato Westphal c1879c8fc5 ospf6d: remove unused constants
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 14:24:07 -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
Quentin Young 7b532137c3
Merge pull request #10070 from idryzhov/ospf6-memcmp-cleanup 2021-11-22 09:33:52 -05:00
Igor Ryzhov 0609190219
Merge pull request #10074 from opensourcerouting/assorted-20211116
lib/vtysh/ospf6d: assorted small bits
2021-11-19 15:43:10 +03:00
Igor Ryzhov 3c52293809
Merge pull request #10092 from ton31337/feature/replace_json_object_string_add_to_json_object_string_addf_for_inet_ntop
*: inet_ntop for JSON output
2021-11-18 22:19:40 +03:00
Donatas Abraitis ce4b236f61 ospf6d: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:41 +02:00
Donald Sharp a8f692edb0 ospf6d: Prevent use after free
I encountered a crash where the ospf6_write thread
was already thought to be scheduled by ospf6d:

(gdb) bt
    t_ptr=0x5624ee6bd260) at lib/thread.c:972
(gdb)

When poking around it was noticed that the ospf6 pointer was crap:
(gdb) p (struct ospf6 *)$7
$8 = (struct ospf6 *) 0x5624ee6c6b20
(gdb) p *$8
$9 = {vrf_id = 3998487040, name = 0x5624ee420010 "\a", router_id = 65892, router_id_static = 65892, router_id_zebra = 0, starttime = {tv_sec = 1654674, tv_usec = 678673},
  area_list = 0x0, backbone = 0x5624ee6c6710, lsdb = 0x5624ee6c2370, lsdb_self = 0x5624ee6c5d80, route_table = 0x5624ee6c5c10, brouter_table = 0x5624ee6c4690,
  external_table = 0x5624ee6c4710, external_id_table = 0x5624ee6c4f10, external_id = 24, redist = {0x0 <repeats 32 times>}, nssa_default_import_check = {refcnt = 0,
    status = false}, flag = 1 '\001', redistribute = 0, config_flags = 0 '\000', default_originate = 0, lsa_minarrival = 1000, spf_delay = 0, spf_holdtime = 50,
  spf_max_holdtime = 5000, spf_hold_multiplier = 1, spf_reason = 554, ts_spf = {tv_sec = 1654712, tv_usec = 122041}, ts_spf_duration = {tv_sec = 0, tv_usec = 48},
  last_spf_reason = 11, fd = -1, t_spf_calc = 0x0, t_ase_calc = 0x0, maxage_remover = 0x0, t_distribute_update = 0x0, t_ospf6_receive = 0x0, t_external_aggr = 0x0,
  t_write = 0x5624ee6cc930, write_oi_count = 20, ref_bandwidth = 100000, distance_all = 0 '\000', distance_intra = 0 '\000', distance_inter = 0 '\000',
  distance_external = 0 '\000', distance_table = 0x5624ee6c4f50, inst_shutdown = 1 '\001', max_multipath = 128, gr_info = {restart_support = false, restart_in_progress = false,
    prepare_in_progress = false, finishing_restart = false, grace_period = 0, t_grace_period = 0x0}, ospf6_helper_cfg = {supported_grace_time = 1800, is_helper_supported = false,
    strict_lsa_check = true, only_planned_restart = false, enable_rtr_list = 0x0, active_restarter_cnt = 0, last_exit_reason = 0}, anyNSSA = 0 '\000', t_abr_task = 0x0,
  oi_write_q = 0x0, redist_count = 0, aggr_action = 1, aggr_delay_interval = 6, rt_aggr_tbl = 0x5624ee6c51b0, qobj_node = {nid = 6163304287853836241, nodehash = {hi = {next = 0x0,
        hashval = 1613461457}}, type = 0x5624ed65e4e0 <qobj_t_ospf6>}}

Upon code inspection there was no place where we disabled the t_write thread upon ospf6 deletion.
If the code were to issue a `no router ospf6` and then recreate it.  We could see this crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-17 18:46:06 -05:00
ckishimo c01326c6fb ospf6d: do not originate Type-4 into NSSA
In a topology like:
     r1(ASBR) ---- 0.0.0.0 ---- r2(ABR) ---- 1.1.1.1 -----r3

where r1 is redistributing statics and area 1.1.1.1 is NSSA, the ABR r2 should
not originate type-4 LSA into the NSSA area. From RFC 3101: "NSSA border routers
should not originate Type-4 summary-LSAs into their NSSAs."

This PR prevents the above LSA of being originated by the ABR r2

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2021-11-16 22:03:05 +01:00
ckishimo 5a0e96e65b ospf6d: do not originate Type-4 for NSSA ASBR
In a topology like:
     r1 ---- 0.0.0.0 ---- r2(ABR) ---- 1.1.1.1 -----r3(ASBR)

where r3 is redistributing statics and area 1.1.1.1 is NSSA, the ABR r2 should
not originate type-4 LSA, according to RFC 3101, section 1.3:

"also an NSSA's border routers never originate Type-4 summary-LSAs for the
NSSA's AS boundary routers, since Type-7 AS-external-LSAs are never flooded
beyond the NSSA's border"

r1# sh ipv6 os database inter-router

        Area Scoped Link State Database (Area 0.0.0.0)

Type LSId           AdvRouter       Age   SeqNum                        Payload
IAR  3.3.3.3        2.2.2.2          49 80000001                        3.3.3.3

This PR prevents the above LSA of being originated by the ABR r2

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2021-11-16 22:03:05 +01: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
David Lamparter 067967b8c7 ospfd6d: replace handler vector with array
No point in using the vector code for this really.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-11-16 13:34:46 +01:00
Igor Ryzhov 66314e9fe0 ospf6d: replace memcmp with correct comparisons
Using memcmp with complex structures like prefix or ospf6_ls_origin is
not correct, because even two structures with same values in all fields
may have different values in padding bytes and comparison will fail.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-16 12:43:36 +03:00
Igor Ryzhov 8f359e1593 ospf6d: remove meaningless ospf6_route_is_identical
As part of the check, it memcompares two structs ospf6_path. This struct
has a pointer field nh_list which is allocated every time a new path is
created, which means it can never be the same for two different paths.
Therefore this check is always false and can be completely removed.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-15 19:27:27 +03: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
Russ White 83323dbf00
Merge pull request #9861 from rgirada/ospf6_coverity
ospf6d: Addressing few coverity issues.
2021-11-11 08:04:28 -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
Donald Sharp 81e06dd3c3 ospf6d: Prevent crash in adj_ok
The adj_ok thread event is being added but not killed
when the underlying interface is deleted.  I am seeing
this crash:

OSPF6: Received signal 11 at 1636142186 (si_addr 0x0, PC 0x561d7fc42285); aborting...
OSPF6: zlog_signal+0x18c                  7f227e93519a     7ffdae024590 /lib/libfrr.so.0 (mapped at 0x7f227e884000)
OSPF6: core_handler+0xe3                  7f227e97305e     7ffdae0246b0 /lib/libfrr.so.0 (mapped at 0x7f227e884000)
OSPF6: funlockfile+0x50                   7f227e863140     7ffdae024800 /lib/x86_64-linux-gnu/libpthread.so.0 (mapped at 0x7f227e84f000)
OSPF6:     ---- signal ----
OSPF6: need_adjacency+0x10                561d7fc42285     7ffdae024db0 /usr/lib/frr/ospf6d (mapped at 0x561d7fbc6000)
OSPF6: adj_ok+0x180                       561d7fc42f0b     7ffdae024dc0 /usr/lib/frr/ospf6d (mapped at 0x561d7fbc6000)
OSPF6: thread_call+0xc2                   7f227e989e32     7ffdae024e00 /lib/libfrr.so.0 (mapped at 0x7f227e884000)
OSPF6: frr_run+0x217                      7f227e92a7f3     7ffdae024ec0 /lib/libfrr.so.0 (mapped at 0x7f227e884000)
OSPF6: main+0xf3                          561d7fc0f573     7ffdae024fd0 /usr/lib/frr/ospf6d (mapped at 0x561d7fbc6000)
OSPF6: __libc_start_main+0xea             7f227e6b0d0a     7ffdae025010 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7f227e68a000)
OSPF6: _start+0x2a                        561d7fc0f06a     7ffdae0250e0 /usr/lib/frr/ospf6d (mapped at 0x561d7fbc6000)
OSPF6: in thread adj_ok scheduled from ospf6d/ospf6_interface.c:678 dr_election()

The crash is in the on->ospf6_if pointer is NULL.  The only way this could
happen from what I can tell is that the event is added to the system
and then we immediately delete the interface, removing the memory
but not freeing up the adj_ok thread event.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-05 18:00:10 -04:00
Donald Sharp 9318fc6a38 ospf6d: Prevent use after free
I am seeing a crash of ospf6d with this stack trace:

OSPF6: Received signal 11 at 1636042827 (si_addr 0x0, PC 0x55efc2d09ec2); aborting...
OSPF6: zlog_signal+0x18c                  7fe20c8ca19a     7ffd08035590 /lib/libfrr.so.0 (mapped at 0x7fe20c819000)
OSPF6: core_handler+0xe3                  7fe20c90805e     7ffd080356b0 /lib/libfrr.so.0 (mapped at 0x7fe20c819000)
OSPF6: funlockfile+0x50                   7fe20c7f8140     7ffd08035800 /lib/x86_64-linux-gnu/libpthread.so.0 (mapped at 0x7fe20c7e4000)
OSPF6:     ---- signal ----
OSPF6: ospf6_neighbor_state_change+0xdc     55efc2d09ec2     7ffd08035d90 /usr/lib/frr/ospf6d (mapped at 0x55efc2c8e000)
OSPF6: exchange_done+0x15c                55efc2d0ab4a     7ffd08035dc0 /usr/lib/frr/ospf6d (mapped at 0x55efc2c8e000)
OSPF6: thread_call+0xc2                   7fe20c91ee32     7ffd08035df0 /lib/libfrr.so.0 (mapped at 0x7fe20c819000)
OSPF6: frr_run+0x217                      7fe20c8bf7f3     7ffd08035eb0 /lib/libfrr.so.0 (mapped at 0x7fe20c819000)
OSPF6: main+0xf3                          55efc2cd7573     7ffd08035fc0 /usr/lib/frr/ospf6d (mapped at 0x55efc2c8e000)
OSPF6: __libc_start_main+0xea             7fe20c645d0a     7ffd08036000 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7fe20c61f000)
OSPF6: _start+0x2a                        55efc2cd706a     7ffd080360d0 /usr/lib/frr/ospf6d (mapped at 0x55efc2c8e000)
OSPF6: in thread exchange_done scheduled from ospf6d/ospf6_message.c:2264 ospf6_dbdesc_send_newone()

The stack trace when decoded is:

(gdb) l *(ospf6_neighbor_state_change+0xdc)
0x7bec2 is in ospf6_neighbor_state_change (ospf6d/ospf6_neighbor.c:200).
warning: Source file is more recent than executable.
195				   on->name, ospf6_neighbor_state_str[prev_state],
196				   ospf6_neighbor_state_str[next_state],
197				   ospf6_neighbor_event_string(event));
198		}
199
200		/* Optionally notify about adjacency changes */
201		if (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
202			       OSPF6_LOG_ADJACENCY_CHANGES)
203		    && (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
204				   OSPF6_LOG_ADJACENCY_DETAIL)

OSPFv3 is creating the event without a managing thread and as such
if the event is not run before a deletion event comes in memory
will be freed up and we'll start trying to access memory we should
not.  Modify ospfv3 to track the thread and appropriately stop
it when the memory is deleted or it is no longer need to run
that bit of code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-05 18:00:07 -04:00
Russ White ed79d896b2
Merge pull request #9833 from idryzhov/cleanup-if-by-index-all-vrf
*: fix usage of if_lookup_by_index_all_vrf
2021-11-05 15:17:31 -04:00
Philippe Guibert f13d33ccd0 ospf6d: avoid writing dumb ospf6 info at startup
in show: 'show ipv6 ospf6' handler command, the reason of SPF
executation is looked up and displayed. At startup, SPF has been
started, but shows no specific reason. Instead of dumping non
initialised string context, reset the string context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-11-03 11:48:55 +01: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
rgirada 6d1a5a1c54 ospf6d: Addressing few coverity issues.
Description:
	Addressed the following TAINTED_SCALAR issue which can possibly
	leads to memory currption.

	1. *** CID 1506514:  Insecure data handling  (TAINTED_SddddddCALAR)
	   /ospf6d/ospf6_gr_helper.c: 1222 in ospf6_grace_lsa_show_info()

	2. *** CID 1506513:  Insecure data handling  (TAINTED_SCALAR)
	   /ospf6d/ospf6_gr_helper.c: 160 in ospf6_extract_grace_lsa_fields()

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-10-29 11:04:06 -07:00
Igor Ryzhov 0373909a5f
Merge pull request #9863 from ton31337/feature/prefix-list_autocomplete
lib: Add autocomplete for prefix-list under route-maps
2021-10-29 13:30:04 +03:00
Igor Ryzhov fd4bd21eee
Merge pull request #9831 from manojvn/379909_383518
ospf6d: minor code enhancements.
2021-10-28 20:05:16 +03:00
Igor Ryzhov dbbcd51697 ospf6d: don't use if_lookup_by_index_all_vrf
if_lookup_by_index_all_vrf doesn't work correctly with netns VRF backend
as the same index may be used in multiple netns simultaneously.

We always know the OSPF6 instance we work with, so use its VRF id for
the interface lookup.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-28 18:54:46 +03:00
Donatas Abraitis 23599e7790 ospf6d: 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
Manoj Naragund 46e9628d01 ospf6d: remove unnecessary break.
Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2021-10-26 00:57:09 -07:00
Manoj Naragund a48bc483b0 ospf6d: prefix structure compare changes.
Description:
Code changes involve replacing memcmp with prefix_same,
for comparing prefix structures.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2021-10-26 00:57:09 -07:00
Manoj Naragund d214b64afa ospf6d: minor code enhancements.
Description:
code changes involve removal of increment and decrement operators
during function calls. These expressions make code less readable.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2021-10-26 00:57:03 -07: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
Russ White ed131d8b74
Merge pull request #9752 from opensourcerouting/ospf6d-nssa-ranges
ospf6d: add support for NSSA Type-7 address ranges
2021-10-19 19:15:40 -04: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 198ef12aef ospf6d: 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
Igor Ryzhov 33f4519d2c ospf6d: remove no-op
ospf6_route_create already sets route->ospf6.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-14 19:47:02 +03:00
David Lamparter c5726f0314
Merge pull request #9676 from donaldsharp/import_register 2021-10-13 22:28:03 +02:00
Renato Westphal d6f60d2276 ospf6d: fix LSA name in debug message
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-12 17:33:32 -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
Igor Ryzhov ad7e12b0d9 ospf6d: add missing vrf parameter to "clear ipv6 ospf6 interface"
Currently, it's not possible to run this command in any VRF other than default.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-09 02:54:10 +03:00
Donatas Abraitis d573b8f863 ospf6d: 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
Igor Ryzhov c6ff5b66e2
Merge pull request #9740 from caracall/forked-upstream/debug_ospf6
ospf6: add the ability of specifying router-id/area-id in no debug ospf6
2021-10-07 18:38:22 +03:00
Russ White 45ebf5f134
Merge pull request #9699 from manojvn/379032-dev
ospf6d: minor struct compare issues.
2021-10-06 19:00:39 -04:00
Russ White ef11fb018f
Merge pull request #9738 from rgirada/ospfv3_crash
ospf6d: ospf6d is crashing upon receiving duplicated Grace LSA.
2021-10-06 18:58:09 -04:00
Manoj Naragund bc465fb6cc ospf6d: code cleanup.
removal of some of the deadcode in ospf6d.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2021-10-06 08:54:47 -07:00
Ahmad Caracalli b25a110347 ospf6: add the ability of specifying router-id/area-id in no debug ospf6
Add the ability to specify the router-id/area-id when deleting the debug
ospf6 configuration.

The new commands are as follow:

no debug ospf6 border-routers router-id [A.B.C.D]
no debug ospf6 border-routers area-id [A.B.C.D]

Update the doc as well.

Signed-off-by: Ahmad Caracalli <ahmad.caracalli@6wind.com>
2021-10-06 15:46:19 +02:00
Renato Westphal 3c77bc809f ospf6d: add support for NSSA Type-7 address ranges
Implement NSSA address ranges as specified by RFC 3101:

   NSSA border routers may be configured with Type-7 address ranges.
   Each Type-7 address range is defined as an [address,mask] pair.  Many
   separate Type-7 networks may fall into a single Type-7 address range,
   just as a subnetted network is composed of many separate subnets.
   NSSA border routers may aggregate Type-7 routes by advertising a
   single Type-5 LSA for each Type-7 address range.  The Type-5 LSA
   resulting from a Type-7 address range match will be distributed to
   all Type-5 capable areas.

Syntax:
  area A.B.C.D nssa range X:X::X:X/M [<not-advertise|cost (0-16777215)>]

Example:
  router ospf6
   ospf6 router-id 1.1.1.1
   area 1 nssa
   area 1 nssa range 2001:db8:1000::/64
   area 1 nssa range 2001:db8:2000::/64
  !

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 2ad3c6dbbe ospf6d: fix lookup of translated Type-5 LSA
Type-7 LSAs and their corresponding Type-5 LSAs don't share the same
LS IDs (unlike in the case of OSPFv2). As such, do not attempt to find
a translated Type-5 LSA using the LS ID of a Type-7 LSA. Instead,
use the LS-ID stored in the OSPF routing table.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 8ee9d58b0d ospf6d: assorted code cleanup
This commits consists of several changes that positively impact
code reability without introducing any logical change.

Summary of the changes:
* Return earlier in ospf6_abr_range_update() in order to reduce one
  level of indentation;
* Remove ospf6_translated_nssa_originate() since it's nothing other
  than a useless wrapper around ospf6_lsa_translated_nssa_new();
* Change ospf6_abr_translate_nssa() to return void;
* Change ospf6_abr_process_nssa_translates() checking for NSSA areas
  before anything else;
* Remove ospf6_abr_remove_unapproved_translates_apply() since it's a
  small function that is only called in one place;
* Change ospf6_abr_check_translate_nssa() to avoid an LSDB lookup when
  the router isn't an ABR.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 7270e0edf3 ospf6d: remove unnecessary check when translating Type-7 LSA
In addition to being unnecessary, this check is problematic for the
upcoming NSSA ranges feature since NSSA ranges aren't added to the
OSPF routing table. Remove this for simplicity.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 14bb568af0 ospf6d: fix memleak when translating NSSA LSA
Stop leaking 4096 bytes for each translated LSA.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal c8093b99bf ospf6d: remove incomplete support for NSSA ranges
This code tries to summarize NSSA Type-7 LSAs using normal ranges
which are intended to summarize Type-3 LSAs only. This is not only
wrong, but the code is incomplete and lacking lots of things. Better
to remove it before implementing NSSA ranges correctly.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 05da1cbfef ospf6d: fix processing of translated AS-external LSAs
The iteration performed on ospf6_abr_unapprove_translates() was
wrong since AS-external LSAs are stored in the global LSDB and not
in the area LSDBs. As such, the "unapproved" flag wasn't being set
in any translated AS-external LSA, leading them to linger forever.

Fix the LSDB iteration and make the required changes to unset the
"unapproved" flag for AS-external LSAs that shouldn't be removed.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 9e49d1aca2 ospf6d: be careful to not refresh translated Type-5 LSAs twice
The ABR task already takes care of refreshing translated Type-5
LSAs that correspond to self-originated Type-7 LSAs. There's no
need to do that in ospf_external_lsa_install() as well. The ospfd
NSSA code takes the same precaution.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 5f2fe4bb77 ospf6d: fix selection of NSSA forwarding address
Change ospf6_get_nssa_fwd_addr() to try finding a global address
on any interface of the area and not on the first one only.

Additionally, do a micro-optimization in
ospf6_interface_get_global_address() to return as soon as a global
address is found.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal 576e842480 ospf6d: add "nssa" option to the "debug ospf6 lsa" command
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:25:55 -03:00
Renato Westphal d2487a6633 ospf6d: remove unnecessary code
Every received or originated LSA is automatically scheduled to be
refreshed periodically, there's no need to do that manually here.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:21:43 -03:00
Renato Westphal a526c05525 ospf6d: declare neighbor memtype as static
This is the only ospf6d memtype that wasn't being declared as static.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:21:43 -03:00
Renato Westphal cdc12294fc ospf6d: remove unused bitfield
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:21:43 -03:00
Renato Westphal 19b8369ca7 ospf6d: remove redundant loop
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:21:43 -03:00
Renato Westphal 36be5c61b3 ospf6d: remove unguarded debug message
This debug message is of little use so remove it instead of adding
a debug guard for it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:21:43 -03:00
Renato Westphal 578e1c5331 ospf6d: remove unused function parameter
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-05 21:21:43 -03:00
Russ White 334d9d259f
Merge pull request #9731 from ton31337/fix/thread_null_set
cleanup: struct thread = NULL
2021-10-05 19:27:23 -04:00
rgirada a60eab9e10 ospf6d: ospf6d is crashing upon receiving duplicated Grace LSA.
Description:
	When grace lsa received, DUT is adding
	the copy of the  lsas  to all nbrs retransmission  list as part of
	flooding procedure and subsequently incrementing the rmt counter in
	the original the LSA. This counter is supposed to be decremented
	when ack is received by nbr and the lsa  will be removed from retransmission list.

	But in our current scenario,
	Step-1:
		When GR helper is disabled, if DUT receives the grace lsa
		it adds the lsa copy to nbrs retransmission list but original
		LSA will be discarded since GR helper disabled.
	Step-2:
		GR helper enabled and DUT receives the grace lsa, as part
		of flooding process all nbrs have same copy of lsa in their
		corresponding rmt list which was added in step -1 due to this
		the corresponding rmt counter in the original lsa is not getting
		incremented.
	Step-3:
		If the same copy of the grace lsa received by DUT, It considers
		as implicit ack from nbr if the same copy of the lsa exits in its
		rmt list and subsequently  decrement the rmt counter.
	Since counter is zero (because of step-1 and 2) , it is asserting while decrement.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-10-05 04:14:37 -07:00
Donatas Abraitis f2b64253b8 ospf6d: 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-04 19:29:06 +03:00
Donald Sharp fc3f4adbc6 ospf6d: Ensure expire thread is properly stopped
The lsa->expire thread is for keeping track of when we
are expecting to expire(remove/delete) a lsa.  There
are situations where we just decide to straight up
delete the lsa, but we are not ensuring that the
lsa is not already setup for expiration.
In that case just stop the expiry thread and
do the deletion.

Additionally there was a case where ospf6d was
just dropping the fact that a thread was already
scheduled for expiration.  In that case we
should just setup the timer again and it will
reset it appropriately.

Fixes: #9721
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-04 12:13:57 -04:00
Manoj Naragund 25dd89e398 ospf6d: minor struct compare issues.
Problem Statement:
Multiple struct compare using memcmp, which might result in issue due to
structure padding/alignment.

Fix:
The code changes involve structure member by member comparison to
remove any issues related to padding/alignment.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
(cherry picked from commit 67db821a1d6d68b19862d50b68ed19278c5f2422)
2021-09-30 09:53:26 -07:00
Donald Sharp ad5c8f67a8 ospf6d: Make ospfv3 use normal address resolution instead of import route
OSPFv3 recently introduced the usage of import route.  Switch it
back to using the normal ZEBRA_NEXTHOP_REGISTER command.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-27 12:38:08 -04:00
Donald Sharp ed6cec97d7 *: Add resolve via default flag 2021-09-27 12:38:08 -04:00
Donald Sharp e2874251ed ospf6d: Log messages cannot have newlines
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-26 19:16:10 -04:00
Russ White b8beb67ef5
Merge pull request #9585 from opensourcerouting/ospf6d-nssa-dflt-originate
ospf6d: add a knob to generate Type-7 default routes
2021-09-24 13:42:49 -04:00
Igor Ryzhov d5cd3fd1e0
Merge pull request #9084 from louis-oui/fix-ospf6-router-id
ospf6d: fix LSAs remain in LSDB with an old router-id value
2021-09-23 19:03:35 +03:00
Louis Scalbert 078f609212 ospf6d: reset areas and redistribution at router-id modification
The ospf6 router-id is provided by order of preference by:

 ospf6d itself if the "ospf6 router-id X.X.X.X" command is set.
- zebra. If the "ip router-id X.X.X.X" zebra command is set, the
  configured IP is provided as the ID or alternatively the highest
  loopback IPv4 address or else the highest interface IPv4 address.

The running ospf6 router-id is stored in ospf6->router-id.

ospf6->router-id can change in the following conditions:

- A configuration change provides a new router-id value according to
  the above rules. ospf6->router-id is updated to the new value if
  there is no adjacency in FULL state. Otherwise, the ospf6d process
  must be restarted to take the new router-id into account.
- On startup of both zebra and ospf6d, if ospf6d has not yet received a
  valid router-id, ospf6d->router-id is set to 0 (i.e. 0.0.0.0). Then,
  zebra notifies ospf6d that the router-id is available.

At ospf6->router-id, the current behavior of ospf6d is the following:

- The self generated LSAs that refer to the previous router-id as the
  advertising router are kept.
- Self generated LSAs are created with router-id value.
- LSAs from the redistribution that refer to the previous router-id are
  kept and no new redistribution LSAs are created.

As a consequence, the routers in the ospf6 areas will get incorrect
LSAs and might not be able to install prefixes of those LSAs into their
RIB.

This fix solves this issue by resetting the areas and the redistribution
when ospf6->router-id updated.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2021-09-23 10:04:36 +02:00
Donald Sharp e39ea73486
Merge pull request #9647 from opensourcerouting/ospf-gr-cmd-rename
ospfd, ospf6d: rename the "graceful-restart helper-only" command
2021-09-22 14:53:40 -04:00
David Lamparter 16c3485e74
Merge pull request #9635 from donaldsharp/ospf6_unit 2021-09-22 14:25:46 +02:00
Renato Westphal 6735622c24 ospf6d: implement Type-7 default routes for NSSA areas
Add the "default-information-originate" option to the "area X nssa"
command. That option allows the origination of Type-7 default routes
on NSSA ABRs and ASBRs.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-21 17:47:13 -03:00
Renato Westphal 210429c747 ospf6d: don't generate Type-7 LSA for route created by "default-information-originate"
The route created by the "default-information-originate" command
isn't a regular external route. As such, an NSSA ABR shouldn't
originate a corresponding Type-7 LSA for it (there's a separate
configuration knob to generate Type-7 default routes).

While here, fix a small issue in ospf6_asbr_redistribute_add()
where routes created by "default-information-originate" were being
displayed with an incorrect "unknown" type.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-21 17:43:45 -03:00
Renato Westphal 16727fd7eb ospf6d: fix issue when displaying the redistribute command
When set to its default value, the metric type associated to a
"redistribute" statement shouldn't be displayed as part of the
running configuration.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-21 17:43:45 -03:00
Renato Westphal 242a9767f7 ospf6d: fix metric type of NSSA Type-7 LSAs
Fix wrong comparison since route->path.metric_type is always set
to either 1 or 2. The OSPF6_PATH_TYPE_EXTERNAL2 constant, whose
value is 4, refers to a route type so its usage was incorrect here.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-21 17:43:45 -03:00
Louis Scalbert a30494760f ospf6d: factorize router-id update
ospf6_router_id_update function is used by ospf6_router_id_update_zebra
to update the running the ospf6 router-id.

This patches makes the functions to (un)configure ospf6 router-id use
the same function as ospf6_router_id_update_zebra.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2021-09-21 19:00:38 +02:00
Louis Scalbert 436a55a1d5 ospf6d: don't update router-id if at least one adjacency is Full
When a router-id change is notified by zebra to ospf6d, we only take
into account the change if no adjacencies are in Full state.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2021-09-21 19:00:38 +02:00
Russ White 48f23c8879
Merge pull request #9640 from opensourcerouting/ospf6d-filters
ospf6d: rework filtering commands to be in line with ospfd
2021-09-21 11:28:58 -04:00
Renato Westphal 6b513b4c92 ospf6d: 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.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-21 11:51:36 -03:00
Donald Sharp 6926bedfb3 ospf6d: Fix debug string in rare case
When looking up the o_path->ls_prefix if it is not found
the debug statement was using a buf that was never initialized.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-21 07:54:54 -04:00
Donald Sharp 9ffafdd76b ospf6d: Always pre-init all header values to 0
When making the ospf6 header, let's actually fill
in all the header values

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-21 07:54:54 -04:00
Donald Sharp d0606e0a85 ospf6d: Use appropriate integer size and more context for reason strings
The ospfv3 spf reason strings are just presented internally in the code
without any real context.  Give a tiny bit more useful information for
the developer and convert the integer to a uint32_t

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-21 07:53:30 -04:00
Renato Westphal f4f0098ca0 ospf6d: rework filtering commands to be in line with ospfd
Issue #9535 describes how the export-list/import-list commands work
differently on ospfd and ospf6d.

In short:
* On ospfd, "area A.B.C.D export-list" filters which internal
  routes an ABR exports to other areas. On ospf6d, instead, that
  command filters which inter-area routes an ABR exports to the
  configured area (which is quite counter-intuitive). In other words,
  both commands do the same but in opposite directions.
* On ospfd, "area A.B.C.D import-list" filters which inter-area
  routes an ABR imports into the configured area. On ospf6d, that
  command filters which inter-area routes an interior router accepts.
* On both daemons, "area A.B.C.D filter-list prefix NAME <in|out>"
  works exactly the same as import/export lists, but using prefix-lists
  instead of ACLs.

The inconsistency on how those commands work is undesirable. This
PR proposes to adapt the ospf6d commands to behave like they do
in ospfd.

These changes are obviously backward incompatible and this PR doesn't
propose any mitigation strategy other than warning users about the
changes in the next release notes. Since these ospf6d commands are
undocumented and work in such a peculiar way, it's unlikely many
users will be affected (if any at all).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-20 13:06:35 -03:00
Donald Sharp cbcf3335b3 ospf6d: Use bool instead of an int
intra_brouter_calc is a int that is being used a bool,
convert to a bool.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-19 07:55:19 -04:00
Renato Westphal b275f44a4a ospf6d: fix build problem with ancient json-c versions
Some CI VMs are using really old versions of json-c (pre 2013 [1])
that expect filenames to be passed as "char *" instead of "const char *".

Add some explicit casts to fix the resulting compiler errors on those
VMs (passing "char *" when the API expects "const char *" is fine).
Hopefully this commit should be reverted once the CI is updated to use
newer versions of json-c.

[1] https://github.com/json-c/json-c/commit/20e4708c

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-16 12:26:48 -03:00
Renato Westphal 7116509803 ospf6d: introduce support for Graceful Restart (restarting mode)
RFC 5187 specifies the Graceful Restart enhancement to the OSPFv3
routing protocol. This commit implements support for the GR
restarting mode.

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 ipv6
  ospf` EXEC-level command needs to be issued before restarting the
  ospf6d 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 ospf6d 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.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-16 12:26:48 -03:00
Renato Westphal 1a898463a3 ospf6d: add missing entry to array of strings
Commit b8212e0310 introduced OSPF6_SPF_FLAGS_ASBR_STATUS_CHANGE but
didn't update the 'ospf6_spf_reason_str' array accordingly. Fix this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-16 12:26:05 -03:00
Igor Ryzhov 175c92e67e ospf6d: cleanup useless checks
om6->ospf6 is always initialized at the start of the execution.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-15 19:21:47 +03:00
Igor Ryzhov 390dce1275 ospf6d: fix possible NULL dereference
OSPF6_CMD_CHECK_RUNNING doesn't check that ospf6 is not NULL.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-15 13:48:29 +03:00
Mark Stapp 5fbbd15d1e
Merge pull request #9438 from ranjanyash54/debug_comm
ospf6d: Add debug commands for lsa all and route all
2021-09-14 11:38:21 -04:00
Russ White 3e2321b88c
Merge pull request #9019 from pjdruddy/ospfv3-early-break-list-walk
ospf6d: break early on route prefix mismatch
2021-09-10 14:29:53 -04:00