]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #4832 from ddutt/master
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 17 Aug 2019 13:00:47 +0000 (09:00 -0400)
committerGitHub <noreply@github.com>
Sat, 17 Aug 2019 13:00:47 +0000 (09:00 -0400)
Clean up zebra's show interface display

14 files changed:
configure.ac
lib/zebra.h
m4/ax_python.m4
ospfd/ospf_packet.c
ospfd/ospf_zebra.c
ripd/ripd.c
staticd/static_routes.c
tests/topotests/all-protocol-startup/r1/ipv4_routes.ref
tests/topotests/all-protocol-startup/r1/ipv6_routes.ref
tests/topotests/all-protocol-startup/r1/zebra.conf
vtysh/vtysh.c
zebra/zebra_dplane.c
zebra/zebra_nhg.c
zebra/zebra_vty.c

index 961336fbd09f218d35fa92f458e73a9f6eef3880..134c8692d43b57cf410fcbc21c205b7f364f0ee8 100755 (executable)
@@ -572,6 +572,20 @@ AC_ARG_ENABLE([thread-sanitizer],
   AS_HELP_STRING([--enable-thread-sanitizer], [enable ThreadSanitizer support for detecting data races]))
 AC_ARG_ENABLE([memory-sanitizer],
   AS_HELP_STRING([--enable-memory-sanitizer], [enable MemorySanitizer support for detecting uninitialized memory reads]))
+AC_ARG_WITH([crypto],
+  AS_HELP_STRING([--with-crypto=<internal|openssl>], [choose between different implementations of cryptographic functions(default value is --with-crypto=internal)]))
+
+#if openssl, else use the internal
+AS_IF([test x"${with_crypto}" = x"openssl"], [
+AC_CHECK_LIB([crypto], [EVP_DigestInit], [LIBS="$LIBS -lcrypto"], [], [])
+if test $ac_cv_lib_crypto_EVP_DigestInit = no; then
+  AC_MSG_ERROR([build with openssl has been specified but openssl library was not found on your system])
+else
+  AC_DEFINE([CRYPTO_OPENSSL], [1], [Compile with openssl support])
+fi
+], [test x"${with_crypto}" = x"internal" || test x"${with_crypto}" = x"" ], [AC_DEFINE([CRYPTO_INTERNAL], [1], [Compile with internal cryptographic implementation])
+], [AC_MSG_ERROR([Unknown value for --with-crypto])]
+)
 
 AS_IF([test "${enable_clippy_only}" != "yes"], [
 AC_CHECK_HEADERS([json-c/json.h])
index 22239f8e6059e168dfd1223691bd376c54ce49ed..352887eca8c78212b7e6d7a96b97559f849994a8 100644 (file)
@@ -134,6 +134,10 @@ typedef unsigned char uint8_t;
 #endif
 #endif
 
+#ifdef CRYPTO_OPENSSL
+#include <openssl/evp.h>
+#endif
+
 #include "openbsd-tree.h"
 
 #include <netinet/in.h>
index 32043c81ae23f51485df53d8ef2c746758397129..66338511a3591e0a3e325b4af6f11e2155c2df31 100644 (file)
@@ -186,7 +186,11 @@ AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
       AC_MSG_RESULT([yes])
 
       PYTHON_CFLAGS="`\"$pycfg\" --includes`"
-      PYTHON_LIBS="`\"$pycfg\" --ldflags`"
+      if test x"${py_ver}" == x"3.8" || test x"{py_ver}" == x"3.9"; then
+        PYTHON_LIBS="`\"$pycfg\" --ldflags --embed`"
+      else
+        PYTHON_LIBS="`\"$pycfg\" --ldflags`"
+      fi
 
       AC_MSG_CHECKING([whether ${pycfg} provides a working build environment])
       _FRR_PYTHON_DEVENV([$py_hex], [
index 50c30a6fa0c15171e5aebc612e7e270f2ba920cb..62b0444796534962578ae22bbc3a1834c3222c5d 100644 (file)
@@ -33,7 +33,9 @@
 #include "log.h"
 #include "sockopt.h"
 #include "checksum.h"
+#ifdef CRYPTO_INTERNAL
 #include "md5.h"
+#endif
 #include "vrf.h"
 #include "lib_errors.h"
 
@@ -332,7 +334,11 @@ static unsigned int ospf_packet_max(struct ospf_interface *oi)
 static int ospf_check_md5_digest(struct ospf_interface *oi,
                                 struct ospf_header *ospfh)
 {
+#ifdef CRYPTO_OPENSSL
+       EVP_MD_CTX *ctx;
+#elif CRYPTO_INTERNAL
        MD5_CTX ctx;
+#endif
        unsigned char digest[OSPF_AUTH_MD5_SIZE];
        struct crypt_key *ck;
        struct ospf_neighbor *nbr;
@@ -361,11 +367,21 @@ static int ospf_check_md5_digest(struct ospf_interface *oi,
        }
 
        /* Generate a digest for the ospf packet - their digest + our digest. */
+#ifdef CRYPTO_OPENSSL
+       unsigned int md5_size = OSPF_AUTH_MD5_SIZE;
+       ctx = EVP_MD_CTX_new();
+       EVP_DigestInit(ctx, EVP_md5());
+       EVP_DigestUpdate(ctx, ospfh, length);
+       EVP_DigestUpdate(ctx, ck->auth_key, OSPF_AUTH_MD5_SIZE);
+       EVP_DigestFinal(ctx, digest, &md5_size);
+       EVP_MD_CTX_free(ctx);
+#elif CRYPTO_INTERNAL
        memset(&ctx, 0, sizeof(ctx));
        MD5Init(&ctx);
        MD5Update(&ctx, ospfh, length);
        MD5Update(&ctx, ck->auth_key, OSPF_AUTH_MD5_SIZE);
        MD5Final(digest, &ctx);
+#endif
 
        /* compare the two */
        if (memcmp((caddr_t)ospfh + length, digest, OSPF_AUTH_MD5_SIZE)) {
@@ -389,7 +405,11 @@ static int ospf_make_md5_digest(struct ospf_interface *oi,
 {
        struct ospf_header *ospfh;
        unsigned char digest[OSPF_AUTH_MD5_SIZE] = {0};
+#ifdef CRYPTO_OPENSSL
+       EVP_MD_CTX *ctx;
+#elif CRYPTO_INTERNAL
        MD5_CTX ctx;
+#endif
        void *ibuf;
        uint32_t t;
        struct crypt_key *ck;
@@ -422,11 +442,21 @@ static int ospf_make_md5_digest(struct ospf_interface *oi,
        }
 
        /* Generate a digest for the entire packet + our secret key. */
+#ifdef CRYPTO_OPENSSL
+       unsigned int md5_size = OSPF_AUTH_MD5_SIZE;
+       ctx = EVP_MD_CTX_new();
+       EVP_DigestInit(ctx, EVP_md5());
+       EVP_DigestUpdate(ctx, ibuf, ntohs(ospfh->length));
+       EVP_DigestUpdate(ctx, auth_key, OSPF_AUTH_MD5_SIZE);
+       EVP_DigestFinal(ctx, digest, &md5_size);
+       EVP_MD_CTX_free(ctx);
+#elif CRYPTO_INTERNAL
        memset(&ctx, 0, sizeof(ctx));
        MD5Init(&ctx);
        MD5Update(&ctx, ibuf, ntohs(ospfh->length));
        MD5Update(&ctx, auth_key, OSPF_AUTH_MD5_SIZE);
        MD5Final(digest, &ctx);
+#endif
 
        /* Append md5 digest to the end of the stream. */
        stream_put(op->s, digest, OSPF_AUTH_MD5_SIZE);
index 47438b985e2aa58fe50ea350530f9e10f05fb9e7..b478832d848284d20828727523fd2cc24dce13c8 100644 (file)
@@ -983,7 +983,8 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS)
                char buf_prefix[PREFIX_STRLEN];
                prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
 
-               zlog_debug("%s: from client %s: vrf_id %d, p %s", __func__,
+               zlog_debug("%s: cmd %s from client %s: vrf_id %d, p %s",
+                          __func__, zserv_command_string(cmd),
                           zebra_route_string(api.type), vrf_id, buf_prefix);
        }
 
index e0ff0430f81a4728cbe5524754975a60bdd0ed45..561fbcb52d1b33b3bdc8cd4950b4a18d54fee0b5 100644 (file)
@@ -37,7 +37,9 @@
 #include "if_rmap.h"
 #include "plist.h"
 #include "distribute.h"
+#ifdef CRYPTO_INTERNAL
 #include "md5.h"
+#endif
 #include "keychain.h"
 #include "privs.h"
 #include "lib_errors.h"
@@ -870,7 +872,11 @@ static int rip_auth_md5(struct rip_packet *packet, struct sockaddr_in *from,
        struct rip_md5_data *md5data;
        struct keychain *keychain;
        struct key *key;
+#ifdef CRYPTO_OPENSSL
+       EVP_MD_CTX *ctx;
+#elif CRYPTO_INTERNAL
        MD5_CTX ctx;
+#endif
        uint8_t digest[RIP_AUTH_MD5_SIZE];
        uint16_t packet_len;
        char auth_str[RIP_AUTH_MD5_SIZE] = {};
@@ -934,11 +940,21 @@ static int rip_auth_md5(struct rip_packet *packet, struct sockaddr_in *from,
                return 0;
 
        /* MD5 digest authentication. */
+#ifdef CRYPTO_OPENSSL
+       unsigned int md5_size = RIP_AUTH_MD5_SIZE;
+       ctx = EVP_MD_CTX_new();
+       EVP_DigestInit(ctx, EVP_md5());
+       EVP_DigestUpdate(ctx, packet, packet_len + RIP_HEADER_SIZE);
+       EVP_DigestUpdate(ctx, auth_str, RIP_AUTH_MD5_SIZE);
+       EVP_DigestFinal(ctx, digest, &md5_size);
+       EVP_MD_CTX_free(ctx);
+#elif CRYPTO_INTERNAL
        memset(&ctx, 0, sizeof(ctx));
        MD5Init(&ctx);
        MD5Update(&ctx, packet, packet_len + RIP_HEADER_SIZE);
        MD5Update(&ctx, auth_str, RIP_AUTH_MD5_SIZE);
        MD5Final(digest, &ctx);
+#endif
 
        if (memcmp(md5data->digest, digest, RIP_AUTH_MD5_SIZE) == 0)
                return packet_len;
@@ -1063,7 +1079,11 @@ static void rip_auth_md5_set(struct stream *s, struct rip_interface *ri,
                             size_t doff, char *auth_str, int authlen)
 {
        unsigned long len;
+#ifdef CRYPTO_OPENSSL
+       EVP_MD_CTX *ctx;
+#elif CRYPTO_INTERNAL
        MD5_CTX ctx;
+#endif
        unsigned char digest[RIP_AUTH_MD5_SIZE];
 
        /* Make it sure this interface is configured as MD5
@@ -1092,11 +1112,21 @@ static void rip_auth_md5_set(struct stream *s, struct rip_interface *ri,
        stream_putw(s, RIP_AUTH_DATA);
 
        /* Generate a digest for the RIP packet. */
+#ifdef CRYPTO_OPENSSL
+       unsigned int md5_size = RIP_AUTH_MD5_SIZE;
+       ctx = EVP_MD_CTX_new();
+       EVP_DigestInit(ctx, EVP_md5());
+       EVP_DigestUpdate(ctx, STREAM_DATA(s), stream_get_endp(s));
+       EVP_DigestUpdate(ctx, auth_str, RIP_AUTH_MD5_SIZE);
+       EVP_DigestFinal(ctx, digest, &md5_size);
+       EVP_MD_CTX_free(ctx);
+#elif CRYPTO_INTERNAL
        memset(&ctx, 0, sizeof(ctx));
        MD5Init(&ctx);
        MD5Update(&ctx, STREAM_DATA(s), stream_get_endp(s));
        MD5Update(&ctx, auth_str, RIP_AUTH_MD5_SIZE);
        MD5Final(digest, &ctx);
+#endif
 
        /* Copy the digest to the packet. */
        stream_write(s, digest, RIP_AUTH_MD5_SIZE);
index b2c61bcbab685567be3f67e7102ed30707148de1..34f58a98e23ff8d6b63aad239c8623a9f7d6b7c5 100644 (file)
@@ -73,6 +73,7 @@ int static_add_route(afi_t afi, safi_t safi, uint8_t type, struct prefix *p,
        struct static_route *cp;
        struct static_route *update = NULL;
        struct route_table *stable = svrf->stable[afi][safi];
+       struct interface *ifp;
 
        if (!stable)
                return -1;
@@ -182,11 +183,26 @@ int static_add_route(afi_t afi, safi_t safi, uint8_t type, struct prefix *p,
        si->next = cp;
 
        /* check whether interface exists in system & install if it does */
-       if (!ifname)
+       switch (si->type) {
+       case STATIC_IPV4_GATEWAY:
+       case STATIC_IPV6_GATEWAY:
                static_zebra_nht_register(rn, si, true);
-       else {
-               struct interface *ifp;
+               break;
+       case STATIC_IPV4_GATEWAY_IFNAME:
+       case STATIC_IPV6_GATEWAY_IFNAME:
+               ifp =  if_lookup_by_name(ifname, nh_svrf->vrf->vrf_id);
+               if (ifp && ifp->ifindex != IFINDEX_INTERNAL)
+                       si->ifindex = ifp->ifindex;
+               else
+                       zlog_warn("Static Route using %s interface not installed because the interface does not exist in specified vrf",
+                                 ifname);
 
+               static_zebra_nht_register(rn, si, true);
+               break;
+       case STATIC_BLACKHOLE:
+               static_install_route(rn, si, safi);
+               break;
+       case STATIC_IFNAME:
                ifp = if_lookup_by_name(ifname, nh_svrf->vrf->vrf_id);
                if (ifp && ifp->ifindex != IFINDEX_INTERNAL) {
                        si->ifindex = ifp->ifindex;
@@ -194,6 +210,8 @@ int static_add_route(afi_t afi, safi_t safi, uint8_t type, struct prefix *p,
                } else
                        zlog_warn("Static Route using %s interface not installed because the interface does not exist in specified vrf",
                                  ifname);
+
+               break;
        }
 
        return 1;
index e75d896721b171adc9adacd35a7c42e7b93ecd2a..1fb70a0e2fbe9cd69f337e4d870f8dae3a2ce41d 100644 (file)
@@ -10,3 +10,9 @@ C>* 192.168.8.0/26 is directly connected, r1-eth8, XX:XX:XX
 C>* 192.168.9.0/26 is directly connected, r1-eth9, XX:XX:XX
 O   192.168.0.0/24 [110/10] is directly connected, r1-eth0, XX:XX:XX
 O   192.168.3.0/26 [110/10] is directly connected, r1-eth3, XX:XX:XX
+S>* 4.5.6.10/32 [1/0] via 192.168.0.2, r1-eth0, XX:XX:XX
+S>* 4.5.6.11/32 [1/0] via 192.168.0.2, r1-eth0, XX:XX:XX
+S>* 4.5.6.12/32 [1/0] is directly connected, r1-eth0, XX:XX:XX
+S>* 4.5.6.7/32 [1/0] unreachable (blackhole), XX:XX:XX
+S>* 4.5.6.8/32 [1/0] unreachable (blackhole), XX:XX:XX
+S>* 4.5.6.9/32 [1/0] unreachable (ICMP unreachable), XX:XX:XX
index 88cee964d6c67a9ff764c90ea939238819492638..6e3e9c87c140a414d09efbcd8785f7ccf34e8129 100644 (file)
@@ -20,3 +20,9 @@ C * fe80::/64 is directly connected, r1-eth7, XX:XX:XX
 C * fe80::/64 is directly connected, r1-eth8, XX:XX:XX
 C * fe80::/64 is directly connected, r1-eth9, XX:XX:XX
 O   fc00:0:0:4::/64 [110/10] is directly connected, r1-eth4, XX:XX:XX
+S>* 4:5::/32 [1/0] is directly connected, r1-eth0, XX:XX:XX
+S>* 4:5::6:10/128 [1/0] via fc00::2, r1-eth0, XX:XX:XX
+S>* 4:5::6:11/128 [1/0] via fc00::2, r1-eth0, XX:XX:XX
+S>* 4:5::6:7/128 [1/0] unreachable (blackhole), XX:XX:XX
+S>* 4:5::6:8/128 [1/0] unreachable (blackhole), XX:XX:XX
+S>* 4:5::6:9/128 [1/0] unreachable (ICMP unreachable), XX:XX:XX
index 164104da7efbbea686e958265a87a9616f2530bb..30e05f01e38a457c8eadd1664a2c448f991de6d7 100644 (file)
@@ -2,6 +2,23 @@ log file zebra.log
 !
 hostname r1
 !
+# Create the various blackhole route types
+ip route 4.5.6.7/32 blackhole
+ipv6 route 4:5::6:7/128 blackhole
+ip route 4.5.6.8/32 Null0
+ipv6 route 4:5::6:8/128 Null0
+ip route 4.5.6.9/32 reject
+ipv6 route 4:5::6:9/128 reject
+# Create normal gateway routes
+ip route 4.5.6.10/32 192.168.0.2
+ipv6 route 4:5::6:10/128 fc00:0:0:0::2
+# Create normal gateway + interface routes
+ip route 4.5.6.11/32 192.168.0.2 r1-eth0
+ipv6 route 4:5::6:11/128 fc00:0:0:0::2 r1-eth0
+# Create ifname routes
+ip route 4.5.6.12/32 r1-eth0
+ipv6 route 4:5::6:12/32 r1-eth0
+!
 interface r1-eth0
  description to sw0 - no routing protocol
  ip address 192.168.0.1/24
index cec5675e013560bad6c90aef2e41422a3b861fcd..fba754f6265ef0b7aa9ccb051fcb51e3045bfbfc 100644 (file)
@@ -852,11 +852,15 @@ int vtysh_mark_file(const char *filename)
                        return CMD_ERR_INCOMPLETE;
                case CMD_SUCCESS:
                        vty_out(vty, "%s", vty->buf);
+                       if (strmatch(vty_buf_trimmed, "exit-vrf"))
+                               vty_out(vty, "end\n");
                        break;
                case CMD_SUCCESS_DAEMON: {
                        int cmd_stat;
 
                        vty_out(vty, "%s", vty->buf);
+                       if (strmatch(vty_buf_trimmed, "exit-vrf"))
+                               vty_out(vty, "end\n");
                        cmd_stat = vtysh_client_execute(&vtysh_client[0],
                                                        vty->buf);
                        if (cmd_stat != CMD_SUCCESS)
index f93562b31b53a2263dc11d05b2455dc073b7efb5..c90e027f02b225c02d0c78b030de83f6bf6301da 100644 (file)
@@ -3023,7 +3023,7 @@ void zebra_dplane_start(void)
        /* Start dataplane pthread */
 
        zdplane_info.dg_pthread = frr_pthread_new(&pattr, "Zebra dplane thread",
-                                                 "Zebra dplane");
+                                                 "zebra_dplane");
 
        zdplane_info.dg_master = zdplane_info.dg_pthread->master;
 
index 977e3bba79e37e13b6284c6bd86495ce6e5c7445..f4b86f3cfe96dd064ddce855f05e3f91a46406ef 100644 (file)
@@ -87,7 +87,7 @@ static void nexthop_set_resolved(afi_t afi, const struct nexthop *newhop,
                break;
        case NEXTHOP_TYPE_BLACKHOLE:
                resolved_hop->type = NEXTHOP_TYPE_BLACKHOLE;
-               resolved_hop->bh_type = nexthop->bh_type;
+               resolved_hop->bh_type = newhop->bh_type;
                break;
        }
 
index 99431e7e6df09853bdce87ede3fee70ac71f3ff4..5c0dc2738019f3a2754cb58455dd4bcf07714680 100644 (file)
@@ -1028,7 +1028,7 @@ DEFPY (show_route_all_table_vrf,
 
 DEFPY (show_ip_nht,
        show_ip_nht_cmd,
-       "show <ip$ipv4|ipv6$ipv6> <nht|import-check>$type [<A.B.C.D|X:X::X:X>$addr|vrf NAME$vrf_name <A.B.C.D|X:X::X:X>$addr|vrf all$vrf_all]",
+       "show <ip$ipv4|ipv6$ipv6> <nht|import-check>$type [<A.B.C.D|X:X::X:X>$addr|vrf NAME$vrf_name [<A.B.C.D|X:X::X:X>$addr]|vrf all$vrf_all]",
        SHOW_STR
        IP_STR
        IP6_STR