: Socket support for feature negotiation and its initialisation
PATCH 7/11 : Socket support for feature negotiation and its initialisation
[DCCP]: Socket support for feature negotiation and its initialisation
This provides feature-negotiation initialisation for both DCCP sockets and DCCP request_sockets, to support feature negotiation during connection setup.
It also resolves a FIXME regarding the congestion control initialisation.
Signed-off-by Gerrit Renker <[email protected]>
--- include/linux/dccp.h | 4 ++++ net/dccp/dccp.h | 3 ++- net/dccp/feat.c | 19 +++++++++++++++++++ net/dccp/feat.h | 1 + net/dccp/input.c | 2 -- net/dccp/ipv4.c | 3 ++- net/dccp/ipv6.c | 3 ++- net/dccp/minisocks.c | 7 ++++++- net/dccp/proto.c | 1 + 9 files changed, 37 insertions(+), 6 deletions(-)
include/linux/dccp.h +4 -0
@@ -424,6 +424,7 @@ struct dccp_ts_echo {* @dreq_iss: initial sequence number sent on the Response (RFC 4340, 7.1) * @dreq_isr: initial sequence number received on the Request * @dreq_service: service code present on the Request (there is just one) +* @dreq_featneg: feature negotiation options for this connection * @dreq_tstamp: most recent timestamp received during connection setup */ struct dccp_request_sock {
@@ -431,6 +432,7 @@ struct dccp_request_sock {__u64 dreq_iss;__u64 dreq_isr;__be32 dreq_service; +struct list_head dreq_featneg;struct dccp_ts_echo *dreq_tstamp; };
@@ -506,6 +508,7 @@ struct dccp_ackvec;* @dccps_mss_cache - current value of MSS (path MTU minus header sizes) * @dccps_rate_last - timestamp for rate-limiting DCCP-Sync (RFC 4340, 7.5.4) * @dccps_minisock - associated minisock (accessed via dccp_msk) +* @dccps_featneg - tracks feature-negotiation state (mostly during handshake) * @dccps_hc_rx_ackvec - rx half connection ack vector * @dccps_hc_rx_ccid - CCID used for the receiver (or receiving half-connection) * @dccps_hc_tx_ccid - CCID used for the sender (or sending half-connection)
@@ -542,6 +545,7 @@ struct dccp_sock {__u32 dccps_mss_cache;unsigned long dccps_rate_last;struct dccp_minisock dccps_minisock; +struct list_head dccps_featneg;struct dccp_ackvec *dccps_hc_rx_ackvec;struct ccid *dccps_hc_rx_ccid;struct ccid *dccps_hc_tx_ccid;
net/dccp/proto.c +1 -0
@@ -177,6 +177,7 @@ int dccp_init_sock(struct sock *sk, consdccp_minisock_init (&dp->dccps_minisock); +INIT_LIST_HEAD (&dp->dccps_featneg);/* * FIXME: We're hardcoding the CCID, and doing this at this point makes * the listening (master) sock get CCID control blocks, which is not
net/dccp/feat.h +1 -0
@@ -95,6 +95,7 @@ extern int dccp_feat_confirm_recv(struc u8 *val, u8 len);extern void dccp_feat_clean (struct dccp_minisock *dmsk);extern int dccp_feat_clone (struct sock *oldsk,struct sock *newsk); +extern int dccp_feat_clone_list (struct list_head const *,struct list_head *);extern int dccp_feat_init (struct dccp_minisock *dmsk);#endif /* _DCCP_FEAT_H */
net/dccp/feat.c +19 -0
@@ -273,6 +273,25 @@ void dccp_feat_list_purge(struct list_heEXPORT_SYMBOL_GPL (dccp_feat_list_purge); +/* generate @to as full clone of @from - @to must not contain any nodes */ +int dccp_feat_clone_list (struct list_head const *from,struct list_head *to) +{ +struct dccp_feat_entry *entry, *new; + +INIT_LIST_HEAD (to); +list_for_each_entry (entry, from, node) { + new =dccp_feat_clone_entry (entry); +if (new =NULL ) + goto cloning_failed; +list_add_tail (&new->node, to); + } +return 0 ; + +cloning_failed: +dccp_feat_list_purge (to); +return -ENOMEM ; +} +int dccp_feat_change (struct dccp_minisock *dmsk,u8 type,u8 feature,u8 *val,u8 len,gfp_t gfp) {
net/dccp/dccp.h +2 -1
@@ -236,7 +236,8 @@ extern const char *dccp_state_name(constextern void dccp_set_state (struct sock *sk,const int state);extern void dccp_done (struct sock *sk); -extern void dccp_reqsk_init (struct request_sock *req,struct sk_buff *skb); +extern int dccp_reqsk_init (struct request_sock *rq,struct dccp_sock const *dp, +struct sk_buff const *skb);extern int dccp_v4_conn_request (struct sock *sk,struct sk_buff *skb);
net/dccp/minisocks.c +6 -1
@@ -124,6 +124,7 @@ struct sock *dccp_create_openreq_child(s newdp->dccps_service = dreq->dreq_service; newicsk->icsk_rto =DCCP_TIMEOUT_INIT ; +INIT_LIST_HEAD (&newdp->dccps_featneg);if (dccp_feat_clone (sk, newsk)) goto out_free;
@@ -302,7 +303,8 @@ void dccp_reqsk_send_ack(struct sk_buffEXPORT_SYMBOL_GPL (dccp_reqsk_send_ack); -void dccp_reqsk_init (struct request_sock *req,struct sk_buff *skb) +int dccp_reqsk_init (struct request_sock *req, +struct dccp_sock const *dp,struct sk_buff const *skb) {struct dccp_request_sock *dreq =dccp_rsk (req);
@@ -310,6 +312,9 @@ void dccp_reqsk_init(struct request_sockinet_rsk (req)->acked =0 ; req->rcv_wnd = sysctl_dccp_feat_sequence_window; dreq->dreq_tstamp =NULL ; + +/* inherit feature negotiation options from listening socket */ +return dccp_feat_clone_list (&dp->dccps_featneg, &dreq->dreq_featneg); }EXPORT_SYMBOL_GPL (dccp_reqsk_init);
net/dccp/ipv4.c +2 -1
@@ -606,7 +606,8 @@ int dccp_v4_conn_request(struct sock *skif (req =NULL ) goto drop; -dccp_reqsk_init (req, skb); +if (dccp_reqsk_init (req,dccp_sk (sk), skb)) + goto drop_and_free; dreq =dccp_rsk (req);if (dccp_parse_options (sk, dreq, skb))
net/dccp/ipv6.c +2 -1
@@ -419,7 +419,8 @@ static int dccp_v6_conn_request(struct sif (req =NULL ) goto drop; -dccp_reqsk_init (req, skb); +if (dccp_reqsk_init (req,dccp_sk (sk), skb)) + goto drop_and_free; dreq =dccp_rsk (req);if (dccp_parse_options (sk, dreq, skb))
net/dccp/input.c +0 -2
@@ -511,8 +511,6 @@ int dccp_rcv_state_process(struct sock *if (inet_csk (sk)->icsk_af_ops->conn_request (sk, skb) <0 )return 1 ; - -/* FIXME: do congestion control initialization */ goto discard; }if (dh->dccph_type =DCCP_PKT_RESET )