From 6a8402d956a6f89910530e6b364c79be821d2d9d Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 15 Mar 2014 20:02:24 +0100 Subject: sd-rtnl: make RTM_NEWLINK report EEXIST by default Use RTM_SETLINK to update an existing link. --- src/libsystemd/sd-rtnl/rtnl-message.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/libsystemd/sd-rtnl') diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c index fca1ff667a..7ea68f18ae 100644 --- a/src/libsystemd/sd-rtnl/rtnl-message.c +++ b/src/libsystemd/sd-rtnl/rtnl-message.c @@ -166,8 +166,7 @@ int sd_rtnl_message_new_link(sd_rtnl *rtnl, sd_rtnl_message **ret, int r; assert_return(rtnl_message_type_is_link(nlmsg_type), -EINVAL); - assert_return(nlmsg_type == RTM_NEWLINK || - nlmsg_type == RTM_SETLINK || index > 0, -EINVAL); + assert_return(nlmsg_type != RTM_DELLINK || index > 0, -EINVAL); assert_return(ret, -EINVAL); r = message_new(rtnl, ret, NLMSG_SPACE(sizeof(struct ifinfomsg))); @@ -177,7 +176,7 @@ int sd_rtnl_message_new_link(sd_rtnl *rtnl, sd_rtnl_message **ret, (*ret)->hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); (*ret)->hdr->nlmsg_type = nlmsg_type; if (nlmsg_type == RTM_NEWLINK) - (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE; + (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL; ifi = NLMSG_DATA((*ret)->hdr); -- cgit v1.2.3-54-g00ecf