aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-16 19:58:33 -0400
committerDavid S. Miller <davem@davemloft.net>2005-09-16 19:58:33 -0400
commit0c10c5d96865ce611d6a780888eff0ef4fab358b (patch)
treeab1303166355b32730185445557623bec09a1dcb /net
parent37f7f421cce13435fdc0d870caf51141e5ebf079 (diff)
[DCCP]: More precisely set reset_code when sending RESET packets
Moving the setting of DCCP_SKB_CB(skb)->dccpd_reset_code to the places where events happen that trigger sending a RESET packet. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dccp/input.c22
-rw-r--r--net/dccp/ipv4.c10
2 files changed, 18 insertions, 14 deletions
diff --git a/net/dccp/input.c b/net/dccp/input.c
index c74034cf7ede..062e9f8359d0 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -384,9 +384,9 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
384 } 384 }
385 385
386out_invalid_packet: 386out_invalid_packet:
387 return 1; /* dccp_v4_do_rcv will send a reset, but... 387 /* dccp_v4_do_rcv will send a reset */
388 FIXME: the reset code should be 388 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_PACKET_ERROR;
389 DCCP_RESET_CODE_PACKET_ERROR */ 389 return 1;
390} 390}
391 391
392static int dccp_rcv_respond_partopen_state_process(struct sock *sk, 392static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
@@ -433,6 +433,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
433 struct dccp_hdr *dh, unsigned len) 433 struct dccp_hdr *dh, unsigned len)
434{ 434{
435 struct dccp_sock *dp = dccp_sk(sk); 435 struct dccp_sock *dp = dccp_sk(sk);
436 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
436 const int old_state = sk->sk_state; 437 const int old_state = sk->sk_state;
437 int queued = 0; 438 int queued = 0;
438 439
@@ -473,7 +474,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
473 if (dh->dccph_type == DCCP_PKT_RESET) 474 if (dh->dccph_type == DCCP_PKT_RESET)
474 goto discard; 475 goto discard;
475 476
476 /* Caller (dccp_v4_do_rcv) will send Reset(No Connection)*/ 477 /* Caller (dccp_v4_do_rcv) will send Reset */
478 dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
477 return 1; 479 return 1;
478 } 480 }
479 481
@@ -487,8 +489,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
487 if (dccp_parse_options(sk, skb)) 489 if (dccp_parse_options(sk, skb))
488 goto discard; 490 goto discard;
489 491
490 if (DCCP_SKB_CB(skb)->dccpd_ack_seq != 492 if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
491 DCCP_PKT_WITHOUT_ACK_SEQ)
492 dccp_event_ack_recv(sk, skb); 493 dccp_event_ack_recv(sk, skb);
493 494
494 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); 495 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
@@ -500,7 +501,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
500 */ 501 */
501 if (dp->dccps_options.dccpo_send_ack_vector) { 502 if (dp->dccps_options.dccpo_send_ack_vector) {
502 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, 503 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk,
503 DCCP_SKB_CB(skb)->dccpd_seq, 504 dcb->dccpd_seq,
504 DCCP_ACKPKTS_STATE_RECEIVED)) 505 DCCP_ACKPKTS_STATE_RECEIVED))
505 goto discard; 506 goto discard;
506 /* 507 /*
@@ -551,8 +552,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
551 dh->dccph_type == DCCP_PKT_REQUEST) || 552 dh->dccph_type == DCCP_PKT_REQUEST) ||
552 (sk->sk_state == DCCP_RESPOND && 553 (sk->sk_state == DCCP_RESPOND &&
553 dh->dccph_type == DCCP_PKT_DATA)) { 554 dh->dccph_type == DCCP_PKT_DATA)) {
554 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, 555 dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNC);
555 DCCP_PKT_SYNC);
556 goto discard; 556 goto discard;
557 } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) { 557 } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) {
558 dccp_rcv_closereq(sk, skb); 558 dccp_rcv_closereq(sk, skb);
@@ -563,13 +563,13 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
563 } 563 }
564 564
565 if (unlikely(dh->dccph_type == DCCP_PKT_SYNC)) { 565 if (unlikely(dh->dccph_type == DCCP_PKT_SYNC)) {
566 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, 566 dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNCACK);
567 DCCP_PKT_SYNCACK);
568 goto discard; 567 goto discard;
569 } 568 }
570 569
571 switch (sk->sk_state) { 570 switch (sk->sk_state) {
572 case DCCP_CLOSED: 571 case DCCP_CLOSED:
572 dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
573 return 1; 573 return 1;
574 574
575 case DCCP_REQUESTING: 575 case DCCP_REQUESTING:
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 2afaa464e7f0..e09907d8b7da 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -669,12 +669,16 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
669 struct dccp_request_sock *dreq; 669 struct dccp_request_sock *dreq;
670 const __u32 saddr = skb->nh.iph->saddr; 670 const __u32 saddr = skb->nh.iph->saddr;
671 const __u32 daddr = skb->nh.iph->daddr; 671 const __u32 daddr = skb->nh.iph->daddr;
672 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
673 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
672 struct dst_entry *dst = NULL; 674 struct dst_entry *dst = NULL;
673 675
674 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */ 676 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
675 if (((struct rtable *)skb->dst)->rt_flags & 677 if (((struct rtable *)skb->dst)->rt_flags &
676 (RTCF_BROADCAST | RTCF_MULTICAST)) 678 (RTCF_BROADCAST | RTCF_MULTICAST)) {
679 reset_code = DCCP_RESET_CODE_NO_CONNECTION;
677 goto drop; 680 goto drop;
681 }
678 682
679 /* 683 /*
680 * TW buckets are converted to open requests without 684 * TW buckets are converted to open requests without
@@ -718,7 +722,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
718 * dccp_create_openreq_child. 722 * dccp_create_openreq_child.
719 */ 723 */
720 dreq = dccp_rsk(req); 724 dreq = dccp_rsk(req);
721 dreq->dreq_isr = DCCP_SKB_CB(skb)->dccpd_seq; 725 dreq->dreq_isr = dcb->dccpd_seq;
722 dreq->dreq_iss = dccp_v4_init_sequence(sk, skb); 726 dreq->dreq_iss = dccp_v4_init_sequence(sk, skb);
723 dreq->dreq_service = dccp_hdr_request(skb)->dccph_req_service; 727 dreq->dreq_service = dccp_hdr_request(skb)->dccph_req_service;
724 728
@@ -735,6 +739,7 @@ drop_and_free:
735 __reqsk_free(req); 739 __reqsk_free(req);
736drop: 740drop:
737 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS); 741 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
742 dcb->dccpd_reset_code = reset_code;
738 return -1; 743 return -1;
739} 744}
740 745
@@ -1005,7 +1010,6 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
1005 return 0; 1010 return 0;
1006 1011
1007reset: 1012reset:
1008 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
1009 dccp_v4_ctl_send_reset(skb); 1013 dccp_v4_ctl_send_reset(skb);
1010discard: 1014discard:
1011 kfree_skb(skb); 1015 kfree_skb(skb);