Skip to content

Commit 49cc66e

Browse files
Richard Alpedavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Jon Maloy <[email protected]> Acked-by: Parthasarathy Bhuvaragan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8dfd329 commit 49cc66e

File tree

9 files changed

+85
-74
lines changed

9 files changed

+85
-74
lines changed

net/tipc/bearer.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "link.h"
4141
#include "discover.h"
4242
#include "bcast.h"
43+
#include "netlink.h"
4344

4445
#define MAX_ADDR_STR 60
4546

@@ -54,23 +55,6 @@ static struct tipc_media * const media_info_array[] = {
5455
NULL
5556
};
5657

57-
static const struct nla_policy
58-
tipc_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-
68-
static 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-
7458
static void bearer_disable(struct net *net, struct tipc_bearer *b);
7559

7660
/**

net/tipc/link.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,6 @@ struct tipc_link {
192192
static const char *link_co_err = "Link tunneling error, ";
193193
static const char *link_rst_msg = "Resetting link ";
194194

195-
/* Properties valid for media, bearar and link */
196-
static 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-
203195
/* Send states for broadcast NACKs
204196
*/
205197
enum {

net/tipc/name_table.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@
4747

4848
#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
4949

50-
static const struct nla_policy
51-
tipc_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-
5650
/**
5751
* struct name_info - name sequence publication info
5852
* @node_list: circular list of publications made by own node

net/tipc/net.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@
4141
#include "socket.h"
4242
#include "node.h"
4343
#include "bcast.h"
44-
45-
static 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-
};
44+
#include "netlink.h"
4945

5046
/*
5147
* The TIPC locking policy is designed to ensure a very fine locking

net/tipc/netlink.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,75 @@ static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
5555
[TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, }
5656
};
5757

58+
const struct nla_policy
59+
tipc_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+
64+
const 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+
72+
const 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+
77+
const 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+
91+
const 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 */
98+
const 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+
105+
const 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+
113+
const 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+
119+
const 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+
58127
/* Users of the legacy API (tipc-config) can't handle that we add operations,
59128
* so we have a separate genl handling for the new API.
60129
*/

net/tipc/netlink.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#ifndef _TIPC_NETLINK_H
3737
#define _TIPC_NETLINK_H
38+
#include <net/netlink.h>
3839

3940
extern struct genl_family tipc_genl_family;
4041
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***buf);
@@ -45,6 +46,16 @@ struct tipc_nl_msg {
4546
u32 seq;
4647
};
4748

49+
extern const struct nla_policy tipc_nl_name_table_policy[];
50+
extern const struct nla_policy tipc_nl_sock_policy[];
51+
extern const struct nla_policy tipc_nl_net_policy[];
52+
extern const struct nla_policy tipc_nl_link_policy[];
53+
extern const struct nla_policy tipc_nl_node_policy[];
54+
extern const struct nla_policy tipc_nl_prop_policy[];
55+
extern const struct nla_policy tipc_nl_bearer_policy[];
56+
extern const struct nla_policy tipc_nl_media_policy[];
57+
extern const struct nla_policy tipc_nl_udp_policy[];
58+
4859
int tipc_netlink_start(void);
4960
int tipc_netlink_compat_start(void);
5061
void tipc_netlink_stop(void);

net/tipc/node.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "socket.h"
4242
#include "bcast.h"
4343
#include "discover.h"
44+
#include "netlink.h"
4445

4546
#define INVALID_NODE_SIG 0x10000
4647

@@ -164,28 +165,6 @@ struct tipc_sock_conn {
164165
struct list_head list;
165166
};
166167

167-
static 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-
183-
static 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-
189168
static struct tipc_link *node_active_link(struct tipc_node *n, int sel)
190169
{
191170
int bearer_id = n->active_links[sel & 1];

net/tipc/socket.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "name_distr.h"
4343
#include "socket.h"
4444
#include "bcast.h"
45+
#include "netlink.h"
4546

4647
#define SS_LISTENING -1 /* socket is listening */
4748
#define SS_READY -2 /* socket is connectionless */
@@ -126,14 +127,6 @@ static const struct proto_ops stream_ops;
126127
static const struct proto_ops msg_ops;
127128
static struct proto tipc_proto;
128129

129-
static 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-
137130
static const struct rhashtable_params tsk_rht_params;
138131

139132
/*

net/tipc/udp_media.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,13 @@
4848
#include <linux/tipc_netlink.h>
4949
#include "core.h"
5050
#include "bearer.h"
51+
#include "netlink.h"
5152

5253
/* IANA assigned UDP port */
5354
#define UDP_PORT_DEFAULT 6118
5455

5556
#define UDP_MIN_HEADROOM 28
5657

57-
static 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-
6558
/**
6659
* struct udp_media_addr - IP/UDP addressing information
6760
*

0 commit comments

Comments
 (0)