Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tipc: move and rename the legacy nl api to "nl compat"

The new netlink API is no longer "v2" but rather the standard API and
the legacy API is now "nl compat". We split them into separate
start/stop and put them in different files in order to further
distinguish them.

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>

authored by

Richard Alpe and committed by
David S. Miller
bfb3e5dd c8ac18f2

+130 -76
+2 -2
net/tipc/Makefile
··· 7 7 tipc-y += addr.o bcast.o bearer.o config.o \ 8 8 core.o link.o discover.o msg.o \ 9 9 name_distr.o subscr.o name_table.o net.o \ 10 - netlink.o node.o socket.o log.o eth_media.o \ 11 - server.o 10 + netlink.o netlink_compat.o node.o socket.o log.o eth_media.o \ 11 + server.o socket.o 12 12 13 13 tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o 14 14 tipc-$(CONFIG_SYSCTL) += sysctl.o
+1 -1
net/tipc/bcast.c
··· 810 810 811 811 tipc_bclink_lock(net); 812 812 813 - hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, 813 + hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, 814 814 NLM_F_MULTI, TIPC_NL_LINK_GET); 815 815 if (!hdr) 816 816 return -EMSGSIZE;
+2 -2
net/tipc/bearer.c
··· 658 658 struct nlattr *attrs; 659 659 struct nlattr *prop; 660 660 661 - hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, 661 + hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, 662 662 NLM_F_MULTI, TIPC_NL_BEARER_GET); 663 663 if (!hdr) 664 664 return -EMSGSIZE; ··· 924 924 struct nlattr *attrs; 925 925 struct nlattr *prop; 926 926 927 - hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, 927 + hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, 928 928 NLM_F_MULTI, TIPC_NL_MEDIA_GET); 929 929 if (!hdr) 930 930 return -EMSGSIZE;
+7
net/tipc/core.c
··· 111 111 if (err) 112 112 goto out_netlink; 113 113 114 + err = tipc_netlink_compat_start(); 115 + if (err) 116 + goto out_netlink_compat; 117 + 114 118 err = tipc_socket_init(); 115 119 if (err) 116 120 goto out_socket; ··· 140 136 out_sysctl: 141 137 tipc_socket_stop(); 142 138 out_socket: 139 + tipc_netlink_compat_stop(); 140 + out_netlink_compat: 143 141 tipc_netlink_stop(); 144 142 out_netlink: 145 143 pr_err("Unable to start in single node mode\n"); ··· 152 146 { 153 147 tipc_bearer_cleanup(); 154 148 tipc_netlink_stop(); 149 + tipc_netlink_compat_stop(); 155 150 tipc_socket_stop(); 156 151 tipc_unregister_sysctl(); 157 152 unregister_pernet_subsys(&tipc_net_ops);
-1
net/tipc/core.h
··· 115 115 #define tipc_register_sysctl() 0 116 116 #define tipc_unregister_sysctl() 117 117 #endif 118 - 119 118 #endif
+1 -1
net/tipc/link.c
··· 2498 2498 struct nlattr *prop; 2499 2499 struct tipc_net *tn = net_generic(net, tipc_net_id); 2500 2500 2501 - hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, 2501 + hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, 2502 2502 NLM_F_MULTI, TIPC_NL_LINK_GET); 2503 2503 if (!hdr) 2504 2504 return -EMSGSIZE;
+1 -1
net/tipc/name_table.c
··· 1055 1055 *last_publ = p->key; 1056 1056 1057 1057 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, 1058 - &tipc_genl_v2_family, NLM_F_MULTI, 1058 + &tipc_genl_family, NLM_F_MULTI, 1059 1059 TIPC_NL_NAME_TABLE_GET); 1060 1060 if (!hdr) 1061 1061 return -EMSGSIZE;
+1 -1
net/tipc/net.c
··· 156 156 void *hdr; 157 157 struct nlattr *attrs; 158 158 159 - hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, 159 + hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, 160 160 NLM_F_MULTI, TIPC_NL_NET_GET); 161 161 if (!hdr) 162 162 return -EMSGSIZE;
+4 -63
net/tipc/netlink.c
··· 35 35 */ 36 36 37 37 #include "core.h" 38 - #include "config.h" 39 38 #include "socket.h" 40 39 #include "name_table.h" 41 40 #include "bearer.h" ··· 42 43 #include "node.h" 43 44 #include "net.h" 44 45 #include <net/genetlink.h> 45 - 46 - static int handle_cmd(struct sk_buff *skb, struct genl_info *info) 47 - { 48 - struct net *net = genl_info_net(info); 49 - struct sk_buff *rep_buf; 50 - struct nlmsghdr *rep_nlh; 51 - struct nlmsghdr *req_nlh = info->nlhdr; 52 - struct tipc_genlmsghdr *req_userhdr = info->userhdr; 53 - int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN); 54 - u16 cmd; 55 - 56 - if ((req_userhdr->cmd & 0xC000) && 57 - (!netlink_net_capable(skb, CAP_NET_ADMIN))) 58 - cmd = TIPC_CMD_NOT_NET_ADMIN; 59 - else 60 - cmd = req_userhdr->cmd; 61 - 62 - rep_buf = tipc_cfg_do_cmd(net, req_userhdr->dest, cmd, 63 - nlmsg_data(req_nlh) + GENL_HDRLEN + 64 - TIPC_GENL_HDRLEN, 65 - nlmsg_attrlen(req_nlh, GENL_HDRLEN + 66 - TIPC_GENL_HDRLEN), hdr_space); 67 - 68 - if (rep_buf) { 69 - skb_push(rep_buf, hdr_space); 70 - rep_nlh = nlmsg_hdr(rep_buf); 71 - memcpy(rep_nlh, req_nlh, hdr_space); 72 - rep_nlh->nlmsg_len = rep_buf->len; 73 - genlmsg_unicast(net, rep_buf, NETLINK_CB(skb).portid); 74 - } 75 - 76 - return 0; 77 - } 78 46 79 47 static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = { 80 48 [TIPC_NLA_UNSPEC] = { .type = NLA_UNSPEC, }, ··· 55 89 [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, } 56 90 }; 57 91 58 - /* Legacy ASCII API */ 59 - static struct genl_family tipc_genl_family = { 60 - .id = GENL_ID_GENERATE, 61 - .name = TIPC_GENL_NAME, 62 - .version = TIPC_GENL_VERSION, 63 - .hdrsize = TIPC_GENL_HDRLEN, 64 - .maxattr = 0, 65 - .netnsok = true, 66 - }; 67 - 68 - /* Legacy ASCII API */ 69 - static struct genl_ops tipc_genl_ops[] = { 70 - { 71 - .cmd = TIPC_GENL_CMD, 72 - .doit = handle_cmd, 73 - }, 74 - }; 75 - 76 92 /* Users of the legacy API (tipc-config) can't handle that we add operations, 77 93 * so we have a separate genl handling for the new API. 78 94 */ 79 - struct genl_family tipc_genl_v2_family = { 95 + struct genl_family tipc_genl_family = { 80 96 .id = GENL_ID_GENERATE, 81 97 .name = TIPC_GENL_V2_NAME, 82 98 .version = TIPC_GENL_V2_VERSION, ··· 150 202 151 203 int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr) 152 204 { 153 - u32 maxattr = tipc_genl_v2_family.maxattr; 205 + u32 maxattr = tipc_genl_family.maxattr; 154 206 155 - *attr = tipc_genl_v2_family.attrbuf; 207 + *attr = tipc_genl_family.attrbuf; 156 208 if (!*attr) 157 209 return -EOPNOTSUPP; 158 210 ··· 163 215 { 164 216 int res; 165 217 166 - res = genl_register_family_with_ops(&tipc_genl_family, tipc_genl_ops); 167 - if (res) { 168 - pr_err("Failed to register legacy interface\n"); 169 - return res; 170 - } 171 - 172 - res = genl_register_family_with_ops(&tipc_genl_v2_family, 218 + res = genl_register_family_with_ops(&tipc_genl_family, 173 219 tipc_genl_v2_ops); 174 220 if (res) { 175 221 pr_err("Failed to register netlink interface\n"); ··· 175 233 void tipc_netlink_stop(void) 176 234 { 177 235 genl_unregister_family(&tipc_genl_family); 178 - genl_unregister_family(&tipc_genl_v2_family); 179 236 }
+3 -1
net/tipc/netlink.h
··· 36 36 #ifndef _TIPC_NETLINK_H 37 37 #define _TIPC_NETLINK_H 38 38 39 - extern struct genl_family tipc_genl_v2_family; 39 + extern struct genl_family tipc_genl_family; 40 40 int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***buf); 41 41 42 42 struct tipc_nl_msg { ··· 46 46 }; 47 47 48 48 int tipc_netlink_start(void); 49 + int tipc_netlink_compat_start(void); 49 50 void tipc_netlink_stop(void); 51 + void tipc_netlink_compat_stop(void); 50 52 51 53 #endif
+1 -1
net/tipc/node.c
··· 623 623 void *hdr; 624 624 struct nlattr *attrs; 625 625 626 - hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, 626 + hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, 627 627 NLM_F_MULTI, TIPC_NL_NODE_GET); 628 628 if (!hdr) 629 629 return -EMSGSIZE;
+2 -2
net/tipc/socket.c
··· 2783 2783 struct tipc_net *tn = net_generic(net, tipc_net_id); 2784 2784 2785 2785 hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, 2786 - &tipc_genl_v2_family, NLM_F_MULTI, TIPC_NL_SOCK_GET); 2786 + &tipc_genl_family, NLM_F_MULTI, TIPC_NL_SOCK_GET); 2787 2787 if (!hdr) 2788 2788 goto msg_cancel; 2789 2789 ··· 2864 2864 struct nlattr *attrs; 2865 2865 2866 2866 hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, 2867 - &tipc_genl_v2_family, NLM_F_MULTI, TIPC_NL_PUBL_GET); 2867 + &tipc_genl_family, NLM_F_MULTI, TIPC_NL_PUBL_GET); 2868 2868 if (!hdr) 2869 2869 goto msg_cancel; 2870 2870