Author: jhb
Date: Sat Mar  3 00:54:12 2018
New Revision: 330303
URL: https://svnweb.freebsd.org/changeset/base/330303

Log:
  MFC 328608: Export tcp_always_keepalive for use by the Chelsio TOM module.
  
  This used to work by accident with ld.bfd even though always_keepalive
  was marked as static. LLD honors static more correctly, so export this
  variable properly (including moving it into the tcp_* namespace).
  
  Relative to HEAD the MFC includes two additional changes:
  - The t3_tom module used for cxgb(4) is also patched.
  - A strong reference from the new name (tcp_always_keepalive) to the old
    name (always_keepalive) has been added to preserve the KBI for existing
    modules.
  
  Suggested by: kib (strong reference)
  Sponsored by: Chelsio Communications

Modified:
  stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
  stable/10/sys/dev/cxgbe/tom/t4_tom.c
  stable/10/sys/netinet/tcp_timer.c
  stable/10/sys/netinet/tcp_timer.h
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
  stable/11/sys/dev/cxgbe/tom/t4_tom.c
  stable/11/sys/netinet/tcp_timer.c
  stable/11/sys/netinet/tcp_timer.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
==============================================================================
--- stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c        Sat Mar  3 00:22:32 
2018        (r330302)
+++ stable/10/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c        Sat Mar  3 00:54:12 
2018        (r330303)
@@ -86,7 +86,6 @@ VNET_DECLARE(int, tcp_autorcvbuf_inc);
 #define V_tcp_autorcvbuf_inc VNET(tcp_autorcvbuf_inc)
 VNET_DECLARE(int, tcp_autorcvbuf_max);
 #define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max)
-extern int always_keepalive;
 
 /*
  * For ULP connections HW may add headers, e.g., for digests, that aren't part
@@ -839,7 +838,7 @@ calc_opt0h(struct socket *so, int mtu_idx, int rscale,
        if (so != NULL) {
                struct inpcb *inp = sotoinpcb(so);
                struct tcpcb *tp = intotcpcb(inp);
-               int keepalive = always_keepalive ||
+               int keepalive = tcp_always_keepalive ||
                    so_options_get(so) & SO_KEEPALIVE;
 
                opt0h |= V_NAGLE((tp->t_flags & TF_NODELAY) == 0);

Modified: stable/10/sys/dev/cxgbe/tom/t4_tom.c
==============================================================================
--- stable/10/sys/dev/cxgbe/tom/t4_tom.c        Sat Mar  3 00:22:32 2018        
(r330302)
+++ stable/10/sys/dev/cxgbe/tom/t4_tom.c        Sat Mar  3 00:54:12 2018        
(r330303)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet6/scope6_var.h>
 #define TCPSTATES
 #include <netinet/tcp_fsm.h>
+#include <netinet/tcp_timer.h>
 #include <netinet/toecore.h>
 
 #ifdef TCP_OFFLOAD
@@ -549,8 +550,6 @@ select_rcv_wscale(void)
        return (wscale);
 }
 
-extern int always_keepalive;
-
 /*
  * socket so could be a listening socket too.
  */
@@ -569,7 +568,7 @@ calc_opt0(struct socket *so, struct vi_info *vi, struc
        if (so != NULL) {
                struct inpcb *inp = sotoinpcb(so);
                struct tcpcb *tp = intotcpcb(inp);
-               int keepalive = always_keepalive ||
+               int keepalive = tcp_always_keepalive ||
                    so_options_get(so) & SO_KEEPALIVE;
 
                opt0 |= V_NAGLE((tp->t_flags & TF_NODELAY) == 0);

Modified: stable/10/sys/netinet/tcp_timer.c
==============================================================================
--- stable/10/sys/netinet/tcp_timer.c   Sat Mar  3 00:22:32 2018        
(r330302)
+++ stable/10/sys/netinet/tcp_timer.c   Sat Mar  3 00:54:12 2018        
(r330303)
@@ -110,9 +110,10 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, rexmit_slop, CTLT
     &tcp_rexmit_slop, 0, sysctl_msec_to_ticks, "I",
     "Retransmission Timer Slop");
 
-static int     always_keepalive = 1;
+int    tcp_always_keepalive = 1;
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, always_keepalive, CTLFLAG_RW,
-    &always_keepalive , 0, "Assume SO_KEEPALIVE on all TCP connections");
+    &tcp_always_keepalive , 0, "Assume SO_KEEPALIVE on all TCP connections");
+__strong_reference(tcp_always_keepalive, always_keepalive);
 
 int    tcp_fast_finwait2_recycle = 0;
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, fast_finwait2_recycle, CTLFLAG_RW, 
@@ -375,7 +376,8 @@ tcp_timer_keep(void *xtp)
        TCPSTAT_INC(tcps_keeptimeo);
        if (tp->t_state < TCPS_ESTABLISHED)
                goto dropit;
-       if ((always_keepalive || inp->inp_socket->so_options & SO_KEEPALIVE) &&
+       if ((tcp_always_keepalive ||
+           inp->inp_socket->so_options & SO_KEEPALIVE) &&
            tp->t_state <= TCPS_CLOSING) {
                if (ticks - tp->t_rcvtime >= TP_KEEPIDLE(tp) + TP_MAXIDLE(tp))
                        goto dropit;

Modified: stable/10/sys/netinet/tcp_timer.h
==============================================================================
--- stable/10/sys/netinet/tcp_timer.h   Sat Mar  3 00:22:32 2018        
(r330302)
+++ stable/10/sys/netinet/tcp_timer.h   Sat Mar  3 00:54:12 2018        
(r330303)
@@ -189,6 +189,7 @@ extern int tcp_ttl;                 /* time to live for TCP 
segs */
 extern int tcp_backoff[];
 extern int tcp_syn_backoff[];
 
+extern int tcp_always_keepalive;
 extern int tcp_finwait2_timeout;
 extern int tcp_fast_finwait2_recycle;
 
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to