]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospf6d: fix display of unknown LSAs in show ipv6 ospf6 database command
authorlynne <lynne@voltanet.io>
Tue, 23 Feb 2021 17:07:28 +0000 (12:07 -0500)
committerlynne <lynne@voltanet.io>
Tue, 23 Feb 2021 18:04:06 +0000 (13:04 -0500)
When an unknown LSA is in the database and the user issues the
"show ipv6 ospf6 database" command there is a crash.  The code currently
doesn't properly handle display of unknown LSAs.

Signed-off-by: Lynne Morrison <lynne@voltaio.net>
ospf6d/ospf6_lsa.c

index f1b04c9bec8ad970af1b396d0a0f173938a65170..e1c3b4038c0d543b78f9ef4d5004112d08cc0578 100644 (file)
@@ -145,7 +145,7 @@ const char *ospf6_lstype_short_name(uint16_t type)
        const struct ospf6_lsa_handler *handler;
 
        handler = ospf6_get_lsa_handler(type);
-       if (handler && handler != &unknown_handler)
+       if (handler)
                return handler->lh_short_name;
 
        snprintf(buf, sizeof(buf), "0x%04hx", ntohs(type));
@@ -420,9 +420,10 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa,
        if (use_json)
                json_obj = json_object_new_object();
 
-       if ((type == OSPF6_LSTYPE_INTER_PREFIX)
-           || (type == OSPF6_LSTYPE_INTER_ROUTER)
-           || (type == OSPF6_LSTYPE_AS_EXTERNAL)) {
+       switch (type) {
+       case OSPF6_LSTYPE_INTER_PREFIX:
+       case OSPF6_LSTYPE_INTER_ROUTER:
+       case OSPF6_LSTYPE_AS_EXTERNAL:
                if (use_json) {
                        json_object_string_add(
                                json_obj, "type",
@@ -447,7 +448,13 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa,
                                (unsigned long)ntohl(lsa->header->seqnum),
                                handler->lh_get_prefix_str(lsa, buf,
                                                           sizeof(buf), 0));
-       } else if (type != OSPF6_LSTYPE_UNKNOWN) {
+               break;
+       case OSPF6_LSTYPE_ROUTER:
+       case OSPF6_LSTYPE_NETWORK:
+       case OSPF6_LSTYPE_GROUP_MEMBERSHIP:
+       case OSPF6_LSTYPE_TYPE_7:
+       case OSPF6_LSTYPE_LINK:
+       case OSPF6_LSTYPE_INTRA_PREFIX:
                while (handler->lh_get_prefix_str(lsa, buf, sizeof(buf), cnt)
                       != NULL) {
                        if (use_json) {
@@ -481,7 +488,8 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa,
                }
                if (use_json)
                        json_object_free(json_obj);
-       } else {
+               break;
+       default:
                if (use_json) {
                        json_object_string_add(
                                json_obj, "type",
@@ -500,6 +508,7 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa,
                                ospf6_lstype_short_name(lsa->header->type), id,
                                adv_router, ospf6_lsa_age_current(lsa),
                                (unsigned long)ntohl(lsa->header->seqnum));
+               break;
        }
 }