Skip to content

Commit 22ae7cf

Browse files
Richard Alpedavem330
authored andcommitted
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>
1 parent 5a81a63 commit 22ae7cf

12 files changed

Lines changed: 13 additions & 301 deletions

File tree

‎net/tipc/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
obj-$(CONFIG_TIPC) := tipc.o
66

7-
tipc-y += addr.o bcast.o bearer.o config.o \
7+
tipc-y += addr.o bcast.o bearer.o \
88
core.o link.o discover.o msg.o \
99
name_distr.o subscr.o name_table.o net.o \
1010
netlink.o netlink_compat.o node.o socket.o log.o eth_media.o \

‎net/tipc/bearer.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
#include <net/sock.h>
3838
#include "core.h"
39-
#include "config.h"
4039
#include "bearer.h"
4140
#include "link.h"
4241
#include "discover.h"

‎net/tipc/config.c‎

Lines changed: 0 additions & 157 deletions
This file was deleted.

‎net/tipc/config.h‎

Lines changed: 0 additions & 67 deletions
This file was deleted.

‎net/tipc/core.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
#include "core.h"
4040
#include "name_table.h"
4141
#include "subscr.h"
42-
#include "config.h"
42+
#include "bearer.h"
43+
#include "net.h"
4344
#include "socket.h"
4445

4546
#include <linux/module.h>

‎net/tipc/link.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "socket.h"
4141
#include "name_distr.h"
4242
#include "discover.h"
43-
#include "config.h"
4443
#include "netlink.h"
4544

4645
#include <linux/pkt_sched.h>

‎net/tipc/log.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
*/
3636

3737
#include "core.h"
38-
#include "config.h"
3938

4039
/**
4140
* tipc_snprintf - append formatted output to print buffer

‎net/tipc/name_table.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636

3737
#include <net/sock.h>
3838
#include "core.h"
39-
#include "config.h"
39+
#include "netlink.h"
4040
#include "name_table.h"
4141
#include "name_distr.h"
4242
#include "subscr.h"
4343
#include "bcast.h"
44+
#include "addr.h"
45+
#include <net/genetlink.h>
4446

4547
#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
4648

‎net/tipc/net.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
#include "subscr.h"
4141
#include "socket.h"
4242
#include "node.h"
43-
#include "config.h"
44-
#include "bcast.h"
4543

4644
static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
4745
[TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },

‎net/tipc/netlink_compat.c‎

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
*/
3333

3434
#include "core.h"
35-
#include "config.h"
3635
#include "bearer.h"
3736
#include "link.h"
3837
#include "name_table.h"
@@ -909,6 +908,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
909908
memset(&doit, 0, sizeof(doit));
910909

911910
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;
912916
case TIPC_CMD_GET_BEARER_NAMES:
913917
msg->rep_size = MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME);
914918
dump.dumpit = tipc_nl_bearer_dump;
@@ -1044,71 +1048,6 @@ static int tipc_nl_compat_recv(struct sk_buff *skb, struct genl_info *info)
10441048
return err;
10451049
}
10461050

1047-
static 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-
*/
1084-
static 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-
11121051
static struct genl_family tipc_genl_compat_family = {
11131052
.id = GENL_ID_GENERATE,
11141053
.name = TIPC_GENL_NAME,
@@ -1121,7 +1060,7 @@ static struct genl_family tipc_genl_compat_family = {
11211060
static struct genl_ops tipc_genl_compat_ops[] = {
11221061
{
11231062
.cmd = TIPC_GENL_CMD,
1124-
.doit = tipc_nl_compat_tmp_wrap,
1063+
.doit = tipc_nl_compat_recv,
11251064
},
11261065
};
11271066

0 commit comments

Comments
 (0)