diff options
author | Richard Alpe <richard.alpe@ericsson.com> | 2015-02-09 03:50:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-09 16:20:49 -0500 |
commit | 22ae7cff509f3bb22caaa0003f67eeb93d338fed (patch) | |
tree | 2d3ee4ec9044797f4520e14c5b34e3605c5ce9fa /net/tipc/netlink_compat.c | |
parent | 5a81a6377b6083fccffdfb7a21ec080b8d58475b (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/netlink_compat.c')
-rw-r--r-- | net/tipc/netlink_compat.c | 73 |
1 files changed, 6 insertions, 67 deletions
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 | ||
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 | |||
1112 | static struct genl_family tipc_genl_compat_family = { | 1051 | static 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 = { | |||
1121 | static struct genl_ops tipc_genl_compat_ops[] = { | 1060 | static 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 | ||