summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2010-02-05 02:15:46 +0100
committerDavid Lamparter <equinox@diac24.net>2010-02-05 02:19:19 +0100
commit54a0b0728e3b0f4d4d4d985b6924d5f87fa06001 (patch)
treed42c124617950c251c7c5ffeb9491307fb6f1b55
parent2d3b742ab0c15303e008cd83f15bea869107fab9 (diff)
downloadquagga-54a0b0728e3b0f4d4d4d985b6924d5f87fa06001.tar.bz2
quagga-54a0b0728e3b0f4d4d4d985b6924d5f87fa06001.tar.xz
lib, ospfd: remove ZEBRA_FLAG_BLACKHOLE from the zclient API
FLAG_BLACKHOLE is used for different things in different places. remove it from the zclient API, instead indicate blackhole routes by ZAPI_MESSAGE_BLACKHOLE, which is converted to the proper zapi indication by zapi_ipv4_route()
-rw-r--r--lib/zclient.c33
-rw-r--r--lib/zclient.h9
-rw-r--r--ospfd/ospf_zebra.c8
3 files changed, 29 insertions, 21 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 0d531ce7..8be9d040 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -405,10 +405,10 @@ zclient_connect (struct thread *t)
* | IPv4 Nexthop address or Interface Index number |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
- * Alternatively, if the flags field has ZEBRA_FLAG_BLACKHOLE or
- * ZEBRA_FLAG_REJECT is set then Nexthop count is set to 1, then _no_
+ * Alternatively, if the route is a blackhole route (indicated to zapi
+ * by ZAPI_MESSAGE_BLACKHOLE), then Nexthop count is set to 1 and _no_
* nexthop information is provided, and the message describes a prefix
- * to blackhole or reject route.
+ * to blackhole route.
*
* If ZAPI_MESSAGE_DISTANCE is set, the distance value is written as a 1
* byte value.
@@ -424,8 +424,18 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p,
{
int i;
int psize;
+ int blackhole = 0;
struct stream *s;
+ /* blackhole routes are sent as containing a single nexthop
+ * of type blackhole. */
+ if (CHECK_FLAG (api->message, ZAPI_MESSAGE_BLACKHOLE))
+ {
+ blackhole = 1;
+ UNSET_FLAG (api->message, ZAPI_MESSAGE_BLACKHOLE);
+ SET_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP);
+ }
+
/* Reset stream. */
s = zclient->obuf;
stream_reset (s);
@@ -443,17 +453,14 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p,
stream_write (s, (u_char *) & p->prefix, psize);
/* Nexthop, ifindex, distance and metric information. */
- if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP))
+ if (blackhole)
{
- if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE))
- {
- stream_putc (s, 1);
- stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE);
- /* XXX assert(api->nexthop_num == 0); */
- /* XXX assert(api->ifindex_num == 0); */
- }
- else
- stream_putc (s, api->nexthop_num + api->ifindex_num);
+ stream_putc (s, 1);
+ stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE);
+ }
+ else 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++)
{
diff --git a/lib/zclient.h b/lib/zclient.h
index 6a63ffa4..7cce73f5 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -85,10 +85,11 @@ struct zclient
};
/* Zebra API message flag. */
-#define ZAPI_MESSAGE_NEXTHOP 0x01
-#define ZAPI_MESSAGE_IFINDEX 0x02
-#define ZAPI_MESSAGE_DISTANCE 0x04
-#define ZAPI_MESSAGE_METRIC 0x08
+#define ZAPI_MESSAGE_NEXTHOP 0x01
+#define ZAPI_MESSAGE_IFINDEX 0x02
+#define ZAPI_MESSAGE_DISTANCE 0x04
+#define ZAPI_MESSAGE_METRIC 0x08
+#define ZAPI_MESSAGE_BLACKHOLE 0x10 /* only for zapi_ipv4_route */
/* Zserv protocol message header */
struct zserv_header
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 6f0a71ff..af8c8f0f 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -481,9 +481,9 @@ ospf_zebra_add_discard (struct prefix_ipv4 *p)
if (zclient->redist[ZEBRA_ROUTE_OSPF])
{
api.type = ZEBRA_ROUTE_OSPF;
- api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.flags = 0;
api.message = 0;
- SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
+ SET_FLAG (api.message, ZAPI_MESSAGE_BLACKHOLE);
api.nexthop_num = 0;
api.ifindex_num = 0;
@@ -503,9 +503,9 @@ ospf_zebra_delete_discard (struct prefix_ipv4 *p)
if (zclient->redist[ZEBRA_ROUTE_OSPF])
{
api.type = ZEBRA_ROUTE_OSPF;
- api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.flags = 0;
api.message = 0;
- SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
+ SET_FLAG (api.message, ZAPI_MESSAGE_BLACKHOLE);
api.nexthop_num = 0;
api.ifindex_num = 0;