summaryrefslogtreecommitdiff
path: root/src/libsystemd-rtnl/sd-rtnl.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-10-29 21:20:25 +0100
committerTom Gundersen <teg@jklm.no>2013-10-29 21:26:22 +0100
commitd4bbdb77aff9abb1aaf13f1f92fb5f9513688ce1 (patch)
treec0a82c9b20e4c88c9df97838da931fa3d93db37f /src/libsystemd-rtnl/sd-rtnl.c
parent897e7561a0f2b0e502fe57081b5d834876c49d7a (diff)
rtnl: fix sockaddr confusion
Diffstat (limited to 'src/libsystemd-rtnl/sd-rtnl.c')
-rw-r--r--src/libsystemd-rtnl/sd-rtnl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libsystemd-rtnl/sd-rtnl.c b/src/libsystemd-rtnl/sd-rtnl.c
index 9c1f40e48a..ed145b9ab3 100644
--- a/src/libsystemd-rtnl/sd-rtnl.c
+++ b/src/libsystemd-rtnl/sd-rtnl.c
@@ -60,6 +60,7 @@ static bool rtnl_pid_changed(sd_rtnl *rtnl) {
int sd_rtnl_open(uint32_t groups, sd_rtnl **ret) {
_cleanup_sd_rtnl_unref_ sd_rtnl *rtnl = NULL;
+ socklen_t addrlen;
int r;
r = sd_rtnl_new(&rtnl);
@@ -72,10 +73,16 @@ int sd_rtnl_open(uint32_t groups, sd_rtnl **ret) {
rtnl->sockaddr.nl.nl_groups = groups;
- r = bind(rtnl->fd, &rtnl->sockaddr.sa, sizeof(rtnl->sockaddr));
+ addrlen = sizeof(rtnl->sockaddr);
+
+ r = bind(rtnl->fd, &rtnl->sockaddr.sa, addrlen);
if (r < 0)
return -errno;
+ r = getsockname(rtnl->fd, &rtnl->sockaddr.sa, &addrlen);
+ if (r < 0)
+ return r;
+
*ret = rtnl;
rtnl = NULL;