diff options
author | Donald Sharp <sharpd@cumulusnetwroks.com> | 2016-09-02 16:32:14 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetwroks.com> | 2016-09-02 16:36:28 +0200 |
commit | 5b30316ea51a86de29450b59ea288afa858953b6 (patch) | |
tree | 005f4ccdedb006ad4f3782d5748447ef098e93de | |
parent | lib: Remove unused ZEBRA_NEXTHOP_IPV4_ONLINK type (diff) | |
download | frr-5b30316ea51a86de29450b59ea288afa858953b6.tar.xz frr-5b30316ea51a86de29450b59ea288afa858953b6.zip |
bgpd, lib, ospfd, pimd, zebra: Use nexthop_types_t
Use the 'enum nexthop_types_t' instead of
the zebra.h #defines. And remove code from
zebra.h that does not belong there.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
-rw-r--r-- | bgpd/bgp_nht.c | 12 | ||||
-rw-r--r-- | isisd/isis_zebra.c | 4 | ||||
-rw-r--r-- | lib/zclient.c | 19 | ||||
-rw-r--r-- | lib/zebra.h | 8 | ||||
-rw-r--r-- | ospfd/ospf_zebra.c | 19 | ||||
-rw-r--r-- | pimd/pim_zlookup.c | 8 | ||||
-rw-r--r-- | zebra/zebra_rnh.c | 10 | ||||
-rw-r--r-- | zebra/zserv.c | 56 |
8 files changed, 64 insertions, 72 deletions
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 42885165c..11b59fb3e 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -397,25 +397,23 @@ bgp_parse_nexthop_update (int command, vrf_id_t vrf_id) nexthop->type = stream_getc (s); switch (nexthop->type) { - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: nexthop->gate.ipv4.s_addr = stream_get_ipv4 (s); break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: nexthop->ifindex = stream_getl (s); break; - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: nexthop->gate.ipv4.s_addr = stream_get_ipv4 (s); nexthop->ifindex = stream_getl (s); break; -#ifdef HAVE_IPV6 - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_get (&nexthop->gate.ipv6, s, 16); break; - case ZEBRA_NEXTHOP_IPV6_IFINDEX: + case NEXTHOP_TYPE_IPV6_IFINDEX: stream_get (&nexthop->gate.ipv6, s, 16); nexthop->ifindex = stream_getl (s); break; -#endif default: /* do nothing */ break; diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 81f9d8693..0e5a7ff3b 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -278,12 +278,12 @@ isis_zebra_route_add_ipv4 (struct prefix *prefix, /* FIXME: can it be ? */ if (nexthop->ip.s_addr != INADDR_ANY) { - stream_putc (stream, ZEBRA_NEXTHOP_IPV4); + stream_putc (stream, NEXTHOP_TYPE_IPV4); stream_put_in_addr (stream, &nexthop->ip); } else { - stream_putc (stream, ZEBRA_NEXTHOP_IFINDEX); + stream_putc (stream, NEXTHOP_TYPE_IFINDEX); stream_putl (stream, nexthop->ifindex); } } diff --git a/lib/zclient.c b/lib/zclient.c index 0259af597..dd13587d7 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -32,6 +32,7 @@ #include "zclient.h" #include "memory.h" #include "table.h" +#include "nexthop.h" /* Zebra client events. */ enum event {ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT}; @@ -746,7 +747,7 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE)) { stream_putc (s, 1); - stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE); + stream_putc (s, NEXTHOP_TYPE_BLACKHOLE); /* XXX assert(api->nexthop_num == 0); */ /* XXX assert(api->ifindex_num == 0); */ } @@ -755,12 +756,12 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, for (i = 0; i < api->nexthop_num; i++) { - stream_putc (s, ZEBRA_NEXTHOP_IPV4); + stream_putc (s, NEXTHOP_TYPE_IPV4); stream_put_in_addr (s, api->nexthop[i]); } for (i = 0; i < api->ifindex_num; i++) { - stream_putc (s, ZEBRA_NEXTHOP_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IFINDEX); stream_putl (s, api->ifindex[i]); } } @@ -813,7 +814,7 @@ zapi_ipv4_route_ipv6_nexthop (u_char cmd, struct zclient *zclient, if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE)) { stream_putc (s, 1); - stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE); + stream_putc (s, NEXTHOP_TYPE_BLACKHOLE); /* XXX assert(api->nexthop_num == 0); */ /* XXX assert(api->ifindex_num == 0); */ } @@ -822,12 +823,12 @@ zapi_ipv4_route_ipv6_nexthop (u_char cmd, struct zclient *zclient, for (i = 0; i < api->nexthop_num; i++) { - stream_putc (s, ZEBRA_NEXTHOP_IPV6); + stream_putc (s, NEXTHOP_TYPE_IPV6); stream_write (s, (u_char *)api->nexthop[i], 16); } for (i = 0; i < api->ifindex_num; i++) { - stream_putc (s, ZEBRA_NEXTHOP_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IFINDEX); stream_putl (s, api->ifindex[i]); } } @@ -879,7 +880,7 @@ zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p, if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE)) { stream_putc (s, 1); - stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE); + stream_putc (s, NEXTHOP_TYPE_BLACKHOLE); /* XXX assert(api->nexthop_num == 0); */ /* XXX assert(api->ifindex_num == 0); */ } @@ -888,12 +889,12 @@ zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p, for (i = 0; i < api->nexthop_num; i++) { - stream_putc (s, ZEBRA_NEXTHOP_IPV6); + stream_putc (s, NEXTHOP_TYPE_IPV6); stream_write (s, (u_char *)api->nexthop[i], 16); } for (i = 0; i < api->ifindex_num; i++) { - stream_putc (s, ZEBRA_NEXTHOP_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IFINDEX); stream_putl (s, api->ifindex[i]); } } diff --git a/lib/zebra.h b/lib/zebra.h index 4b4845483..546f0dd3d 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -493,14 +493,6 @@ extern const char *zserv_command_string (unsigned int command); #define ZEBRA_FLAG_REJECT 0x80 #define ZEBRA_FLAG_SCOPE_LINK 0x100 -/* Zebra nexthop flags. */ -#define ZEBRA_NEXTHOP_IFINDEX 1 -#define ZEBRA_NEXTHOP_IPV4 2 -#define ZEBRA_NEXTHOP_IPV4_IFINDEX 3 -#define ZEBRA_NEXTHOP_IPV6 4 -#define ZEBRA_NEXTHOP_IPV6_IFINDEX 5 -#define ZEBRA_NEXTHOP_BLACKHOLE 6 - #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */ #endif diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index f945a4acb..a31ef5f70 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -35,6 +35,7 @@ #include "plist.h" #include "log.h" #include "lib/bfd.h" +#include "nexthop.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -393,18 +394,18 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or) (path->nexthop.s_addr != INADDR_ANY && path->ifindex != 0)) { - stream_putc (s, ZEBRA_NEXTHOP_IPV4_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IPV4_IFINDEX); stream_put_in_addr (s, &path->nexthop); stream_putl (s, path->ifindex); } else if (path->nexthop.s_addr != INADDR_ANY) { - stream_putc (s, ZEBRA_NEXTHOP_IPV4); + stream_putc (s, NEXTHOP_TYPE_IPV4); stream_put_in_addr (s, &path->nexthop); } else { - stream_putc (s, ZEBRA_NEXTHOP_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IFINDEX); if (path->ifindex) stream_putl (s, path->ifindex); else @@ -414,18 +415,18 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or) if (path->nexthop.s_addr != INADDR_ANY && path->ifindex != 0) { - stream_putc (s, ZEBRA_NEXTHOP_IPV4_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IPV4_IFINDEX); stream_put_in_addr (s, &path->nexthop); stream_putl (s, path->ifindex); } else if (path->nexthop.s_addr != INADDR_ANY) { - stream_putc (s, ZEBRA_NEXTHOP_IPV4); + stream_putc (s, NEXTHOP_TYPE_IPV4); stream_put_in_addr (s, &path->nexthop); } else { - stream_putc (s, ZEBRA_NEXTHOP_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IFINDEX); if (path->ifindex) stream_putl (s, path->ifindex); else @@ -514,18 +515,18 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or) if (path->nexthop.s_addr != INADDR_ANY && path->ifindex != 0) { - stream_putc (s, ZEBRA_NEXTHOP_IPV4_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IPV4_IFINDEX); stream_put_in_addr (s, &path->nexthop); stream_putl (s, path->ifindex); } else if (path->nexthop.s_addr != INADDR_ANY) { - stream_putc (s, ZEBRA_NEXTHOP_IPV4); + stream_putc (s, NEXTHOP_TYPE_IPV4); stream_put_in_addr (s, &path->nexthop); } else { - stream_putc (s, ZEBRA_NEXTHOP_IFINDEX); + stream_putc (s, NEXTHOP_TYPE_IFINDEX); stream_putl (s, path->ifindex); } diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 1f8cdfa07..86d7edbd0 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -229,8 +229,8 @@ static int zclient_read_nexthop(struct zclient *zlookup, --length; switch (nexthop_type) { - case ZEBRA_NEXTHOP_IFINDEX: - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: if (num_ifindex >= tab_size) { char addr_str[100]; pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); @@ -239,7 +239,7 @@ static int zclient_read_nexthop(struct zclient *zlookup, (num_ifindex + 1), tab_size, addr_str); return num_ifindex; } - if (nexthop_type == ZEBRA_NEXTHOP_IPV4_IFINDEX) { + if (nexthop_type == NEXTHOP_TYPE_IPV4_IFINDEX) { if (length < 4) { zlog_err("%s: socket %d short input expecting nexthop IPv4-addr: len=%d", __func__, zlookup->sock, length); @@ -256,7 +256,7 @@ static int zclient_read_nexthop(struct zclient *zlookup, nexthop_tab[num_ifindex].route_metric = metric; ++num_ifindex; break; - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: if (num_ifindex >= tab_size) { char addr_str[100]; pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 7b4840164..ef2357b99 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -886,21 +886,21 @@ send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vr stream_putc (s, nexthop->type); switch (nexthop->type) { - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: stream_put_in_addr (s, &nexthop->gate.ipv4); break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: stream_putl (s, nexthop->ifindex); break; - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: stream_put_in_addr (s, &nexthop->gate.ipv4); stream_putl (s, nexthop->ifindex); break; #ifdef HAVE_IPV6 - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_put (s, &nexthop->gate.ipv6, 16); break; - case ZEBRA_NEXTHOP_IPV6_IFINDEX: + case NEXTHOP_TYPE_IPV6_IFINDEX: stream_put (s, &nexthop->gate.ipv6, 16); stream_putl (s, nexthop->ifindex); break; diff --git a/zebra/zserv.c b/zebra/zserv.c index c09cb1750..480c73471 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -758,21 +758,21 @@ zsend_nexthop_lookup (struct zserv *client, afi_t afi, safi_t safi, stream_putc (s, nexthop->type); switch (nexthop->type) { - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: stream_put_in_addr (s, &nexthop->gate.ipv4); break; - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: stream_put_in_addr (s, &nexthop->gate.ipv4); stream_putl (s, nexthop->ifindex); break; - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_put (s, &nexthop->gate.ipv6, 16); break; - case ZEBRA_NEXTHOP_IPV6_IFINDEX: + case NEXTHOP_TYPE_IPV6_IFINDEX: stream_put (s, &nexthop->gate.ipv6, 16); stream_putl (s, nexthop->ifindex); break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: stream_putl (s, nexthop->ifindex); break; default: @@ -946,14 +946,14 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struc stream_putc (s, nexthop->type); switch (nexthop->type) { - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: stream_put_in_addr (s, &nexthop->gate.ipv4); break; - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: stream_put_in_addr (s, &nexthop->gate.ipv4); stream_putl (s, nexthop->ifindex); break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: stream_putl (s, nexthop->ifindex); break; default: @@ -1011,14 +1011,14 @@ zsend_ipv4_import_lookup (struct zserv *client, struct prefix_ipv4 *p, stream_putc (s, nexthop->type); switch (nexthop->type) { - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: stream_put_in_addr (s, &nexthop->gate.ipv4); break; - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: stream_put_in_addr (s, &nexthop->gate.ipv4); stream_putl (s, nexthop->ifindex); break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: stream_putl (s, nexthop->ifindex); break; default: @@ -1177,23 +1177,23 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) switch (nexthop_type) { - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: ifindex = stream_getl (s); rib_nexthop_ifindex_add (rib, ifindex); break; - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: nexthop.s_addr = stream_get_ipv4 (s); rib_nexthop_ipv4_add (rib, &nexthop, NULL); break; - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: nexthop.s_addr = stream_get_ipv4 (s); ifindex = stream_getl (s); rib_nexthop_ipv4_ifindex_add (rib, &nexthop, NULL, ifindex); break; - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_forward_getp (s, IPV6_MAX_BYTELEN); break; - case ZEBRA_NEXTHOP_BLACKHOLE: + case NEXTHOP_TYPE_BLACKHOLE: rib_nexthop_blackhole_add (rib); break; } @@ -1276,19 +1276,19 @@ zread_ipv4_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf) switch (nexthop_type) { - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: ifindex = stream_getl (s); break; - case ZEBRA_NEXTHOP_IPV4: + case NEXTHOP_TYPE_IPV4: nexthop.s_addr = stream_get_ipv4 (s); nexthop_p = (union g_addr *)&nexthop; break; - case ZEBRA_NEXTHOP_IPV4_IFINDEX: + case NEXTHOP_TYPE_IPV4_IFINDEX: nexthop.s_addr = stream_get_ipv4 (s); nexthop_p = (union g_addr *)&nexthop; ifindex = stream_getl (s); break; - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_forward_getp (s, IPV6_MAX_BYTELEN); break; } @@ -1423,18 +1423,18 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct switch (nexthop_type) { - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_get (&nexthop, s, 16); if (nh_count < MULTIPATH_NUM) { nexthops[nh_count++] = nexthop; } break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: if (if_count < MULTIPATH_NUM) { ifindices[if_count++] = stream_getl (s); } break; - case ZEBRA_NEXTHOP_BLACKHOLE: + case NEXTHOP_TYPE_BLACKHOLE: rib_nexthop_blackhole_add (rib); break; } @@ -1547,18 +1547,18 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) switch (nexthop_type) { - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_get (&nexthop, s, 16); if (nh_count < MULTIPATH_NUM) { nexthops[nh_count++] = nexthop; } break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: if (if_count < MULTIPATH_NUM) { ifindices[if_count++] = stream_getl (s); } break; - case ZEBRA_NEXTHOP_BLACKHOLE: + case NEXTHOP_TYPE_BLACKHOLE: rib_nexthop_blackhole_add (rib); break; } @@ -1654,11 +1654,11 @@ zread_ipv6_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf) switch (nexthop_type) { - case ZEBRA_NEXTHOP_IPV6: + case NEXTHOP_TYPE_IPV6: stream_get (&nexthop, s, 16); pnexthop = (union g_addr *)&nexthop; break; - case ZEBRA_NEXTHOP_IFINDEX: + case NEXTHOP_TYPE_IFINDEX: ifindex = stream_getl (s); break; } |