: calling dccp_v{4,6}_reqsk_send_ack is a BUG
PATCH 6/10 : 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 unnecessary, 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 - see e.g. the posting on
http://www.mail-archive.com/[email protected]/msg00419.html
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.
Commiter note: I've demoted the BUG() all to the equivalente of a WARN_ON, i.e. print a message and dump the stack.
------------------------------------------------------------------------------
dccp.h | 2 ++ ipv4.c | 48 +----------------------------------------------- ipv6.c | 57 +-------------------------------------------------------- minisocks.c | 10 ++++++++++ 4 files changed, 14 insertions(+), 103 deletions(-)
------------------------------------------------------------------------------
net/dccp/dccp.h +2 -0
@@ -131,6 +131,8 @@ extern int dccp_retransmit_skb(struct sextern void dccp_send_ack (struct sock *sk);extern void dccp_send_delayed_ack (struct sock *sk); +extern void dccp_reqsk_send_ack (struct sk_buff *sk,struct request_sock *rsk); +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
net/dccp/minisocks.c +10 -0
@@ -11,6 +11,7 @@*/ #include <linux/dccp.h> +#include <linux/kernel.h> #include <linux/skbuff.h> #include <linux/timer.h>
@@ -283,3 +284,12 @@ int dccp_child_process(struct sock *pare }EXPORT_SYMBOL_GPL (dccp_child_process); + +void dccp_reqsk_send_ack (struct sk_buff *skb,struct request_sock *rsk) +{ +pr_info (KERN_WARNING "DCCP: ACK packets are never sent in " +"LISTEN/RESPOND state\n" ); +dump_stack (); +} + +EXPORT_SYMBOL_GPL (dccp_reqsk_send_ack);