blob: cad2a611efde4960b1333499094df94c24708ec3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _INET_COMMON_H
3#define _INET_COMMON_H
4
Paolo Abeniaaa5d902018-12-14 11:51:58 +01005#include <linux/indirect_call_wrapper.h>
6
Changli Gao53d31762010-07-10 20:41:06 +00007extern const struct proto_ops inet_stream_ops;
8extern const struct proto_ops inet_dgram_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10/*
11 * INET4 prototypes used by INET6
12 */
13
Arnaldo Carvalho de Melo77d8bf92005-08-09 20:00:51 -070014struct msghdr;
15struct sock;
16struct sockaddr;
17struct socket;
18
Joe Perches1fd51152013-09-21 10:22:41 -070019int inet_release(struct socket *sock);
20int inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
21 int addr_len, int flags);
22int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
Willy Tarreau3979ad72017-01-25 14:42:46 +010023 int addr_len, int flags, int is_sendmsg);
Joe Perches1fd51152013-09-21 10:22:41 -070024int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr,
25 int addr_len, int flags);
David Howellscdfbabf2017-03-09 08:09:05 +000026int inet_accept(struct socket *sock, struct socket *newsock, int flags,
27 bool kern);
Paolo Abenie47309362019-07-03 16:06:52 +020028int inet_send_prepare(struct sock *sk);
Ying Xue1b784142015-03-02 15:37:48 +080029int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size);
Joe Perches1fd51152013-09-21 10:22:41 -070030ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset,
31 size_t size, int flags);
Ying Xue1b784142015-03-02 15:37:48 +080032int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
33 int flags);
Joe Perches1fd51152013-09-21 10:22:41 -070034int inet_shutdown(struct socket *sock, int how);
35int inet_listen(struct socket *sock, int backlog);
36void inet_sock_destruct(struct sock *sk);
37int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
Stanislav Fomichevcb0721c2020-05-08 10:46:10 -070038/* Don't allocate port at this moment, defer to connect. */
39#define BIND_FORCE_ADDRESS_NO_PORT (1 << 0)
40/* Grab and release socket lock. */
41#define BIND_WITH_LOCK (1 << 1)
Stanislav Fomichev8086fba2020-05-08 10:46:11 -070042/* Called from BPF program. */
43#define BIND_FROM_BPF (1 << 2)
Stanislav Fomichev77241212021-01-27 11:31:39 -080044/* Skip CAP_NET_BIND_SERVICE check. */
45#define BIND_NO_CAP_NET_BIND_SERVICE (1 << 3)
Andrey Ignatov3679d582018-03-30 15:08:04 -070046int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
Stanislav Fomichevcb0721c2020-05-08 10:46:10 -070047 u32 flags);
Denys Vlasenko9b2c45d2018-02-12 20:00:20 +010048int inet_getname(struct socket *sock, struct sockaddr *uaddr,
Joe Perches1fd51152013-09-21 10:22:41 -070049 int peer);
50int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
51int inet_ctl_sock_create(struct sock **sk, unsigned short family,
52 unsigned short type, unsigned char protocol,
53 struct net *net);
Willem de Bruijnf4713a32014-11-26 14:53:02 -050054int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,
55 int *addr_len);
Denis V. Lunev56772422008-04-03 14:28:30 -070056
David Millerd4546c22018-06-24 14:13:49 +090057struct sk_buff *inet_gro_receive(struct list_head *head, struct sk_buff *skb);
Tom Herbertb8921ca2016-05-18 09:06:23 -070058int inet_gro_complete(struct sk_buff *skb, int nhoff);
59struct sk_buff *inet_gso_segment(struct sk_buff *skb,
60 netdev_features_t features);
61
Denis V. Lunev56772422008-04-03 14:28:30 -070062static inline void inet_ctl_sock_destroy(struct sock *sk)
63{
Eric Dumazet8fa677d2015-11-02 07:50:07 -080064 if (sk)
65 sock_release(sk->sk_socket);
Denis V. Lunev56772422008-04-03 14:28:30 -070066}
Denis V. Lunev3d58b5f2008-04-03 14:22:32 -070067
Paolo Abeni028e0a42018-12-14 11:51:59 +010068#define indirect_call_gro_receive(f2, f1, cb, head, skb) \
69({ \
70 unlikely(gro_recursion_inc_test(skb)) ? \
71 NAPI_GRO_CB(skb)->flush |= 1, NULL : \
72 INDIRECT_CALL_2(cb, f2, f1, head, skb); \
73})
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#endif