aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/output.c')
-rw-r--r--net/dccp/output.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/net/dccp/output.c b/net/dccp/output.c
index f4bde2056204..6a334ed5e9d6 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -327,6 +327,58 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
327 327
328EXPORT_SYMBOL_GPL(dccp_make_response); 328EXPORT_SYMBOL_GPL(dccp_make_response);
329 329
330/* answer offending packet in @rcv_skb with Reset from control socket @ctl */
331struct sk_buff *dccp_ctl_make_reset(struct socket *ctl, struct sk_buff *rcv_skb)
332{
333 struct dccp_hdr *rxdh = dccp_hdr(rcv_skb), *dh;
334 struct dccp_skb_cb *dcb = DCCP_SKB_CB(rcv_skb);
335 const u32 dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
336 sizeof(struct dccp_hdr_ext) +
337 sizeof(struct dccp_hdr_reset);
338 struct dccp_hdr_reset *dhr;
339 struct sk_buff *skb;
340
341 skb = alloc_skb(ctl->sk->sk_prot->max_header, GFP_ATOMIC);
342 if (skb == NULL)
343 return NULL;
344
345 skb_reserve(skb, ctl->sk->sk_prot->max_header);
346
347 /* Swap the send and the receive. */
348 dh = dccp_zeroed_hdr(skb, dccp_hdr_reset_len);
349 dh->dccph_type = DCCP_PKT_RESET;
350 dh->dccph_sport = rxdh->dccph_dport;
351 dh->dccph_dport = rxdh->dccph_sport;
352 dh->dccph_doff = dccp_hdr_reset_len / 4;
353 dh->dccph_x = 1;
354
355 dhr = dccp_hdr_reset(skb);
356 dhr->dccph_reset_code = dcb->dccpd_reset_code;
357
358 switch (dcb->dccpd_reset_code) {
359 case DCCP_RESET_CODE_PACKET_ERROR:
360 dhr->dccph_reset_data[0] = rxdh->dccph_type;
361 break;
362 case DCCP_RESET_CODE_OPTION_ERROR: /* fall through */
363 case DCCP_RESET_CODE_MANDATORY_ERROR:
364 memcpy(dhr->dccph_reset_data, dcb->dccpd_reset_data, 3);
365 break;
366 }
367 /*
368 * From RFC 4340, 8.3.1:
369 * If P.ackno exists, set R.seqno := P.ackno + 1.
370 * Else set R.seqno := 0.
371 */
372 if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
373 dccp_hdr_set_seq(dh, ADD48(dcb->dccpd_ack_seq, 1));
374 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dcb->dccpd_seq);
375
376 dccp_csum_outgoing(skb);
377 return skb;
378}
379
380EXPORT_SYMBOL_GPL(dccp_ctl_make_reset);
381
330/* send Reset on established socket, to close or abort the connection */ 382/* send Reset on established socket, to close or abort the connection */
331int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code) 383int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code)
332{ 384{