Changed tcp_ctloutput to return ENOPROTOOPT for unknown options.
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 4 Jan 1994 09:36:48 +0000 (01:36 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 4 Jan 1994 09:36:48 +0000 (01:36 -0800)
While doing this, I noticed that an mbuf is lost if a setsockopt is done
on a tcp connection that has been reset, and fixed this as well.
From: Mike Karels <karels@BSDI.COM>

SCCS-vsn: sys/netinet/tcp_usrreq.c 8.2

usr/src/sys/netinet/tcp_usrreq.c

index dab29a7..39bd80b 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tcp_usrreq.c        8.1 (Berkeley) %G%
+ *     @(#)tcp_usrreq.c        8.2 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -328,6 +328,8 @@ tcp_ctloutput(op, so, level, optname, mp)
        inp = sotoinpcb(so);
        if (inp == NULL) {
                splx(s);
        inp = sotoinpcb(so);
        if (inp == NULL) {
                splx(s);
+               if (op == PRCO_SETOPT && *mp)
+                       (void) m_free(*mp);
                return (ECONNRESET);
        }
        if (level != IPPROTO_TCP) {
                return (ECONNRESET);
        }
        if (level != IPPROTO_TCP) {
@@ -360,7 +362,7 @@ tcp_ctloutput(op, so, level, optname, mp)
                        break;
 
                default:
                        break;
 
                default:
-                       error = EINVAL;
+                       error = ENOPROTOOPT;
                        break;
                }
                if (m)
                        break;
                }
                if (m)
@@ -379,7 +381,7 @@ tcp_ctloutput(op, so, level, optname, mp)
                        *mtod(m, int *) = tp->t_maxseg;
                        break;
                default:
                        *mtod(m, int *) = tp->t_maxseg;
                        break;
                default:
-                       error = EINVAL;
+                       error = ENOPROTOOPT;
                        break;
                }
                break;
                        break;
                }
                break;