diff options
author | Richard Alpe <richard.alpe@ericsson.com> | 2015-02-09 03:50:08 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-09 16:20:48 -0500 |
commit | 37e2d4843f9e2f5aad6bf3be5dad174f2838f375 (patch) | |
tree | ca5744499c3def40973364c7a70a0bf05173f1dc /net/tipc/link.c | |
parent | 357ebdbfca0baa9a8d8d85307393e9ec3406affc (diff) |
tipc: convert legacy nl link prop set to nl compat
Convert setting of link proprieties to compat doit calls.
Commands converted in this patch:
TIPC_CMD_SET_LINK_TOL
TIPC_CMD_SET_LINK_PRI
TIPC_CMD_SET_LINK_WINDOW
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r-- | net/tipc/link.c | 146 |
1 files changed, 1 insertions, 145 deletions
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; |