Deleted Added
full compact
tcp_usrreq.c (32821) tcp_usrreq.c (38482)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
34 * $Id: tcp_usrreq.c,v 1.36 1997/12/18 09:50:38 davidg Exp $
34 * $Id: tcp_usrreq.c,v 1.37 1998/01/27 09:15:11 davidg Exp $
35 */
36
37#include "opt_tcpdebug.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>
42#include <sys/sysctl.h>

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

555 } else {
556 taop->tao_ccsent = 0;
557 tp->t_flags |= TF_SENDCCNEW;
558 }
559
560 return 0;
561}
562
35 */
36
37#include "opt_tcpdebug.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>
42#include <sys/sysctl.h>

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

555 } else {
556 taop->tao_ccsent = 0;
557 tp->t_flags |= TF_SENDCCNEW;
558 }
559
560 return 0;
561}
562
563/*
564 * The new sockopt interface makes it possible for us to block in the
565 * copyin/out step (if we take a page fault). Taking a page fault at
566 * splnet() is probably a Bad Thing. (Since sockets and pcbs both now
567 * use TSM, there probably isn't any need for this function to run at
568 * splnet() any more. This needs more examination.)
569 */
563int
570int
564tcp_ctloutput(op, so, level, optname, mp, p)
565 int op;
571tcp_ctloutput(so, sopt)
566 struct socket *so;
572 struct socket *so;
567 int level, optname;
568 struct mbuf **mp;
569 struct proc *p;
573 struct sockopt *sopt;
570{
574{
571 int error = 0, s;
572 struct inpcb *inp;
573 register struct tcpcb *tp;
574 register struct mbuf *m;
575 register int i;
575 int error, opt, optval, s;
576 struct inpcb *inp;
577 struct tcpcb *tp;
578 struct mbuf *m;
576
579
577 s = splnet();
580 error = 0;
581 s = splnet(); /* XXX */
578 inp = sotoinpcb(so);
579 if (inp == NULL) {
580 splx(s);
582 inp = sotoinpcb(so);
583 if (inp == NULL) {
584 splx(s);
581 if (op == PRCO_SETOPT && *mp)
582 (void) m_free(*mp);
583 return (ECONNRESET);
584 }
585 return (ECONNRESET);
586 }
585 if (level != IPPROTO_TCP) {
586 error = ip_ctloutput(op, so, level, optname, mp, p);
587 if (sopt->sopt_level != IPPROTO_TCP) {
588 error = ip_ctloutput(so, sopt);
587 splx(s);
588 return (error);
589 }
590 tp = intotcpcb(inp);
591
589 splx(s);
590 return (error);
591 }
592 tp = intotcpcb(inp);
593
592 switch (op) {
594 switch (sopt->sopt_dir) {
595 case SOPT_SET:
596 switch (sopt->sopt_name) {
597 case TCP_NODELAY:
598 case TCP_NOOPT:
599 case TCP_NOPUSH:
600 error = sooptcopyin(sopt, &optval, sizeof optval,
601 sizeof optval);
602 if (error)
603 break;
593
604
594 case PRCO_SETOPT:
595 m = *mp;
596 switch (optname) {
605 switch (sopt->sopt_name) {
606 case TCP_NODELAY:
607 opt = TF_NODELAY;
608 break;
609 case TCP_NOOPT:
610 opt = TF_NOOPT;
611 break;
612 case TCP_NOPUSH:
613 opt = TF_NOPUSH;
614 break;
615 default:
616 opt = 0; /* dead code to fool gcc */
617 break;
618 }
597
619
598 case TCP_NODELAY:
599 if (m == NULL || m->m_len < sizeof (int))
600 error = EINVAL;
601 else if (*mtod(m, int *))
602 tp->t_flags |= TF_NODELAY;
620 if (optval)
621 tp->t_flags |= opt;
603 else
622 else
604 tp->t_flags &= ~TF_NODELAY;
623 tp->t_flags &= ~opt;
605 break;
606
607 case TCP_MAXSEG:
624 break;
625
626 case TCP_MAXSEG:
608 if (m && (i = *mtod(m, int *)) > 0 && i <= tp->t_maxseg)
609 tp->t_maxseg = i;
610 else
611 error = EINVAL;
612 break;
627 error = sooptcopyin(sopt, &optval, sizeof optval,
628 sizeof optval);
629 if (error)
630 break;
613
631
614 case TCP_NOOPT:
615 if (m == NULL || m->m_len < sizeof (int))
616 error = EINVAL;
617 else if (*mtod(m, int *))
618 tp->t_flags |= TF_NOOPT;
632 if (optval > 0 && optval <= tp->t_maxseg)
633 tp->t_maxseg = optval;
619 else
634 else
620 tp->t_flags &= ~TF_NOOPT;
621 break;
622
623 case TCP_NOPUSH:
624 if (m == NULL || m->m_len < sizeof (int))
625 error = EINVAL;
635 error = EINVAL;
626 else if (*mtod(m, int *))
627 tp->t_flags |= TF_NOPUSH;
628 else
629 tp->t_flags &= ~TF_NOPUSH;
630 break;
631
632 default:
633 error = ENOPROTOOPT;
634 break;
635 }
636 break;
637
638 default:
639 error = ENOPROTOOPT;
640 break;
641 }
636 if (m)
637 (void) m_free(m);
638 break;
639
642 break;
643
640 case PRCO_GETOPT:
641 *mp = m = m_get(M_WAIT, MT_SOOPTS);
642 m->m_len = sizeof(int);
643
644 switch (optname) {
644 case SOPT_GET:
645 switch (sopt->sopt_name) {
645 case TCP_NODELAY:
646 case TCP_NODELAY:
646 *mtod(m, int *) = tp->t_flags & TF_NODELAY;
647 optval = tp->t_flags & TF_NODELAY;
647 break;
648 case TCP_MAXSEG:
648 break;
649 case TCP_MAXSEG:
649 *mtod(m, int *) = tp->t_maxseg;
650 optval = tp->t_maxseg;
650 break;
651 case TCP_NOOPT:
651 break;
652 case TCP_NOOPT:
652 *mtod(m, int *) = tp->t_flags & TF_NOOPT;
653 optval = tp->t_flags & TF_NOOPT;
653 break;
654 case TCP_NOPUSH:
654 break;
655 case TCP_NOPUSH:
655 *mtod(m, int *) = tp->t_flags & TF_NOPUSH;
656 optval = tp->t_flags & TF_NOPUSH;
656 break;
657 default:
658 error = ENOPROTOOPT;
659 break;
660 }
657 break;
658 default:
659 error = ENOPROTOOPT;
660 break;
661 }
662 if (error == 0)
663 error = sooptcopyout(sopt, &optval, sizeof optval);
661 break;
662 }
663 splx(s);
664 return (error);
665}
666
667/*
668 * tcp_sendspace and tcp_recvspace are the default send and receive window

--- 119 unchanged lines hidden ---
664 break;
665 }
666 splx(s);
667 return (error);
668}
669
670/*
671 * tcp_sendspace and tcp_recvspace are the default send and receive window

--- 119 unchanged lines hidden ---