nbd: Quit server after any write error
We should never ignore failure from nbd_negotiate_send_rep(); if we are unable to write to the client, then it is not worth trying to continue the negotiation. Fortunately, the problem is not too severe - chances are that the errors being ignored here (mainly inability to write the reply to the client) are indications of a closed connection or something similar, which will also affect the next attempt to interact with the client and eventually reach a point where the errors are detected to end the loop. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1463006384-7734-4-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
		
							parent
							
								
									2cb347493c
								
							
						
					
					
						commit
						63d5ef869e
					
				
							
								
								
									
										24
									
								
								nbd/server.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								nbd/server.c
									
									
									
									
									
								
							@ -334,7 +334,10 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,
 | 
				
			|||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, NBD_OPT_STARTTLS);
 | 
					    if (nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK,
 | 
				
			||||||
 | 
					                               NBD_OPT_STARTTLS) < 0) {
 | 
				
			||||||
 | 
					        return NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tioc = qio_channel_tls_new_server(ioc,
 | 
					    tioc = qio_channel_tls_new_server(ioc,
 | 
				
			||||||
                                      client->tlscreds,
 | 
					                                      client->tlscreds,
 | 
				
			||||||
@ -460,8 +463,11 @@ static int nbd_negotiate_options(NBDClient *client)
 | 
				
			|||||||
                if (nbd_negotiate_drop_sync(client->ioc, length) != length) {
 | 
					                if (nbd_negotiate_drop_sync(client->ioc, length) != length) {
 | 
				
			||||||
                    return -EIO;
 | 
					                    return -EIO;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_TLS_REQD,
 | 
					                ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_TLS_REQD,
 | 
				
			||||||
                                             clientflags);
 | 
					                                             clientflags);
 | 
				
			||||||
 | 
					                if (ret < 0) {
 | 
				
			||||||
 | 
					                    return ret;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (fixedNewstyle) {
 | 
					        } else if (fixedNewstyle) {
 | 
				
			||||||
@ -485,21 +491,29 @@ static int nbd_negotiate_options(NBDClient *client)
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                if (client->tlscreds) {
 | 
					                if (client->tlscreds) {
 | 
				
			||||||
                    TRACE("TLS already enabled");
 | 
					                    TRACE("TLS already enabled");
 | 
				
			||||||
                    nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_INVALID,
 | 
					                    ret = nbd_negotiate_send_rep(client->ioc,
 | 
				
			||||||
 | 
					                                                 NBD_REP_ERR_INVALID,
 | 
				
			||||||
                                                 clientflags);
 | 
					                                                 clientflags);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    TRACE("TLS not configured");
 | 
					                    TRACE("TLS not configured");
 | 
				
			||||||
                    nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_POLICY,
 | 
					                    ret = nbd_negotiate_send_rep(client->ioc,
 | 
				
			||||||
 | 
					                                                 NBD_REP_ERR_POLICY,
 | 
				
			||||||
                                                 clientflags);
 | 
					                                                 clientflags);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                if (ret < 0) {
 | 
				
			||||||
 | 
					                    return ret;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                TRACE("Unsupported option 0x%" PRIx32, clientflags);
 | 
					                TRACE("Unsupported option 0x%" PRIx32, clientflags);
 | 
				
			||||||
                if (nbd_negotiate_drop_sync(client->ioc, length) != length) {
 | 
					                if (nbd_negotiate_drop_sync(client->ioc, length) != length) {
 | 
				
			||||||
                    return -EIO;
 | 
					                    return -EIO;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_UNSUP,
 | 
					                ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_UNSUP,
 | 
				
			||||||
                                             clientflags);
 | 
					                                             clientflags);
 | 
				
			||||||
 | 
					                if (ret < 0) {
 | 
				
			||||||
 | 
					                    return ret;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user