diff --git a/lib/zclient.c b/lib/zclient.c index 91dbe30a09..a135d18744 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -293,6 +293,10 @@ int zclient_send_message(struct zclient *zclient) return 0; } +/* + * If we add more data to this structure please ensure that + * struct zmsghdr in lib/zclient.h is updated as appropriate. + */ void zclient_create_header(struct stream *s, uint16_t command, vrf_id_t vrf_id) { /* length placeholder, caller can update */ diff --git a/lib/zclient.h b/lib/zclient.h index 5f9edc36ff..2131d4d47a 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -298,7 +298,8 @@ struct zmsghdr { uint8_t version; vrf_id_t vrf_id; uint16_t command; -}; +} __attribute__((packed)); +#define ZAPI_HEADER_CMD_LOCATION offsetof(struct zmsghdr, command) struct zapi_nexthop { enum nexthop_types_t type; diff --git a/zebra/zserv.c b/zebra/zserv.c index c008441d6a..b0991e98f8 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -240,7 +240,7 @@ static int zserv_write(struct thread *thread) if (cache->tail) { msg = cache->tail; stream_set_getp(msg, 0); - wcmd = stream_getw_from(msg, 6); + wcmd = stream_getw_from(msg, ZAPI_HEADER_CMD_LOCATION); } while (stream_fifo_head(cache)) {