server.c (d85e60e993808d69287dd5e3734642421e23ec45) | server.c (b25e12daff2c3e5ba933f85e8ba278f5bcba8f4d) |
---|---|
1/* 2 * Copyright (C) 2016-2018 Red Hat, Inc. 3 * Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws> 4 * 5 * Network Block Device Server Side 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 97 unchanged lines hidden (view full) --- 106} NBDExportMetaContexts; 107 108struct NBDClient { 109 int refcount; 110 void (*close_fn)(NBDClient *client, bool negotiated); 111 112 NBDExport *exp; 113 QCryptoTLSCreds *tlscreds; | 1/* 2 * Copyright (C) 2016-2018 Red Hat, Inc. 3 * Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws> 4 * 5 * Network Block Device Server Side 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 97 unchanged lines hidden (view full) --- 106} NBDExportMetaContexts; 107 108struct NBDClient { 109 int refcount; 110 void (*close_fn)(NBDClient *client, bool negotiated); 111 112 NBDExport *exp; 113 QCryptoTLSCreds *tlscreds; |
114 char *tlsaclname; | 114 char *tlsauthz; |
115 QIOChannelSocket *sioc; /* The underlying data channel */ 116 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */ 117 118 Coroutine *recv_coroutine; 119 120 CoMutex send_lock; 121 Coroutine *send_coroutine; 122 --- 558 unchanged lines hidden (view full) --- 681 ioc = client->ioc; 682 683 if (nbd_negotiate_send_rep(client, NBD_REP_ACK, errp) < 0) { 684 return NULL; 685 } 686 687 tioc = qio_channel_tls_new_server(ioc, 688 client->tlscreds, | 115 QIOChannelSocket *sioc; /* The underlying data channel */ 116 QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */ 117 118 Coroutine *recv_coroutine; 119 120 CoMutex send_lock; 121 Coroutine *send_coroutine; 122 --- 558 unchanged lines hidden (view full) --- 681 ioc = client->ioc; 682 683 if (nbd_negotiate_send_rep(client, NBD_REP_ACK, errp) < 0) { 684 return NULL; 685 } 686 687 tioc = qio_channel_tls_new_server(ioc, 688 client->tlscreds, |
689 client->tlsaclname, | 689 client->tlsauthz, |
690 errp); 691 if (!tioc) { 692 return NULL; 693 } 694 695 qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-server-tls"); 696 trace_nbd_negotiate_handle_starttls_handshake(); 697 data.loop = g_main_loop_new(g_main_context_default(), FALSE); --- 645 unchanged lines hidden (view full) --- 1343 assert(client->closing); 1344 1345 qio_channel_detach_aio_context(client->ioc); 1346 object_unref(OBJECT(client->sioc)); 1347 object_unref(OBJECT(client->ioc)); 1348 if (client->tlscreds) { 1349 object_unref(OBJECT(client->tlscreds)); 1350 } | 690 errp); 691 if (!tioc) { 692 return NULL; 693 } 694 695 qio_channel_set_name(QIO_CHANNEL(tioc), "nbd-server-tls"); 696 trace_nbd_negotiate_handle_starttls_handshake(); 697 data.loop = g_main_loop_new(g_main_context_default(), FALSE); --- 645 unchanged lines hidden (view full) --- 1343 assert(client->closing); 1344 1345 qio_channel_detach_aio_context(client->ioc); 1346 object_unref(OBJECT(client->sioc)); 1347 object_unref(OBJECT(client->ioc)); 1348 if (client->tlscreds) { 1349 object_unref(OBJECT(client->tlscreds)); 1350 } |
1351 g_free(client->tlsaclname); | 1351 g_free(client->tlsauthz); |
1352 if (client->exp) { 1353 QTAILQ_REMOVE(&client->exp->clients, client, next); 1354 nbd_export_put(client->exp); 1355 } 1356 g_free(client); 1357 } 1358} 1359 --- 1060 unchanged lines hidden (view full) --- 2420 2421/* 2422 * Create a new client listener using the given channel @sioc. 2423 * Begin servicing it in a coroutine. When the connection closes, call 2424 * @close_fn with an indication of whether the client completed negotiation. 2425 */ 2426void nbd_client_new(QIOChannelSocket *sioc, 2427 QCryptoTLSCreds *tlscreds, | 1352 if (client->exp) { 1353 QTAILQ_REMOVE(&client->exp->clients, client, next); 1354 nbd_export_put(client->exp); 1355 } 1356 g_free(client); 1357 } 1358} 1359 --- 1060 unchanged lines hidden (view full) --- 2420 2421/* 2422 * Create a new client listener using the given channel @sioc. 2423 * Begin servicing it in a coroutine. When the connection closes, call 2424 * @close_fn with an indication of whether the client completed negotiation. 2425 */ 2426void nbd_client_new(QIOChannelSocket *sioc, 2427 QCryptoTLSCreds *tlscreds, |
2428 const char *tlsaclname, | 2428 const char *tlsauthz, |
2429 void (*close_fn)(NBDClient *, bool)) 2430{ 2431 NBDClient *client; 2432 Coroutine *co; 2433 2434 client = g_new0(NBDClient, 1); 2435 client->refcount = 1; 2436 client->tlscreds = tlscreds; 2437 if (tlscreds) { 2438 object_ref(OBJECT(client->tlscreds)); 2439 } | 2429 void (*close_fn)(NBDClient *, bool)) 2430{ 2431 NBDClient *client; 2432 Coroutine *co; 2433 2434 client = g_new0(NBDClient, 1); 2435 client->refcount = 1; 2436 client->tlscreds = tlscreds; 2437 if (tlscreds) { 2438 object_ref(OBJECT(client->tlscreds)); 2439 } |
2440 client->tlsaclname = g_strdup(tlsaclname); | 2440 client->tlsauthz = g_strdup(tlsauthz); |
2441 client->sioc = sioc; 2442 object_ref(OBJECT(client->sioc)); 2443 client->ioc = QIO_CHANNEL(sioc); 2444 object_ref(OBJECT(client->ioc)); 2445 client->close_fn = close_fn; 2446 2447 co = qemu_coroutine_create(nbd_co_client_start, client); 2448 qemu_coroutine_enter(co); 2449} | 2441 client->sioc = sioc; 2442 object_ref(OBJECT(client->sioc)); 2443 client->ioc = QIO_CHANNEL(sioc); 2444 object_ref(OBJECT(client->ioc)); 2445 client->close_fn = close_fn; 2446 2447 co = qemu_coroutine_create(nbd_co_client_start, client); 2448 qemu_coroutine_enter(co); 2449} |