Commit 670f4f88 authored by Richard Alpe's avatar Richard Alpe Committed by David S. Miller

tipc: add broadcast link window set/get to nl api

Add the ability to get or set the broadcast link window through the
new netlink API. The functionality was unintentionally missing from
the new netlink API. Adding this means that we also fix the breakage
in the old API when coming through the compat layer.

Fixes: 37e2d484 (tipc: convert legacy nl link prop set to nl compat)
Reported-by: default avatarTomi Ollila <tomi.ollila@iki.fi>
Signed-off-by: default avatarRichard Alpe <richard.alpe@ericsson.com>
Reviewed-by: default avatarErik Hugne <erik.hugne@ericsson.com>
Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c3d6fb85
...@@ -866,6 +866,27 @@ int tipc_bclink_set_queue_limits(struct net *net, u32 limit) ...@@ -866,6 +866,27 @@ int tipc_bclink_set_queue_limits(struct net *net, u32 limit)
return 0; return 0;
} }
int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[])
{
int err;
u32 win;
struct nlattr *props[TIPC_NLA_PROP_MAX + 1];
if (!attrs[TIPC_NLA_LINK_PROP])
return -EINVAL;
err = tipc_nl_parse_link_prop(attrs[TIPC_NLA_LINK_PROP], props);
if (err)
return err;
if (!props[TIPC_NLA_PROP_WIN])
return -EOPNOTSUPP;
win = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
return tipc_bclink_set_queue_limits(net, win);
}
int tipc_bclink_init(struct net *net) int tipc_bclink_init(struct net *net)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
......
...@@ -131,6 +131,7 @@ uint tipc_bclink_get_mtu(void); ...@@ -131,6 +131,7 @@ uint tipc_bclink_get_mtu(void);
int tipc_bclink_xmit(struct net *net, struct sk_buff_head *list); int tipc_bclink_xmit(struct net *net, struct sk_buff_head *list);
void tipc_bclink_wakeup_users(struct net *net); void tipc_bclink_wakeup_users(struct net *net);
int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg); int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg);
int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
void tipc_bclink_input(struct net *net); void tipc_bclink_input(struct net *net);
#endif #endif
...@@ -1893,6 +1893,9 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) ...@@ -1893,6 +1893,9 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info)
name = nla_data(attrs[TIPC_NLA_LINK_NAME]); name = nla_data(attrs[TIPC_NLA_LINK_NAME]);
if (strcmp(name, tipc_bclink_name) == 0)
return tipc_nl_bc_link_set(net, attrs);
node = tipc_link_find_owner(net, name, &bearer_id); node = tipc_link_find_owner(net, name, &bearer_id);
if (!node) if (!node)
return -EINVAL; return -EINVAL;
...@@ -2175,50 +2178,53 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2175,50 +2178,53 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb)
int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info)
{ {
struct net *net = genl_info_net(info); struct net *net = genl_info_net(info);
struct sk_buff *ans_skb;
struct tipc_nl_msg msg; struct tipc_nl_msg msg;
struct tipc_link *link;
struct tipc_node *node;
char *name; char *name;
int bearer_id;
int err; int err;
msg.portid = info->snd_portid;
msg.seq = info->snd_seq;
if (!info->attrs[TIPC_NLA_LINK_NAME]) if (!info->attrs[TIPC_NLA_LINK_NAME])
return -EINVAL; return -EINVAL;
name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]); name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]);
node = tipc_link_find_owner(net, name, &bearer_id);
if (!node)
return -EINVAL;
ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
if (!ans_skb) if (!msg.skb)
return -ENOMEM; return -ENOMEM;
msg.skb = ans_skb; if (strcmp(name, tipc_bclink_name) == 0) {
msg.portid = info->snd_portid; err = tipc_nl_add_bc_link(net, &msg);
msg.seq = info->snd_seq; if (err) {
nlmsg_free(msg.skb);
return err;
}
} else {
int bearer_id;
struct tipc_node *node;
struct tipc_link *link;
node = tipc_link_find_owner(net, name, &bearer_id);
if (!node)
return -EINVAL;
tipc_node_lock(node); tipc_node_lock(node);
link = node->links[bearer_id]; link = node->links[bearer_id];
if (!link) { if (!link) {
err = -EINVAL; tipc_node_unlock(node);
goto err_out; nlmsg_free(msg.skb);
return -EINVAL;
} }
err = __tipc_nl_add_link(net, &msg, link, 0); err = __tipc_nl_add_link(net, &msg, link, 0);
if (err)
goto err_out;
tipc_node_unlock(node); tipc_node_unlock(node);
if (err) {
return genlmsg_reply(ans_skb, info); nlmsg_free(msg.skb);
err_out:
tipc_node_unlock(node);
nlmsg_free(ans_skb);
return err; return err;
}
}
return genlmsg_reply(msg.skb, info);
} }
int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment