From: kettenis Date: Fri, 13 Jul 2018 07:29:08 +0000 (+0000) Subject: Check protocol version number before sending an ack indicating that we X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=25f16b1bd882bcff0ba2bb9feddea00bcdfacb2a;p=openbsd Check protocol version number before sending an ack indicating that we support a domain services protocol. --- diff --git a/usr.sbin/ldomd/ds.c b/usr.sbin/ldomd/ds.c index 6e19a8051bc..38330af281e 100644 --- a/usr.sbin/ldomd/ds.c +++ b/usr.sbin/ldomd/ds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ds.c,v 1.6 2018/07/09 14:46:08 kettenis Exp $ */ +/* $OpenBSD: ds.c,v 1.7 2018/07/13 07:29:08 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -448,10 +448,12 @@ ds_rx_msg(struct ldc_conn *lc, void *data, size_t len) DPRINTF(("DS_REG_REQ %s %d.%d 0x%016llx\n", dr->svc_id, dr->major_vers, dr->minor_vers, dr->svc_handle)); TAILQ_FOREACH(dcs, &dc->services, link) { - if (strcmp(dr->svc_id, dcs->service->ds_svc_id) == 0) { + if (strcmp(dr->svc_id, dcs->service->ds_svc_id) == 0 && + dr->major_vers == dcs->service->ds_major_vers) { dcs->svc_handle = dr->svc_handle; dcs->ackid = lc->lc_tx_seqid; - ds_reg_ack(lc, dcs->svc_handle); + ds_reg_ack(lc, dcs->svc_handle, + dcs->service->ds_minor_vers); dcs->service->ds_start(lc, dcs->svc_handle); return; } @@ -505,7 +507,7 @@ ds_init_ack(struct ldc_conn *lc) } void -ds_reg_ack(struct ldc_conn *lc, uint64_t svc_handle) +ds_reg_ack(struct ldc_conn *lc, uint64_t svc_handle, uint16_t minor) { struct ds_reg_ack da; @@ -514,7 +516,7 @@ ds_reg_ack(struct ldc_conn *lc, uint64_t svc_handle) da.msg_type = DS_REG_ACK; da.payload_len = sizeof(da) - 8; da.svc_handle = svc_handle; - da.minor_vers = 0; + da.minor_vers = minor; ds_send_msg(lc, &da, sizeof(da)); } diff --git a/usr.sbin/ldomd/ds.h b/usr.sbin/ldomd/ds.h index a55c6d73922..ab3249a414b 100644 --- a/usr.sbin/ldomd/ds.h +++ b/usr.sbin/ldomd/ds.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ds.h,v 1.2 2012/11/04 18:57:10 kettenis Exp $ */ +/* $OpenBSD: ds.h,v 1.3 2018/07/13 07:29:08 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -199,7 +199,7 @@ void ldc_ack(struct ldc_conn *, uint32_t); void ds_rx_msg(struct ldc_conn *, void *, size_t); void ds_init_ack(struct ldc_conn *); -void ds_reg_ack(struct ldc_conn *, uint64_t); +void ds_reg_ack(struct ldc_conn *, uint64_t, uint16_t); void ds_reg_nack(struct ldc_conn *, uint64_t); void ds_unreg_ack(struct ldc_conn *, uint64_t); void ds_unreg_nack(struct ldc_conn *, uint64_t);