: calling dccp_v{4,6}_reqsk_send_ack is a BUG
PATCH 10/17 : calling dccp_v{4,6}_reqsk_send_ack is a BUG
[DCCP]: calling dccp_v{4,6}_reqsk_send_ack is a BUG
This patch removes two functions, the send_ack functions of request_sock, which are not called/used by the DCCP code. It is correct that these functions are not called, below is a justification why calling these functions (on a passive socket in the LISTEN/RESPOND state) would mean a DCCP protocol violation.
A) bACKground: using request_sock in TCP:
-----------------------------------------
req->rsk_ops->send_ack is called only once, in tcp_check_req() of net/ipv4/tcp_minisocks.c
This single case deals with a socket in the SYN-RECEIVED state; RFC 793 on page 69 describes
the case for SYN-RECEIVED and other states: "If an incoming segment is not acceptable, an
acknowledgment should be sent in reply (unless the RST bit is set, if so drop the segment
and return):
<SEQ=SND.NXT><ACK=RCV.NXT><CTL¬K>"
( SND.NXT = ISS + 1, RCV.NEXT = SEG.SEQ + 1 if SYN-RECEIVED was entered from LISTEN)
This is referenced by the following code segment:
if (paws_reject || !tcp_in_window(...)) {
/* Out of window: send ACK and drop. */
if (!(flg & TCP_FLAG_RST))
req->rsk_ops->send_ack(skb, req);
/* ... */
return NULL;
}
This is the _only_ occurrence where rsk_ops->send_ack() is called for TCP.B) The Problem: protocol constraints of DCCP:
---------------------------------------------
(1) rsk_ops->send_ack is called _nowhere_ throughout the DCCP code (grep confirms)
(2) This is correct, due to the following:
(a) RFC 4340, sec. 8.5, step 3: The only acceptable packets in LISTEN state are DCCP-Request or packets with a valid InitCookie option (InitCookie is an optional, not mandatory, protocol feature). Only if such a packet arrives, RESPOND is entered after sending a DCCP-Response. Then, in step 11, receiving any packet other than DCCP-Request, will trigger the transition to OPEN (`Established') => the request_sock will become a full socket here.
(b) DCCP uses the Sync where TCP would use an ACK - in the case of sequence-invalid packets (RFC 4340, 7.5.4). This however is already handled by calling dccp_send_sync in dccp_check_seqno(),__dcp_rcv_established(), dccp_rcv_state_process(), dccp_rcv_closereq().
c) Conclusion:
--------------
In DCCP the function pointer send_ack of struct request_sock_ops is not necessary, and calling it would mean a protocol violation. The DCCP code is correct in this regard in that it does not call the send_ack virtual function pointer, but the existence of two functions - which are never called and are not necessary - is highly confusing. Therefore, the attached patch replaces the functions with a verbose message (if debugging is enabled), and otherwise flags a BUG().
This solution preserves the generic structure of the request_sock while making sure that RFC 4340 is not violated by the implementation.
------------------------------------------------------------------------------
net/dccp/dccp.h | 5 ++++ net/dccp/ipv4.c | 48 ----------------------------------------------- net/dccp/ipv6.c | 57 -------------------------------------------------------- 3 files changed, 7 insertions(+), 103 deletions(-)
------------------------------------------------------------------------------
net/dccp/dccp.h +5 -0
@@ -130,6 +130,11 @@ extern int dccp_retransmit_skb(struct sextern void dccp_send_ack (struct sock *sk);extern void dccp_send_delayed_ack (struct sock *sk); +static inline void dccp_reqsk_send_ack (struct sk_buff *s,struct request_sock *r) +{ +BUG ();/* ACK packets are never sent in LISTEN/RESPOND state */ +} +extern void dccp_send_sync (struct sock *sk,const u64 seq,const enum dccp_pkt_type pkt_type);
net/dccp/ipv4.c +1 -47
60 lines not on this page · raw message
net/dccp/ipv6.c +1 -56
75 lines not on this page · raw message