proto.c (9b8321531a90c400e9c561d903926eee79639dcf) proto.c (871a2c16c21b988688b4ab1a78eadd969765c0a3)
1/*
2 * net/dccp/proto.c
3 *
4 * An implementation of the DCCP protocol
5 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as

--- 171 unchanged lines hidden (view full) ---

180 sk->sk_state = DCCP_CLOSED;
181 sk->sk_write_space = dccp_write_space;
182 icsk->icsk_sync_mss = dccp_sync_mss;
183 dp->dccps_mss_cache = 536;
184 dp->dccps_rate_last = jiffies;
185 dp->dccps_role = DCCP_ROLE_UNDEFINED;
186 dp->dccps_service = DCCP_SERVICE_CODE_IS_ABSENT;
187 dp->dccps_l_ack_ratio = dp->dccps_r_ack_ratio = 1;
1/*
2 * net/dccp/proto.c
3 *
4 * An implementation of the DCCP protocol
5 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as

--- 171 unchanged lines hidden (view full) ---

180 sk->sk_state = DCCP_CLOSED;
181 sk->sk_write_space = dccp_write_space;
182 icsk->icsk_sync_mss = dccp_sync_mss;
183 dp->dccps_mss_cache = 536;
184 dp->dccps_rate_last = jiffies;
185 dp->dccps_role = DCCP_ROLE_UNDEFINED;
186 dp->dccps_service = DCCP_SERVICE_CODE_IS_ABSENT;
187 dp->dccps_l_ack_ratio = dp->dccps_r_ack_ratio = 1;
188 dp->dccps_tx_qlen = sysctl_dccp_tx_qlen;
188
189 dccp_init_xmit_timers(sk);
190
191 INIT_LIST_HEAD(&dp->dccps_featneg);
192 /* control socket doesn't need feat nego */
193 if (likely(ctl_sock_initialized))
194 return dccp_feat_init(sk);
195 return 0;

--- 331 unchanged lines hidden (view full) ---

527 dp->dccps_server_timewait = (val != 0);
528 break;
529 case DCCP_SOCKOPT_SEND_CSCOV:
530 err = dccp_setsockopt_cscov(sk, val, false);
531 break;
532 case DCCP_SOCKOPT_RECV_CSCOV:
533 err = dccp_setsockopt_cscov(sk, val, true);
534 break;
189
190 dccp_init_xmit_timers(sk);
191
192 INIT_LIST_HEAD(&dp->dccps_featneg);
193 /* control socket doesn't need feat nego */
194 if (likely(ctl_sock_initialized))
195 return dccp_feat_init(sk);
196 return 0;

--- 331 unchanged lines hidden (view full) ---

528 dp->dccps_server_timewait = (val != 0);
529 break;
530 case DCCP_SOCKOPT_SEND_CSCOV:
531 err = dccp_setsockopt_cscov(sk, val, false);
532 break;
533 case DCCP_SOCKOPT_RECV_CSCOV:
534 err = dccp_setsockopt_cscov(sk, val, true);
535 break;
536 case DCCP_SOCKOPT_QPOLICY_ID:
537 if (sk->sk_state != DCCP_CLOSED)
538 err = -EISCONN;
539 else if (val < 0 || val >= DCCPQ_POLICY_MAX)
540 err = -EINVAL;
541 else
542 dp->dccps_qpolicy = val;
543 break;
544 case DCCP_SOCKOPT_QPOLICY_TXQLEN:
545 if (val < 0)
546 err = -EINVAL;
547 else
548 dp->dccps_tx_qlen = val;
549 break;
535 default:
536 err = -ENOPROTOOPT;
537 break;
538 }
539 release_sock(sk);
540
541 return err;
542}

--- 91 unchanged lines hidden (view full) ---

634 val = dp->dccps_server_timewait;
635 break;
636 case DCCP_SOCKOPT_SEND_CSCOV:
637 val = dp->dccps_pcslen;
638 break;
639 case DCCP_SOCKOPT_RECV_CSCOV:
640 val = dp->dccps_pcrlen;
641 break;
550 default:
551 err = -ENOPROTOOPT;
552 break;
553 }
554 release_sock(sk);
555
556 return err;
557}

--- 91 unchanged lines hidden (view full) ---

649 val = dp->dccps_server_timewait;
650 break;
651 case DCCP_SOCKOPT_SEND_CSCOV:
652 val = dp->dccps_pcslen;
653 break;
654 case DCCP_SOCKOPT_RECV_CSCOV:
655 val = dp->dccps_pcrlen;
656 break;
657 case DCCP_SOCKOPT_QPOLICY_ID:
658 val = dp->dccps_qpolicy;
659 break;
660 case DCCP_SOCKOPT_QPOLICY_TXQLEN:
661 val = dp->dccps_tx_qlen;
662 break;
642 case 128 ... 191:
643 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
644 len, (u32 __user *)optval, optlen);
645 case 192 ... 255:
646 return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname,
647 len, (u32 __user *)optval, optlen);
648 default:
649 return -ENOPROTOOPT;

--- 26 unchanged lines hidden (view full) ---

676 return inet_csk_compat_getsockopt(sk, level, optname,
677 optval, optlen);
678 return do_dccp_getsockopt(sk, level, optname, optval, optlen);
679}
680
681EXPORT_SYMBOL_GPL(compat_dccp_getsockopt);
682#endif
683
663 case 128 ... 191:
664 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
665 len, (u32 __user *)optval, optlen);
666 case 192 ... 255:
667 return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname,
668 len, (u32 __user *)optval, optlen);
669 default:
670 return -ENOPROTOOPT;

--- 26 unchanged lines hidden (view full) ---

697 return inet_csk_compat_getsockopt(sk, level, optname,
698 optval, optlen);
699 return do_dccp_getsockopt(sk, level, optname, optval, optlen);
700}
701
702EXPORT_SYMBOL_GPL(compat_dccp_getsockopt);
703#endif
704
705static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb)
706{
707 struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
708
709 /*
710 * Assign an (opaque) qpolicy priority value to skb->priority.
711 *
712 * We are overloading this skb field for use with the qpolicy subystem.
713 * The skb->priority is normally used for the SO_PRIORITY option, which
714 * is initialised from sk_priority. Since the assignment of sk_priority
715 * to skb->priority happens later (on layer 3), we overload this field
716 * for use with queueing priorities as long as the skb is on layer 4.
717 * The default priority value (if nothing is set) is 0.
718 */
719 skb->priority = 0;
720
721 for (; cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
722
723 if (!CMSG_OK(msg, cmsg))
724 return -EINVAL;
725
726 if (cmsg->cmsg_level != SOL_DCCP)
727 continue;
728
729 switch (cmsg->cmsg_type) {
730 case DCCP_SCM_PRIORITY:
731 if (cmsg->cmsg_len != CMSG_LEN(sizeof(__u32)))
732 return -EINVAL;
733 skb->priority = *(__u32 *)CMSG_DATA(cmsg);
734 break;
735 default:
736 return -EINVAL;
737 }
738 }
739 return 0;
740}
741
684int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
685 size_t len)
686{
687 const struct dccp_sock *dp = dccp_sk(sk);
688 const int flags = msg->msg_flags;
689 const int noblock = flags & MSG_DONTWAIT;
690 struct sk_buff *skb;
691 int rc, size;
692 long timeo;
693
694 if (len > dp->dccps_mss_cache)
695 return -EMSGSIZE;
696
697 lock_sock(sk);
698
742int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
743 size_t len)
744{
745 const struct dccp_sock *dp = dccp_sk(sk);
746 const int flags = msg->msg_flags;
747 const int noblock = flags & MSG_DONTWAIT;
748 struct sk_buff *skb;
749 int rc, size;
750 long timeo;
751
752 if (len > dp->dccps_mss_cache)
753 return -EMSGSIZE;
754
755 lock_sock(sk);
756
699 if (sysctl_dccp_tx_qlen &&
700 (sk->sk_write_queue.qlen >= sysctl_dccp_tx_qlen)) {
757 if (dccp_qpolicy_full(sk)) {
701 rc = -EAGAIN;
702 goto out_release;
703 }
704
705 timeo = sock_sndtimeo(sk, noblock);
706
707 /*
708 * We have to use sk_stream_wait_connect here to set sk_write_pending,

--- 11 unchanged lines hidden (view full) ---

720 if (skb == NULL)
721 goto out_release;
722
723 skb_reserve(skb, sk->sk_prot->max_header);
724 rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
725 if (rc != 0)
726 goto out_discard;
727
758 rc = -EAGAIN;
759 goto out_release;
760 }
761
762 timeo = sock_sndtimeo(sk, noblock);
763
764 /*
765 * We have to use sk_stream_wait_connect here to set sk_write_pending,

--- 11 unchanged lines hidden (view full) ---

777 if (skb == NULL)
778 goto out_release;
779
780 skb_reserve(skb, sk->sk_prot->max_header);
781 rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
782 if (rc != 0)
783 goto out_discard;
784
728 skb_queue_tail(&sk->sk_write_queue, skb);
785 rc = dccp_msghdr_parse(msg, skb);
786 if (rc != 0)
787 goto out_discard;
788
789 dccp_qpolicy_push(sk, skb);
729 /*
730 * The xmit_timer is set if the TX CCID is rate-based and will expire
731 * when congestion control permits to release further packets into the
732 * network. Window-based CCIDs do not use this timer.
733 */
734 if (!timer_pending(&dp->dccps_xmit_timer))
735 dccp_write_xmit(sk);
736out_release:

--- 456 unchanged lines hidden ---
790 /*
791 * The xmit_timer is set if the TX CCID is rate-based and will expire
792 * when congestion control permits to release further packets into the
793 * network. Window-based CCIDs do not use this timer.
794 */
795 if (!timer_pending(&dp->dccps_xmit_timer))
796 dccp_write_xmit(sk);
797out_release:

--- 456 unchanged lines hidden ---