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