Commit graph

1400 commits

Author SHA1 Message Date
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
Donald Sharp 7932dd9331 ospf6d: Cleanup headers to our standard
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-09 16:42:52 -04:00
Renato Westphal 8a60820f70 ospf6d: add support for NSSA totally stub areas
Add a knob to turn a NSSA area into a totally stub area. In this
configuration a Type-3 default summary route is generated by default.

Syntax: `area A.B.C.D nssa no-summary`.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-07 11:43:35 -03:00
Igor Ryzhov 0f90ef494a
Merge pull request #9521 from opensourcerouting/ospf6d-gr-fixes
ospf6d: minor GR fixes
2021-09-06 12:36:54 +03:00
Donald Sharp 819a0202ae ospf6d: Prevent crash of show ipv6 ospf data adv-router 0.0.0.0 linkstate-id 0.0.0.0
With this sequence of events:
eva# conf
eva(config)# router ospf6
eva(config-ospf6)# end
eva# show ipv6 ospf data adv-router 0.0.0.0 linkstate-id 0.0.0.0
OSPF6: Received signal 11 at 1630442431 (si_addr 0x0, PC 0x559dcfa3a656); aborting...
OSPF6: zlog_signal+0x18c                  7fd2cc8229f7     7fff606775d0 /lib/libfrr.so.0 (mapped at 0x7fd2cc770000)
OSPF6: core_handler+0xe3                  7fd2cc8616ad     7fff606776f0 /lib/libfrr.so.0 (mapped at 0x7fd2cc770000)
OSPF6: funlockfile+0x50                   7fd2cc74f140     7fff60677840 /lib/x86_64-linux-gnu/libpthread.so.0 (mapped at 0x7fd2cc73b000)
OSPF6:     ---- signal ----
OSPF6: ospf6_lsdb_type_show_wrapper+0x5d     559dcfa3a656     7fff60677dd0 /usr/lib/frr/ospf6d (mapped at 0x559dcf9a5000)
OSPF6: show_ipv6_ospf6_database_adv_router_linkstate_id+0x1f9     559dcfa3c24a     7fff60677e50 /usr/lib/frr/ospf6d (mapped at 0x559dcf9a5000)

OSPF6 crashes.  Fix.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-01 08:07:53 -04:00
Renato Westphal 3ebc5e4be9 ospf6d: fix display of debug command in the running configuration
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-31 01:48:22 -03:00
Renato Westphal 950b49f80c ospf6d: fix unguarded GR debug message
The message about ignoring a one-way hello should only be logged
when the router is acting a helper for another one.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-31 01:45:50 -03:00
Russ White 26bf593efb
Merge pull request #9503 from opensourcerouting/ospf6d-redistribute-metrics
ospf6d: extend the "redistribute" command with more options
2021-08-28 09:20:44 -04:00
David Lamparter 8268be3d16
Merge pull request #9496 from idryzhov/vrf-cmd-init-unused-arg
lib: remove unused argument from vrf_cmd_init
2021-08-27 10:39:45 +02:00
Renato Westphal 476e957517 ospf6d: extend the "redistribute" command with more options
Add the "metric" and "metric-type" options to the "redistribute"
command.

This is a small commit since the logic of setting the metric
value and type of external routes was already present due to the
implementation of the "default-information originate" command months
ago. This commit merely extends the "redistribute" command to
leverage that functionality.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-26 15:05:53 -03:00
Christian Hopps d448e2c5f9
Merge pull request #9331 from idryzhov/explicit-exit
*: explicitly print "exit" at the end of every node config
2021-08-26 11:57:33 -04:00
Igor Ryzhov cfc369c43a lib: remove unused argument from vrf_cmd_init
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-26 12:01:22 +03:00
Yash Ranjan d5cb350834 ospf6d: Add debug commands for lsa all and route all
Debug commad for all lsa types and route types are not present.

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2021-08-25 04:54:11 -07:00
Donatas Abraitis d10bda270e *: Drop break after using frr_help_exit() in switch/case
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-25 10:49:05 +03:00
Igor Ryzhov bf41d65ebe
Merge pull request #9449 from opensourcerouting/ospf6d-nssa-fixes
ospf6d: NSSA fixes
2021-08-24 22:34:29 +03:00
Mark Stapp ea5e814cf7
Merge pull request #9457 from anlancs/ospf6-void
ospf6d: suppress coverity warning of return value
2021-08-24 15:30:45 -04:00
Mark Stapp 5809c297fb
Merge pull request #9458 from anlancs/fix-ospf6-null
ospf6d: fix lock leak of using ALL_LSDB in GR helper
2021-08-24 12:12:05 -04:00
Renato Westphal aea082d578 ospf6d: further validate NSSA ASBR routes used for route computation
Add missing sanity check specified in the NSSA RFC.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 11:53:36 -03:00
Renato Westphal 0c293b92ee ospf6d: do not allow an area to be stub and NSSA at the same time
That should not be allowed under any circumstance.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 11:53:36 -03:00
Renato Westphal 9142948e39 ospf6d: fix logging of border router routes
The prefix of routes to border routers consists of two pieces of
information embedded in a single struct (prefix.u.lp):

  struct prefix {
          uint8_t family;
          uint16_t prefixlen;
          union {
  		[snip]
                  struct {
                          struct in_addr id;
                          struct in_addr adv_router;
                  } lp;
          } u __attribute__((aligned(8)));
  };

As such, using prefix2str() (or the %pFX format specifier) isn't
correct when logging such routes.

This commit adds a few special cases here and there to handle
OSPF6_DEST_TYPE_ROUTER routes differently. It'd probably be a good
idea to add a helper function to handle all cases in a single place,
but that can be left for a second moment.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 11:53:36 -03:00
Renato Westphal 6df89791ba ospf6d: remove incorrect debug guard
Also, update the ospf6_topo2 topotest since the expected output
was wrong. With this fix, NSSA routes will be created on r2
("redistribute connected"), and NSSA routes appear in the routing
table as regular external routes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 00:39:56 -03:00
Renato Westphal dd551b9d1f ospf6d: flush external LSAs when NSSA is configured
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 00:24:41 -03:00
Renato Westphal ccfffce4a0 ospf6d: fix flushing of all LSAs when NSSA is unconfigured
Once NSSA is unconfigured on an area, all self-originated Type-7
LSAs need to be flushed. The existing code was iterating over the
LSDB in the wrong way, causing ospf6_nssa_flush_area() to flush
LSAs of all types.  Use the ALL_LSDB_TYPED_ADVRTR macro to perform
the intended iteration correctly.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 00:24:41 -03:00
Renato Westphal bb257321b2 ospf6d: don't delete area when NSSA is unconfigured
Once NSSA is unconfigured, the OSPF area should still be operational
as a normal area instead of being deleted.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 00:24:41 -03:00
Renato Westphal d36a6a19d9 ospf6d: always unset the E-bit on NSSA ABRs
RFC 3101 - Section 2.1 says:
"(..) Interfaces associated with an NSSA will not send or receive
Type-5 LSAs on that interface but may send and receive Type-7 LSAs.
Therefore, if the N-bit is set in the options field, the E-bit must
be clear."

If the E-bit isn't cleared on an NSSA ABR, that will cause hello
packets to be dropped (due to parameters mismatch), which will
prevent the ABR from forming adjacencies with others routers in
the NSSA area.

This problem didn't affect the existing NSSA topotest by chance
of luck.  In that topotest, in the NSSA ABR, the NSSA area is
configured before any interface is associated to it. That caused
ospf6_check_and_set_router_abr() to return false, leading to
the unsetting of the E-bit. With this fix, the order in which
areas/interfaces are configured shouldn't matter because the E-bit
will always be unset on NSSA areas.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-24 00:24:41 -03:00
Igor Ryzhov 07679ad98a *: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

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

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

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

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 22:08:20 +03:00
Igor Ryzhov 6b73885556
Merge pull request #9446 from mobash-rasool/ospfv3-bug-fixes
ospf6d: External LSAs reoriginates on every redistribute CLI
2021-08-23 19:00:23 +03:00
Mobashshera Rasool 058c4c783f ospf6d: External LSAs reoriginates on every redistribute CLI
Problem Statement:
==================
Everytime redistribute CLI is executed, external LSAs are
re-originated. When there is no change in the CLI parameters
the LSAs should not get re-originated.

Fix:
=================
Check if the CLI params are same, do not re-originate the LSA.

Fixes: #9445

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-08-23 04:47:10 -07:00
anlan_cs 37692712a5 ospf6d: fix lock leak of using ALL_LSDB in GR helper
The lsa and lsanext must be unlocked if break out of ALL_LSDB loop.

Incidentally correct the comment of ALL_LSDB.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-08-22 05:26:20 -04:00
anlan_cs 4d97dde2d1 ospf6d: suppress coverity warning of return value
Fix #CID 1506511

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-08-21 22:04:12 -04:00
Renato Westphal f70b917249
Merge pull request #8935 from rgirada/ospfv3_gr_helper
ospf6d: Support for ospfv3  graceful restart  helper functionality
2021-08-19 15:01:34 -03:00
Russ White 0512687b30
Merge pull request #9342 from mobash-rasool/ospfv3-asbr-summarisation
OSPF6d: Fixed assert at ospf6_originate_summary_lsa asbr.c:2849 and flushing of Type-7 LSAs
2021-08-17 10:31:29 -04:00
Quentin Young 6ddb368d6b ospf6d: JSON output for database dump show command
Added missing output to "show ipv6 ospf6 databse dump json" VTY shell
command.

Co-authored-by: David Schweizer dschweizer@opensourcerouting.org
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-08-12 16:26:01 -04:00
rgirada 0fc3e11323 ospf6d: GR helper configurations
Description:
	Adding the following cli commands to enable/disable GR helper
	functionality.
	1. [no] graceful-restart helper-only [A.B.C.D]
	2. [no] graceful-restart helper lsa-check-disable
	3. [no] graceful-restart helper planned-only
	4. [no] graceful-restart helper supported-grace-time (10-1800)

	show commands:
	show ipv6 ospf6 graceful-restart helper [detail] [json]

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-11 23:06:49 -07:00
rgirada 9a06f23d0b ospf6d: GR helper exit scenarios
Description:
	Changes to cover all the following  GR helper exit scenarios.
	1. Upon receiving max age grace lsa.( successful graceful restart)
	2. Topo change
	3. Grace timer expiry.
	4. User changes( like config deletion , interface down)

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
rgirada 0d1753a7db ospf6d: Helper functionality changes
Description:
	1. changes to process GRACE LSA packet.
	2. Validation changes to enter Helper role.
	3. Helper functionality during graceful restart.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
rgirada 0694366601 ospf6d: debug command support for helper support.
Description:
	Adding debug support for helper functionality.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
rgirada 59790f521a ospf6d: Init/De-init gr helper functionality
Description:
	Graceful restart helper functionality initialisation and deinit apis.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
rgirada 91c169f7d7 ospf6d: Datastructure modification for GR helper functionality.
Description:
	Adding GR helper specific datastructures.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
Mobashshera Rasool 523232c5c5 ospf6d: Remove Type-7 LSA when Type-5 LSA is removed
Fix:
When summarised Type-5 LSA is removed, the corresponding Type-7
LSAs also need to be removed from area.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-08-09 09:11:10 -07:00
Mobashshera Rasool 4e0702dc74 ospf6d: Remove assert and fix LSA removal in ASBR summarisation
Fix:
1. The assert at line ospf6_asbr.c:2849 is not required.
2. When Individual LSAs are present and summarisation is configured
we need to remove such LSAs and originate the summarised ones.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-08-09 09:11:04 -07:00
Yash Ranjan a867da2b6b ospf6d: Check the cost only when asbr_present for ECMP routes
For ECMP routes, the metric cost and metric type are compared
even when the asbr entry is not present. This stops the routes
from getting removed when max age LSAs are received for the
ECMP routes.

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2021-08-04 05:03:10 -07:00
Donald Sharp 3e18e550ed
Merge pull request #9108 from opensourcerouting/ospf6d-range-fixes
ospf6d: fix argument processing in the "area ... range" command
2021-08-03 21:15:12 -04:00
Renato Westphal 488599bfa2
Merge pull request #9232 from idryzhov/interface-node-cleanup
*: cleanup interface node installation
2021-08-02 21:13:29 -03:00
Russ White e448fefbb4
Merge pull request #9028 from mobash-rasool/ospfv3-asbr-summarisation
Ospfv3 ASBR summarisation feature
2021-07-30 06:37:50 -04:00
Russ White 3ad921a98c
Merge pull request #9193 from mobash-rasool/ospfv3-bug-fixes
ospf6d: Type-7 LSA originated with wrong sequence number
2021-07-29 15:00:55 -04:00
Igor Ryzhov 9da01b0b7b *: cleanup interface node installation
The only difference in daemons' interface node definition is the config
write function. No need to define the node in every daemon, just pass
the callback as an argument to a library function and define the node
there.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-29 21:35:25 +03:00
Igor Ryzhov 36d3fcccb4
Merge pull request #8944 from opensourcerouting/ospf6-mtu-revert
ospf6d: revert PR #8622
2021-07-27 16:06:40 +03:00
Mobashshera Rasool 96cad17163 ospf6d: Type-7 LSA originated with wrong sequence number
RCA: When Type-7 LSA is updated, the LSDB is searched, if the
LSA is present in the LSDB then the LSA is updated with next
sequence number and if not then it is originated with the
INITIAL sequence number.
Here while originating Type-7 LSA Process Level LSDB is searched
for instead of area level LSDB.

Fix: Search in the area level LSDB and not in the process level.

Fixes #9099

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-27 05:39:37 -07:00
Donald Sharp cb01669fe6
Merge pull request #9090 from opensourcerouting/ospfv3-fixes-20210720
ospf6d: small batch of random fixes/improvements
2021-07-27 08:06:54 -04:00
Renato Westphal 848db95c5a ospf6d: fix argument processing in the "area ... range" command
* When the "cost" argument isn't present, the default cost should be
  used instead of preserving the previously configured one (if any);
* When the "not-advertise" argument isn't present, the "not-advertise"
  flag should be unset regardless if it was previously configured or
  not.

Configuration commands should be deterministic and work in the same
way regardless of the current state.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-07-21 15:02:13 -03:00
David Lamparter 63116a7008 build: fix AM_LDFLAGS usage (and gcov)
like the other automake variables, setting `xyz_LDFLAGS` causes
`AM_LDFLAGS` to be ignored for `xyz`.  For some reason I had in my mind
that automake doesn't do this for LDFLAGS, but... it does.  (Which is
consistent with `_CFLAGS` and co.)

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

Fixes: #9034
Fixes: 0c4285d77e ("build: properly split CFLAGS from AC_CFLAGS")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-21 17:10:08 +02:00
Mobashshera Rasool ad21f6c285 ospf6d: ASBR summarisation per VRF
Added code to support the ASBR summarisation per VRF.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-21 05:20:33 +00:00
Mobashshera Rasool 22813fdb86 ospf6d: Store ospf6 back pointer in route struct
Storing the pointer to ospf6 struct in route struct.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-21 05:20:30 +00:00
Mobashshera Rasool 789828186e ospf6d: Review comment fixes
This commit is ease reviewing the review comment fixes.

Signed:-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-21 05:16:54 +00:00
Mobashshera Rasool c405b00fcf ospf6d: install summary route NULL0 as nexthop
This is a requirement for avoiding sending traffic somewhere it was not
supposed to go: install summary route to local RIB to send traffic to
Null0.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-21 05:16:54 +00:00
Mobashshera Rasool d2e5d5d444 ospf6d: support blackhole next hops
This feature is required for creating summary routes that drop traffic
without more specific routes.

Authored-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-21 05:16:54 +00:00
Mobashshera Rasool c3a70f6517 ospf6d: ASBR summarisation feature changes for NSSA area
1. ASBR summarisation for Type-7 LSAs are done here.

2. Fixed Code warnings

Signed-off-by: Mobashshera Rasool<mrasool@vmware.com>
2021-07-21 05:16:54 +00:00
Mobashshera Rasool 4dc4388691 ospf6d: ASBR Summarisation feature implementation
Feature Implementation.
========================
This feature will help in advertising the External LSAs with aggregation.
The commands allow us to tune the advertisement with different parameters
as mentioned in the CLI List below.
It can also help in case we do not want to advertise any prefix with the
no-advertise option.

New CLIs added:
===============
summary-address X:X::X:X/M$prefix [tag (1-4294967295)] [{metric (0-16777215) | metric-type (1-2)}]
no summary-address X:X::X:X/M$prefix [tag (1-4294967295)] [{metric (0-16777215) | metric-type (1-2)}]
summary-address X:X::X:X/M$prefix no-advertise
no summary-address X:X::X:X/M$prefix no-advertise
aggregation timer (5-1800)
no aggregation timer (5-1800)
show ipv6 ospf6 summary-address [detail$detail] [json]
debug ospf6 lsa aggregation

CAT RUN:
========
QE to add test scripts

Signed-Off-by: Mobashshera Rasool <mrassol@vmware.com>
2021-07-21 05:16:54 +00:00
Rafael Zalamena 80d1eb49b1 ospf6d: always generate default route for stubs
In RFC 2328 OSPF Version 2, Section 12.4.3.1 "Originating summary-LSAs
into stub areas" mentions that the stub areas should not import external
routes and instead should generate a 'default summary-LSA' set to
default destination.

> In a stub area, instead of importing external routes
> each area border router originates a "default summary-
> LSA" into the area. The Link State ID for the default
> summary-LSA is set to DefaultDestination, and the metric
> set to the (per-area) configurable parameter
> StubDefaultCost.  Note that StubDefaultCost need not be
> configured identically in all of the stub area's area
> border routers.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-07-20 09:43:03 -03:00
Pat Ruddy 0c7f982a38 ospf6d: break early on route prefix mismatch
The route linked list in ospf6d is ordered in prefix batches which
are associated with a the route node denoting the prefix. So if
you look up the prefix in the tree and start walking the list, if you
find a prefix which differs from the one you are interested in then
you have gone beyond the batch of routes for that prefix.

In some cases the route database linked list is used on a per-prefix
basis. The existing code simply does a continue when the prefix does
not match and continues to walk. This works with small numbers of
routes because the walk continues through unrelated prefix batches and
never finds anything to operate on. However if we have many thousands
of routes these walks become expensive and can cause the SPF thread
(amongst others) to run very long, causing issues with adjacencies
where the dead timer is short.

Add a break to these prefix-based loops to exit early if we get a
prefix mismatch to avoid continuing down the route list if we have
overshot.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-07-20 11:19:48 +01:00
David Lamparter 621ee705b5 ospf6d: use OSPF6_INTERFACE_LOOPBACK state
The OSPF6_INTERFACE_LOOPBACK interface state wasn't entered anywhere,
even if the interface was OSPF6_IFTYPE_LOOPBACK.  Fix.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-20 11:22:21 +02:00
David Lamparter 2e9db233b1 ospf6d: don't create Adv-ID:0.0.0.0 LSAs at start
When ospf6d comes up, it gets interface and address state before it
decides on its router ID.  This results in a bunch of LSAs with
advertising router ID 0.0.0.0 in the LSDB.  Not quite right.

There's a whole bunch of paths leading to this, so just drop the LSA in
ospf6_lsa_originate.  The router-ID change causes everything to be
readvertised anyway (... but the delete doesn't catch the 0.0.0.0 stuff
because the router-ID is now different.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-20 11:22:21 +02:00
David Lamparter b08221513c ospf6d: actually print prefix options
Well at least I had a good laugh at the "xxx".

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-20 11:22:21 +02:00
David Lamparter 4699ad7296 ospf6d: move prefix_options from _path to _route
Prefix options are per-prefix, not per-path.  As evident by the fact
that the field is never used on ECMP paths.  Move it where it belongs.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-20 11:22:21 +02:00
Rafael Zalamena ae2ba0c219 ospf6d: remove extra debug message
Somehow the hello message debugging code slipped outside the debug
guard. Lets just remove it.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-07-14 14:52:26 -03:00
Donald Sharp 802a83935f
Merge pull request #9037 from idryzhov/ospf6-freebsd
ospf6d: fix freebsd mcast group issues
2021-07-13 09:40:13 -04:00
Igor Ryzhov 93828a9923 ospf6d: fix freebsd mcast group issues
There's a delay in FreeBSD between issuing a command to leave a
multicast group and an actual leave. If we execute "no router ospf6" and
"router ospf6" fast enough, we can end up in a situation when OS
performs the leave later than it performs the join and the interface
remains without a multicast group.

Instead of counting on a one second delay, we must wait until the
interface actually leaves the group.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-12 22:56:04 +03:00
Donald Sharp 482467dc6a ospf6d: Correct spelling in debug
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-12 07:24:16 -04:00
Igor Ryzhov cf420d4b48
Merge pull request #9010 from opensourcerouting/ospf-misc
doc,lib,ospfd,ospf6d: trivial improvements
2021-07-09 19:19:13 +03:00
Igor Ryzhov d0f980f8bb
Merge pull request #9016 from LabNConsulting/chopps/ospf6d-fix-backlink-chk
ospf6d: fix backlink check
2021-07-09 15:46:43 +03:00
Rafael Zalamena a0fbad5869 ospf6d: rework default-information configuration
Move code to its own function and remove most of the code indentation
(e.g. test for failure and quit as soon as possible).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-07-09 07:55:25 -03:00
Rafael Zalamena 1fe59b44fc lib,ospfd,ospf6d: remove duplicated function
Move `is_default_prefix` variations to `lib/prefix.h` and make the code
use the library version instead of implementing it again.

NOTE
----

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

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

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

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-07-09 07:55:25 -03:00
Rafael Zalamena f45f6a22b0
Merge pull request #8978 from kssoman/ospf_new
ospf6d : Send LSA update immediately when ospf instance is deleted
2021-07-09 07:46:11 -03:00
Christian Hopps ff2052eefc ospf6d: fix backlink check
This code has been wrong ~ever (according to git history). There are 3
conditional blocks with the added assertion that both the LSA and the
vertex being checked can't both be network LSAs.

The third block is clearly assuming both LSA and vertex are router
LSAs b/c it is accessing the backlink and lsdesc as router lsdesc's also
making sure both are p2p links (which they would have to be to point at
each other).

The programming error here is that (A && B) == False does NOT imply !A,
but the code is written that way.

So we end up in the third block one of LSA or vertex being network LSAs
rather easily (whenever that is the case and the desc isn't the backlink
being sought).

This was caught by ASAN b/c the lsdesc and backlinks are being accessed
(> 4 byte field offsets) as if they were router lsdesc's in the third
block, when in fact one of them is a network lsdesc which is only 4
bytes long -- so ASAN flags the access beyond bounds.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-07-09 04:15:34 -04:00
Soman K.S 7359e9ba71 ospf6d : Send LSA update immediately when ospf instance is deleted
Fix: The fix is to call ospf6_write to send the packet immediately to all neighbors

Signed-off-by: kssoman <somanks@gmail.com>
2021-07-08 19:10:29 +05:30
Igor Ryzhov 5ee7655ee9
Merge pull request #8987 from mobash-rasool/ospfv3-bug-fixes
ospf6d: Fix crash in ospf6_asbr_lsa_remove at ospf6d/ospf6_asbr.c:696
2021-07-07 17:28:14 +03:00
Donald Sharp 568f6d6c94
Merge pull request #8919 from mobash-rasool/ospfv3-fixes
ospf6d: Max aged LSAs are not getting deleted from DB
2021-07-06 16:13:05 -04:00
Donald Sharp 54ce9feb5a
Merge pull request #8930 from pjdruddy/ospf6_packet_debug
Ospf6 packet debug
2021-07-06 16:09:07 -04:00
github login name 908f5e616b ospf6d: Fix crash in ospf6_asbr_lsa_remove at ospf6d/ospf6_asbr.c:696
Issue: Crash observed when LSAs are removed from LSDB after max age
when there is no area configured.
(gdb) bt
0  raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
1  0x00007fdb190548bc in core_handler (signo=6, siginfo=0x7ffdd2f5a470, context=<optimized out>) at lib/sigevent.c:262
2  <signal handler called>
3  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
4  0x00007fdb185ad921 in __GI_abort () at abort.c:79
5  0x00007fdb1907f199 in _zlog_assert_failed (xref=xref@entry=0x55f30902aa20 <_xref.21999>, extra=extra@entry=0x0) at lib/zlog.c:581
6  0x000055f308dc4f78 in ospf6_asbr_lsa_remove (lsa=0x55f30a7546d0, asbr_entry=0x0) at ospf6d/ospf6_asbr.c:696
7  0x000055f308dd8f0d in ospf6_lsdb_remove (lsa=0x55f30a7546d0, lsdb=lsdb@entry=0x55f30a73d300) at ospf6d/ospf6_lsdb.c:166
8  0x000055f308dd9701 in ospf6_lsdb_maxage_remover (lsdb=0x55f30a73d300) at ospf6d/ospf6_lsdb.c:376
9  0x000055f308dee724 in ospf6_maxage_remover (thread=<optimized out>) at ospf6d/ospf6_top.c:603
10 0x00007fdb1906520d in thread_call (thread=thread@entry=0x7ffdd2f5ae90) at lib/thread.c:1919
11 0x00007fdb19023e48 in frr_run (master=0x55f30a569b70) at lib/libfrr.c:1155
12 0x000055f308dc09b6 in main (argc=6, argv=0x7ffdd2f5b198, envp=<optimized out>) at ospf6d/ospf6_main.c:235
(gdb)

Steps to reproduce the issue:
1. router ospf6
2. redistribute static
3. ipv6 route 1::1/128 Null0
4. no redistribute static
5. wait for Max aged LSA to flush
6. Check DB, crash occurs.

RCA:
Crash occurred while accessing listgetdata(listhead(ospf6->area_list))
When there is no area attached to any of the interface listhead(ospf6->area_list)
is NULL. Therefore it crashed due to NULL access.

Fix:
Check before accessing null pointer.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-06 08:32:23 -07:00
Donald Sharp 30885c7099
Revert "ospf6d: fix LSAs remain in LSDB with an old router-id value" 2021-07-02 12:38:11 -04:00
Mark Stapp 0a9fcd96d1
Merge pull request #8970 from ton31337/fix/use_IPV6_MAX_BITLEN
*: Do not use 32/128 numbers for prefixlen
2021-07-02 07:52:22 -04:00
Philippe Guibert 1e15822698
Merge pull request #8795 from louis-oui/fix-ospf6-router-id
ospf6d: fix LSAs remain in LSDB with an old router-id value
2021-07-02 11:11:47 +02:00
Donatas Abraitis 12256b84a5 *: Convert numeric 32 into IPV4_MAX_BITLEN for prefixlen
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 23:50:39 +03:00
Donatas Abraitis f4d81e5507 *: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLEN
Just drop IPV6_MAX_PREFIXLEN at all, no need keeping both.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 17:41:09 +03:00
Louis Scalbert c295917b4a ospf6d: harmonize ospf6_asbr_redistribute_disable and _reset
Harmonize the code of functions ospf6_asbr_redistribute_disable and
ospf6_asbr_redistribute_reset.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2021-07-01 14:40:14 +02:00
Louis Scalbert c54fb080a0 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-07-01 14:40:14 +02:00
Louis Scalbert 6794884231 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-07-01 14:40:14 +02:00
Louis Scalbert 08965422d0 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-07-01 14:40:07 +02:00
Igor Ryzhov bc65216a29
Merge pull request #8954 from mobash-rasool/ospfv3-feature
ospf6d: route-map config changed, not getting applied on all types of…
2021-07-01 14:47:40 +03:00
Mobashshera Rasool 2f43e34de1 ospf6d: route-map config changed, not getting applied on all types of routes
Problem Statement:
==================
when route-map config is changed from permit to deny, it is not getting
applied to both connected and static and vice versa

RCA:
==================
When route-map changes from permit to deny or vice versa, a notification is
sent to ospf6 daemon via ospf6_asbr_routemap_update. In this function, a thread
is scheduled after 5 seconds to apply the route-map changes. In this thread
(ospf6_asbr_routemap_update_timer), only the first type is passed as argument
and only the first type i.e "connected" is passed and hence in callback only
on this type of route route-map gets applied.

Fix:
====
Need to loop through all the route-types in the call back and process
the route-map changes. Added a flag to mark which all route-types needs
to be processed.

Test Executed:
===============
1. Change route-map from permit to deny.
2. Change route-map from deny to permit.
3. Add new route and checked.
4. Verified summarised routes.

Risk:
============
Low

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-06-30 11:55:17 +00:00
Igor Ryzhov 3c5122c5a7 ospf6d: use per-vrf router id instead of one global
This code was not fully completed when adding support for VRFs.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-29 18:10:41 +03:00
David Lamparter 0c3a104a7a Revert "ospf6d: Limit the number of interface addresses being supported"
This reverts commit f85b76195a.
2021-06-29 15:17:01 +02:00
Igor Ryzhov ba88ced84c
Merge pull request #8835 from ranjanyash54/clear_process
ospf6d: "clear ipv6 ospf6 process" command
2021-06-29 11:54:39 +03:00
Quentin Young 3f8711681e
Merge pull request #8850 from opensourcerouting/ospf6-checksum-json
ospf6d: consistent checksum JSON output
2021-06-29 02:23:06 +00:00
Yash Ranjan f71ed6df3e ospf6d: "clear ipv6 ospf6 process" command
Adding the "clear ipv6 ospf6 command" . It resets
the ospfv3 datastructures and clears the database
as well as route tables. It resets the neighborship
by restarting the interface state machine.
If the user wants to change the router-id, this
command updates the router-id to the latest static
router-id and starts the neighbor formation with
the new router-id.

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2021-06-27 20:56:10 -07:00
Pat Ruddy 779d972213 ospf6d: remove inet_ntop calls in ospf6_write
substitute pI6 formatter.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-06-26 11:16:19 +01:00
Pat Ruddy a91f9d699c ospf6d: correctly protect packet debugs in ospf6_write
Some unprotected debugs need to have macro protection,
Split these into the existing covering macro section to remove
a check per-packet from the main path.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-06-26 11:16:19 +01:00
Pat Ruddy 0dd5ec1297 ospf6: fix coverity overflow issues
Coverity flagged the possibility of an overflow in the latency
calculation, ensure that 64 bit integers are used in the
calculation to avoid this error.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-06-26 11:16:19 +01:00
Igor Ryzhov 709bd20421 ospf6d: fix duplicated packet read
When OSPFv3 router is configured in both default and non-default VRFs,
every packet destined to a non-default VRF is read twice. This makes it
impossible to establish neighborship because every DbDesc packet is
treated as duplicated and we end up infinitely exchanging DbDescs.

We should drop packets received in the default VRF if an interface we
received it on is bound to another VRF.

Same thing was done for OSPFv2 in 555691e.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-26 12:57:26 +03:00
Mobashshera Rasool c1e4c0dcf8 ospf6d: Max aged LSAs are not getting deleted from DB
Problem Statement:
==================
Max aged LSAs are not getting deleted from DB when there are multiple
neighbors in a LAN.

Root Cause Analysis:
====================
When the LSA is added to the neighbor's retransmit list, the LSA retrans count
is incremented but it is not checked if the LSA is already present in the
retransmit list leading to the count being incremented multiple times
untill the ack is not received and when the ack is received the count is
decremented once and hence the count never becomes 0 and
it remains in the DB forever.

Fix:
====================
Do not increment the retrans count multiple times if the LSA is already
present in the retransmit list of the neighbor. Also do not add the LSA
in the retransmit List if already present.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-06-24 11:16:12 +00:00