Skip to content

Commit

Permalink
tipc: remove wrong use of NLM_F_MULTI
Browse files Browse the repository at this point in the history
NLM_F_MULTI must be used only when a NLMSG_DONE message is sent. In fact,
it is sent only at the end of a dump.

Libraries like libnl will wait forever for NLMSG_DONE.

Fixes: 35b9dd7 ("tipc: add bearer get/dump to new netlink api")
Fixes: 7be57fc ("tipc: add link get/dump to new netlink api")
Fixes: 46f15c6 ("tipc: add media get/dump to new netlink api")
CC: Richard Alpe <richard.alpe@ericsson.com>
CC: Jon Maloy <jon.maloy@ericsson.com>
CC: Ying Xue <ying.xue@windriver.com>
CC: tipc-discussion@lists.sourceforge.net
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
NicolasDichtel authored and davem330 committed Apr 29, 2015
1 parent 46c264d commit f2f6739
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
17 changes: 9 additions & 8 deletions net/tipc/bearer.c
Expand Up @@ -591,14 +591,14 @@ void tipc_bearer_stop(struct net *net)

/* Caller should hold rtnl_lock to protect the bearer */
static int __tipc_nl_add_bearer(struct tipc_nl_msg *msg,
struct tipc_bearer *bearer)
struct tipc_bearer *bearer, int nlflags)
{
void *hdr;
struct nlattr *attrs;
struct nlattr *prop;

hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
NLM_F_MULTI, TIPC_NL_BEARER_GET);
nlflags, TIPC_NL_BEARER_GET);
if (!hdr)
return -EMSGSIZE;

Expand Down Expand Up @@ -657,7 +657,7 @@ int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb)
if (!bearer)
continue;

err = __tipc_nl_add_bearer(&msg, bearer);
err = __tipc_nl_add_bearer(&msg, bearer, NLM_F_MULTI);
if (err)
break;
}
Expand Down Expand Up @@ -705,7 +705,7 @@ int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info)
goto err_out;
}

err = __tipc_nl_add_bearer(&msg, bearer);
err = __tipc_nl_add_bearer(&msg, bearer, 0);
if (err)
goto err_out;
rtnl_unlock();
Expand Down Expand Up @@ -857,14 +857,14 @@ int tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
}

static int __tipc_nl_add_media(struct tipc_nl_msg *msg,
struct tipc_media *media)
struct tipc_media *media, int nlflags)
{
void *hdr;
struct nlattr *attrs;
struct nlattr *prop;

hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
NLM_F_MULTI, TIPC_NL_MEDIA_GET);
nlflags, TIPC_NL_MEDIA_GET);
if (!hdr)
return -EMSGSIZE;

Expand Down Expand Up @@ -916,7 +916,8 @@ int tipc_nl_media_dump(struct sk_buff *skb, struct netlink_callback *cb)

rtnl_lock();
for (; media_info_array[i] != NULL; i++) {
err = __tipc_nl_add_media(&msg, media_info_array[i]);
err = __tipc_nl_add_media(&msg, media_info_array[i],
NLM_F_MULTI);
if (err)
break;
}
Expand Down Expand Up @@ -963,7 +964,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info)
goto err_out;
}

err = __tipc_nl_add_media(&msg, media);
err = __tipc_nl_add_media(&msg, media, 0);
if (err)
goto err_out;
rtnl_unlock();
Expand Down
8 changes: 4 additions & 4 deletions net/tipc/link.c
Expand Up @@ -2013,7 +2013,7 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s)

/* Caller should hold appropriate locks to protect the link */
static int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
struct tipc_link *link)
struct tipc_link *link, int nlflags)
{
int err;
void *hdr;
Expand All @@ -2022,7 +2022,7 @@ static int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
struct tipc_net *tn = net_generic(net, tipc_net_id);

hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
NLM_F_MULTI, TIPC_NL_LINK_GET);
nlflags, TIPC_NL_LINK_GET);
if (!hdr)
return -EMSGSIZE;

Expand Down Expand Up @@ -2095,7 +2095,7 @@ static int __tipc_nl_add_node_links(struct net *net, struct tipc_nl_msg *msg,
if (!node->links[i])
continue;

err = __tipc_nl_add_link(net, msg, node->links[i]);
err = __tipc_nl_add_link(net, msg, node->links[i], NLM_F_MULTI);
if (err)
return err;
}
Expand Down Expand Up @@ -2209,7 +2209,7 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info)
goto err_out;
}

err = __tipc_nl_add_link(net, &msg, link);
err = __tipc_nl_add_link(net, &msg, link, 0);
if (err)
goto err_out;

Expand Down

0 comments on commit f2f6739

Please sign in to comment.