diff options
Diffstat (limited to 'net')
| -rw-r--r-- | net/tipc/config.c | 23 | ||||
| -rw-r--r-- | net/tipc/netlink_compat.c | 17 |
2 files changed, 14 insertions, 26 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index 2a2d05be8a27..080cc92eedca 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -134,26 +134,6 @@ static struct sk_buff *tipc_show_stats(void) | |||
| 134 | return buf; | 134 | return buf; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | static struct sk_buff *cfg_set_netid(struct net *net) | ||
| 138 | { | ||
| 139 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 140 | u32 value; | ||
| 141 | |||
| 142 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) | ||
| 143 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 144 | value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | ||
| 145 | if (value == tn->net_id) | ||
| 146 | return tipc_cfg_reply_none(); | ||
| 147 | if (value < 1 || value > 9999) | ||
| 148 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | ||
| 149 | " (network id must be 1-9999)"); | ||
| 150 | if (tn->own_addr) | ||
| 151 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
| 152 | " (cannot change network id once TIPC has joined a network)"); | ||
| 153 | tn->net_id = value; | ||
| 154 | return tipc_cfg_reply_none(); | ||
| 155 | } | ||
| 156 | |||
| 157 | struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | 137 | struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, |
| 158 | const void *request_area, int request_space, | 138 | const void *request_area, int request_space, |
| 159 | int reply_headroom) | 139 | int reply_headroom) |
| @@ -185,9 +165,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | |||
| 185 | case TIPC_CMD_SHOW_STATS: | 165 | case TIPC_CMD_SHOW_STATS: |
| 186 | rep_tlv_buf = tipc_show_stats(); | 166 | rep_tlv_buf = tipc_show_stats(); |
| 187 | break; | 167 | break; |
| 188 | case TIPC_CMD_SET_NETID: | ||
| 189 | rep_tlv_buf = cfg_set_netid(net); | ||
| 190 | break; | ||
| 191 | case TIPC_CMD_GET_NETID: | 168 | case TIPC_CMD_GET_NETID: |
| 192 | rep_tlv_buf = tipc_cfg_reply_unsigned(tn->net_id); | 169 | rep_tlv_buf = tipc_cfg_reply_unsigned(tn->net_id); |
| 193 | break; | 170 | break; |
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index aa0e3256ae93..c355476a6e7c 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include "name_table.h" | 38 | #include "name_table.h" |
| 39 | #include "socket.h" | 39 | #include "socket.h" |
| 40 | #include "node.h" | 40 | #include "node.h" |
| 41 | #include "net.h" | ||
| 41 | #include <net/genetlink.h> | 42 | #include <net/genetlink.h> |
| 42 | #include <linux/tipc_config.h> | 43 | #include <linux/tipc_config.h> |
| 43 | 44 | ||
| @@ -863,9 +864,13 @@ static int tipc_nl_compat_net_set(struct sk_buff *skb, | |||
| 863 | if (!net) | 864 | if (!net) |
| 864 | return -EMSGSIZE; | 865 | return -EMSGSIZE; |
| 865 | 866 | ||
| 866 | if (nla_put_u32(skb, TIPC_NLA_NET_ADDR, val)) | 867 | if (msg->cmd == TIPC_CMD_SET_NODE_ADDR) { |
| 867 | return -EMSGSIZE; | 868 | if (nla_put_u32(skb, TIPC_NLA_NET_ADDR, val)) |
| 868 | 869 | return -EMSGSIZE; | |
| 870 | } else if (msg->cmd == TIPC_CMD_SET_NETID) { | ||
| 871 | if (nla_put_u32(skb, TIPC_NLA_NET_ID, val)) | ||
| 872 | return -EMSGSIZE; | ||
| 873 | } | ||
| 869 | nla_nest_end(skb, net); | 874 | nla_nest_end(skb, net); |
| 870 | 875 | ||
| 871 | return 0; | 876 | return 0; |
| @@ -949,6 +954,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) | |||
| 949 | doit.doit = tipc_nl_net_set; | 954 | doit.doit = tipc_nl_net_set; |
| 950 | doit.transcode = tipc_nl_compat_net_set; | 955 | doit.transcode = tipc_nl_compat_net_set; |
| 951 | return tipc_nl_compat_doit(&doit, msg); | 956 | return tipc_nl_compat_doit(&doit, msg); |
| 957 | case TIPC_CMD_SET_NETID: | ||
| 958 | msg->req_type = TIPC_TLV_UNSIGNED; | ||
| 959 | doit.doit = tipc_nl_net_set; | ||
| 960 | doit.transcode = tipc_nl_compat_net_set; | ||
| 961 | return tipc_nl_compat_doit(&doit, msg); | ||
| 952 | } | 962 | } |
| 953 | 963 | ||
| 954 | return -EOPNOTSUPP; | 964 | return -EOPNOTSUPP; |
| @@ -1059,6 +1069,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info) | |||
| 1059 | case TIPC_CMD_GET_MEDIA_NAMES: | 1069 | case TIPC_CMD_GET_MEDIA_NAMES: |
| 1060 | case TIPC_CMD_GET_NODES: | 1070 | case TIPC_CMD_GET_NODES: |
| 1061 | case TIPC_CMD_SET_NODE_ADDR: | 1071 | case TIPC_CMD_SET_NODE_ADDR: |
| 1072 | case TIPC_CMD_SET_NETID: | ||
| 1062 | return tipc_nl_compat_recv(skb, info); | 1073 | return tipc_nl_compat_recv(skb, info); |
| 1063 | } | 1074 | } |
| 1064 | 1075 | ||
