The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c348e8805365dab2a042ab951045b879a290602b

commit c348e8805365dab2a042ab951045b879a290602b
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2022-10-31 15:57:15 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2022-10-31 15:57:15 +0000

    tcp: make tcp_handle_wakeup() static and robust
    
    It is called only from tcp_input() and always has valid parameter.
    
    Reviewed by:            rscheff, tuexen
    Differential revision:  https://reviews.freebsd.org/D37115
---
 sys/netinet/tcp_input.c | 25 +++++++++----------------
 sys/netinet/tcp_var.h   |  1 -
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 1ea3d72d9a9d..84574aaa00ae 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1520,22 +1520,15 @@ tcp_input(struct mbuf **mp, int *offp, int proto)
        return(tcp_input_with_port(mp, offp, proto, 0));
 }
 
-void
-tcp_handle_wakeup(struct tcpcb *tp, struct socket *so)
+static void
+tcp_handle_wakeup(struct tcpcb *tp)
 {
-       /*
-        * Since tp might be gone if the session entered
-        * the TIME_WAIT state before coming here, we need
-        * to check if the socket is still connected.
-        */
-       if (tp == NULL) {
-               return;
-       }
-       if (so == NULL) {
-               return;
-       }
-       INP_LOCK_ASSERT(tp->t_inpcb);
+
+       INP_WLOCK_ASSERT(tp->t_inpcb);
+
        if (tp->t_flags & TF_WAKESOR) {
+               struct socket *so = tp->t_inpcb->inp_socket;
+
                tp->t_flags &= ~TF_WAKESOR;
                SOCKBUF_LOCK_ASSERT(&so->so_rcv);
                sorwakeup_locked(so);
@@ -2521,7 +2514,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct 
socket *so,
                if (tlen == 0 && (thflags & TH_FIN) == 0) {
                        (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0,
                            (struct mbuf *)0);
-                       tcp_handle_wakeup(tp, so);
+                       tcp_handle_wakeup(tp);
                }
                tp->snd_wl1 = th->th_seq - 1;
                /* FALLTHROUGH */
@@ -3258,7 +3251,7 @@ dodata:                                                   
/* XXX */
                                    save_start + tlen);
                        }
                }
-               tcp_handle_wakeup(tp, so);
+               tcp_handle_wakeup(tp);
 #if 0
                /*
                 * Note the amount of data that peer has sent into
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 1514e016ee13..d115a18d66d5 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1099,7 +1099,6 @@ int        tcp_input(struct mbuf **, int *, int);
 int     tcp_autorcvbuf(struct mbuf *, struct tcphdr *, struct socket *,
            struct tcpcb *, int);
 int     tcp_input_with_port(struct mbuf **, int *, int, uint16_t);
-void    tcp_handle_wakeup(struct tcpcb *, struct socket *);
 void    tcp_do_segment(struct mbuf *, struct tcphdr *,
                        struct socket *, struct tcpcb *, int, int, uint8_t);
 

Reply via email to