summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
authorpaul <paul>2005-05-31 08:38:50 +0000
committerpaul <paul>2005-05-31 08:38:50 +0000
commit1dcb51729b4a8bd7ed21126c7e5e61bc096f8674 (patch)
tree751f35fe2742a037d9f5b4651cd3a8c53a9453d1 /zebra
parent0cb8a01c38284a5a3f4ee4b017b69cd5f3e39f9a (diff)
2005-05-31 Paul Jakma <paul.jakma@sun.com>
* zserv.c: (zsend_route_multipath) Fix bug if route is sent with no NEXTHOP_FLAG_FIB nexthops. As ZAPI_MESSAGE_IFINDEX and ZAPI_MESSAGE_NEXTHOP are always set, clients would try read non-existent nexthop information and hit stream assert. Zserv is still broken for multi-nexthop messages, but it always was.
Diffstat (limited to 'zebra')
-rw-r--r--zebra/ChangeLog8
-rw-r--r--zebra/zserv.c40
2 files changed, 33 insertions, 15 deletions
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index 11676eb7..dbeac4d5 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -1,3 +1,11 @@
+2005-05-31 Paul Jakma <paul.jakma@sun.com>
+
+ * zserv.c: (zsend_route_multipath) Fix bug if route is sent
+ with no NEXTHOP_FLAG_FIB nexthops. As ZAPI_MESSAGE_IFINDEX
+ and ZAPI_MESSAGE_NEXTHOP are always set, clients would try
+ read non-existent nexthop information and hit stream assert.
+ Zserv is still broken for multi-nexthop messages, but it always was.
+
2005-05-06 Paul Jakma <paul.jakma@sun.com>
* zserv.h: Remove ZEBRA_PORT definition, its in lib/zebra.h now
diff --git a/zebra/zserv.c b/zebra/zserv.c
index c02eac89..17e7888d 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -404,9 +404,9 @@ zsend_route_multipath (int cmd, struct zserv *client, struct prefix *p,
int psize;
struct stream *s;
struct nexthop *nexthop;
- unsigned long nhnummark = 0;
+ unsigned long nhnummark = 0, messmark = 0;
int nhnum = 0;
- u_char zapi_flags = ZAPI_MESSAGE_NEXTHOP | ZAPI_MESSAGE_IFINDEX;
+ u_char zapi_flags = 0;
s = client->obuf;
stream_reset (s);
@@ -418,15 +418,10 @@ zsend_route_multipath (int cmd, struct zserv *client, struct prefix *p,
stream_putc (s, cmd);
stream_putc (s, rib->type);
stream_putc (s, rib->flags);
-
- /*
- * XXX no need to set ZAPI_MESSAGE_NEXTHOP if we are going to
- * send empty nexthop?
- */
- if (cmd == ZEBRA_IPV4_ROUTE_ADD || ZEBRA_IPV6_ROUTE_ADD)
- zapi_flags |= ZAPI_MESSAGE_METRIC;
-
- stream_putc (s, zapi_flags);
+
+ /* marker for message flags field */
+ messmark = stream_get_endp (s);
+ stream_putc (s, 0);
/* Prefix. */
psize = PSIZE (p->prefixlen);
@@ -442,12 +437,20 @@ zsend_route_multipath (int cmd, struct zserv *client, struct prefix *p,
* is hard-coded.
*/
/* Nexthop */
+
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
{
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
{
- nhnummark = stream_get_endp (s);
- stream_putc (s, 1); /* placeholder */
+ SET_FLAG (zapi_flags, ZAPI_MESSAGE_NEXTHOP);
+ SET_FLAG (zapi_flags, ZAPI_MESSAGE_IFINDEX);
+
+ if (nhnummark == 0)
+ {
+ nhnummark = stream_get_endp (s);
+ stream_putc (s, 1); /* placeholder */
+ }
+
nhnum++;
switch(nexthop->type)
@@ -488,8 +491,15 @@ zsend_route_multipath (int cmd, struct zserv *client, struct prefix *p,
}
/* Metric */
- stream_putl (s, rib->metric);
-
+ if (cmd == ZEBRA_IPV4_ROUTE_ADD || ZEBRA_IPV6_ROUTE_ADD)
+ {
+ SET_FLAG (zapi_flags, ZAPI_MESSAGE_METRIC);
+ stream_putl (s, rib->metric);
+ }
+
+ /* write real message flags value */
+ stream_putc_at (s, messmark, zapi_flags);
+
/* Write next-hop number */
if (nhnummark)
stream_putc_at (s, nhnummark, nhnum);