summaryrefslogtreecommitdiffstats
path: root/net/tipc/netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/netlink.c')
-rw-r--r--net/tipc/netlink.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index ad844d365340..af506ae0a129 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * net/tipc/netlink.c: TIPC configuration handling 2 * net/tipc/netlink.c: TIPC configuration handling
3 * 3 *
4 * Copyright (c) 2005-2006, Ericsson AB 4 * Copyright (c) 2005-2006, 2014, Ericsson AB
5 * Copyright (c) 2005-2007, Wind River Systems 5 * Copyright (c) 2005-2007, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -36,6 +36,7 @@
36 36
37#include "core.h" 37#include "core.h"
38#include "config.h" 38#include "config.h"
39#include "bearer.h"
39#include <net/genetlink.h> 40#include <net/genetlink.h>
40 41
41static int handle_cmd(struct sk_buff *skb, struct genl_info *info) 42static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
@@ -68,6 +69,12 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
68 return 0; 69 return 0;
69} 70}
70 71
72static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
73 [TIPC_NLA_UNSPEC] = { .type = NLA_UNSPEC, },
74 [TIPC_NLA_BEARER] = { .type = NLA_NESTED, },
75};
76
77/* Legacy ASCII API */
71static struct genl_family tipc_genl_family = { 78static struct genl_family tipc_genl_family = {
72 .id = GENL_ID_GENERATE, 79 .id = GENL_ID_GENERATE,
73 .name = TIPC_GENL_NAME, 80 .name = TIPC_GENL_NAME,
@@ -76,6 +83,7 @@ static struct genl_family tipc_genl_family = {
76 .maxattr = 0, 83 .maxattr = 0,
77}; 84};
78 85
86/* Legacy ASCII API */
79static struct genl_ops tipc_genl_ops[] = { 87static struct genl_ops tipc_genl_ops[] = {
80 { 88 {
81 .cmd = TIPC_GENL_CMD, 89 .cmd = TIPC_GENL_CMD,
@@ -83,12 +91,43 @@ static struct genl_ops tipc_genl_ops[] = {
83 }, 91 },
84}; 92};
85 93
94/* Users of the legacy API (tipc-config) can't handle that we add operations,
95 * so we have a separate genl handling for the new API.
96 */
97struct genl_family tipc_genl_v2_family = {
98 .id = GENL_ID_GENERATE,
99 .name = TIPC_GENL_V2_NAME,
100 .version = TIPC_GENL_V2_VERSION,
101 .hdrsize = 0,
102 .maxattr = TIPC_NLA_MAX,
103};
104
105static const struct genl_ops tipc_genl_v2_ops[] = {
106 {
107 .cmd = TIPC_NL_BEARER_DISABLE,
108 .doit = tipc_nl_bearer_disable,
109 .policy = tipc_nl_policy,
110 },
111 {
112 .cmd = TIPC_NL_BEARER_ENABLE,
113 .doit = tipc_nl_bearer_enable,
114 .policy = tipc_nl_policy,
115 }
116};
117
86int tipc_netlink_start(void) 118int tipc_netlink_start(void)
87{ 119{
88 int res; 120 int res;
89 121
90 res = genl_register_family_with_ops(&tipc_genl_family, tipc_genl_ops); 122 res = genl_register_family_with_ops(&tipc_genl_family, tipc_genl_ops);
91 if (res) { 123 if (res) {
124 pr_err("Failed to register legacy interface\n");
125 return res;
126 }
127
128 res = genl_register_family_with_ops(&tipc_genl_v2_family,
129 tipc_genl_v2_ops);
130 if (res) {
92 pr_err("Failed to register netlink interface\n"); 131 pr_err("Failed to register netlink interface\n");
93 return res; 132 return res;
94 } 133 }
@@ -98,4 +137,5 @@ int tipc_netlink_start(void)
98void tipc_netlink_stop(void) 137void tipc_netlink_stop(void)
99{ 138{
100 genl_unregister_family(&tipc_genl_family); 139 genl_unregister_family(&tipc_genl_family);
140 genl_unregister_family(&tipc_genl_v2_family);
101} 141}