On 10/14/2017 08:01 PM, Eric Blake wrote: > From: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > > Minimal implementation of structured read: one structured reply chunk, > no segmentation. > Minimal structured error implementation: no text message. > Support DF flag, but just ignore it, as there is no segmentation any > way. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > Signed-off-by: Eric Blake <ebl...@redhat.com> >
> + > + case NBD_OPT_STRUCTURED_REPLY: > + if (client->structured_reply) { > + ret = nbd_negotiate_send_rep_err( > + client->ioc, NBD_REP_ERR_INVALID, option, errp, > + "structured reply already negotiated"); > + } else { > + ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, > + option, errp); > + } Fails spectacularly if the client sent a non-zero length payload along with the option, because we forgot to nbd_drop the payload, getting the server out-of-sync with the client's next option request. I'm requesting clarification from the NBD list on how to best handle that (presumably with NBD_REP_ERR_INVALID), and in the meantime will copy what we do for NBD_OPT_LIST with unexpected payload. It also made me realize that we don't reject unexpected payload for NBD_OPT_STARTTLS; a common helper function would make that easier, so guess what I'm adding in v5 :) -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature