Skip to content

Commit 4090fa3

Browse files
q2venkuba-moo
authored andcommitted
af_unix: Replace garbage collection algorithm.
If we find a dead SCC during iteration, we call unix_collect_skb() to splice all skb in the SCC to the global sk_buff_head, hitlist. After iterating all SCC, we unlock unix_gc_lock and purge the queue. Signed-off-by: Kuniyuki Iwashima <[email protected]> Acked-by: Paolo Abeni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a15702d commit 4090fa3

File tree

3 files changed

+64
-258
lines changed

3 files changed

+64
-258
lines changed

include/net/af_unix.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ static inline struct unix_sock *unix_get_socket(struct file *filp)
1919

2020
extern spinlock_t unix_gc_lock;
2121
extern unsigned int unix_tot_inflight;
22-
23-
void unix_inflight(struct user_struct *user, struct file *fp);
24-
void unix_notinflight(struct user_struct *user, struct file *fp);
2522
void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver);
2623
void unix_del_edges(struct scm_fp_list *fpl);
2724
void unix_update_edges(struct unix_sock *receiver);
@@ -85,12 +82,7 @@ struct unix_sock {
8582
struct sock *peer;
8683
struct sock *listener;
8784
struct unix_vertex *vertex;
88-
struct list_head link;
89-
unsigned long inflight;
9085
spinlock_t lock;
91-
unsigned long gc_flags;
92-
#define UNIX_GC_CANDIDATE 0
93-
#define UNIX_GC_MAYBE_CYCLE 1
9486
struct socket_wq peer_wq;
9587
wait_queue_entry_t peer_wake;
9688
struct scm_stat scm_stat;

net/unix/af_unix.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -980,12 +980,10 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern,
980980
sk->sk_destruct = unix_sock_destructor;
981981
u = unix_sk(sk);
982982
u->listener = NULL;
983-
u->inflight = 0;
984983
u->vertex = NULL;
985984
u->path.dentry = NULL;
986985
u->path.mnt = NULL;
987986
spin_lock_init(&u->lock);
988-
INIT_LIST_HEAD(&u->link);
989987
mutex_init(&u->iolock); /* single task reading lock */
990988
mutex_init(&u->bindlock); /* single task binding lock */
991989
init_waitqueue_head(&u->peer_wait);
@@ -1793,8 +1791,6 @@ static inline bool too_many_unix_fds(struct task_struct *p)
17931791

17941792
static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
17951793
{
1796-
int i;
1797-
17981794
if (too_many_unix_fds(current))
17991795
return -ETOOMANYREFS;
18001796

@@ -1806,9 +1802,6 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
18061802
if (!UNIXCB(skb).fp)
18071803
return -ENOMEM;
18081804

1809-
for (i = scm->fp->count - 1; i >= 0; i--)
1810-
unix_inflight(scm->fp->user, scm->fp->fp[i]);
1811-
18121805
if (unix_prepare_fpl(UNIXCB(skb).fp))
18131806
return -ENOMEM;
18141807

@@ -1817,15 +1810,10 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
18171810

18181811
static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb)
18191812
{
1820-
int i;
1821-
18221813
scm->fp = UNIXCB(skb).fp;
18231814
UNIXCB(skb).fp = NULL;
18241815

18251816
unix_destroy_fpl(scm->fp);
1826-
1827-
for (i = scm->fp->count - 1; i >= 0; i--)
1828-
unix_notinflight(scm->fp->user, scm->fp->fp[i]);
18291817
}
18301818

18311819
static void unix_peek_fds(struct scm_cookie *scm, struct sk_buff *skb)

0 commit comments

Comments
 (0)