Bug 1979426

Summary: FRR: Unable to configure OSPF in multi-instance mode
Product: Red Hat Enterprise Linux 8 Reporter: suresh kumar <surkumar>
Component: frrAssignee: Michal Ruprich <mruprich>
Status: CLOSED ERRATA QA Contact: FrantiĊĦek Hrdina <fhrdina>
Severity: medium Docs Contact:
Priority: high    
Version: 8.4CC: fhrdina
Target Milestone: betaKeywords: Patch, Reproducer, Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: frr-7.5-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 13:36:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description suresh kumar 2021-07-06 02:01:59 UTC
Description of problem:
Unable to configure ospf instances in multi-instance mode

Version-Release number of selected component (if applicable):

frr-7.5-4.el8.x86_64

How reproducible:

Always


Steps to Reproduce:

1. configure frr with below lines in /etc/frr/daemons

     ospfd=yes
     ospfd_instances=1,2

2. Start frr daemon

3. configure ospf

  # configure t
  # router ospf 2
  # ospf router-id 1.2.3.4

Actual results:

# sh ru
Building configuration...

Current configuration:
!
frr version 7.5
frr defaults traditional
hostname localhost.localdomain
no ip forwarding
no ipv6 forwarding
no service integrated-vtysh-config
!
line vty
!
end


Expected results:

# sh ru
Building configuration...

Current configuration:
!
frr version 7.5
frr defaults traditional
hostname localhost.localdomain
no ip forwarding
no ipv6 forwarding
no service integrated-vtysh-config
!
router ospf 1
!
router ospf 2
 ospf router-id 1.2.3.4
!
line vty
!
end



Additional info:

While writing the configuration, it says:

onfiguration saved to /etc/frr/zebra.conf
Configuration saved to /etc/frr/ospfd-1.conf
Configuration saved to /etc/frr/ospfd-2.conf
Configuration saved to /etc/frr/staticd.conf


but ospfd*.conf has only default lines.

# cat ospfd-2.conf
!
! Zebra configuration saved from vty
!   2021/07/05 21:23:23
!
frr version 7.5
frr defaults traditional
!
hostname localhost.localdomain
!
!
!
!
!
!
!
line vty
!



This issue was observed while upgrading RHEL8 where the frr package got updated from 7.0  to 7.5.


Below commit solves the issue. Tested on both customer and local environment

commit e4f632caec8641278ee2e583445f3176e949e1f4
Author: Igor Ryzhov <iryzhov>
Date:   Wed Dec 2 03:36:10 2020 +0300

    ospf: fix instance initialization when using multi-instance mode
    
    OSPF instance initialization was moved from "router ospf" vty command to
    ospf_get function some time ago but the same thing must be done in
    ospf_get_instance function used when multi-instance mode is enabled.
    
    Signed-off-by: Igor Ryzhov <iryzhov>

diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index d7c4e108c..3ca9453bc 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -377,12 +377,50 @@ struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
        return NULL;
 }
 
-struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
+static void ospf_init(struct ospf *ospf)
 {
-       struct ospf *ospf;
        struct vrf *vrf;
        struct interface *ifp;
 
+       ospf_opaque_type11_lsa_init(ospf);
+
+       if (ospf->vrf_id != VRF_UNKNOWN)
+               ospf->oi_running = 1;
+
+       /* Activate 'ip ospf area x' configured interfaces for given
+        * vrf. Activate area on vrf x aware interfaces.
+        * vrf_enable callback calls router_id_update which
+        * internally will call ospf_if_update to trigger
+        * network_run_state
+        */
+       vrf = vrf_lookup_by_id(ospf->vrf_id);
+
+       FOR_ALL_INTERFACES (vrf, ifp) {
+               struct ospf_if_params *params;
+               struct route_node *rn;
+               uint32_t count = 0;
+
+               params = IF_DEF_PARAMS(ifp);
+               if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
+                       count++;
+
+               for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn))
+                       if ((params = rn->info) && OSPF_IF_PARAM_CONFIGURED(params, if_area))
+                               count++;
+
+               if (count > 0) {
+                       ospf_interface_area_set(ospf, ifp);
+                       ospf->if_ospf_cli_count += count;
+               }
+       }
+
+       ospf_router_id_update(ospf);
+}
+
+struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
+{
+       struct ospf *ospf;
+
        /* vrf name provided call inst and name based api
         * in case of no name pass default ospf instance */
        if (name)
@@ -395,39 +433,7 @@ struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
                ospf = ospf_new(instance, name);
                ospf_add(ospf);
 
-               ospf_opaque_type11_lsa_init(ospf);
-
-               if (ospf->vrf_id != VRF_UNKNOWN)
-                       ospf->oi_running = 1;
-
-               /* Activate 'ip ospf area x' configured interfaces for given
-                * vrf. Activate area on vrf x aware interfaces.
-                * vrf_enable callback calls router_id_update which
-                * internally will call ospf_if_update to trigger
-                * network_run_state
-                */
-               vrf = vrf_lookup_by_id(ospf->vrf_id);
-
-               FOR_ALL_INTERFACES (vrf, ifp) {
-                       struct ospf_if_params *params;
-                       struct route_node *rn;
-                       uint32_t count = 0;
-
-                       params = IF_DEF_PARAMS(ifp);
-                       if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
-                               count++;
-
-                       for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn))
-                               if ((params = rn->info) && OSPF_IF_PARAM_CONFIGURED(params, if_area))
-                                       count++;
-
-                       if (count > 0) {
-                               ospf_interface_area_set(ospf, ifp);
-                               ospf->if_ospf_cli_count += count;
-                       }
-               }
-
-               ospf_router_id_update(ospf);
+               ospf_init(ospf);
        }
 
        return ospf;
@@ -443,7 +449,7 @@ struct ospf *ospf_get_instance(unsigned short instance, bool *created)
                ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/);
                ospf_add(ospf);
 
-               ospf_opaque_type11_lsa_init(ospf);
+               ospf_init(ospf);
        }
 
        return ospf;
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index dba7ee8c3..b18484ef4 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -556,7 +556,6 @@ extern int ospf_nbr_nbma_poll_interval_set(struct ospf *, struct in_addr,
                                           unsigned int);
 extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *, struct in_addr);
 extern void ospf_prefix_list_update(struct prefix_list *);
-extern void ospf_init(void);
 extern void ospf_if_update(struct ospf *, struct interface *);
 extern void ospf_ls_upd_queue_empty(struct ospf_interface *);
 extern void ospf_terminate(void);

Comment 13 errata-xmlrpc 2022-05-10 13:36:44 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (frr bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:1778