]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospf6d: rework default-information configuration
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 7 Jul 2021 13:20:01 +0000 (10:20 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Fri, 9 Jul 2021 10:55:25 +0000 (07:55 -0300)
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>
ospf6d/ospf6_asbr.c

index aad4e7571d119405196151c2815ba32cd26fe5e5..3e911a743a6813c68cfb25df3a1d1b9b9d6bb32c 100644 (file)
@@ -2568,36 +2568,41 @@ int config_write_ospf6_debug_asbr(struct vty *vty)
        return 0;
 }
 
-int ospf6_distribute_config_write(struct vty *vty, struct ospf6 *ospf6)
+static void ospf6_default_originate_write(struct vty *vty, struct ospf6 *o)
 {
        struct ospf6_redist *red;
 
-       if (ospf6) {
-               /* default-route print. */
-               if (ospf6->default_originate != DEFAULT_ORIGINATE_NONE) {
-                       vty_out(vty, " default-information originate");
-                       if (ospf6->default_originate
-                           == DEFAULT_ORIGINATE_ALWAYS)
-                               vty_out(vty, " always");
-
-                       red = ospf6_redist_lookup(ospf6, DEFAULT_ROUTE, 0);
-                       if (red) {
-                               if (red->dmetric.value >= 0)
-                                       vty_out(vty, " metric %d",
-                                               red->dmetric.value);
-
-                               if (red->dmetric.type >= 0)
-                                       vty_out(vty, " metric-type %d",
-                                               red->dmetric.type);
-
-                               if (ROUTEMAP_NAME(red))
-                                       vty_out(vty, " route-map %s",
-                                               ROUTEMAP_NAME(red));
-                       }
+       vty_out(vty, " default-information originate");
+       if (o->default_originate == DEFAULT_ORIGINATE_ALWAYS)
+               vty_out(vty, " always");
 
-                       vty_out(vty, "\n");
-               }
+       red = ospf6_redist_lookup(o, DEFAULT_ROUTE, 0);
+       if (red == NULL) {
+               vty_out(vty, "\n");
+               return;
        }
+
+       if (red->dmetric.value >= 0)
+               vty_out(vty, " metric %d", red->dmetric.value);
+
+       if (red->dmetric.type >= 0)
+               vty_out(vty, " metric-type %d", red->dmetric.type);
+
+       if (ROUTEMAP_NAME(red))
+               vty_out(vty, " route-map %s", ROUTEMAP_NAME(red));
+
+       vty_out(vty, "\n");
+}
+
+int ospf6_distribute_config_write(struct vty *vty, struct ospf6 *o)
+{
+       if (o == NULL)
+               return 0;
+
+       /* Print default originate configuration. */
+       if (o->default_originate != DEFAULT_ORIGINATE_NONE)
+               ospf6_default_originate_write(vty, o);
+
        return 0;
 }