summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2018-08-24 19:41:17 +0200
committerGitHub <noreply@github.com>2018-08-24 19:41:17 +0200
commit9b8c3903bdf0f681df17a532286bc717e1f607ad (patch)
tree747815ef08149b7faa329bd5aa3bcc47fbc05d5f
parentMerge pull request #2804 from kssoman/bgp_fix (diff)
parentdoc, lib, zebra: Remove deprecated encode and decode functionality (diff)
downloadfrr-9b8c3903bdf0f681df17a532286bc717e1f607ad.tar.xz
frr-9b8c3903bdf0f681df17a532286bc717e1f607ad.zip
Merge pull request #2901 from donaldsharp/remove_zapi_deprecated
Remove zapi deprecated
-rw-r--r--doc/developer/zebra.rst8
-rw-r--r--lib/log.c4
-rw-r--r--lib/zclient.c239
-rw-r--r--lib/zclient.h85
-rw-r--r--zebra/client_main.c208
-rw-r--r--zebra/subdir.am5
-rw-r--r--zebra/zapi_msg.c612
7 files changed, 8 insertions, 1153 deletions
diff --git a/doc/developer/zebra.rst b/doc/developer/zebra.rst
index 3d64b6711..1bf31e962 100644
--- a/doc/developer/zebra.rst
+++ b/doc/developer/zebra.rst
@@ -102,14 +102,6 @@ Zebra Protocol Commands
+-----------------------------------+-------+
| ZEBRA_INTERFACE_DOWN | 6 |
+-----------------------------------+-------+
-| ZEBRA_IPV4_ROUTE_ADD | 7 |
-+-----------------------------------+-------+
-| ZEBRA_IPV4_ROUTE_DELETE | 8 |
-+-----------------------------------+-------+
-| ZEBRA_IPV6_ROUTE_ADD | 9 |
-+-----------------------------------+-------+
-| ZEBRA_IPV6_ROUTE_DELETE | 10 |
-+-----------------------------------+-------+
| ZEBRA_REDISTRIBUTE_ADD | 11 |
+-----------------------------------+-------+
| ZEBRA_REDISTRIBUTE_DELETE | 12 |
diff --git a/lib/log.c b/lib/log.c
index 361521f56..b067018e0 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -908,10 +908,6 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_ROUTE_ADD),
DESC_ENTRY(ZEBRA_ROUTE_DELETE),
DESC_ENTRY(ZEBRA_ROUTE_NOTIFY_OWNER),
- DESC_ENTRY(ZEBRA_IPV4_ROUTE_ADD),
- DESC_ENTRY(ZEBRA_IPV4_ROUTE_DELETE),
- DESC_ENTRY(ZEBRA_IPV6_ROUTE_ADD),
- DESC_ENTRY(ZEBRA_IPV6_ROUTE_DELETE),
DESC_ENTRY(ZEBRA_REDISTRIBUTE_ADD),
DESC_ENTRY(ZEBRA_REDISTRIBUTE_DELETE),
DESC_ENTRY(ZEBRA_REDISTRIBUTE_DEFAULT_ADD),
diff --git a/lib/zclient.c b/lib/zclient.c
index cc91705ee..b2bafcb7d 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -676,11 +676,11 @@ int zclient_send_rnh(struct zclient *zclient, int command, struct prefix *p,
* "xdr_encode"-like interface that allows daemon (client) to send
* a message to zebra server for a route that needs to be
* added/deleted to the kernel. Info about the route is specified
- * by the caller in a struct zapi_ipv4. zapi_ipv4_read() then writes
+ * by the caller in a struct zapi_route. zapi_route_encode() then writes
* the info down the zclient socket using the stream_* functions.
*
* The corresponding read ("xdr_decode") function on the server
- * side is zread_ipv4_add()/zread_ipv4_delete().
+ * side is zapi_route_decode().
*
* 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -707,21 +707,16 @@ int zclient_send_rnh(struct zclient *zclient, int command, struct prefix *p,
* is set to 1 and a nexthop of type NEXTHOP_TYPE_BLACKHOLE is the sole
* nexthop.
*
- * The original struct zapi_ipv4, zapi_ipv4_route() and zread_ipv4_*()
- * infrastructure was built around the traditional (32-bit "gate OR
- * ifindex") nexthop data unit. A special encoding can be used to feed
- * onlink (64-bit "gate AND ifindex") nexthops into zapi_ipv4_route()
- * using the same zapi_ipv4 structure. This is done by setting zapi_ipv4
- * fields as follows:
+ * The original struct zapi_route_*() infrastructure was built around
+ * the traditional (32-bit "gate OR ifindex") nexthop data unit.
+ * A special encoding can be used to feed onlink (64-bit "gate AND ifindex")
+ * nexthops into zapi_route_encode() using the same zapi_route structure.
+ * This is done by setting zapi_route fields as follows:
* - .message |= ZAPI_MESSAGE_NEXTHOP | ZAPI_MESSAGE_ONLINK
* - .nexthop_num == .ifindex_num
* - .nexthop and .ifindex are filled with gate and ifindex parts of
* each compound nexthop, both in the same order
*
- * zapi_ipv4_route() will produce two nexthop data units for each such
- * interleaved 64-bit nexthop. On the zserv side of the socket it will be
- * mapped to a singlle NEXTHOP_TYPE_IPV4_IFINDEX_OL RIB nexthop structure.
- *
* If ZAPI_MESSAGE_DISTANCE is set, the distance value is written as a 1
* byte value.
*
@@ -734,226 +729,6 @@ int zclient_send_rnh(struct zclient *zclient, int command, struct prefix *p,
*
* XXX: No attention paid to alignment.
*/
-int zapi_ipv4_route(uint8_t cmd, struct zclient *zclient, struct prefix_ipv4 *p,
- struct zapi_ipv4 *api)
-{
- int i;
- int psize;
- struct stream *s;
-
- /* Reset stream. */
- s = zclient->obuf;
- stream_reset(s);
-
- /* Some checks for labeled-unicast. The current expectation is that each
- * nexthop is accompanied by a label in the case of labeled-unicast.
- */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)
- && CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
- /* We expect prefixes installed with labels and the number to
- * match
- * the number of nexthops.
- */
- assert(api->label_num == api->nexthop_num);
- }
-
- zclient_create_header(s, cmd, api->vrf_id);
-
- /* Put type and nexthop. */
- stream_putc(s, api->type);
- stream_putw(s, api->instance);
- stream_putl(s, api->flags);
- stream_putc(s, api->message);
- stream_putw(s, api->safi);
-
- /* Put prefix information. */
- psize = PSIZE(p->prefixlen);
- stream_putc(s, p->prefixlen);
- stream_write(s, (uint8_t *)&p->prefix, psize);
-
- /* Nexthop, ifindex, distance and metric information. */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
- stream_putc(s, api->nexthop_num + api->ifindex_num);
-
- for (i = 0; i < api->nexthop_num; i++) {
- stream_putc(s, NEXTHOP_TYPE_IPV4);
- stream_put_in_addr(s, api->nexthop[i]);
- /* For labeled-unicast, each nexthop is followed by
- * label. */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL))
- stream_putl(s, api->label[i]);
- }
- for (i = 0; i < api->ifindex_num; i++) {
- stream_putc(s, NEXTHOP_TYPE_IFINDEX);
- stream_putl(s, api->ifindex[i]);
- }
- }
-
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
- stream_putc(s, api->distance);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
- stream_putl(s, api->metric);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
- stream_putl(s, api->tag);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
- stream_putl(s, api->mtu);
-
- /* Put length at the first point of the stream. */
- stream_putw_at(s, 0, stream_get_endp(s));
-
- return zclient_send_message(zclient);
-}
-
-int zapi_ipv4_route_ipv6_nexthop(uint8_t cmd, struct zclient *zclient,
- struct prefix_ipv4 *p, struct zapi_ipv6 *api)
-{
- int i;
- int psize;
- struct stream *s;
-
- /* Reset stream. */
- s = zclient->obuf;
- stream_reset(s);
-
- /* Some checks for labeled-unicast. The current expectation is that each
- * nexthop is accompanied by a label in the case of labeled-unicast.
- */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)
- && CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
- /* We expect prefixes installed with labels and the number to
- * match
- * the number of nexthops.
- */
- assert(api->label_num == api->nexthop_num);
- }
-
- zclient_create_header(s, cmd, api->vrf_id);
-
- /* Put type and nexthop. */
- stream_putc(s, api->type);
- stream_putw(s, api->instance);
- stream_putl(s, api->flags);
- stream_putc(s, api->message);
- stream_putw(s, api->safi);
-
- /* Put prefix information. */
- psize = PSIZE(p->prefixlen);
- stream_putc(s, p->prefixlen);
- stream_write(s, (uint8_t *)&p->prefix, psize);
-
- /* Nexthop, ifindex, distance and metric information. */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
- stream_putc(s, api->nexthop_num + api->ifindex_num);
-
- for (i = 0; i < api->nexthop_num; i++) {
- stream_putc(s, NEXTHOP_TYPE_IPV6);
- stream_write(s, (uint8_t *)api->nexthop[i], 16);
- /* For labeled-unicast, each nexthop is followed by
- * label. */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL))
- stream_putl(s, api->label[i]);
- }
- for (i = 0; i < api->ifindex_num; i++) {
- stream_putc(s, NEXTHOP_TYPE_IFINDEX);
- stream_putl(s, api->ifindex[i]);
- }
- }
-
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
- stream_putc(s, api->distance);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
- stream_putl(s, api->metric);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
- stream_putl(s, api->tag);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
- stream_putl(s, api->mtu);
-
- /* Put length at the first point of the stream. */
- stream_putw_at(s, 0, stream_get_endp(s));
-
- return zclient_send_message(zclient);
-}
-
-int zapi_ipv6_route(uint8_t cmd, struct zclient *zclient, struct prefix_ipv6 *p,
- struct prefix_ipv6 *src_p, struct zapi_ipv6 *api)
-{
- int i;
- int psize;
- struct stream *s;
-
- /* either we have !SRCPFX && src_p == NULL, or SRCPFX && src_p != NULL
- */
- assert(!(api->message & ZAPI_MESSAGE_SRCPFX) == !src_p);
-
- /* Reset stream. */
- s = zclient->obuf;
- stream_reset(s);
-
- /* Some checks for labeled-unicast. The current expectation is that each
- * nexthop is accompanied by a label in the case of labeled-unicast.
- */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)
- && CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
- /* We expect prefixes installed with labels and the number to
- * match
- * the number of nexthops.
- */
- assert(api->label_num == api->nexthop_num);
- }
-
- zclient_create_header(s, cmd, api->vrf_id);
-
- /* Put type and nexthop. */
- stream_putc(s, api->type);
- stream_putw(s, api->instance);
- stream_putl(s, api->flags);
- stream_putc(s, api->message);
- stream_putw(s, api->safi);
-
- /* Put prefix information. */
- psize = PSIZE(p->prefixlen);
- stream_putc(s, p->prefixlen);
- stream_write(s, (uint8_t *)&p->prefix, psize);
-
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) {
- psize = PSIZE(src_p->prefixlen);
- stream_putc(s, src_p->prefixlen);
- stream_write(s, (uint8_t *)&src_p->prefix, psize);
- }
-
- /* Nexthop, ifindex, distance and metric information. */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
- stream_putc(s, api->nexthop_num + api->ifindex_num);
-
- for (i = 0; i < api->nexthop_num; i++) {
- stream_putc(s, NEXTHOP_TYPE_IPV6);
- stream_write(s, (uint8_t *)api->nexthop[i], 16);
- /* For labeled-unicast, each nexthop is followed by
- * label. */
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL))
- stream_putl(s, api->label[i]);
- }
- for (i = 0; i < api->ifindex_num; i++) {
- stream_putc(s, NEXTHOP_TYPE_IFINDEX);
- stream_putl(s, api->ifindex[i]);
- }
- }
-
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
- stream_putc(s, api->distance);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
- stream_putl(s, api->metric);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
- stream_putl(s, api->tag);
- if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
- stream_putl(s, api->mtu);
-
- /* Put length at the first point of the stream. */
- stream_putw_at(s, 0, stream_get_endp(s));
-
- return zclient_send_message(zclient);
-}
-
int zclient_route_send(uint8_t cmd, struct zclient *zclient,
struct zapi_route *api)
{
diff --git a/lib/zclient.h b/lib/zclient.h
index 962b1707c..b8ff85e80 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -73,10 +73,6 @@ typedef enum {
ZEBRA_ROUTE_ADD,
ZEBRA_ROUTE_DELETE,
ZEBRA_ROUTE_NOTIFY_OWNER,
- ZEBRA_IPV4_ROUTE_ADD,
- ZEBRA_IPV4_ROUTE_DELETE,
- ZEBRA_IPV6_ROUTE_ADD,
- ZEBRA_IPV6_ROUTE_DELETE,
ZEBRA_REDISTRIBUTE_ADD,
ZEBRA_REDISTRIBUTE_DELETE,
ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
@@ -286,7 +282,7 @@ struct zclient {
*/
#define ZAPI_MESSAGE_TABLEID 0x80
-#define ZSERV_VERSION 5
+#define ZSERV_VERSION 6
/* Zserv protocol message header */
struct zmsghdr {
uint16_t length;
@@ -353,37 +349,6 @@ struct zapi_route {
uint32_t tableid;
};
-/* Zebra IPv4 route message API. */
-struct zapi_ipv4 {
- uint8_t type;
- unsigned short instance;
-
- uint32_t flags;
-
- uint8_t message;
-
- safi_t safi;
-
- uint8_t nexthop_num;
- struct in_addr **nexthop;
-
- uint8_t ifindex_num;
- ifindex_t *ifindex;
-
- uint8_t label_num;
- unsigned int *label;
-
- uint8_t distance;
-
- uint32_t metric;
-
- route_tag_t tag;
-
- uint32_t mtu;
-
- vrf_id_t vrf_id;
-};
-
struct zapi_pw {
char ifname[IF_NAMESIZE];
ifindex_t ifindex;
@@ -600,15 +565,6 @@ extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
extern void zebra_interface_if_set_value(struct stream *, struct interface *);
extern void zebra_router_id_update_read(struct stream *s, struct prefix *rid);
-/* clang-format off */
-#if CONFDATE > 20180823
-CPP_NOTICE("zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as well as the zapi_ipv4 and zapi_ipv6 data structures should be removed now");
-#endif
-/* clang-format on */
-
-extern int zapi_ipv4_route(uint8_t, struct zclient *, struct prefix_ipv4 *,
- struct zapi_ipv4 *) __attribute__((deprecated));
-
extern struct interface *zebra_interface_link_params_read(struct stream *);
extern size_t zebra_interface_link_params_write(struct stream *,
struct interface *);
@@ -635,45 +591,6 @@ extern void zebra_read_pw_status_update(int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id,
struct zapi_pw_status *pw);
-/* IPv6 prefix add and delete function prototype. */
-
-struct zapi_ipv6 {
- uint8_t type;
- unsigned short instance;
-
- uint32_t flags;
-
- uint8_t message;
-
- safi_t safi;
-
- uint8_t nexthop_num;
- struct in6_addr **nexthop;
-
- uint8_t ifindex_num;
- ifindex_t *ifindex;
-
- uint8_t label_num;
- unsigned int *label;
-
- uint8_t distance;
-
- uint32_t metric;
-
- route_tag_t tag;
-
- uint32_t mtu;
-
- vrf_id_t vrf_id;
-};
-
-extern int zapi_ipv6_route(uint8_t cmd, struct zclient *zclient,
- struct prefix_ipv6 *p, struct prefix_ipv6 *src_p,
- struct zapi_ipv6 *api) __attribute__((deprecated));
-extern int zapi_ipv4_route_ipv6_nexthop(uint8_t, struct zclient *,
- struct prefix_ipv4 *,
- struct zapi_ipv6 *)
- __attribute__((deprecated));
extern int zclient_route_send(uint8_t, struct zclient *, struct zapi_route *);
extern int zclient_send_rnh(struct zclient *zclient, int command,
struct prefix *p, bool exact_match,
diff --git a/zebra/client_main.c b/zebra/client_main.c
deleted file mode 100644
index 1ead7ee1f..000000000
--- a/zebra/client_main.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * GNU Zebra client test main routine.
- * Copyright (C) 1997 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra 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, or (at your option) any
- * later version.
- *
- * GNU Zebra 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>
-
-#include "prefix.h"
-#include "stream.h"
-#include "zclient.h"
-#include "thread.h"
-#include "table.h"
-#include "zebra/rib.h"
-#include "zebra/zserv.h"
-
-struct thread *master;
-
-/* Zebra client structure. */
-struct zclient *zclient = NULL;
-
-/* Zebra socket. */
-int sock;
-
-/* IPv4 route add and delete test. */
-void zebra_test_ipv4(int command, int type, char *prefix, char *gateway,
- uint8_t distance)
-{
- struct zapi_ipv4 api;
- struct prefix_ipv4 p;
- struct in_addr gate;
- struct in_addr *gpnt;
-
- str2prefix_ipv4(prefix, &p);
- if (!inet_aton(gateway, &gate)) {
- printf("Gateway specified: %s is illegal\n", gateway);
- return;
- }
-
- gpnt = &gate;
-
- api.vrf_id = VRF_DEFAULT;
- api.type = type;
- api.flags = 0;
-
- api.message = 0;
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = 1;
- api.nexthop = &gpnt;
- api.ifindex_num = 0;
- if (distance) {
- SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
- api.distance = distance;
- }
-
-
- switch (command) {
- case ZEBRA_IPV4_ROUTE_ADD:
- zapi_ipv4_add(zclient, &p, &api);
- break;
- case ZEBRA_IPV4_ROUTE_DELETE:
- zapi_ipv4_delete(zclient, &p, &api);
- break;
- }
-}
-
-/* IPv6 route add and delete test. */
-void zebra_test_v6(int sock)
-{
- struct prefix_ipv6 p;
- struct in6_addr nexthop;
-
- str2prefix_ipv6("3ffe:506::2/128", &p);
- inet_pton(AF_INET6, "::1", &nexthop);
-
- /* zebra_ipv6_add (sock, ZEBRA_ROUTE_STATIC, 0, &p, &nexthop, 1); */
-
- sleep(5);
- /* zebra_ipv6_delete (sock, ZEBRA_ROUTE_STATIC, 0, &p, &nexthop, 1); */
-}
-
-/* Print out usage and exit. */
-void usage_exit()
-{
- fprintf(stderr, "Usage: client filename\n");
- exit(1);
-}
-
-struct zebra_info {
- char *str;
- int type;
-} zebra_type[] = {{"static", ZEBRA_ROUTE_STATIC},
- {"rip", ZEBRA_ROUTE_RIP},
- {"ripng", ZEBRA_ROUTE_RIPNG},
- {"ospf", ZEBRA_ROUTE_OSPF},
- {"ospf6", ZEBRA_ROUTE_OSPF6},
- {"bgp", ZEBRA_ROUTE_BGP},
- {"nhrp", ZEBRA_ROUTE_NHRP},
- {"pim", ZEBRA_ROUTE_PIM},
- {NULL, 0}};
-
-/* Zebra route simulator. */
-void zebra_sim(FILE *fp)
-{
- char buf[BUFSIZ];
- char distance_str[BUFSIZ];
- uint8_t distance;
-
- while (fgets(buf, sizeof buf, fp)) {
- int i;
- int ret;
- int type;
- char str[BUFSIZ], command[BUFSIZ], prefix[BUFSIZ],
- gateway[BUFSIZ];
-
- distance = 0;
-
- if (*buf == '#')
- continue;
-
- type = ZEBRA_ROUTE_STATIC;
-
- ret = sscanf(buf, "%s %s %s %s %s\n", command, str, prefix,
- gateway, distance_str);
-
- if (ret == 5) {
- distance = atoi(distance_str);
- } else {
- ret = sscanf(buf, "%s %s %s %s\n", command, str, prefix,
- gateway);
-
- if (ret != 4)
- continue;
- }
-
- i = 0;
- while (zebra_type[i++].str) {
- if (strcmp(zebra_type[i].str, str) == 0) {
- type = zebra_type[i].type;
- break;
- }
- }
-
- if (strcmp(command, "add") == 0) {
- zebra_test_ipv4(ZEBRA_IPV4_ROUTE_ADD, type, prefix,
- gateway, distance);
- printf("%s", buf);
- continue;
- }
-
- if (strcmp(command, "del") == 0) {
- zebra_test_ipv4(ZEBRA_IPV4_ROUTE_DELETE, type, prefix,
- gateway, distance);
- printf("%s", buf);
- continue;
- }
- }
-}
-
-/* Test zebra client main routine. */
-int main(int argc, char **argv)
-{
- struct thread_master *master;
- FILE *fp;
-
- if (argc == 1)
- usage_exit();
-
- master = thread_master_create(NULL);
- /* Establish connection to zebra. */
- zclient = zclient_new_notify(master, &zclient_options_default);
- zclient->enable = 1;
- zclient_socket_connect(zclient);
-
- /* Open simulation file. */
- fp = fopen(argv[1], "r");
- if (fp == NULL) {
- fprintf(stderr,
- "%% Can't open configuration file %s due to '%s'\n",
- argv[1], safe_strerror(errno));
- exit(1);
- }
-
- /* Do main work. */
- zebra_sim(fp);
-
- sleep(100);
-
- fclose(fp);
- close(sock);
-
- return 0;
-}
diff --git a/zebra/subdir.am b/zebra/subdir.am
index f44574b23..69f7bc204 100644
--- a/zebra/subdir.am
+++ b/zebra/subdir.am
@@ -146,8 +146,3 @@ EXTRA_DIST += \
zebra/GNOME-SMI \
zebra/GNOME-PRODUCT-ZEBRA-MIB \
# end
-
-# -- unmaintained --
-# noinst_PROGRAMS += zebra/client
-# zebra_client_SOURCES = zebra/client_main.c
-# zebra_client_LDADD = lib/libfrr.la
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 008fc8f06..6990fd95f 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -1584,202 +1584,6 @@ static void zread_route_del(ZAPI_HANDLER_ARGS)
}
}
-/* This function support multiple nexthop. */
-/*
- * Parse the ZEBRA_IPV4_ROUTE_ADD sent from client. Update re and
- * add kernel route.
- */
-static void zread_ipv4_add(ZAPI_HANDLER_ARGS)
-{
- int i;
- struct route_entry *re;
- struct prefix p;
- uint8_t message;
- struct in_addr nhop_addr;
- uint8_t nexthop_num;
- uint8_t nexthop_type;
- struct stream *s;
- ifindex_t ifindex;
- safi_t safi;
- int ret;
- enum lsp_types_t label_type = ZEBRA_LSP_NONE;
- mpls_label_t label;
- struct nexthop *nexthop;
- enum blackhole_type bh_type = BLACKHOLE_NULL;
-
- /* Get input stream. */
- s = msg;
-
- /* Allocate new re. */
- re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
-
- /* Type, flags, message. */
- STREAM_GETC(s, re->type);
- if (re->type > ZEBRA_ROUTE_MAX) {
- zlog_warn("%s: Specified route type %d is not a legal value\n",
- __PRETTY_FUNCTION__, re->type);
- XFREE(MTYPE_RE, re);
- return;
- }
- STREAM_GETW(s, re->instance);
- STREAM_GETL(s, re->flags);
- STREAM_GETC(s, message);
- STREAM_GETW(s, safi);
- re->uptime = time(NULL);
-
- /* IPv4 prefix. */
- memset(&p, 0, sizeof(struct prefix_ipv4));
- p.family = AF_INET;
- STREAM_GETC(s, p.prefixlen);
- if (p.prefixlen > IPV4_MAX_BITLEN) {
- zlog_warn(
- "%s: Specified prefix length %d is greater than what v4 can be",
- __PRETTY_FUNCTION__, p.prefixlen);
- XFREE(MTYPE_RE, re);
- return;
- }
- STREAM_GET(&p.u.prefix4, s, PSIZE(p.prefixlen));
-
- /* VRF ID */
- re->vrf_id = zvrf_id(zvrf);
-
- /* Nexthop parse. */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) {
- STREAM_GETC(s, nexthop_num);
- zserv_nexthop_num_warn(__func__, (const struct prefix *)&p,
- nexthop_num);
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
- label_type = lsp_type_from_re_type(client->proto);
-
- for (i = 0; i < nexthop_num; i++) {
- STREAM_GETC(s, nexthop_type);
-
- switch (nexthop_type) {
- case NEXTHOP_TYPE_IFINDEX:
- STREAM_GETL(s, ifindex);
- route_entry_nexthop_ifindex_add(re, ifindex,
- re->vrf_id);
- break;
- case NEXTHOP_TYPE_IPV4:
- STREAM_GET(&nhop_addr.s_addr, s,
- IPV4_MAX_BYTELEN);
- nexthop = route_entry_nexthop_ipv4_add(
- re, &nhop_addr, NULL, re->vrf_id);
- /*
- * For labeled-unicast, each nexthop is followed
- * by the label.
- */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL)) {
- STREAM_GETL(s, label);
- nexthop_add_labels(nexthop, label_type,
- 1, &label);
- }
- break;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- STREAM_GET(&nhop_addr.s_addr, s,
- IPV4_MAX_BYTELEN);
- STREAM_GETL(s, ifindex);
- route_entry_nexthop_ipv4_ifindex_add(
- re, &nhop_addr, NULL, ifindex,
- re->vrf_id);
- break;
- case NEXTHOP_TYPE_IPV6:
- zlog_warn(
- "%s: Please use ZEBRA_ROUTE_ADD if you want to pass v6 nexthops",
- __PRETTY_FUNCTION__);
- nexthops_free(re->ng.nexthop);
- XFREE(MTYPE_RE, re);
- return;
- case NEXTHOP_TYPE_BLACKHOLE:
- route_entry_nexthop_blackhole_add(re, bh_type);
- break;
- default:
- zlog_warn(
- "%s: Specified nexthop type: %d does not exist",
- __PRETTY_FUNCTION__, nexthop_type);
- nexthops_free(re->ng.nexthop);
- XFREE(MTYPE_RE, re);
- return;
- }
- }
- }
-
- /* Distance. */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
- STREAM_GETC(s, re->distance);
-
- /* Metric. */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC))
- STREAM_GETL(s, re->metric);
-
- /* Tag */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_TAG))
- STREAM_GETL(s, re->tag);
- else
- re->tag = 0;
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_MTU))
- STREAM_GETL(s, re->mtu);
- else
- re->mtu = 0;
-
- /* Table */
- re->table = zvrf->table_id;
-
- ret = rib_add_multipath(AFI_IP, safi, &p, NULL, re);
-
- /* Stats */
- if (ret > 0)
- client->v4_route_add_cnt++;
- else if (ret < 0)
- client->v4_route_upd8_cnt++;
-
- return;
-
-stream_failure:
- nexthops_free(re->ng.nexthop);
- XFREE(MTYPE_RE, re);
-}
-
-/* Zebra server IPv4 prefix delete function. */
-static void zread_ipv4_delete(ZAPI_HANDLER_ARGS)
-{
- struct stream *s;
- struct zapi_ipv4 api;
- struct prefix p;
- uint32_t table_id;
-
- s = msg;
-
- /* Type, flags, message. */
- STREAM_GETC(s, api.type);
- STREAM_GETW(s, api.instance);
- STREAM_GETL(s, api.flags);
- STREAM_GETC(s, api.message);
- STREAM_GETW(s, api.safi);
-
- /* IPv4 prefix. */
- memset(&p, 0, sizeof(struct prefix));
- p.family = AF_INET;
- STREAM_GETC(s, p.prefixlen);
- if (p.prefixlen > IPV4_MAX_BITLEN) {
- zlog_warn("%s: Passed in prefixlen %d is impossible",
- __PRETTY_FUNCTION__, p.prefixlen);
- return;
- }
- STREAM_GET(&p.u.prefix4, s, PSIZE(p.prefixlen));
-
- table_id = zvrf->table_id;
-
- rib_delete(AFI_IP, api.safi, zvrf_id(zvrf), api.type, api.instance,
- api.flags, &p, NULL, NULL, table_id, 0, 0, false);
- client->v4_route_del_cnt++;
-
-stream_failure:
- return;
-}
-
/* MRIB Nexthop lookup for IPv4. */
static void zread_ipv4_nexthop_lookup_mrib(ZAPI_HANDLER_ARGS)
{
@@ -1794,417 +1598,6 @@ stream_failure:
return;
}
-/* Zebra server IPv6 prefix add function. */
-static void zread_ipv4_route_ipv6_nexthop_add(ZAPI_HANDLER_ARGS)
-{
- unsigned int i;
- struct stream *s;
- struct in6_addr nhop_addr;
- struct route_entry *re;
- uint8_t message;
- uint8_t nexthop_num;
- uint8_t nexthop_type;
- struct prefix p;
- safi_t safi;
- static struct in6_addr nexthops[MULTIPATH_NUM];
- static unsigned int ifindices[MULTIPATH_NUM];
- int ret;
- static mpls_label_t labels[MULTIPATH_NUM];
- enum lsp_types_t label_type = ZEBRA_LSP_NONE;
- mpls_label_t label;
- struct nexthop *nexthop;
- enum blackhole_type bh_type = BLACKHOLE_NULL;
-
- /* Get input stream. */
- s = msg;
-
- memset(&nhop_addr, 0, sizeof(struct in6_addr));
-
- /* Allocate new re. */
- re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
-
- /* Type, flags, message. */
- STREAM_GETC(s, re->type);
- if (re->type > ZEBRA_ROUTE_MAX) {
- zlog_warn("%s: Specified route type: %d is not a legal value\n",
- __PRETTY_FUNCTION__, re->type);
- XFREE(MTYPE_RE, re);
- return;
- }
- STREAM_GETW(s, re->instance);
- STREAM_GETL(s, re->flags);
- STREAM_GETC(s, message);
- STREAM_GETW(s, safi);
- re->uptime = time(NULL);
-
- /* IPv4 prefix. */
- memset(&p, 0, sizeof(struct prefix_ipv4));
- p.family = AF_INET;
- STREAM_GETC(s, p.prefixlen);
- if (p.prefixlen > IPV4_MAX_BITLEN) {
- zlog_warn(
- "%s: Prefix Length %d is greater than what a v4 address can use",
- __PRETTY_FUNCTION__, p.prefixlen);
- XFREE(MTYPE_RE, re);
- return;
- }
- STREAM_GET(&p.u.prefix4, s, PSIZE(p.prefixlen));
-
- /* VRF ID */
- re->vrf_id = zvrf_id(zvrf);
-
- /*
- * We need to give nh-addr, nh-ifindex with the same next-hop object
- * to the re to ensure that IPv6 multipathing works; need to coalesce
- * these. Clients should send the same number of paired set of
- * next-hop-addr/next-hop-ifindices.
- */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) {
- unsigned int nh_count = 0;
- unsigned int if_count = 0;
- unsigned int max_nh_if = 0;
-
- STREAM_GETC(s, nexthop_num);
- zserv_nexthop_num_warn(__func__, (const struct prefix *)&p,
- nexthop_num);
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
- label_type = lsp_type_from_re_type(client->proto);
-
- for (i = 0; i < nexthop_num; i++) {
- STREAM_GETC(s, nexthop_type);
-
- switch (nexthop_type) {
- case NEXTHOP_TYPE_IPV6:
- STREAM_GET(&nhop_addr, s, 16);
- if (nh_count < MULTIPATH_NUM) {
- /*
- * For labeled-unicast, each nexthop is
- * followed by the label.
- */
- if (CHECK_FLAG(message,
- ZAPI_MESSAGE_LABEL)) {
- STREAM_GETL(s, label);
- labels[nh_count] = label;
- }
- nexthops[nh_count] = nhop_addr;
- nh_count++;
- }
- break;
- case NEXTHOP_TYPE_IFINDEX:
- if (if_count < multipath_num)
- STREAM_GETL(s, ifindices[if_count++]);
- break;
- case NEXTHOP_TYPE_BLACKHOLE:
- route_entry_nexthop_blackhole_add(re, bh_type);
- break;
- default:
- zlog_warn(
- "%s: Please use ZEBRA_ROUTE_ADD if you want to pass non v6 nexthops",
- __PRETTY_FUNCTION__);
- nexthops_free(re->ng.nexthop);
- XFREE(MTYPE_RE, re);
- return;
- }
- }
-
- max_nh_if = (nh_count > if_count) ? nh_count : if_count;
- for (i = 0; i < max_nh_if; i++) {
- if ((i < nh_count)
- && !IN6_IS_ADDR_UNSPECIFIED(&nexthops[i])) {
- if ((i < if_count) && ifindices[i])
- nexthop =
- route_entry_nexthop_ipv6_ifindex_add(
- re, &nexthops[i],
- ifindices[i],
- re->vrf_id);
- else
- nexthop = route_entry_nexthop_ipv6_add(
- re, &nexthops[i], re->vrf_id);
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
- nexthop_add_labels(nexthop, label_type,
- 1, &labels[i]);
- } else {
- if ((i < if_count) && ifindices[i])
- route_entry_nexthop_ifindex_add(
- re, ifindices[i], re->vrf_id);
- }
- }
- }
-
- /* Distance. */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
- STREAM_GETC(s, re->distance);
-
- /* Metric. */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC))
- STREAM_GETL(s, re->metric);
-
- /* Tag */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_TAG))
- STREAM_GETL(s, re->tag);
- else
- re->tag = 0;
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_MTU))
- STREAM_GETL(s, re->mtu);
- else
- re->mtu = 0;
-
- /* Table */
- re->table = zvrf->table_id;
-
- ret = rib_add_multipath(AFI_IP6, safi, &p, NULL, re);
- /* Stats */
- if (ret > 0)
- client->v4_route_add_cnt++;
- else if (ret < 0)
- client->v4_route_upd8_cnt++;
-
- return;
-
-stream_failure:
- nexthops_free(re->ng.nexthop);
- XFREE(MTYPE_RE, re);
-}
-
-static void zread_ipv6_add(ZAPI_HANDLER_ARGS)
-{
- unsigned int i;
- struct stream *s;
- struct in6_addr nhop_addr;
- ifindex_t ifindex;
- struct route_entry *re;
- uint8_t message;
- uint8_t nexthop_num;
- uint8_t nexthop_type;
- struct prefix p;
- struct prefix_ipv6 src_p, *src_pp;
- safi_t safi;
- static struct in6_addr nexthops[MULTIPATH_NUM];
- static unsigned int ifindices[MULTIPATH_NUM];
- int ret;
- static mpls_label_t labels[MULTIPATH_NUM];
- enum lsp_types_t label_type = ZEBRA_LSP_NONE;
- mpls_label_t label;
- struct nexthop *nexthop;
- enum blackhole_type bh_type = BLACKHOLE_NULL;
-
- /* Get input stream. */
- s = msg;
-
- memset(&nhop_addr, 0, sizeof(struct in6_addr));
-
- /* Allocate new re. */
- re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
-
- /* Type, flags, message. */
- STREAM_GETC(s, re->type);
- if (re->type > ZEBRA_ROUTE_MAX) {
- zlog_warn("%s: Specified route type: %d is not a legal value\n",
- __PRETTY_FUNCTION__, re->type);
- XFREE(MTYPE_RE, re);
- return;
- }
- STREAM_GETW(s, re->instance);
- STREAM_GETL(s, re->flags);
- STREAM_GETC(s, message);
- STREAM_GETW(s, safi);
- re->uptime = time(NULL);
-
- /* IPv6 prefix. */
- memset(&p, 0, sizeof(p));
- p.family = AF_INET6;
- STREAM_GETC(s, p.prefixlen);
- if (p.prefixlen > IPV6_MAX_BITLEN) {
- zlog_warn(
- "%s: Specified prefix length %d is to large for v6 prefix",
- __PRETTY_FUNCTION__, p.prefixlen);
- XFREE(MTYPE_RE, re);
- return;
- }
- STREAM_GET(&p.u.prefix6, s, PSIZE(p.prefixlen));
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_SRCPFX)) {
- memset(&src_p, 0, sizeof(src_p));
- src_p.family = AF_INET6;
- STREAM_GETC(s, src_p.prefixlen);
- if (src_p.prefixlen > IPV6_MAX_BITLEN) {
- zlog_warn(
- "%s: Specified src prefix length %d is to large for v6 prefix",
- __PRETTY_FUNCTION__, src_p.prefixlen);
- XFREE(MTYPE_RE, re);
- return;
- }
- STREAM_GET(&src_p.prefix, s, PSIZE(src_p.prefixlen));
- src_pp = &src_p;
- } else
- src_pp = NULL;
-
- /* VRF ID */
- re->vrf_id = zvrf_id(zvrf);
-
- /*
- * We need to give nh-addr, nh-ifindex with the same next-hop object
- * to the re to ensure that IPv6 multipathing works; need to coalesce
- * these. Clients should send the same number of paired set of
- * next-hop-addr/next-hop-ifindices.
- */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) {
- unsigned int nh_count = 0;
- unsigned int if_count = 0;
- unsigned int max_nh_if = 0;
-
- STREAM_GETC(s, nexthop_num);
- zserv_nexthop_num_warn(__func__, (const struct prefix *)&p,
- nexthop_num);
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
- label_type = lsp_type_from_re_type(client->proto);
-
- for (i = 0; i < nexthop_num; i++) {
- STREAM_GETC(s, nexthop_type);
-
- switch (nexthop_type) {
- case NEXTHOP_TYPE_IPV6:
- STREAM_GET(&nhop_addr, s, 16);
- if (nh_count < MULTIPATH_NUM) {
- /*
- * For labeled-unicast, each nexthop is
- * followed by label.
- */
- if (CHECK_FLAG(message,
- ZAPI_MESSAGE_LABEL)) {
- STREAM_GETL(s, label);
- labels[nh_count] = label;
- }
- nexthops[nh_count++] = nhop_addr;
- }
- break;
- case NEXTHOP_TYPE_IPV6_IFINDEX:
- STREAM_GET(&nhop_addr, s, 16);
- STREAM_GETL(s, ifindex);
- route_entry_nexthop_ipv6_ifindex_add(
- re, &nhop_addr, ifindex, re->vrf_id);
- break;
- case NEXTHOP_TYPE_IFINDEX:
- if (if_count < multipath_num)
- STREAM_GETL(s, ifindices[if_count++]);
- break;
- case NEXTHOP_TYPE_BLACKHOLE:
- route_entry_nexthop_blackhole_add(re, bh_type);
- break;
- default:
- zlog_warn(
- "%s: Please use ZEBRA_ROUTE_ADD if you want to pass non v6 nexthops",
- __PRETTY_FUNCTION__);
- nexthops_free(re->ng.nexthop);
- XFREE(MTYPE_RE, re);
- return;
- }
- }
-
- max_nh_if = (nh_count > if_count) ? nh_count : if_count;
- for (i = 0; i < max_nh_if; i++) {
- if ((i < nh_count)
- && !IN6_IS_ADDR_UNSPECIFIED(&nexthops[i])) {
- if ((i < if_count) && ifindices[i])
- nexthop =
- route_entry_nexthop_ipv6_ifindex_add(
- re, &nexthops[i],
- ifindices[i],
- re->vrf_id);
- else
- nexthop = route_entry_nexthop_ipv6_add(
- re, &nexthops[i], re->vrf_id);
- if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
- nexthop_add_labels(nexthop, label_type,
- 1, &labels[i]);
- } else {
- if ((i < if_count) && ifindices[i])
- route_entry_nexthop_ifindex_add(
- re, ifindices[i], re->vrf_id);
- }
- }
- }
-
- /* Distance. */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
- STREAM_GETC(s, re->distance);
-
- /* Metric. */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC))
- STREAM_GETL(s, re->metric);
-
- /* Tag */
- if (CHECK_FLAG(message, ZAPI_MESSAGE_TAG))
- STREAM_GETL(s, re->tag);
- else
- re->tag = 0;
-
- if (CHECK_FLAG(message, ZAPI_MESSAGE_MTU))
- STREAM_GETL(s, re->mtu);
- else
- re->mtu = 0;
-
- re->table = zvrf->table_id;
-
- ret = rib_add_multipath(AFI_IP6, safi, &p, src_pp, re);
- /* Stats */
- if (ret > 0)
- client->v6_route_add_cnt++;
- else if (ret < 0)
- client->v6_route_upd8_cnt++;
-
- return;
-
-stream_failure:
- nexthops_free(re->ng.nexthop);
- XFREE(MTYPE_RE, re);
-}
-
-/* Zebra server IPv6 prefix delete function. */
-static void zread_ipv6_delete(ZAPI_HANDLER_ARGS)
-{
- struct stream *s;
- struct zapi_ipv6 api;
- struct prefix p;
- struct prefix_ipv6 src_p, *src_pp;
-
- s = msg;
-
- /* Type, flags, message. */
- STREAM_GETC(s, api.type);
- STREAM_GETW(s, api.instance);
- STREAM_GETL(s, api.flags);
- STREAM_GETC(s, api.message);
- STREAM_GETW(s, api.safi);
-
- /* IPv4 prefix. */
- memset(&p, 0, sizeof(struct prefix));
- p.family = AF_INET6;
- STREAM_GETC(s, p.prefixlen);
- STREAM_GET(&p.u.prefix6, s, PSIZE(p.prefixlen));
-
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) {
- memset(&src_p, 0, sizeof(struct prefix_ipv6));
- src_p.family = AF_INET6;
- STREAM_GETC(s, src_p.prefixlen);
- STREAM_GET(&src_p.prefix, s, PSIZE(src_p.prefixlen));
- src_pp = &src_p;
- } else
- src_pp = NULL;
-
- rib_delete(AFI_IP6, api.safi, zvrf_id(zvrf), api.type, api.instance,
- api.flags, &p, src_pp, NULL, client->rtm_table, 0, 0, false);
-
- client->v6_route_del_cnt++;
-
-stream_failure:
- return;
-}
-
/* Register zebra server router-id information. Send current router-id */
static void zread_router_id_add(ZAPI_HANDLER_ARGS)
{
@@ -3011,11 +2404,6 @@ void (*zserv_handlers[])(ZAPI_HANDLER_ARGS) = {
[ZEBRA_INTERFACE_DELETE] = zread_interface_delete,
[ZEBRA_ROUTE_ADD] = zread_route_add,
[ZEBRA_ROUTE_DELETE] = zread_route_del,
- [ZEBRA_IPV4_ROUTE_ADD] = zread_ipv4_add,
- [ZEBRA_IPV4_ROUTE_DELETE] = zread_ipv4_delete,
- [ZEBRA_IPV4_ROUTE_IPV6_NEXTHOP_ADD] = zread_ipv4_route_ipv6_nexthop_add,
- [ZEBRA_IPV6_ROUTE_ADD] = zread_ipv6_add,
- [ZEBRA_IPV6_ROUTE_DELETE] = zread_ipv6_delete,
[ZEBRA_REDISTRIBUTE_ADD] = zebra_redistribute_add,
[ZEBRA_REDISTRIBUTE_DELETE] = zebra_redistribute_delete,
[ZEBRA_REDISTRIBUTE_DEFAULT_ADD] = zebra_redistribute_default_add,