| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _INET_COMMON_H |
| 3 | #define _INET_COMMON_H |
| 4 | |
| 5 | #include <linux/indirect_call_wrapper.h> |
| 6 | #include <linux/net.h> |
| 7 | #include <linux/netdev_features.h> |
| 8 | #include <linux/types.h> |
| 9 | #include <net/sock.h> |
| 10 | |
| 11 | extern const struct proto_ops inet_stream_ops; |
| 12 | extern const struct proto_ops inet_dgram_ops; |
| 13 | |
| 14 | /* |
| 15 | * INET4 prototypes used by INET6 |
| 16 | */ |
| 17 | |
| 18 | struct msghdr; |
| 19 | struct net; |
| 20 | struct page; |
| 21 | struct sock; |
| 22 | struct socket; |
| 23 | |
| 24 | int inet_release(struct socket *sock); |
| 25 | int inet_stream_connect(struct socket *sock, struct sockaddr_unsized *uaddr, |
| 26 | int addr_len, int flags); |
| 27 | int __inet_stream_connect(struct socket *sock, struct sockaddr_unsized *uaddr, |
| 28 | int addr_len, int flags, int is_sendmsg); |
| 29 | int inet_dgram_connect(struct socket *sock, struct sockaddr_unsized *uaddr, |
| 30 | int addr_len, int flags); |
| 31 | int inet_accept(struct socket *sock, struct socket *newsock, |
| 32 | struct proto_accept_arg *arg); |
| 33 | void __inet_accept(struct socket *sock, struct socket *newsock, |
| 34 | struct sock *newsk); |
| 35 | int inet_send_prepare(struct sock *sk); |
| 36 | int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size); |
| 37 | void inet_splice_eof(struct socket *sock); |
| 38 | int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, |
| 39 | int flags); |
| 40 | int inet_shutdown(struct socket *sock, int how); |
| 41 | int inet_listen(struct socket *sock, int backlog); |
| 42 | int __inet_listen_sk(struct sock *sk, int backlog); |
| 43 | void inet_sock_destruct(struct sock *sk); |
| 44 | int inet_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int addr_len); |
| 45 | int inet_bind_sk(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len); |
| 46 | /* Don't allocate port at this moment, defer to connect. */ |
| 47 | #define BIND_FORCE_ADDRESS_NO_PORT (1 << 0) |
| 48 | /* Grab and release socket lock. */ |
| 49 | #define BIND_WITH_LOCK (1 << 1) |
| 50 | /* Called from BPF program. */ |
| 51 | #define BIND_FROM_BPF (1 << 2) |
| 52 | /* Skip CAP_NET_BIND_SERVICE check. */ |
| 53 | #define BIND_NO_CAP_NET_BIND_SERVICE (1 << 3) |
| 54 | int __inet_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len, |
| 55 | u32 flags); |
| 56 | int inet_getname(struct socket *sock, struct sockaddr *uaddr, |
| 57 | int peer); |
| 58 | int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); |
| 59 | int inet_ctl_sock_create(struct sock **sk, unsigned short family, |
| 60 | unsigned short type, unsigned char protocol, |
| 61 | struct net *net); |
| 62 | int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, |
| 63 | int *addr_len); |
| 64 | |
| 65 | struct sk_buff *inet_gro_receive(struct list_head *head, struct sk_buff *skb); |
| 66 | int inet_gro_complete(struct sk_buff *skb, int nhoff); |
| 67 | struct sk_buff *inet_gso_segment(struct sk_buff *skb, |
| 68 | netdev_features_t features); |
| 69 | |
| 70 | static inline void inet_ctl_sock_destroy(struct sock *sk) |
| 71 | { |
| 72 | if (sk) |
| 73 | sock_release(sock: sk->sk_socket); |
| 74 | } |
| 75 | |
| 76 | #define indirect_call_gro_receive(f2, f1, cb, head, skb) \ |
| 77 | ({ \ |
| 78 | unlikely(gro_recursion_inc_test(skb)) ? \ |
| 79 | NAPI_GRO_CB(skb)->flush |= 1, NULL : \ |
| 80 | INDIRECT_CALL_2(cb, f2, f1, head, skb); \ |
| 81 | }) |
| 82 | |
| 83 | #endif |
| 84 | |