From 87d308708712ff6075c4dd54b0519b47fdad8816 Mon Sep 17 00:00:00 2001 From: Oleksandr Suvorov Date: Thu, 26 Mar 2020 12:44:27 +0200 Subject: Backports v5.4.27 Backports generated by toradex backports f6e8852f1ef28e6d3c9bae8400eb6a87a6b0c3e7 against mainline kernel tag v5.4.27 Signed-off-by: Oleksandr Suvorov --- backport-include/net/sock.h | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 backport-include/net/sock.h (limited to 'backport-include/net/sock.h') diff --git a/backport-include/net/sock.h b/backport-include/net/sock.h new file mode 100644 index 0000000..39bf008 --- /dev/null +++ b/backport-include/net/sock.h @@ -0,0 +1,78 @@ +#ifndef __BACKPORT_NET_SOCK_H +#define __BACKPORT_NET_SOCK_H +#include_next +#include + +#if LINUX_VERSION_IS_LESS(3,9,0) +#include + +#define sk_for_each3(__sk, node, list) \ + hlist_for_each_entry(__sk, node, list, sk_node) + +#define sk_for_each_safe4(__sk, node, tmp, list) \ + hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node) + +#define sk_for_each2(__sk, list) \ + hlist_for_each_entry(__sk, list, sk_node) + +#define sk_for_each_safe3(__sk, tmp, list) \ + hlist_for_each_entry_safe(__sk, tmp, list, sk_node) + +#undef sk_for_each +#define sk_for_each(...) \ + macro_dispatcher(sk_for_each, __VA_ARGS__)(__VA_ARGS__) +#undef sk_for_each_safe +#define sk_for_each_safe(...) \ + macro_dispatcher(sk_for_each_safe, __VA_ARGS__)(__VA_ARGS__) + +#endif + +#if LINUX_VERSION_IS_LESS(3,10,0) +/* + * backport SOCK_SELECT_ERR_QUEUE -- see commit + * "net: add option to enable error queue packets waking select" + * + * Adding 14 to SOCK_QUEUE_SHRUNK will reach a bet that can't be + * set on older kernels, so sock_flag() will always return false. + */ +#define SOCK_SELECT_ERR_QUEUE (SOCK_QUEUE_SHRUNK + 14) +#endif + +#ifndef sock_skb_cb_check_size +#define sock_skb_cb_check_size(size) \ + BUILD_BUG_ON((size) > FIELD_SIZEOF(struct sk_buff, cb)) +#endif + +#if LINUX_VERSION_IS_LESS(4,2,0) +#define sk_alloc(net, family, priority, prot, kern) sk_alloc(net, family, priority, prot) +#endif + +#if LINUX_VERSION_IS_LESS(4,5,0) +#define sk_set_bit LINUX_BACKPORT(sk_set_bit) +static inline void sk_set_bit(int nr, struct sock *sk) +{ + set_bit(nr, &sk->sk_socket->flags); +} +#endif /* < 4.5 */ + +#if LINUX_VERSION_IS_LESS(4,5,0) +#define sk_clear_bit LINUX_BACKPORT(sk_clear_bit) +static inline void sk_clear_bit(int nr, struct sock *sk) +{ + clear_bit(nr, &sk->sk_socket->flags); +} +#endif /* < 4.5 */ + +#if LINUX_VERSION_IS_LESS(4,16,0) +#define sk_pacing_shift_update LINUX_BACKPORT(sk_pacing_shift_update) +static inline void sk_pacing_shift_update(struct sock *sk, int val) +{ +#if LINUX_VERSION_IS_GEQ(4,15,0) + if (!sk || !sk_fullsock(sk) || sk->sk_pacing_shift == val) + return; + sk->sk_pacing_shift = val; +#endif /* >= 4.15 */ +} +#endif /* < 4.16 */ + +#endif /* __BACKPORT_NET_SOCK_H */ -- cgit v1.2.3