git: aa1223ac3afc - main - tcp: limit visibility of symbols

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Sat, 06 Jan 2024 11:08:24 UTC
The branch main has been updated by tuexen:

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

commit aa1223ac3afc5c2054cde84a73e01a48dc4e8c6a
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-01-06 11:00:38 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-01-06 11:00:38 +0000

    tcp: limit visibility of symbols
    
    Put most symbols under __BSD_VISIBLE and limit the namespace of
    tcp_[gs]et_flags.
    
    Reviewed by:            kib, karels, rscheff
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D43245
---
 sys/netinet/tcp.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/sys/netinet/tcp.h b/sys/netinet/tcp.h
index 64286ede9575..f9e561f6ce35 100644
--- a/sys/netinet/tcp.h
+++ b/sys/netinet/tcp.h
@@ -80,18 +80,23 @@ struct tcphdr {
 };
 
 static __inline uint16_t
-tcp_get_flags(const struct tcphdr *th)
+__tcp_get_flags(const struct tcphdr *th)
 {
-        return (((uint16_t)th->th_x2 << 8) | th->th_flags);
+	return (((uint16_t)th->th_x2 << 8) | th->th_flags);
 }
 
 static __inline void
-tcp_set_flags(struct tcphdr *th, uint16_t flags)
+__tcp_set_flags(struct tcphdr *th, uint16_t flags)
 {
-        th->th_x2    = (flags >> 8) & 0x0f;
-        th->th_flags = flags & 0xff;
+	th->th_x2 = (flags >> 8) & 0x0f;
+	th->th_flags = flags & 0xff;
 }
 
+#ifdef _KERNEL
+#define tcp_get_flags(th) __tcp_get_flags(th)
+#define tcp_set_flags(th, flags) __tcp_set_flags(th, flags)
+#endif
+
 #define	PADTCPOLEN(len)		((((len) / 4) + !!((len) % 4)) * 4)
 
 #define	TCPOPT_EOL		0
@@ -455,7 +460,7 @@ struct tcp_fastopen {
 	int enable;
 	uint8_t psk[TCP_FASTOPEN_PSK_LEN];
 };
-#endif
+
 #define TCP_FUNCTION_NAME_LEN_MAX 32
 
 struct tcp_function_set {
@@ -542,4 +547,5 @@ struct tcp_hybrid_req {
 #define TCP_REUSPORT_LB_NUMA_NODOM	(-2) /* remove numa binding */
 #define TCP_REUSPORT_LB_NUMA_CURDOM	(-1) /* bind to current domain */
 
+#endif /* __BSD_VISIBLE */
 #endif /* !_NETINET_TCP_H_ */