]> 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 cc4f71e688bfede481c2e4fead8b005d30be3e5c..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>
 
@@ -176,9 +163,9 @@ struct test_peer_attr {
 
        enum test_peer_attr_type type;
        union {
-               uint32_t flag;
+               uint64_t flag;
                struct {
-                       uint32_t flag;
+                       uint64_t flag;
                        size_t direct;
                } filter;
        } u;
@@ -281,6 +268,18 @@ static struct test_peer_attr test_peer_attrs[] = {
                .o.invert_peer = true,
                .o.use_iface_peer = true,
        },
+       {
+               .cmd = "capability software-version",
+               .u.flag = PEER_FLAG_CAPABILITY_SOFT_VERSION,
+               .type = PEER_AT_GLOBAL_FLAG,
+       },
+       {
+               .cmd = "capability software-version",
+               .u.flag = PEER_FLAG_CAPABILITY_SOFT_VERSION,
+               .type = PEER_AT_GLOBAL_FLAG,
+               .o.invert_peer = true,
+               .o.use_iface_peer = true,
+       },
        {
                .cmd = "description",
                .peer_cmd = "description FRR Peer",
@@ -651,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)
@@ -1151,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);
        }
@@ -1218,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);
        }
@@ -1266,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);
        }
@@ -1465,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);