[tcp] redefine conflicting symbols (#11174)

This commit redefines tcplp symbols that conflict with LWIP's TCP implementation:
- tcp_input has been renamed tcplp_input
- tcp_output has be renamed tcplp_output
- tcp_close has been renamed tcp_close_tcb
- tcp_init was already removed but the prototype was still present and was deleted
- TCP_MSS and TCP6_MSS have been renamed to TCP_MAXSS and TCP6_MAXSS

Signed-off-by: Marius Preda <marius.preda@nxp.com>
This commit is contained in:
Marius Preda
2025-01-22 20:59:24 +02:00
committed by GitHub
parent 0c3d2c2bde
commit a21666e275
12 changed files with 60 additions and 61 deletions
+2 -2
View File
@@ -657,7 +657,7 @@ Error Tcp::HandleMessage(ot::Ip6::Header &aIp6Header, Message &aMessage, Message
size_t priorBacklog = endpoint->GetSendBufferBytes() - endpoint->GetInFlightBytes();
ClearAllBytes(sig);
nextAction = tcp_input(ip6Header, tcpHeader, &aMessage, tp, nullptr, &sig);
nextAction = tcplp_input(ip6Header, tcpHeader, &aMessage, tp, nullptr, &sig);
if (nextAction != RELOOKUP_REQUIRED)
{
ProcessSignals(*endpoint, priorHead, priorBacklog, sig);
@@ -673,7 +673,7 @@ Error Tcp::HandleMessage(ot::Ip6::Header &aIp6Header, Message &aMessage, Message
struct tcpcb_listen *tpl = &listener->GetTcbListen();
ClearAllBytes(sig);
nextAction = tcp_input(ip6Header, tcpHeader, &aMessage, nullptr, tpl, &sig);
nextAction = tcplp_input(ip6Header, tcpHeader, &aMessage, nullptr, tpl, &sig);
OT_ASSERT(nextAction != RELOOKUP_REQUIRED);
if (sig.accepted_connection != nullptr)
{
+2 -2
View File
@@ -140,8 +140,8 @@ struct tcphdr {
*
* We use explicit numerical definition here to avoid header pollution.
*/
#define TCP_MSS 536
#define TCP6_MSS 1220
#define TCP_MAXSS 536
#define TCP6_MAXSS 1220
/*
* Limit the lowest MSS we accept for path MTU discovery and the TCP SYN MSS
+1 -1
View File
@@ -80,7 +80,7 @@
#define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT)
/*
* Flags used when sending segments in tcp_output. Basic flags (TH_RST,
* Flags used when sending segments in tcplp_output. Basic flags (TH_RST,
* TH_ACK,TH_SYN,TH_FIN) are totally determined by state, with the proviso
* that TH_FIN is sent only if all data queued for output is included in the
* segment.
+22 -22
View File
@@ -424,9 +424,9 @@ tcp_dropwithreset(struct ip6_hdr* ip6, struct tcphdr *th, struct tcpcb *tp, otIn
/*
* TCP input handling is split into multiple parts:
* tcp6_input is a thin wrapper around tcp_input for the extended
* tcp6_input is a thin wrapper around tcplp_input for the extended
* ip6_protox[] call format in ip6_input
* tcp_input handles primary segment validation, inpcb lookup and
* tcplp_input handles primary segment validation, inpcb lookup and
* SYN processing on listen sockets
* tcp_do_segment processes the ACK and text of the segment for
* establishing, established and closing connections
@@ -435,7 +435,7 @@ tcp_dropwithreset(struct ip6_hdr* ip6, struct tcphdr *th, struct tcpcb *tp, otIn
tcp_input(struct mbuf **mp, int *offp, int proto) */
/* NOTE: tcp_fields_to_host(th) must be called before this function is called. */
int
tcp_input(struct ip6_hdr* ip6, struct tcphdr* th, otMessage* msg, struct tcpcb* tp, struct tcpcb_listen* tpl,
tcplp_input(struct ip6_hdr* ip6, struct tcphdr* th, otMessage* msg, struct tcpcb* tp, struct tcpcb_listen* tpl,
struct tcplp_signals* sig)
{
/*
@@ -830,7 +830,7 @@ tcp_input(struct ip6_hdr* ip6, struct tcphdr* th, otMessage* msg, struct tcpcb*
tp->snd_wl1 = th->th_seq;
/*
* samkumar: We remove the "+ 1"s below since we use
* tcp_output to send the appropriate SYN-ACK. For
* tcplp_output to send the appropriate SYN-ACK. For
* example, syncache_tfo_expand eliminates the "+ 1"s
* too. My understanding is that syncache_socket has
* the "+ 1"s because it's normally called once the
@@ -959,7 +959,7 @@ tcp_input(struct ip6_hdr* ip6, struct tcphdr* th, otMessage* msg, struct tcpcb*
tp->t_flags |= TF_ACKNOW; // samkumar: my addition
}
tcp_output(tp); // to send the SYN-ACK
tcplp_output(tp); // to send the SYN-ACK
tp->accepted_from = tpl;
return (IPPROTO_DONE);
@@ -1175,12 +1175,12 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
else
/*
* samkumar: The original code here would set
* mss to either TCP6_MSS or TCP_MSS depending
* mss to either TCP6_MAXSS or TCP_MAXSS depending
* on whether the INP_IPV6 flag is present in
* tp->t_inpcb->inp_vflag. In TCPlp, we always
* assume IPv6.
*/
mss = TCP6_MSS;
mss = TCP6_MAXSS;
tcp_fastopen_update_cache(tp, mss,
to.to_tfo_len, to.to_tfo_cookie);
} else
@@ -1312,7 +1312,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
* using current (possibly backed-off) value.
* If process is waiting for space,
* wakeup/selwakeup/signal. If data
* are ready to send, let tcp_output
* are ready to send, let tcplp_output
* decide between more output or persist.
*/
@@ -1335,7 +1335,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
* lbuf_used_space.
*/
if (lbuf_used_space(&tp->sendbuf))
(void) tcp_output(tp);
(void) tcplp_output(tp);
goto check_delack;
}
} else if (th->th_ack == tp->snd_una &&
@@ -1456,7 +1456,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
tp->t_flags |= TF_DELACK;
} else {
tp->t_flags |= TF_ACKNOW;
tcp_output(tp);
tcplp_output(tp);
}
goto check_delack;
}
@@ -1626,7 +1626,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
tcp_timer_activate(tp, TT_REXMT, 0);
tcp_state_change(tp, TCPS_SYN_RECEIVED);
/*
* samkumar: We would have incremented snd_next in tcp_output when
* samkumar: We would have incremented snd_next in tcplp_output when
* we sent the original SYN, so decrement it here. (Another
* consequence of removing the SYN cache.)
*/
@@ -1734,7 +1734,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
tcp_state_change(tp, TCPS_CLOSED);
/* FALLTHROUGH */
default:
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, droperror);
}
} else {
@@ -2129,7 +2129,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
#ifdef INSTRUMENT_TCP
tcplp_sys_log("TCP DUPACK");
#endif
(void) tcp_output(tp);
(void) tcplp_output(tp);
goto drop;
} else if (tp->t_dupacks == tcprexmtthresh) {
tcp_seq onxt = tp->snd_nxt;
@@ -2165,13 +2165,13 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
if (tp->t_flags & TF_SACK_PERMIT) {
tp->sack_newdata = tp->snd_nxt;
tp->snd_cwnd = tp->t_maxseg;
(void) tcp_output(tp);
(void) tcplp_output(tp);
goto drop;
}
tp->snd_nxt = th->th_ack;
tp->snd_cwnd = tp->t_maxseg;
(void) tcp_output(tp);
(void) tcplp_output(tp);
/*
* samkumar: I added casts to uint64_t below to
* fix an OpenThread code scanning alert relating
@@ -2220,7 +2220,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
(tp->t_dupacks - tp->snd_limited) *
tp->t_maxseg;
/*
* Only call tcp_output when there
* Only call tcplp_output when there
* is new data available to be sent.
* Otherwise we would send pure ACKs.
*/
@@ -2231,7 +2231,7 @@ tcp_do_segment(struct ip6_hdr* ip6, struct tcphdr *th, otMessage* msg,
avail = lbuf_used_space(&tp->sendbuf) -
(tp->snd_nxt - tp->snd_una);
if (avail > 0)
(void) tcp_output(tp);
(void) tcplp_output(tp);
sent = tp->snd_max - oldsndmax;
if (sent > tp->t_maxseg) {
KASSERT((tp->t_dupacks == 2 &&
@@ -2478,7 +2478,7 @@ process_ACK:
*/
case TCPS_LAST_ACK:
if (ourfinisacked) {
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, CONN_LOST_NORMAL);
goto drop;
}
@@ -2721,7 +2721,7 @@ step6:
* Return any desired output.
*/
if (needoutput || (tp->t_flags & TF_ACKNOW))
(void) tcp_output(tp);
(void) tcplp_output(tp);
check_delack:
if (tp->t_flags & TF_DELACK) {
@@ -2754,7 +2754,7 @@ dropafterack:
}
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
(void) tcplp_output(tp);
return;
dropwithreset:
@@ -3111,7 +3111,7 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer,
* Sanity check: make sure that maxopd will be large
* enough to allow some data on segments even if the
* all the option space is used (40bytes). Otherwise
* funny things may happen in tcp_output.
* funny things may happen in tcplp_output.
*/
/*
* samkumar: When I was experimenting with different MSS values, I had
@@ -3258,7 +3258,7 @@ tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th)
#ifdef INSTRUMENT_TCP
tcplp_sys_log("TCP Partial_ACK");
#endif
(void) tcp_output(tp);
(void) tcplp_output(tp);
tp->snd_cwnd = ocwnd;
if (SEQ_GT(onxt, tp->snd_nxt))
tp->snd_nxt = onxt;
+6 -6
View File
@@ -97,7 +97,7 @@ tcp_setpersist(struct tcpcb *tp)
* Tcp output routine: figure out what should be sent and send it.
*/
int
tcp_output(struct tcpcb *tp)
tcplp_output(struct tcpcb *tp)
{
/*
* samkumar: The biggest change in this function is in how outgoing
@@ -181,7 +181,7 @@ again:
* to send out new data (when sendalot is 1), bypass this function.
* If we retransmit in fast recovery mode, decrement snd_cwnd, since
* we're replacing a (future) new transmission with a retransmission
* now, and we previously incremented snd_cwnd in tcp_input().
* now, and we previously incremented snd_cwnd in tcplp_input().
*/
/*
* Still in sack recovery , reset rxmit flag to zero.
@@ -647,7 +647,7 @@ dontupdate:
((tp->t_flags & TF_SENTFIN) == 0 || tp->snd_nxt == tp->snd_una))
goto send;
/*
* In SACK, it is possible for tcp_output to fail to send a segment
* In SACK, it is possible for tcplp_output to fail to send a segment
* after the retransmission timer has been turned off. Make sure
* that the retransmission timer is set.
*/
@@ -1048,9 +1048,9 @@ send:
}
/*
* samkumar: Make tcp_output reply with ECE flag in the SYN-ACK for
* samkumar: Make tcplp_output reply with ECE flag in the SYN-ACK for
* ECN-enabled connections. The existing code in FreeBSD didn't have to do
* this, because it didn't use tcp_output to send the SYN-ACK; it
* this, because it didn't use tcplp_output to send the SYN-ACK; it
* constructed the SYN-ACK segment manually. Yet another consequnce of
* removing the SYN cache...
*/
@@ -1282,7 +1282,7 @@ timer:
* 3) A -> B: ACK for #2, 0 len packet
*
* In this case, A will not activate the persist timer,
* because it chose to send a packet. Unless tcp_output
* because it chose to send a packet. Unless tcplp_output
* is called for some other reason (delayed ack timer,
* another input packet from B, socket syscall), A will
* not send zero window probes.
+1 -1
View File
@@ -46,7 +46,7 @@
* reassembly buffer. I have kept the original code as a comment below this
* function, for reference.
*
* Looking at the usage of this function in tcp_input, this just has to set
* Looking at the usage of this function in tcplp_input, this just has to set
* *tlenp to 0 if the received segment is already completely buffered; it does
* not need to update it if only part of the segment is trimmed off.
*/
+1 -1
View File
@@ -561,7 +561,7 @@ tcp_sack_partialack(struct tcpcb *tp, struct tcphdr *th)
if (tp->snd_cwnd > tp->snd_ssthresh)
tp->snd_cwnd = tp->snd_ssthresh;
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
(void) tcplp_output(tp);
}
/*
+3 -3
View File
@@ -179,7 +179,7 @@ tcp_discardcb(struct tcpcb *tp)
* needed for TCP.
*/
struct tcpcb *
tcp_close(struct tcpcb *tp)
tcp_close_tcb(struct tcpcb *tp)
{
/* samkumar: Eliminate the TFO pending counter. */
/*
@@ -353,11 +353,11 @@ tcp_drop(struct tcpcb *tp, int errnum)
{
if (TCPS_HAVERCVDSYN(tp->t_state)) {
tcp_state_change(tp, TCPS_CLOSED);
(void) tcp_output(tp);
(void) tcplp_output(tp);
}
if (errnum == ETIMEDOUT && tp->t_softerror)
errnum = tp->t_softerror;
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, errnum);
return tp;
}
+6 -6
View File
@@ -80,7 +80,7 @@ tcp_timer_delack(struct tcpcb* tp)
* I also removed stats collection, locking, and vnet, throughout the code.
*/
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
(void) tcplp_output(tp);
return 0;
}
@@ -224,7 +224,7 @@ tcp_timer_persist(struct tcpcb* tp)
tcp_setpersist(tp);
tp->t_flags |= TF_FORCEDATA;
tcplp_sys_log("Persist output: %zu bytes in sendbuf", lbuf_used_space(&tp->sendbuf));
(void) tcp_output(tp);
(void) tcplp_output(tp);
tp->t_flags &= ~TF_FORCEDATA;
out:
@@ -286,7 +286,7 @@ tcp_timer_2msl(struct tcpcb* tp)
* state, and acts appropriately if so.
*/
if (tp->t_state == TCP6S_TIME_WAIT) {
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, CONN_LOST_NORMAL);
dropped = 1;
return dropped;
@@ -303,7 +303,7 @@ tcp_timer_2msl(struct tcpcb* tp)
*/
if (tcp_fast_finwait2_recycle && tp->t_state == TCPS_FIN_WAIT_2 &&
tpiscantrcv(tp)) {
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, CONN_LOST_NORMAL);
dropped = 1;
} else {
@@ -315,7 +315,7 @@ tcp_timer_2msl(struct tcpcb* tp)
tpmarktimeractive(tp, TT_2MSL);
tcplp_sys_set_timer(tp, TT_2MSL, TP_KEEPINTVL(tp));
} else {
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, CONN_LOST_NORMAL);
dropped = 1;
}
@@ -455,7 +455,7 @@ tcp_timer_rexmt(struct tcpcb *tp)
cc_cong_signal(tp, NULL, CC_RTO);
(void) tcp_output(tp);
(void) tcplp_output(tp);
out:
/*
+2 -2
View File
@@ -212,7 +212,7 @@ tcp_twstart(struct tcpcb *tp)
error = in_localip(inp->inp_faddr);
#endif
if (error) {
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
if (tp != NULL)
INP_WUNLOCK(inp);
return;
@@ -364,7 +364,7 @@ tcp_twcheck(struct tcpcb* tp, struct tcphdr *th, int tlen)
* do it as below since TCPlp represents TIME-WAIT connects as
* struct tcpcb's.
*/
tcp_close(tp);
tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, CONN_LOST_NORMAL);
return (1);
}
+10 -10
View File
@@ -199,7 +199,7 @@ tcp6_usr_connect(struct tcpcb* tp, struct sockaddr_in6* sin6p)
* v4-mapped addresses. It would call in6_sin6_2_sin to convert the
* struct sockaddr_in6 to a struct sockaddr_in, set the INP_IPV4 flag
* and clear the INP_IPV6 flag on inp->inp_vflag, do some other
* processing, and finally call tcp_connect and tcp_output. However,
* processing, and finally call tcp_connect and tcplp_output. However,
* it would first check if the IN6P_IPV6_V6ONLY flag was set in
* inp->inp_flags, and if so, it would return with EINVAL. In TCPlp, we
* support IPv6 only, so I removed the check for IN6P_IPV6_V6ONLY and
@@ -224,7 +224,7 @@ tcp6_usr_connect(struct tcpcb* tp, struct sockaddr_in6* sin6p)
goto out;
tcp_timer_activate(tp, TT_KEEP, TP_KEEPINIT(tp));
error = tcp_output(tp);
error = tcplp_output(tp);
out:
return (error);
@@ -329,7 +329,7 @@ int tcp_usr_send(struct tcpcb* tp, int moretocome, otLinkedBuffer* data, size_t
* samkumar: The code below was previously wrapped in an if statement
* that checked that the INP_DROPPED flag in inp->inp_flags and the
* PRUS_NOTREADY flag in the former flags parameter were both clear.
* If either one was set, then tcp_output would not be called.
* If either one was set, then tcplp_output would not be called.
*
* The "more to come" functionality was previously triggered via the
* PRUS_MORETOCOME flag in the flags parameter to this function. Since
@@ -338,7 +338,7 @@ int tcp_usr_send(struct tcpcb* tp, int moretocome, otLinkedBuffer* data, size_t
*/
if (moretocome)
tp->t_flags |= TF_MORETOCOME;
error = tcp_output(tp);
error = tcplp_output(tp);
if (moretocome)
tp->t_flags &= ~TF_MORETOCOME;
@@ -381,7 +381,7 @@ tcp_usr_rcvd(struct tcpcb* tp)
(tp->t_state == TCPS_SYN_RECEIVED))
goto out;
tcp_output(tp);
tcplp_output(tp);
out:
return (error);
@@ -425,7 +425,7 @@ tcp_usr_shutdown(struct tcpcb* tp)
* this check on tp->t_state.
*/
if (tp->t_state != TCPS_CLOSED)
error = tcp_output(tp);
error = tcplp_output(tp);
out:
return (error);
@@ -453,14 +453,14 @@ tcp_usrclosed(struct tcpcb *tp)
tcp_state_change(tp, TCPS_CLOSED);
/* FALLTHROUGH */
case TCPS_CLOSED:
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, CONN_LOST_NORMAL);
/*
* tcp_close() should never return NULL here as the socket is
* tcp_close_tcb() should never return NULL here as the socket is
* still open.
*/
KASSERT(tp != NULL,
("tcp_usrclosed: tcp_close() returned NULL"));
("tcp_usrclosed: tcp_close_tcb() returned NULL"));
break;
case TCPS_SYN_SENT:
@@ -523,7 +523,7 @@ tcp_usr_abort(struct tcpcb* tp)
tp->t_state != TCP6S_CLOSED) {
tcp_drop(tp, ECONNABORTED);
} else if (tp->t_state == TCPS_TIME_WAIT) { // samkumar: I added this clause
tp = tcp_close(tp);
tp = tcp_close_tcb(tp);
tcplp_sys_connection_lost(tp, CONN_LOST_NORMAL);
}
}
+4 -5
View File
@@ -381,10 +381,9 @@ void initialize_tcb(struct tcpcb* tp);
/* Copied from the "dead" portions below. */
void tcp_init(void);
void tcp_state_change(struct tcpcb *, int);
tcp_seq tcp_new_isn(struct tcpcb *);
struct tcpcb *tcp_close(struct tcpcb *);
struct tcpcb *tcp_close_tcb(struct tcpcb *);
struct tcpcb *tcp_drop(struct tcpcb *, int);
void
tcp_respond(struct tcpcb *tp, otInstance* instance, struct ip6_hdr* ip6gen, struct tcphdr *thgen,
@@ -483,7 +482,7 @@ void tcp_usr_abort(struct tcpcb* tp);
/*
* Structure to hold TCP options that are only used during segment
* processing (in tcp_input), but not held in the tcpcb.
* processing (in tcplp_input), but not held in the tcpcb.
* It's basically used to reduce the number of parameters
* to tcp_dooptions and tcp_addoptions.
* The binary order of the to_flags is relevant for packing of the
@@ -596,9 +595,9 @@ void tcp_twclose(struct tcpcb*, int);
int tcp_twcheck(struct tcpcb*, struct tcphdr *, int);
void tcp_dropwithreset(struct ip6_hdr* ip6, struct tcphdr *th, struct tcpcb *tp, otInstance* instance,
int tlen, int rstreason);
int tcp_input(struct ip6_hdr* ip6, struct tcphdr* th, otMessage* msg, struct tcpcb* tp, struct tcpcb_listen* tpl,
int tcplp_input(struct ip6_hdr* ip6, struct tcphdr* th, otMessage* msg, struct tcpcb* tp, struct tcpcb_listen* tpl,
struct tcplp_signals* sig);
int tcp_output(struct tcpcb *);
int tcplp_output(struct tcpcb *);
void tcpip_maketemplate(struct tcpcb *, struct tcptemp*);
void tcpip_fillheaders(struct tcpcb *, otMessageInfo *, void *);
uint64_t tcp_maxmtu6(struct tcpcb*, struct tcp_ifcap *);