]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: make bgp_packet_mpattr_start more prescriptive when using enum's
authorDonald Sharp <sharpd@nvidia.com>
Fri, 16 Dec 2022 13:17:18 +0000 (08:17 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 16 Dec 2022 13:17:18 +0000 (08:17 -0500)
This function was just using default: case statements for
the encoding of nlri's to a peer.  Lay out all the different
cases and make things fail hard when a dev escape is found.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_attr.c

index 47baed5af538d0537ae4cb0925f4e53e62208195..1c8dfea33ce187d3b7f61b3202f3021e8c791c5c 100644 (file)
@@ -3876,7 +3876,10 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
                                stream_putc(s, attr->mp_nexthop_len);
                                stream_put_ipv4(s, attr->nexthop.s_addr);
                        }
-               default:
+                       break;
+               case SAFI_UNSPEC:
+               case SAFI_MAX:
+                       assert(!"SAFI's UNSPEC or MAX being specified are a DEV ESCAPE");
                        break;
                }
                break;
@@ -3927,17 +3930,24 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
                        break;
                case SAFI_FLOWSPEC:
                        stream_putc(s, 0); /* no nexthop for flowspec */
-               default:
+                       break;
+               case SAFI_UNSPEC:
+               case SAFI_MAX:
+                       assert(!"SAFI's UNSPEC or MAX being specified are a DEV ESCAPE");
                        break;
                }
                break;
-       default:
+       case AFI_L2VPN:
                if (safi != SAFI_FLOWSPEC)
                        flog_err(
                                EC_BGP_ATTR_NH_SEND_LEN,
                                "Bad nexthop when sending to %s, AFI %u SAFI %u nhlen %d",
                                peer->host, afi, safi, attr->mp_nexthop_len);
                break;
+       case AFI_UNSPEC:
+       case AFI_MAX:
+               assert(!"DEV ESCAPE: AFI_UNSPEC or AFI_MAX should not be used here");
+               break;
        }
 
        /* SNPA */