Skip to content

Commit

Permalink
netlink: af_netlink cleanup (v2)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stephen hemminger authored and David S. Miller committed Dec 23, 2011
1 parent 65c64ce commit b57ef81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
30 changes: 13 additions & 17 deletions net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static inline struct netlink_sock *nlk_sk(struct sock *sk)
return container_of(sk, struct netlink_sock, sk);
}

static inline int netlink_is_kernel(struct sock *sk)
static inline int netlink_is_kernel(const struct sock *sk)
{
return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET;
}
Expand Down Expand Up @@ -139,12 +139,12 @@ static atomic_t nl_table_users = ATOMIC_INIT(0);

static ATOMIC_NOTIFIER_HEAD(netlink_chain);

static u32 netlink_group_mask(u32 group)
static inline u32 netlink_group_mask(u32 group)
{
return group ? 1 << (group - 1) : 0;
}

static struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid)
static inline struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid)
{
return &hash->table[jhash_1word(pid, hash->rnd) & hash->mask];
}
Expand Down Expand Up @@ -226,8 +226,7 @@ netlink_unlock_table(void)
wake_up(&nl_table_wait);
}

static inline struct sock *netlink_lookup(struct net *net, int protocol,
u32 pid)
static struct sock *netlink_lookup(struct net *net, int protocol, u32 pid)
{
struct nl_pid_hash *hash = &nl_table[protocol].hash;
struct hlist_head *head;
Expand All @@ -248,7 +247,7 @@ static inline struct sock *netlink_lookup(struct net *net, int protocol,
return sk;
}

static inline struct hlist_head *nl_pid_hash_zalloc(size_t size)
static struct hlist_head *nl_pid_hash_zalloc(size_t size)
{
if (size <= PAGE_SIZE)
return kzalloc(size, GFP_ATOMIC);
Expand All @@ -258,7 +257,7 @@ static inline struct hlist_head *nl_pid_hash_zalloc(size_t size)
get_order(size));
}

static inline void nl_pid_hash_free(struct hlist_head *table, size_t size)
static void nl_pid_hash_free(struct hlist_head *table, size_t size)
{
if (size <= PAGE_SIZE)
kfree(table);
Expand Down Expand Up @@ -578,7 +577,7 @@ static int netlink_autobind(struct socket *sock)
return err;
}

static inline int netlink_capable(struct socket *sock, unsigned int flag)
static inline int netlink_capable(const struct socket *sock, unsigned int flag)
{
return (nl_table[sock->sk->sk_protocol].nl_nonroot & flag) ||
capable(CAP_NET_ADMIN);
Expand Down Expand Up @@ -846,8 +845,7 @@ void netlink_detachskb(struct sock *sk, struct sk_buff *skb)
sock_put(sk);
}

static inline struct sk_buff *netlink_trim(struct sk_buff *skb,
gfp_t allocation)
static struct sk_buff *netlink_trim(struct sk_buff *skb, gfp_t allocation)
{
int delta;

Expand All @@ -871,7 +869,7 @@ static inline struct sk_buff *netlink_trim(struct sk_buff *skb,
return skb;
}

static inline void netlink_rcv_wake(struct sock *sk)
static void netlink_rcv_wake(struct sock *sk)
{
struct netlink_sock *nlk = nlk_sk(sk);

Expand All @@ -881,7 +879,7 @@ static inline void netlink_rcv_wake(struct sock *sk)
wake_up_interruptible(&nlk->wait);
}

static inline int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb)
static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb)
{
int ret;
struct netlink_sock *nlk = nlk_sk(sk);
Expand Down Expand Up @@ -952,8 +950,7 @@ int netlink_has_listeners(struct sock *sk, unsigned int group)
}
EXPORT_SYMBOL_GPL(netlink_has_listeners);

static inline int netlink_broadcast_deliver(struct sock *sk,
struct sk_buff *skb)
static int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb)
{
struct netlink_sock *nlk = nlk_sk(sk);

Expand Down Expand Up @@ -982,7 +979,7 @@ struct netlink_broadcast_data {
void *tx_data;
};

static inline int do_one_broadcast(struct sock *sk,
static int do_one_broadcast(struct sock *sk,
struct netlink_broadcast_data *p)
{
struct netlink_sock *nlk = nlk_sk(sk);
Expand Down Expand Up @@ -1110,8 +1107,7 @@ struct netlink_set_err_data {
int code;
};

static inline int do_one_set_err(struct sock *sk,
struct netlink_set_err_data *p)
static int do_one_set_err(struct sock *sk, struct netlink_set_err_data *p)
{
struct netlink_sock *nlk = nlk_sk(sk);
int ret = 0;
Expand Down
2 changes: 1 addition & 1 deletion net/netlink/genetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family)
/* Of course we are going to have problems once we hit
* 2^16 alive types, but that can only happen by year 2K
*/
static inline u16 genl_generate_id(void)
static u16 genl_generate_id(void)
{
static u16 id_gen_idx = GENL_MIN_ID;
int i;
Expand Down

0 comments on commit b57ef81

Please sign in to comment.