X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd%2Fsd-rtnl%2Frtnl-util.c;fp=src%2Flibsystemd%2Fsd-rtnl%2Frtnl-util.c;h=fe0f34e125de53c7c3b55641df489c46b46cb15b;hb=4c83d994566718043e61e568cc214bdc4587f869;hp=0bc2c9b1f5720f68772d4264c61bbafb19a49720;hpb=b081b27e1433cdc7ac72b25ae8b4db887d79187f;p=elogind.git diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c index 0bc2c9b1f..fe0f34e12 100644 --- a/src/libsystemd/sd-rtnl/rtnl-util.c +++ b/src/libsystemd/sd-rtnl/rtnl-util.c @@ -26,7 +26,7 @@ #include "rtnl-util.h" #include "rtnl-internal.h" -int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) { +int rtnl_set_link_name(sd_rtnl **rtnl, int ifindex, const char *name) { _cleanup_rtnl_message_unref_ sd_rtnl_message *message = NULL; int r; @@ -34,7 +34,13 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) { assert(ifindex > 0); assert(name); - r = sd_rtnl_message_new_link(rtnl, &message, RTM_SETLINK, ifindex); + if (!*rtnl) { + r = sd_rtnl_open(rtnl, 0); + if (r < 0) + return r; + } + + r = sd_rtnl_message_new_link(*rtnl, &message, RTM_SETLINK, ifindex); if (r < 0) return r; @@ -42,7 +48,7 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) { if (r < 0) return r; - r = sd_rtnl_call(rtnl, message, 0, NULL); + r = sd_rtnl_call(*rtnl, message, 0, NULL); if (r < 0) return r;