Check protocol version number before sending an ack indicating that we
authorkettenis <kettenis@openbsd.org>
Fri, 13 Jul 2018 07:29:08 +0000 (07:29 +0000)
committerkettenis <kettenis@openbsd.org>
Fri, 13 Jul 2018 07:29:08 +0000 (07:29 +0000)
support a domain services protocol.

usr.sbin/ldomd/ds.c
usr.sbin/ldomd/ds.h

index 6e19a80..38330af 100644 (file)
@@ -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));
 }
 
index a55c6d7..ab3249a 100644 (file)
@@ -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);