aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2015-02-09 03:50:18 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-09 16:20:49 -0500
commit22ae7cff509f3bb22caaa0003f67eeb93d338fed (patch)
tree2d3ee4ec9044797f4520e14c5b34e3605c5ce9fa /net/tipc
parent5a81a6377b6083fccffdfb7a21ec080b8d58475b (diff)
tipc: nl compat add noop and remove legacy nl framework
Add TIPC_CMD_NOOP to compat layer and remove the old framework. All legacy nl commands are now converted to the compat layer in netlink_compat.c. 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')
-rw-r--r--net/tipc/Makefile2
-rw-r--r--net/tipc/bearer.c1
-rw-r--r--net/tipc/config.c157
-rw-r--r--net/tipc/config.h67
-rw-r--r--net/tipc/core.c3
-rw-r--r--net/tipc/link.c1
-rw-r--r--net/tipc/log.c1
-rw-r--r--net/tipc/name_table.c4
-rw-r--r--net/tipc/net.c2
-rw-r--r--net/tipc/netlink_compat.c73
-rw-r--r--net/tipc/node.c2
-rw-r--r--net/tipc/socket.c1
12 files changed, 13 insertions, 301 deletions
diff --git a/net/tipc/Makefile b/net/tipc/Makefile
index 69b82bbc60d3..6864b9de2404 100644
--- a/net/tipc/Makefile
+++ b/net/tipc/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-$(CONFIG_TIPC) := tipc.o 5obj-$(CONFIG_TIPC) := tipc.o
6 6
7tipc-y += addr.o bcast.o bearer.o config.o \ 7tipc-y += addr.o bcast.o bearer.o \
8 core.o link.o discover.o msg.o \ 8 core.o link.o discover.o msg.o \
9 name_distr.o subscr.o name_table.o net.o \ 9 name_distr.o subscr.o name_table.o net.o \
10 netlink.o netlink_compat.o node.o socket.o log.o eth_media.o \ 10 netlink.o netlink_compat.o node.o socket.o log.o eth_media.o \
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index c7e3b5d3baa9..858c5a6c32df 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -36,7 +36,6 @@
36 36
37#include <net/sock.h> 37#include <net/sock.h>
38#include "core.h" 38#include "core.h"
39#include "config.h"
40#include "bearer.h" 39#include "bearer.h"
41#include "link.h" 40#include "link.h"
42#include "discover.h" 41#include "discover.h"
diff --git a/net/tipc/config.c b/net/tipc/config.c
deleted file mode 100644
index c2ad2ff32a15..000000000000
--- a/net/tipc/config.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/*
2 * net/tipc/config.c: TIPC configuration management code
3 *
4 * Copyright (c) 2002-2006, Ericsson AB
5 * Copyright (c) 2004-2007, 2010-2013, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#include "core.h"
38#include "socket.h"
39#include "name_table.h"
40#include "config.h"
41#include "server.h"
42
43#define REPLY_TRUNCATED "<truncated>\n"
44
45static const void *req_tlv_area; /* request message TLV area */
46static int req_tlv_space; /* request message TLV area size */
47static int rep_headroom; /* reply message headroom to use */
48
49struct sk_buff *tipc_cfg_reply_alloc(int payload_size)
50{
51 struct sk_buff *buf;
52
53 buf = alloc_skb(rep_headroom + payload_size, GFP_ATOMIC);
54 if (buf)
55 skb_reserve(buf, rep_headroom);
56 return buf;
57}
58
59int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
60 void *tlv_data, int tlv_data_size)
61{
62 struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(buf);
63 int new_tlv_space = TLV_SPACE(tlv_data_size);
64
65 if (skb_tailroom(buf) < new_tlv_space)
66 return 0;
67 skb_put(buf, new_tlv_space);
68 tlv->tlv_type = htons(tlv_type);
69 tlv->tlv_len = htons(TLV_LENGTH(tlv_data_size));
70 if (tlv_data_size && tlv_data)
71 memcpy(TLV_DATA(tlv), tlv_data, tlv_data_size);
72 return 1;
73}
74
75struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string)
76{
77 struct sk_buff *buf;
78 int string_len = strlen(string) + 1;
79
80 buf = tipc_cfg_reply_alloc(TLV_SPACE(string_len));
81 if (buf)
82 tipc_cfg_append_tlv(buf, tlv_type, string, string_len);
83 return buf;
84}
85
86struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
87 const void *request_area, int request_space,
88 int reply_headroom)
89{
90 struct sk_buff *rep_tlv_buf;
91
92 rtnl_lock();
93
94 /* Save request and reply details in a well-known location */
95 req_tlv_area = request_area;
96 req_tlv_space = request_space;
97 rep_headroom = reply_headroom;
98
99 /* Check command authorization */
100 if (likely(in_own_node(net, orig_node))) {
101 /* command is permitted */
102 } else {
103 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
104 " (cannot be done remotely)");
105 goto exit;
106 }
107
108 /* Call appropriate processing routine */
109 switch (cmd) {
110 case TIPC_CMD_NOOP:
111 rep_tlv_buf = tipc_cfg_reply_none();
112 break;
113 case TIPC_CMD_NOT_NET_ADMIN:
114 rep_tlv_buf =
115 tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN);
116 break;
117 case TIPC_CMD_SET_MAX_ZONES:
118 case TIPC_CMD_GET_MAX_ZONES:
119 case TIPC_CMD_SET_MAX_SLAVES:
120 case TIPC_CMD_GET_MAX_SLAVES:
121 case TIPC_CMD_SET_MAX_CLUSTERS:
122 case TIPC_CMD_GET_MAX_CLUSTERS:
123 case TIPC_CMD_SET_MAX_NODES:
124 case TIPC_CMD_GET_MAX_NODES:
125 case TIPC_CMD_SET_MAX_SUBSCR:
126 case TIPC_CMD_GET_MAX_SUBSCR:
127 case TIPC_CMD_SET_MAX_PUBL:
128 case TIPC_CMD_GET_MAX_PUBL:
129 case TIPC_CMD_SET_LOG_SIZE:
130 case TIPC_CMD_SET_REMOTE_MNG:
131 case TIPC_CMD_GET_REMOTE_MNG:
132 case TIPC_CMD_DUMP_LOG:
133 case TIPC_CMD_SET_MAX_PORTS:
134 case TIPC_CMD_GET_MAX_PORTS:
135 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
136 " (obsolete command)");
137 break;
138 default:
139 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
140 " (unknown command)");
141 break;
142 }
143
144 WARN_ON(rep_tlv_buf->len > TLV_SPACE(ULTRA_STRING_MAX_LEN));
145
146 /* Append an error message if we cannot return all requested data */
147 if (rep_tlv_buf->len == TLV_SPACE(ULTRA_STRING_MAX_LEN)) {
148 if (*(rep_tlv_buf->data + ULTRA_STRING_MAX_LEN) != '\0')
149 sprintf(rep_tlv_buf->data + rep_tlv_buf->len -
150 sizeof(REPLY_TRUNCATED) - 1, REPLY_TRUNCATED);
151 }
152
153 /* Return reply buffer */
154exit:
155 rtnl_unlock();
156 return rep_tlv_buf;
157}
diff --git a/net/tipc/config.h b/net/tipc/config.h
deleted file mode 100644
index 9e9b575fc429..000000000000
--- a/net/tipc/config.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * net/tipc/config.h: Include file for TIPC configuration service code
3 *
4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _TIPC_CONFIG_H
38#define _TIPC_CONFIG_H
39
40#include "link.h"
41
42#define ULTRA_STRING_MAX_LEN 32768
43
44struct sk_buff *tipc_cfg_reply_alloc(int payload_size);
45int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
46 void *tlv_data, int tlv_data_size);
47struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string);
48
49static inline struct sk_buff *tipc_cfg_reply_none(void)
50{
51 return tipc_cfg_reply_alloc(0);
52}
53
54static inline struct sk_buff *tipc_cfg_reply_error_string(char *string)
55{
56 return tipc_cfg_reply_string_type(TIPC_TLV_ERROR_STRING, string);
57}
58
59static inline struct sk_buff *tipc_cfg_reply_ultra_string(char *string)
60{
61 return tipc_cfg_reply_string_type(TIPC_TLV_ULTRA_STRING, string);
62}
63
64struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
65 const void *req_tlv_area, int req_tlv_space,
66 int headroom);
67#endif
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 2d06d1f8b6e6..935205e6bcfe 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -39,7 +39,8 @@
39#include "core.h" 39#include "core.h"
40#include "name_table.h" 40#include "name_table.h"
41#include "subscr.h" 41#include "subscr.h"
42#include "config.h" 42#include "bearer.h"
43#include "net.h"
43#include "socket.h" 44#include "socket.h"
44 45
45#include <linux/module.h> 46#include <linux/module.h>
diff --git a/net/tipc/link.c b/net/tipc/link.c
index dfe6f4d0b402..a4cf364316de 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -40,7 +40,6 @@
40#include "socket.h" 40#include "socket.h"
41#include "name_distr.h" 41#include "name_distr.h"
42#include "discover.h" 42#include "discover.h"
43#include "config.h"
44#include "netlink.h" 43#include "netlink.h"
45 44
46#include <linux/pkt_sched.h> 45#include <linux/pkt_sched.h>
diff --git a/net/tipc/log.c b/net/tipc/log.c
index abef644f27d8..b186af06e361 100644
--- a/net/tipc/log.c
+++ b/net/tipc/log.c
@@ -35,7 +35,6 @@
35 */ 35 */
36 36
37#include "core.h" 37#include "core.h"
38#include "config.h"
39 38
40/** 39/**
41 * tipc_snprintf - append formatted output to print buffer 40 * tipc_snprintf - append formatted output to print buffer
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index c8eaa2afe875..105ba7adf06f 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -36,11 +36,13 @@
36 36
37#include <net/sock.h> 37#include <net/sock.h>
38#include "core.h" 38#include "core.h"
39#include "config.h" 39#include "netlink.h"
40#include "name_table.h" 40#include "name_table.h"
41#include "name_distr.h" 41#include "name_distr.h"
42#include "subscr.h" 42#include "subscr.h"
43#include "bcast.h" 43#include "bcast.h"
44#include "addr.h"
45#include <net/genetlink.h>
44 46
45#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */ 47#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
46 48
diff --git a/net/tipc/net.c b/net/tipc/net.c
index e4028f927c8a..a54f3cbe2246 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -40,8 +40,6 @@
40#include "subscr.h" 40#include "subscr.h"
41#include "socket.h" 41#include "socket.h"
42#include "node.h" 42#include "node.h"
43#include "config.h"
44#include "bcast.h"
45 43
46static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = { 44static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
47 [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC }, 45 [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index cb9086d259df..ce9121e8e990 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -32,7 +32,6 @@
32 */ 32 */
33 33
34#include "core.h" 34#include "core.h"
35#include "config.h"
36#include "bearer.h" 35#include "bearer.h"
37#include "link.h" 36#include "link.h"
38#include "name_table.h" 37#include "name_table.h"
@@ -909,6 +908,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
909 memset(&doit, 0, sizeof(doit)); 908 memset(&doit, 0, sizeof(doit));
910 909
911 switch (msg->cmd) { 910 switch (msg->cmd) {
911 case TIPC_CMD_NOOP:
912 msg->rep = tipc_tlv_alloc(0);
913 if (!msg->rep)
914 return -ENOMEM;
915 return 0;
912 case TIPC_CMD_GET_BEARER_NAMES: 916 case TIPC_CMD_GET_BEARER_NAMES:
913 msg->rep_size = MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME); 917 msg->rep_size = MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME);
914 dump.dumpit = tipc_nl_bearer_dump; 918 dump.dumpit = tipc_nl_bearer_dump;
@@ -1044,71 +1048,6 @@ send:
1044 return err; 1048 return err;
1045} 1049}
1046 1050
1047static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
1048{
1049 struct net *net = genl_info_net(info);
1050 struct sk_buff *rep_buf;
1051 struct nlmsghdr *rep_nlh;
1052 struct nlmsghdr *req_nlh = info->nlhdr;
1053 struct tipc_genlmsghdr *req_userhdr = info->userhdr;
1054 int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN);
1055 u16 cmd;
1056
1057 if ((req_userhdr->cmd & 0xC000) &&
1058 (!netlink_net_capable(skb, CAP_NET_ADMIN)))
1059 cmd = TIPC_CMD_NOT_NET_ADMIN;
1060 else
1061 cmd = req_userhdr->cmd;
1062
1063 rep_buf = tipc_cfg_do_cmd(net, req_userhdr->dest, cmd,
1064 nlmsg_data(req_nlh) + GENL_HDRLEN +
1065 TIPC_GENL_HDRLEN,
1066 nlmsg_attrlen(req_nlh, GENL_HDRLEN +
1067 TIPC_GENL_HDRLEN), hdr_space);
1068
1069 if (rep_buf) {
1070 skb_push(rep_buf, hdr_space);
1071 rep_nlh = nlmsg_hdr(rep_buf);
1072 memcpy(rep_nlh, req_nlh, hdr_space);
1073 rep_nlh->nlmsg_len = rep_buf->len;
1074 genlmsg_unicast(net, rep_buf, NETLINK_CB(skb).portid);
1075 }
1076
1077 return 0;
1078}
1079
1080/* Temporary function to keep functionality throughout the patchset
1081 * without having to mess with the global variables and other trickery
1082 * of the old API.
1083 */
1084static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
1085{
1086 struct tipc_genlmsghdr *req = info->userhdr;
1087
1088 switch (req->cmd) {
1089 case TIPC_CMD_GET_BEARER_NAMES:
1090 case TIPC_CMD_ENABLE_BEARER:
1091 case TIPC_CMD_DISABLE_BEARER:
1092 case TIPC_CMD_SHOW_LINK_STATS:
1093 case TIPC_CMD_GET_LINKS:
1094 case TIPC_CMD_SET_LINK_TOL:
1095 case TIPC_CMD_SET_LINK_PRI:
1096 case TIPC_CMD_SET_LINK_WINDOW:
1097 case TIPC_CMD_RESET_LINK_STATS:
1098 case TIPC_CMD_SHOW_NAME_TABLE:
1099 case TIPC_CMD_SHOW_PORTS:
1100 case TIPC_CMD_GET_MEDIA_NAMES:
1101 case TIPC_CMD_GET_NODES:
1102 case TIPC_CMD_SET_NODE_ADDR:
1103 case TIPC_CMD_SET_NETID:
1104 case TIPC_CMD_GET_NETID:
1105 case TIPC_CMD_SHOW_STATS:
1106 return tipc_nl_compat_recv(skb, info);
1107 }
1108
1109 return handle_cmd(skb, info);
1110}
1111
1112static struct genl_family tipc_genl_compat_family = { 1051static struct genl_family tipc_genl_compat_family = {
1113 .id = GENL_ID_GENERATE, 1052 .id = GENL_ID_GENERATE,
1114 .name = TIPC_GENL_NAME, 1053 .name = TIPC_GENL_NAME,
@@ -1121,7 +1060,7 @@ static struct genl_family tipc_genl_compat_family = {
1121static struct genl_ops tipc_genl_compat_ops[] = { 1060static struct genl_ops tipc_genl_compat_ops[] = {
1122 { 1061 {
1123 .cmd = TIPC_GENL_CMD, 1062 .cmd = TIPC_GENL_CMD,
1124 .doit = tipc_nl_compat_tmp_wrap, 1063 .doit = tipc_nl_compat_recv,
1125 }, 1064 },
1126}; 1065};
1127 1066
diff --git a/net/tipc/node.c b/net/tipc/node.c
index ddaa2bbaa35d..86152de8248d 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "core.h" 37#include "core.h"
38#include "config.h" 38#include "link.h"
39#include "node.h" 39#include "node.h"
40#include "name_distr.h" 40#include "name_distr.h"
41#include "socket.h" 41#include "socket.h"
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index e77d738bb771..f73e975af80b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -40,7 +40,6 @@
40#include "name_table.h" 40#include "name_table.h"
41#include "node.h" 41#include "node.h"
42#include "link.h" 42#include "link.h"
43#include "config.h"
44#include "name_distr.h" 43#include "name_distr.h"
45#include "socket.h" 44#include "socket.h"
46 45