aboutsummaryrefslogtreecommitdiff
path: root/chardev/char-udp.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-04-26 09:36:41 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-05-09 09:14:40 +0200
commitbd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 (patch)
tree82ef0cd9da0812afc7021d5690c14f72e8e13177 /chardev/char-udp.c
parent62cf396b5d397948c5ac4d04d09596ca14f6c173 (diff)
sockets: Limit SocketAddressLegacy to external interfaces
SocketAddressLegacy is a simple union, and simple unions are awkward: they have their variant members wrapped in a "data" object on the wire, and require additional indirections in C. SocketAddress is the equivalent flat union. Convert all users of SocketAddressLegacy to SocketAddress, except for existing external interfaces. See also commit fce5d53..9445673 and 85a82e8..c5f1ae3. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1493192202-3184-7-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Minor editing accident fixed, commit message and a comment tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'chardev/char-udp.c')
-rw-r--r--chardev/char-udp.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/chardev/char-udp.c b/chardev/char-udp.c
index d705c4f26b..5f2f717928 100644
--- a/chardev/char-udp.c
+++ b/chardev/char-udp.c
@@ -191,13 +191,17 @@ static void qmp_chardev_open_udp(Chardev *chr,
Error **errp)
{
ChardevUdp *udp = backend->u.udp.data;
+ SocketAddress *local_addr = socket_address_flatten(udp->local);
+ SocketAddress *remote_addr = socket_address_flatten(udp->remote);
QIOChannelSocket *sioc = qio_channel_socket_new();
char *name;
UdpChardev *s = UDP_CHARDEV(chr);
+ int ret;
- if (qio_channel_socket_dgram_sync(sioc,
- udp->local, udp->remote,
- errp) < 0) {
+ ret = qio_channel_socket_dgram_sync(sioc, local_addr, remote_addr, errp);
+ qapi_free_SocketAddress(local_addr);
+ qapi_free_SocketAddress(remote_addr);
+ if (ret < 0) {
object_unref(OBJECT(sioc));
return;
}