--- zzzz-none-000/linux-5.4.213/net/core/sock.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/net/core/sock.c 2024-05-29 11:20:02.000000000 +0000 @@ -140,6 +140,7 @@ static DEFINE_MUTEX(proto_list_mutex); static LIST_HEAD(proto_list); +static atomic64_t cookie_gen; static void sock_inuse_add(struct net *net, int val); @@ -539,6 +540,18 @@ } EXPORT_SYMBOL(__sk_receive_skb); +u64 sock_gen_cookie(struct sock *sk) +{ + while (1) { + u64 res = atomic64_read(&sk->sk_cookie); + + if (res) + return res; + res = atomic64_inc_return(&cookie_gen); + atomic64_cmpxchg(&sk->sk_cookie, 0, res); + } +} + struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) { struct dst_entry *dst = __sk_dst_get(sk); @@ -1760,9 +1773,11 @@ if (likely(sk->sk_net_refcnt)) sock_inuse_add(sock_net(sk), -1); +#ifdef CONFIG_SOCK_DIAG if (unlikely(sk->sk_net_refcnt && sock_diag_has_destroy_listeners(sk))) sock_diag_broadcast_destroy(sk); else +#endif sk_destruct(sk); } @@ -2011,6 +2026,9 @@ #endif skb->destructor = sock_wfree; skb_set_hash_from_sk(skb, sk); +#ifdef CONFIG_AVM_SK_TC_INDEX + skb->tc_index = sk->sk_tc_index; +#endif /* * We used to take a refcount on sk, but following operation * is enough to guarantee sk_free() wont free this sock until @@ -3626,6 +3644,8 @@ static int __init proto_init(void) { + if (IS_ENABLED(CONFIG_PROC_STRIPPED)) + return 0; return register_pernet_subsys(&proto_net_ops); }