]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/bgpd/test_peer_attr.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / bgpd / test_peer_attr.c
index cdedd0c906a52aa073d50b38b8db5cf1bd84f90a..652aaa25d44c169defef2d50daeb299e39c12356 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * BGP Peer Attribute Unit Tests
  * Copyright (C) 2018  Pascal Mathis
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include <zebra.h>
 
@@ -663,21 +650,14 @@ static const char *str_from_afi(afi_t afi)
                return "ipv4";
        case AFI_IP6:
                return "ipv6";
-       default:
-               return "<unknown AFI>";
+       case AFI_L2VPN:
+               return "l2vpn";
+       case AFI_MAX:
+       case AFI_UNSPEC:
+               return "bad-value";
        }
-}
 
-static const char *str_from_safi(safi_t safi)
-{
-       switch (safi) {
-       case SAFI_UNICAST:
-               return "unicast";
-       case SAFI_MULTICAST:
-               return "multicast";
-       default:
-               return "<unknown SAFI>";
-       }
+       assert(!"Reached end of function we should never reach");
 }
 
 static const char *str_from_attr_type(enum test_peer_attr_type at)
@@ -1163,7 +1143,7 @@ static void test_peer_attr(struct test *test, struct test_peer_attr *pa)
                test_log(test, "prepare: switch address-family to [%s]",
                         get_afi_safi_str(pa->afi, pa->safi, false));
                test_execute(test, "address-family %s %s",
-                            str_from_afi(pa->afi), str_from_safi(pa->safi));
+                            str_from_afi(pa->afi), safi2str(pa->safi));
                test_execute(test, "neighbor %s activate", g->name);
                test_execute(test, "neighbor %s activate", p->host);
        }
@@ -1230,7 +1210,7 @@ static void test_peer_attr(struct test *test, struct test_peer_attr *pa)
                test_log(test, "prepare: switch address-family to [%s]",
                         get_afi_safi_str(pa->afi, pa->safi, false));
                test_execute(test, "address-family %s %s",
-                            str_from_afi(pa->afi), str_from_safi(pa->safi));
+                            str_from_afi(pa->afi), safi2str(pa->safi));
                test_execute(test, "neighbor %s activate", g->name);
                test_execute(test, "neighbor %s activate", p->host);
        }
@@ -1278,7 +1258,7 @@ static void test_peer_attr(struct test *test, struct test_peer_attr *pa)
                test_log(test, "prepare: switch address-family to [%s]",
                         get_afi_safi_str(pa->afi, pa->safi, false));
                test_execute(test, "address-family %s %s",
-                            str_from_afi(pa->afi), str_from_safi(pa->safi));
+                            str_from_afi(pa->afi), safi2str(pa->safi));
                test_execute(test, "neighbor %s activate", g->name);
                test_execute(test, "neighbor %s activate", p->host);
        }
@@ -1477,7 +1457,7 @@ int main(void)
                if (pa->afi && pa->safi)
                        desc = asprintfrr(MTYPE_TMP, "peer\\%s-%s\\%s",
                                          str_from_afi(pa->afi),
-                                         str_from_safi(pa->safi), pa->cmd);
+                                         safi2str(pa->safi), pa->cmd);
                else
                        desc = asprintfrr(MTYPE_TMP, "peer\\%s", pa->cmd);