[NETNS]: Add namespace parameter to ip_cmsg_send.
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / raw.c
index a3002fe65b7f4a345c1333c4d7f36392bee3b172..7d29a05bf8875c711c7eac13deee3dcd955e32e5 100644 (file)
 #include <linux/netfilter_ipv4.h>
 
 static struct raw_hashinfo raw_v4_hashinfo = {
-       .lock = __RW_LOCK_UNLOCKED(),
+       .lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock),
 };
 
-void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h)
+void raw_hash_sk(struct sock *sk)
 {
+       struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
        struct hlist_head *head;
 
        head = &h->ht[inet_sk(sk)->num & (RAW_HTABLE_SIZE - 1)];
@@ -97,8 +98,10 @@ void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h)
 }
 EXPORT_SYMBOL_GPL(raw_hash_sk);
 
-void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h)
+void raw_unhash_sk(struct sock *sk)
 {
+       struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
+
        write_lock_bh(&h->lock);
        if (sk_del_node_init(sk))
                sock_prot_inuse_add(sk->sk_prot, -1);
@@ -106,16 +109,6 @@ void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h)
 }
 EXPORT_SYMBOL_GPL(raw_unhash_sk);
 
-static void raw_v4_hash(struct sock *sk)
-{
-       raw_hash_sk(sk, &raw_v4_hashinfo);
-}
-
-static void raw_v4_unhash(struct sock *sk)
-{
-       raw_unhash_sk(sk, &raw_v4_hashinfo);
-}
-
 static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
                unsigned short num, __be32 raddr, __be32 laddr, int dif)
 {
@@ -506,7 +499,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        ipc.oif = sk->sk_bound_dev_if;
 
        if (msg->msg_controllen) {
-               err = ip_cmsg_send(msg, &ipc);
+               err = ip_cmsg_send(&init_net, msg, &ipc);
                if (err)
                        goto out;
                if (ipc.opt)
@@ -841,9 +834,10 @@ struct proto raw_prot = {
        .recvmsg           = raw_recvmsg,
        .bind              = raw_bind,
        .backlog_rcv       = raw_rcv_skb,
-       .hash              = raw_v4_hash,
-       .unhash            = raw_v4_unhash,
+       .hash              = raw_hash_sk,
+       .unhash            = raw_unhash_sk,
        .obj_size          = sizeof(struct raw_sock),
+       .h.raw_hash        = &raw_v4_hashinfo,
 #ifdef CONFIG_COMPAT
        .compat_setsockopt = compat_raw_setsockopt,
        .compat_getsockopt = compat_raw_getsockopt,