aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2016-03-04 11:04:42 -0500
committerDavid S. Miller <davem@davemloft.net>2016-03-07 14:56:41 -0500
commit49cc66eaee19e772997b63b057ea4b4bf7d48db0 (patch)
tree94239e052435b3c2d505c8be6e2f7582db5d1da8
parent8dfd329fbc240729938d24bf87aca49ea89289c5 (diff)
tipc: move netlink policies to netlink.c
Make the c files less cluttered and enable netlink attributes to be shared between files. Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Acked-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/tipc/bearer.c18
-rw-r--r--net/tipc/link.c8
-rw-r--r--net/tipc/name_table.c6
-rw-r--r--net/tipc/net.c6
-rw-r--r--net/tipc/netlink.c69
-rw-r--r--net/tipc/netlink.h11
-rw-r--r--net/tipc/node.c23
-rw-r--r--net/tipc/socket.c9
-rw-r--r--net/tipc/udp_media.c9
9 files changed, 85 insertions, 74 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 802ffad3200d..27a5406213c6 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -40,6 +40,7 @@
40#include "link.h" 40#include "link.h"
41#include "discover.h" 41#include "discover.h"
42#include "bcast.h" 42#include "bcast.h"
43#include "netlink.h"
43 44
44#define MAX_ADDR_STR 60 45#define MAX_ADDR_STR 60
45 46
@@ -54,23 +55,6 @@ static struct tipc_media * const media_info_array[] = {
54 NULL 55 NULL
55}; 56};
56 57
57static const struct nla_policy
58tipc_nl_bearer_policy[TIPC_NLA_BEARER_MAX + 1] = {
59 [TIPC_NLA_BEARER_UNSPEC] = { .type = NLA_UNSPEC },
60 [TIPC_NLA_BEARER_NAME] = {
61 .type = NLA_STRING,
62 .len = TIPC_MAX_BEARER_NAME
63 },
64 [TIPC_NLA_BEARER_PROP] = { .type = NLA_NESTED },
65 [TIPC_NLA_BEARER_DOMAIN] = { .type = NLA_U32 }
66};
67
68static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = {
69 [TIPC_NLA_MEDIA_UNSPEC] = { .type = NLA_UNSPEC },
70 [TIPC_NLA_MEDIA_NAME] = { .type = NLA_STRING },
71 [TIPC_NLA_MEDIA_PROP] = { .type = NLA_NESTED }
72};
73
74static void bearer_disable(struct net *net, struct tipc_bearer *b); 58static void bearer_disable(struct net *net, struct tipc_bearer *b);
75 59
76/** 60/**
diff --git a/net/tipc/link.c b/net/tipc/link.c
index fc2fa833749e..7d2bb3e70baa 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -192,14 +192,6 @@ struct tipc_link {
192static const char *link_co_err = "Link tunneling error, "; 192static const char *link_co_err = "Link tunneling error, ";
193static const char *link_rst_msg = "Resetting link "; 193static const char *link_rst_msg = "Resetting link ";
194 194
195/* Properties valid for media, bearar and link */
196static const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
197 [TIPC_NLA_PROP_UNSPEC] = { .type = NLA_UNSPEC },
198 [TIPC_NLA_PROP_PRIO] = { .type = NLA_U32 },
199 [TIPC_NLA_PROP_TOL] = { .type = NLA_U32 },
200 [TIPC_NLA_PROP_WIN] = { .type = NLA_U32 }
201};
202
203/* Send states for broadcast NACKs 195/* Send states for broadcast NACKs
204 */ 196 */
205enum { 197enum {
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 777b979b8463..e190460fe0d3 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -47,12 +47,6 @@
47 47
48#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */ 48#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
49 49
50static const struct nla_policy
51tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
52 [TIPC_NLA_NAME_TABLE_UNSPEC] = { .type = NLA_UNSPEC },
53 [TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED }
54};
55
56/** 50/**
57 * struct name_info - name sequence publication info 51 * struct name_info - name sequence publication info
58 * @node_list: circular list of publications made by own node 52 * @node_list: circular list of publications made by own node
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 86d68b352bd6..28bf4feeb81c 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -41,11 +41,7 @@
41#include "socket.h" 41#include "socket.h"
42#include "node.h" 42#include "node.h"
43#include "bcast.h" 43#include "bcast.h"
44 44#include "netlink.h"
45static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
46 [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
47 [TIPC_NLA_NET_ID] = { .type = NLA_U32 }
48};
49 45
50/* 46/*
51 * The TIPC locking policy is designed to ensure a very fine locking 47 * The TIPC locking policy is designed to ensure a very fine locking
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 8975b0135b76..56935df2167a 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -55,6 +55,75 @@ static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
55 [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, } 55 [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, }
56}; 56};
57 57
58const struct nla_policy
59tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
60 [TIPC_NLA_NAME_TABLE_UNSPEC] = { .type = NLA_UNSPEC },
61 [TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED }
62};
63
64const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
65 [TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC },
66 [TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 },
67 [TIPC_NLA_SOCK_REF] = { .type = NLA_U32 },
68 [TIPC_NLA_SOCK_CON] = { .type = NLA_NESTED },
69 [TIPC_NLA_SOCK_HAS_PUBL] = { .type = NLA_FLAG }
70};
71
72const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
73 [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
74 [TIPC_NLA_NET_ID] = { .type = NLA_U32 }
75};
76
77const struct nla_policy tipc_nl_link_policy[TIPC_NLA_LINK_MAX + 1] = {
78 [TIPC_NLA_LINK_UNSPEC] = { .type = NLA_UNSPEC },
79 [TIPC_NLA_LINK_NAME] = { .type = NLA_STRING,
80 .len = TIPC_MAX_LINK_NAME },
81 [TIPC_NLA_LINK_MTU] = { .type = NLA_U32 },
82 [TIPC_NLA_LINK_BROADCAST] = { .type = NLA_FLAG },
83 [TIPC_NLA_LINK_UP] = { .type = NLA_FLAG },
84 [TIPC_NLA_LINK_ACTIVE] = { .type = NLA_FLAG },
85 [TIPC_NLA_LINK_PROP] = { .type = NLA_NESTED },
86 [TIPC_NLA_LINK_STATS] = { .type = NLA_NESTED },
87 [TIPC_NLA_LINK_RX] = { .type = NLA_U32 },
88 [TIPC_NLA_LINK_TX] = { .type = NLA_U32 }
89};
90
91const struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = {
92 [TIPC_NLA_NODE_UNSPEC] = { .type = NLA_UNSPEC },
93 [TIPC_NLA_NODE_ADDR] = { .type = NLA_U32 },
94 [TIPC_NLA_NODE_UP] = { .type = NLA_FLAG }
95};
96
97/* Properties valid for media, bearer and link */
98const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
99 [TIPC_NLA_PROP_UNSPEC] = { .type = NLA_UNSPEC },
100 [TIPC_NLA_PROP_PRIO] = { .type = NLA_U32 },
101 [TIPC_NLA_PROP_TOL] = { .type = NLA_U32 },
102 [TIPC_NLA_PROP_WIN] = { .type = NLA_U32 }
103};
104
105const struct nla_policy tipc_nl_bearer_policy[TIPC_NLA_BEARER_MAX + 1] = {
106 [TIPC_NLA_BEARER_UNSPEC] = { .type = NLA_UNSPEC },
107 [TIPC_NLA_BEARER_NAME] = { .type = NLA_STRING,
108 .len = TIPC_MAX_BEARER_NAME },
109 [TIPC_NLA_BEARER_PROP] = { .type = NLA_NESTED },
110 [TIPC_NLA_BEARER_DOMAIN] = { .type = NLA_U32 }
111};
112
113const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = {
114 [TIPC_NLA_MEDIA_UNSPEC] = { .type = NLA_UNSPEC },
115 [TIPC_NLA_MEDIA_NAME] = { .type = NLA_STRING },
116 [TIPC_NLA_MEDIA_PROP] = { .type = NLA_NESTED }
117};
118
119const struct nla_policy tipc_nl_udp_policy[TIPC_NLA_UDP_MAX + 1] = {
120 [TIPC_NLA_UDP_UNSPEC] = {.type = NLA_UNSPEC},
121 [TIPC_NLA_UDP_LOCAL] = {.type = NLA_BINARY,
122 .len = sizeof(struct sockaddr_storage)},
123 [TIPC_NLA_UDP_REMOTE] = {.type = NLA_BINARY,
124 .len = sizeof(struct sockaddr_storage)},
125};
126
58/* Users of the legacy API (tipc-config) can't handle that we add operations, 127/* Users of the legacy API (tipc-config) can't handle that we add operations,
59 * so we have a separate genl handling for the new API. 128 * so we have a separate genl handling for the new API.
60 */ 129 */
diff --git a/net/tipc/netlink.h b/net/tipc/netlink.h
index 08a1db67b927..ed1dbcb4afbd 100644
--- a/net/tipc/netlink.h
+++ b/net/tipc/netlink.h
@@ -35,6 +35,7 @@
35 35
36#ifndef _TIPC_NETLINK_H 36#ifndef _TIPC_NETLINK_H
37#define _TIPC_NETLINK_H 37#define _TIPC_NETLINK_H
38#include <net/netlink.h>
38 39
39extern struct genl_family tipc_genl_family; 40extern struct genl_family tipc_genl_family;
40int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***buf); 41int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***buf);
@@ -45,6 +46,16 @@ struct tipc_nl_msg {
45 u32 seq; 46 u32 seq;
46}; 47};
47 48
49extern const struct nla_policy tipc_nl_name_table_policy[];
50extern const struct nla_policy tipc_nl_sock_policy[];
51extern const struct nla_policy tipc_nl_net_policy[];
52extern const struct nla_policy tipc_nl_link_policy[];
53extern const struct nla_policy tipc_nl_node_policy[];
54extern const struct nla_policy tipc_nl_prop_policy[];
55extern const struct nla_policy tipc_nl_bearer_policy[];
56extern const struct nla_policy tipc_nl_media_policy[];
57extern const struct nla_policy tipc_nl_udp_policy[];
58
48int tipc_netlink_start(void); 59int tipc_netlink_start(void);
49int tipc_netlink_compat_start(void); 60int tipc_netlink_compat_start(void);
50void tipc_netlink_stop(void); 61void tipc_netlink_stop(void);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 590d597589cf..ace178fd3850 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -41,6 +41,7 @@
41#include "socket.h" 41#include "socket.h"
42#include "bcast.h" 42#include "bcast.h"
43#include "discover.h" 43#include "discover.h"
44#include "netlink.h"
44 45
45#define INVALID_NODE_SIG 0x10000 46#define INVALID_NODE_SIG 0x10000
46 47
@@ -164,28 +165,6 @@ struct tipc_sock_conn {
164 struct list_head list; 165 struct list_head list;
165}; 166};
166 167
167static const struct nla_policy tipc_nl_link_policy[TIPC_NLA_LINK_MAX + 1] = {
168 [TIPC_NLA_LINK_UNSPEC] = { .type = NLA_UNSPEC },
169 [TIPC_NLA_LINK_NAME] = {
170 .type = NLA_STRING,
171 .len = TIPC_MAX_LINK_NAME
172 },
173 [TIPC_NLA_LINK_MTU] = { .type = NLA_U32 },
174 [TIPC_NLA_LINK_BROADCAST] = { .type = NLA_FLAG },
175 [TIPC_NLA_LINK_UP] = { .type = NLA_FLAG },
176 [TIPC_NLA_LINK_ACTIVE] = { .type = NLA_FLAG },
177 [TIPC_NLA_LINK_PROP] = { .type = NLA_NESTED },
178 [TIPC_NLA_LINK_STATS] = { .type = NLA_NESTED },
179 [TIPC_NLA_LINK_RX] = { .type = NLA_U32 },
180 [TIPC_NLA_LINK_TX] = { .type = NLA_U32 }
181};
182
183static const struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = {
184 [TIPC_NLA_NODE_UNSPEC] = { .type = NLA_UNSPEC },
185 [TIPC_NLA_NODE_ADDR] = { .type = NLA_U32 },
186 [TIPC_NLA_NODE_UP] = { .type = NLA_FLAG }
187};
188
189static struct tipc_link *node_active_link(struct tipc_node *n, int sel) 168static struct tipc_link *node_active_link(struct tipc_node *n, int sel)
190{ 169{
191 int bearer_id = n->active_links[sel & 1]; 170 int bearer_id = n->active_links[sel & 1];
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 69c29050f14a..56b8a96c2257 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -42,6 +42,7 @@
42#include "name_distr.h" 42#include "name_distr.h"
43#include "socket.h" 43#include "socket.h"
44#include "bcast.h" 44#include "bcast.h"
45#include "netlink.h"
45 46
46#define SS_LISTENING -1 /* socket is listening */ 47#define SS_LISTENING -1 /* socket is listening */
47#define SS_READY -2 /* socket is connectionless */ 48#define SS_READY -2 /* socket is connectionless */
@@ -126,14 +127,6 @@ static const struct proto_ops stream_ops;
126static const struct proto_ops msg_ops; 127static const struct proto_ops msg_ops;
127static struct proto tipc_proto; 128static struct proto tipc_proto;
128 129
129static const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
130 [TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC },
131 [TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 },
132 [TIPC_NLA_SOCK_REF] = { .type = NLA_U32 },
133 [TIPC_NLA_SOCK_CON] = { .type = NLA_NESTED },
134 [TIPC_NLA_SOCK_HAS_PUBL] = { .type = NLA_FLAG }
135};
136
137static const struct rhashtable_params tsk_rht_params; 130static const struct rhashtable_params tsk_rht_params;
138 131
139/* 132/*
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index fb2f7ec68eef..49b3c2ede7ab 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -48,20 +48,13 @@
48#include <linux/tipc_netlink.h> 48#include <linux/tipc_netlink.h>
49#include "core.h" 49#include "core.h"
50#include "bearer.h" 50#include "bearer.h"
51#include "netlink.h"
51 52
52/* IANA assigned UDP port */ 53/* IANA assigned UDP port */
53#define UDP_PORT_DEFAULT 6118 54#define UDP_PORT_DEFAULT 6118
54 55
55#define UDP_MIN_HEADROOM 28 56#define UDP_MIN_HEADROOM 28
56 57
57static const struct nla_policy tipc_nl_udp_policy[TIPC_NLA_UDP_MAX + 1] = {
58 [TIPC_NLA_UDP_UNSPEC] = {.type = NLA_UNSPEC},
59 [TIPC_NLA_UDP_LOCAL] = {.type = NLA_BINARY,
60 .len = sizeof(struct sockaddr_storage)},
61 [TIPC_NLA_UDP_REMOTE] = {.type = NLA_BINARY,
62 .len = sizeof(struct sockaddr_storage)},
63};
64
65/** 58/**
66 * struct udp_media_addr - IP/UDP addressing information 59 * struct udp_media_addr - IP/UDP addressing information
67 * 60 *