aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2011-12-22 03:52:02 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-22 22:37:19 -0500
commitb57ef81ff8ffb830e1b3e404d692e55161992d27 (patch)
tree4c14d18425e3c1f7185677e6f2b618ac4de14a7e /net/netlink
parent65c64ce8ee642eb330a4c4d94b664725f2902b44 (diff)
netlink: af_netlink cleanup (v2)
Don't inline functions that cover several lines, and do inline the trivial ones. Also make some arguments const. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r--net/netlink/af_netlink.c30
-rw-r--r--net/netlink/genetlink.c2
2 files changed, 14 insertions, 18 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 1201b6d4183d..a0abfe0a537c 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -98,7 +98,7 @@ static inline struct netlink_sock *nlk_sk(struct sock *sk)
98 return container_of(sk, struct netlink_sock, sk); 98 return container_of(sk, struct netlink_sock, sk);
99} 99}
100 100
101static inline int netlink_is_kernel(struct sock *sk) 101static inline int netlink_is_kernel(const struct sock *sk)
102{ 102{
103 return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET; 103 return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET;
104} 104}
@@ -139,12 +139,12 @@ static atomic_t nl_table_users = ATOMIC_INIT(0);
139 139
140static ATOMIC_NOTIFIER_HEAD(netlink_chain); 140static ATOMIC_NOTIFIER_HEAD(netlink_chain);
141 141
142static u32 netlink_group_mask(u32 group) 142static inline u32 netlink_group_mask(u32 group)
143{ 143{
144 return group ? 1 << (group - 1) : 0; 144 return group ? 1 << (group - 1) : 0;
145} 145}
146 146
147static struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid) 147static inline struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid)
148{ 148{
149 return &hash->table[jhash_1word(pid, hash->rnd) & hash->mask]; 149 return &hash->table[jhash_1word(pid, hash->rnd) & hash->mask];
150} 150}
@@ -226,8 +226,7 @@ netlink_unlock_table(void)
226 wake_up(&nl_table_wait); 226 wake_up(&nl_table_wait);
227} 227}
228 228
229static inline struct sock *netlink_lookup(struct net *net, int protocol, 229static struct sock *netlink_lookup(struct net *net, int protocol, u32 pid)
230 u32 pid)
231{ 230{
232 struct nl_pid_hash *hash = &nl_table[protocol].hash; 231 struct nl_pid_hash *hash = &nl_table[protocol].hash;
233 struct hlist_head *head; 232 struct hlist_head *head;
@@ -248,7 +247,7 @@ found:
248 return sk; 247 return sk;
249} 248}
250 249
251static inline struct hlist_head *nl_pid_hash_zalloc(size_t size) 250static struct hlist_head *nl_pid_hash_zalloc(size_t size)
252{ 251{
253 if (size <= PAGE_SIZE) 252 if (size <= PAGE_SIZE)
254 return kzalloc(size, GFP_ATOMIC); 253 return kzalloc(size, GFP_ATOMIC);
@@ -258,7 +257,7 @@ static inline struct hlist_head *nl_pid_hash_zalloc(size_t size)
258 get_order(size)); 257 get_order(size));
259} 258}
260 259
261static inline void nl_pid_hash_free(struct hlist_head *table, size_t size) 260static void nl_pid_hash_free(struct hlist_head *table, size_t size)
262{ 261{
263 if (size <= PAGE_SIZE) 262 if (size <= PAGE_SIZE)
264 kfree(table); 263 kfree(table);
@@ -578,7 +577,7 @@ retry:
578 return err; 577 return err;
579} 578}
580 579
581static inline int netlink_capable(struct socket *sock, unsigned int flag) 580static inline int netlink_capable(const struct socket *sock, unsigned int flag)
582{ 581{
583 return (nl_table[sock->sk->sk_protocol].nl_nonroot & flag) || 582 return (nl_table[sock->sk->sk_protocol].nl_nonroot & flag) ||
584 capable(CAP_NET_ADMIN); 583 capable(CAP_NET_ADMIN);
@@ -846,8 +845,7 @@ void netlink_detachskb(struct sock *sk, struct sk_buff *skb)
846 sock_put(sk); 845 sock_put(sk);
847} 846}
848 847
849static inline struct sk_buff *netlink_trim(struct sk_buff *skb, 848static struct sk_buff *netlink_trim(struct sk_buff *skb, gfp_t allocation)
850 gfp_t allocation)
851{ 849{
852 int delta; 850 int delta;
853 851
@@ -871,7 +869,7 @@ static inline struct sk_buff *netlink_trim(struct sk_buff *skb,
871 return skb; 869 return skb;
872} 870}
873 871
874static inline void netlink_rcv_wake(struct sock *sk) 872static void netlink_rcv_wake(struct sock *sk)
875{ 873{
876 struct netlink_sock *nlk = nlk_sk(sk); 874 struct netlink_sock *nlk = nlk_sk(sk);
877 875
@@ -881,7 +879,7 @@ static inline void netlink_rcv_wake(struct sock *sk)
881 wake_up_interruptible(&nlk->wait); 879 wake_up_interruptible(&nlk->wait);
882} 880}
883 881
884static inline int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb) 882static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb)
885{ 883{
886 int ret; 884 int ret;
887 struct netlink_sock *nlk = nlk_sk(sk); 885 struct netlink_sock *nlk = nlk_sk(sk);
@@ -952,8 +950,7 @@ int netlink_has_listeners(struct sock *sk, unsigned int group)
952} 950}
953EXPORT_SYMBOL_GPL(netlink_has_listeners); 951EXPORT_SYMBOL_GPL(netlink_has_listeners);
954 952
955static inline int netlink_broadcast_deliver(struct sock *sk, 953static int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb)
956 struct sk_buff *skb)
957{ 954{
958 struct netlink_sock *nlk = nlk_sk(sk); 955 struct netlink_sock *nlk = nlk_sk(sk);
959 956
@@ -982,7 +979,7 @@ struct netlink_broadcast_data {
982 void *tx_data; 979 void *tx_data;
983}; 980};
984 981
985static inline int do_one_broadcast(struct sock *sk, 982static int do_one_broadcast(struct sock *sk,
986 struct netlink_broadcast_data *p) 983 struct netlink_broadcast_data *p)
987{ 984{
988 struct netlink_sock *nlk = nlk_sk(sk); 985 struct netlink_sock *nlk = nlk_sk(sk);
@@ -1110,8 +1107,7 @@ struct netlink_set_err_data {
1110 int code; 1107 int code;
1111}; 1108};
1112 1109
1113static inline int do_one_set_err(struct sock *sk, 1110static int do_one_set_err(struct sock *sk, struct netlink_set_err_data *p)
1114 struct netlink_set_err_data *p)
1115{ 1111{
1116 struct netlink_sock *nlk = nlk_sk(sk); 1112 struct netlink_sock *nlk = nlk_sk(sk);
1117 int ret = 0; 1113 int ret = 0;
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 28453ae2a97b..21a82410ec7c 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -106,7 +106,7 @@ static struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family)
106/* Of course we are going to have problems once we hit 106/* Of course we are going to have problems once we hit
107 * 2^16 alive types, but that can only happen by year 2K 107 * 2^16 alive types, but that can only happen by year 2K
108*/ 108*/
109static inline u16 genl_generate_id(void) 109static u16 genl_generate_id(void)
110{ 110{
111 static u16 id_gen_idx = GENL_MIN_ID; 111 static u16 id_gen_idx = GENL_MIN_ID;
112 int i; 112 int i;