Lines Matching refs:sock

68 #include <net/sock.h>
85 static inline int netlink_is_kernel(struct sock *sk)
133 static int netlink_dump(struct sock *sk, bool lock_taken);
265 struct sock *sk = skb->sk;
289 struct sock *sk = skb->sk;
343 static void netlink_deliver_tap_kernel(struct sock *dst, struct sock *src,
350 static void netlink_overrun(struct sock *sk)
362 static void netlink_rcv_wake(struct sock *sk)
385 static void netlink_skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
394 static void netlink_sock_destruct(struct sock *sk)
510 static struct sock *__netlink_lookup(struct netlink_table *table, u32 portid,
520 static int __netlink_insert(struct netlink_table *table, struct sock *sk)
530 static struct sock *netlink_lookup(struct net *net, int protocol, u32 portid)
533 struct sock *sk;
547 netlink_update_listeners(struct sock *sk)
570 static int netlink_insert(struct sock *sk, u32 portid)
611 static void netlink_remove(struct sock *sk)
638 static int __netlink_create(struct net *net, struct socket *sock,
642 struct sock *sk;
645 sock->ops = &netlink_ops;
651 sock_init_data(sock, sk);
666 static int netlink_create(struct net *net, struct socket *sock, int protocol,
674 void (*release)(struct sock *sock, unsigned long *groups);
677 sock->state = SS_UNCONNECTED;
679 if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
708 err = __netlink_create(net, sock, cb_mutex, protocol, kern);
714 nlk = nlk_sk(sock->sk);
730 struct sock *sk = &nlk->sk;
747 static int netlink_release(struct socket *sock)
749 struct sock *sk = sock->sk;
780 sock->sk = NULL;
831 static int netlink_autobind(struct socket *sock)
833 struct sock *sk = sock->sk;
935 static inline int netlink_allowed(const struct socket *sock, unsigned int flag)
937 return (nl_table[sock->sk->sk_protocol].flags & flag) ||
938 ns_capable(sock_net(sock->sk)->user_ns, CAP_NET_ADMIN);
942 netlink_update_subscriptions(struct sock *sk, unsigned int subscriptions)
953 static int netlink_realloc_groups(struct sock *sk)
987 struct sock *sk)
1000 static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1003 struct sock *sk = sock->sk;
1020 if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
1062 netlink_autobind(sock);
1088 static int netlink_connect(struct socket *sock, struct sockaddr *addr,
1092 struct sock *sk = sock->sk;
1114 !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
1122 err = netlink_autobind(sock);
1135 static int netlink_getname(struct socket *sock, struct sockaddr *addr,
1138 struct sock *sk = sock->sk;
1159 static int netlink_ioctl(struct socket *sock, unsigned int cmd,
1167 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
1169 struct sock *sock;
1172 sock = netlink_lookup(sock_net(ssk), ssk->sk_protocol, portid);
1173 if (!sock)
1177 nlk = nlk_sk(sock);
1179 if (READ_ONCE(sock->sk_state) == NETLINK_CONNECTED &&
1181 sock_put(sock);
1184 return sock;
1187 struct sock *netlink_getsockbyfilp(struct file *filp)
1190 struct sock *sock;
1195 sock = SOCKET_I(inode)->sk;
1196 if (sock->sk_family != AF_NETLINK)
1199 sock_hold(sock);
1200 return sock;
1231 * < 0: error. skb freed, reference to sock dropped.
1235 int netlink_attachskb(struct sock *sk, struct sk_buff *skb,
1236 long *timeo, struct sock *ssk)
1275 static int __netlink_sendskb(struct sock *sk, struct sk_buff *skb)
1286 int netlink_sendskb(struct sock *sk, struct sk_buff *skb)
1294 void netlink_detachskb(struct sock *sk, struct sk_buff *skb)
1323 static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb,
1324 struct sock *ssk)
1344 int netlink_unicast(struct sock *ssk, struct sk_buff *skb,
1347 struct sock *sk;
1380 int netlink_has_listeners(struct sock *sk, unsigned int group)
1405 static int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb)
1419 struct sock *exclude_sk;
1429 int (*tx_filter)(struct sock *dsk, struct sk_buff *skb, void *data);
1433 static void do_one_broadcast(struct sock *sk,
1513 int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
1521 struct sock *sk;
1565 int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 portid,
1574 struct sock *exclude_sk;
1580 static int do_one_set_err(struct sock *sk, struct netlink_set_err_data *p)
1616 int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code)
1620 struct sock *sk;
1653 static int netlink_setsockopt(struct socket *sock, int level, int optname,
1656 struct sock *sk = sock->sk;
1676 if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
1729 static int netlink_getsockopt(struct socket *sock, int level, int optname,
1732 struct sock *sk = sock->sk;
1813 static void netlink_cmsg_listen_all_nsid(struct sock *sk, struct msghdr *msg,
1823 static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
1825 struct sock *sk = sock->sk;
1843 err = scm_send(sock, msg, &scm, true);
1857 !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
1868 err = netlink_autobind(sock);
1912 static int netlink_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
1916 struct sock *sk = sock->sk;
1994 scm_recv(sock, msg, &scm, flags);
2000 static void netlink_data_ready(struct sock *sk)
2011 struct sock *
2015 struct socket *sock;
2016 struct sock *sk;
2027 if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock))
2030 if (__netlink_create(net, sock, cb_mutex, unit, 1) < 0)
2033 sk = sock->sk;
2080 sock_release(sock);
2086 netlink_kernel_release(struct sock *sk)
2095 int __netlink_change_ngroups(struct sock *sk, unsigned int groups)
2130 int netlink_change_ngroups(struct sock *sk, unsigned int groups)
2141 void __netlink_clear_multicast_users(struct sock *ksk, unsigned int group)
2143 struct sock *sk;
2264 static int netlink_dump(struct sock *sk, bool lock_taken)
2400 int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
2406 struct sock *sk;
2592 int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
2714 struct sock *s = v;
2750 ctx.sk = nlk_sk((struct sock *)v);