diff options
Diffstat (limited to 'net')
| -rw-r--r-- | net/tipc/config.c | 6 | ||||
| -rw-r--r-- | net/tipc/link.c | 146 | ||||
| -rw-r--r-- | net/tipc/link.h | 2 | ||||
| -rw-r--r-- | net/tipc/netlink_compat.c | 47 |
4 files changed, 48 insertions, 153 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index 1b17f5846e86..75a130e493f5 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -226,12 +226,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | |||
| 226 | case TIPC_CMD_SHOW_STATS: | 226 | case TIPC_CMD_SHOW_STATS: |
| 227 | rep_tlv_buf = tipc_show_stats(); | 227 | rep_tlv_buf = tipc_show_stats(); |
| 228 | break; | 228 | break; |
| 229 | case TIPC_CMD_SET_LINK_TOL: | ||
| 230 | case TIPC_CMD_SET_LINK_PRI: | ||
| 231 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 232 | rep_tlv_buf = tipc_link_cmd_config(net, req_tlv_area, | ||
| 233 | req_tlv_space, cmd); | ||
| 234 | break; | ||
| 235 | case TIPC_CMD_SET_NODE_ADDR: | 229 | case TIPC_CMD_SET_NODE_ADDR: |
| 236 | rep_tlv_buf = cfg_set_own_addr(net); | 230 | rep_tlv_buf = cfg_set_own_addr(net); |
| 237 | break; | 231 | break; |
diff --git a/net/tipc/link.c b/net/tipc/link.c index 2622fb99344a..ec136b5cc339 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -1959,150 +1959,6 @@ static struct tipc_node *tipc_link_find_owner(struct net *net, | |||
| 1959 | } | 1959 | } |
| 1960 | 1960 | ||
| 1961 | /** | 1961 | /** |
| 1962 | * link_value_is_valid -- validate proposed link tolerance/priority/window | ||
| 1963 | * | ||
| 1964 | * @cmd: value type (TIPC_CMD_SET_LINK_*) | ||
| 1965 | * @new_value: the new value | ||
| 1966 | * | ||
| 1967 | * Returns 1 if value is within range, 0 if not. | ||
| 1968 | */ | ||
| 1969 | static int link_value_is_valid(u16 cmd, u32 new_value) | ||
| 1970 | { | ||
| 1971 | switch (cmd) { | ||
| 1972 | case TIPC_CMD_SET_LINK_TOL: | ||
| 1973 | return (new_value >= TIPC_MIN_LINK_TOL) && | ||
| 1974 | (new_value <= TIPC_MAX_LINK_TOL); | ||
| 1975 | case TIPC_CMD_SET_LINK_PRI: | ||
| 1976 | return (new_value <= TIPC_MAX_LINK_PRI); | ||
| 1977 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 1978 | return (new_value >= TIPC_MIN_LINK_WIN) && | ||
| 1979 | (new_value <= TIPC_MAX_LINK_WIN); | ||
| 1980 | } | ||
| 1981 | return 0; | ||
| 1982 | } | ||
| 1983 | |||
| 1984 | /** | ||
| 1985 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media | ||
| 1986 | * @net: the applicable net namespace | ||
| 1987 | * @name: ptr to link, bearer, or media name | ||
| 1988 | * @new_value: new value of link, bearer, or media setting | ||
| 1989 | * @cmd: which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) | ||
| 1990 | * | ||
| 1991 | * Caller must hold RTNL lock to ensure link/bearer/media is not deleted. | ||
| 1992 | * | ||
| 1993 | * Returns 0 if value updated and negative value on error. | ||
| 1994 | */ | ||
| 1995 | static int link_cmd_set_value(struct net *net, const char *name, u32 new_value, | ||
| 1996 | u16 cmd) | ||
| 1997 | { | ||
| 1998 | struct tipc_node *node; | ||
| 1999 | struct tipc_link *l_ptr; | ||
| 2000 | struct tipc_bearer *b_ptr; | ||
| 2001 | struct tipc_media *m_ptr; | ||
| 2002 | int bearer_id; | ||
| 2003 | int res = 0; | ||
| 2004 | |||
| 2005 | node = tipc_link_find_owner(net, name, &bearer_id); | ||
| 2006 | if (node) { | ||
| 2007 | tipc_node_lock(node); | ||
| 2008 | l_ptr = node->links[bearer_id]; | ||
| 2009 | |||
| 2010 | if (l_ptr) { | ||
| 2011 | switch (cmd) { | ||
| 2012 | case TIPC_CMD_SET_LINK_TOL: | ||
| 2013 | link_set_supervision_props(l_ptr, new_value); | ||
| 2014 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, | ||
| 2015 | new_value, 0, 0); | ||
| 2016 | break; | ||
| 2017 | case TIPC_CMD_SET_LINK_PRI: | ||
| 2018 | l_ptr->priority = new_value; | ||
| 2019 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, | ||
| 2020 | 0, new_value, 0); | ||
| 2021 | break; | ||
| 2022 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 2023 | tipc_link_set_queue_limits(l_ptr, new_value); | ||
| 2024 | break; | ||
| 2025 | default: | ||
| 2026 | res = -EINVAL; | ||
| 2027 | break; | ||
| 2028 | } | ||
| 2029 | } | ||
| 2030 | tipc_node_unlock(node); | ||
| 2031 | return res; | ||
| 2032 | } | ||
| 2033 | |||
| 2034 | b_ptr = tipc_bearer_find(net, name); | ||
| 2035 | if (b_ptr) { | ||
| 2036 | switch (cmd) { | ||
| 2037 | case TIPC_CMD_SET_LINK_TOL: | ||
| 2038 | b_ptr->tolerance = new_value; | ||
| 2039 | break; | ||
| 2040 | case TIPC_CMD_SET_LINK_PRI: | ||
| 2041 | b_ptr->priority = new_value; | ||
| 2042 | break; | ||
| 2043 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 2044 | b_ptr->window = new_value; | ||
| 2045 | break; | ||
| 2046 | default: | ||
| 2047 | res = -EINVAL; | ||
| 2048 | break; | ||
| 2049 | } | ||
| 2050 | return res; | ||
| 2051 | } | ||
| 2052 | |||
| 2053 | m_ptr = tipc_media_find(name); | ||
| 2054 | if (!m_ptr) | ||
| 2055 | return -ENODEV; | ||
| 2056 | switch (cmd) { | ||
| 2057 | case TIPC_CMD_SET_LINK_TOL: | ||
| 2058 | m_ptr->tolerance = new_value; | ||
| 2059 | break; | ||
| 2060 | case TIPC_CMD_SET_LINK_PRI: | ||
| 2061 | m_ptr->priority = new_value; | ||
| 2062 | break; | ||
| 2063 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 2064 | m_ptr->window = new_value; | ||
| 2065 | break; | ||
| 2066 | default: | ||
| 2067 | res = -EINVAL; | ||
| 2068 | break; | ||
| 2069 | } | ||
| 2070 | return res; | ||
| 2071 | } | ||
| 2072 | |||
| 2073 | struct sk_buff *tipc_link_cmd_config(struct net *net, const void *req_tlv_area, | ||
| 2074 | int req_tlv_space, u16 cmd) | ||
| 2075 | { | ||
| 2076 | struct tipc_link_config *args; | ||
| 2077 | u32 new_value; | ||
| 2078 | int res; | ||
| 2079 | |||
| 2080 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) | ||
| 2081 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 2082 | |||
| 2083 | args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); | ||
| 2084 | new_value = ntohl(args->value); | ||
| 2085 | |||
| 2086 | if (!link_value_is_valid(cmd, new_value)) | ||
| 2087 | return tipc_cfg_reply_error_string( | ||
| 2088 | "cannot change, value invalid"); | ||
| 2089 | |||
| 2090 | if (!strcmp(args->name, tipc_bclink_name)) { | ||
| 2091 | if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && | ||
| 2092 | (tipc_bclink_set_queue_limits(net, new_value) == 0)) | ||
| 2093 | return tipc_cfg_reply_none(); | ||
| 2094 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
| 2095 | " (cannot change setting on broadcast link)"); | ||
| 2096 | } | ||
| 2097 | |||
| 2098 | res = link_cmd_set_value(net, args->name, new_value, cmd); | ||
| 2099 | if (res) | ||
| 2100 | return tipc_cfg_reply_error_string("cannot change link setting"); | ||
| 2101 | |||
| 2102 | return tipc_cfg_reply_none(); | ||
| 2103 | } | ||
| 2104 | |||
| 2105 | /** | ||
| 2106 | * link_reset_statistics - reset link statistics | 1962 | * link_reset_statistics - reset link statistics |
| 2107 | * @l_ptr: pointer to link | 1963 | * @l_ptr: pointer to link |
| 2108 | */ | 1964 | */ |
| @@ -2216,7 +2072,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | |||
| 2216 | struct tipc_link *link; | 2072 | struct tipc_link *link; |
| 2217 | struct tipc_node *node; | 2073 | struct tipc_node *node; |
| 2218 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2074 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
| 2219 | struct net *net = genl_info_net(info); | 2075 | struct net *net = sock_net(skb->sk); |
| 2220 | 2076 | ||
| 2221 | if (!info->attrs[TIPC_NLA_LINK]) | 2077 | if (!info->attrs[TIPC_NLA_LINK]) |
| 2222 | return -EINVAL; | 2078 | return -EINVAL; |
diff --git a/net/tipc/link.h b/net/tipc/link.h index 8c8340cf991f..6eb9d606063b 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
| @@ -215,8 +215,6 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr); | |||
| 215 | int tipc_link_is_up(struct tipc_link *l_ptr); | 215 | int tipc_link_is_up(struct tipc_link *l_ptr); |
| 216 | int tipc_link_is_active(struct tipc_link *l_ptr); | 216 | int tipc_link_is_active(struct tipc_link *l_ptr); |
| 217 | void tipc_link_purge_queues(struct tipc_link *l_ptr); | 217 | void tipc_link_purge_queues(struct tipc_link *l_ptr); |
| 218 | struct sk_buff *tipc_link_cmd_config(struct net *net, const void *req_tlv_area, | ||
| 219 | int req_tlv_space, u16 cmd); | ||
| 220 | struct sk_buff *tipc_link_cmd_reset_stats(struct net *net, | 218 | struct sk_buff *tipc_link_cmd_reset_stats(struct net *net, |
| 221 | const void *req_tlv_area, | 219 | const void *req_tlv_area, |
| 222 | int req_tlv_space); | 220 | int req_tlv_space); |
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index bff9403899ed..056532b41e7e 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
| @@ -569,6 +569,43 @@ static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg, | |||
| 569 | &link_info, sizeof(link_info)); | 569 | &link_info, sizeof(link_info)); |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | static int tipc_nl_compat_link_set(struct sk_buff *skb, | ||
| 573 | struct tipc_nl_compat_msg *msg) | ||
| 574 | { | ||
| 575 | struct nlattr *link; | ||
| 576 | struct nlattr *prop; | ||
| 577 | struct tipc_link_config *lc; | ||
| 578 | |||
| 579 | lc = (struct tipc_link_config *)TLV_DATA(msg->req); | ||
| 580 | |||
| 581 | link = nla_nest_start(skb, TIPC_NLA_LINK); | ||
| 582 | if (!link) | ||
| 583 | return -EMSGSIZE; | ||
| 584 | |||
| 585 | if (nla_put_string(skb, TIPC_NLA_LINK_NAME, lc->name)) | ||
| 586 | return -EMSGSIZE; | ||
| 587 | |||
| 588 | prop = nla_nest_start(skb, TIPC_NLA_LINK_PROP); | ||
| 589 | if (!prop) | ||
| 590 | return -EMSGSIZE; | ||
| 591 | |||
| 592 | if (msg->cmd == TIPC_CMD_SET_LINK_PRI) { | ||
| 593 | if (nla_put_u32(skb, TIPC_NLA_PROP_PRIO, ntohl(lc->value))) | ||
| 594 | return -EMSGSIZE; | ||
| 595 | } else if (msg->cmd == TIPC_CMD_SET_LINK_TOL) { | ||
| 596 | if (nla_put_u32(skb, TIPC_NLA_PROP_TOL, ntohl(lc->value))) | ||
| 597 | return -EMSGSIZE; | ||
| 598 | } else if (msg->cmd == TIPC_CMD_SET_LINK_WINDOW) { | ||
| 599 | if (nla_put_u32(skb, TIPC_NLA_PROP_WIN, ntohl(lc->value))) | ||
| 600 | return -EMSGSIZE; | ||
| 601 | } | ||
| 602 | |||
| 603 | nla_nest_end(skb, prop); | ||
| 604 | nla_nest_end(skb, link); | ||
| 605 | |||
| 606 | return 0; | ||
| 607 | } | ||
| 608 | |||
| 572 | static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) | 609 | static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) |
| 573 | { | 610 | { |
| 574 | struct tipc_nl_compat_cmd_dump dump; | 611 | struct tipc_nl_compat_cmd_dump dump; |
| @@ -606,6 +643,13 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) | |||
| 606 | dump.dumpit = tipc_nl_link_dump; | 643 | dump.dumpit = tipc_nl_link_dump; |
| 607 | dump.format = tipc_nl_compat_link_dump; | 644 | dump.format = tipc_nl_compat_link_dump; |
| 608 | return tipc_nl_compat_dumpit(&dump, msg); | 645 | return tipc_nl_compat_dumpit(&dump, msg); |
| 646 | case TIPC_CMD_SET_LINK_TOL: | ||
| 647 | case TIPC_CMD_SET_LINK_PRI: | ||
| 648 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 649 | msg->req_type = TIPC_TLV_LINK_CONFIG; | ||
| 650 | doit.doit = tipc_nl_link_set; | ||
| 651 | doit.transcode = tipc_nl_compat_link_set; | ||
| 652 | return tipc_nl_compat_doit(&doit, msg); | ||
| 609 | } | 653 | } |
| 610 | 654 | ||
| 611 | return -EOPNOTSUPP; | 655 | return -EOPNOTSUPP; |
| @@ -707,6 +751,9 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info) | |||
| 707 | case TIPC_CMD_DISABLE_BEARER: | 751 | case TIPC_CMD_DISABLE_BEARER: |
| 708 | case TIPC_CMD_SHOW_LINK_STATS: | 752 | case TIPC_CMD_SHOW_LINK_STATS: |
| 709 | case TIPC_CMD_GET_LINKS: | 753 | case TIPC_CMD_GET_LINKS: |
| 754 | case TIPC_CMD_SET_LINK_TOL: | ||
| 755 | case TIPC_CMD_SET_LINK_PRI: | ||
| 756 | case TIPC_CMD_SET_LINK_WINDOW: | ||
| 710 | return tipc_nl_compat_recv(skb, info); | 757 | return tipc_nl_compat_recv(skb, info); |
| 711 | } | 758 | } |
| 712 | 759 | ||
