diff options
author | brian <brian@FreeBSD.org> | 1999-08-06 13:53:03 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-08-06 13:53:03 +0000 |
commit | 29c67703e3751c283a1bdfe7764effe015c13b83 (patch) | |
tree | ef1e40a5b9d87f3d7f7d7336ae7dc5a534520d3d /sys | |
parent | df1c1756e31202c817f6c35422ebc847da176a0a (diff) | |
download | FreeBSD-src-29c67703e3751c283a1bdfe7764effe015c13b83.zip FreeBSD-src-29c67703e3751c283a1bdfe7764effe015c13b83.tar.gz |
Define IF_MAXMTU and IF_MINMTU and don't allow MTUs with
out-of-range values.
``comparison is always 0'' warnings are silly !
Ok'd by: wollman, dg
Advised by: bde
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 8 | ||||
-rw-r--r-- | sys/net/if_loop.c | 7 | ||||
-rw-r--r-- | sys/net/if_ppp.c | 10 | ||||
-rw-r--r-- | sys/net/if_tun.c | 11 | ||||
-rw-r--r-- | sys/net/if_var.h | 10 |
5 files changed, 31 insertions, 15 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index c6f5c5e..1887c91 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if.c 8.3 (Berkeley) 1/4/94 - * $Id: if.c,v 1.72 1999/06/06 09:28:01 phk Exp $ + * $Id: if.c,v 1.73 1999/06/19 18:42:26 phk Exp $ */ #include "opt_compat.h" @@ -685,11 +685,7 @@ ifioctl(so, cmd, data, p) return (error); if (ifp->if_ioctl == NULL) return (EOPNOTSUPP); - /* - * 72 was chosen below because it is the size of a TCP/IP - * header (40) + the minimum mss (32). - */ - if (ifr->ifr_mtu < 72 || ifr->ifr_mtu > 65535) + if (ifr->ifr_mtu < IF_MINMTU || ifr->ifr_mtu > IF_MAXMTU) return (EINVAL); error = (*ifp->if_ioctl)(ifp, cmd, data); if (error == 0) diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 55abbf5..bc4b544 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_loop.c 8.1 (Berkeley) 6/10/93 - * $Id: if_loop.c,v 1.38 1999/02/20 21:03:53 dt Exp $ + * $Id: if_loop.c,v 1.39 1999/07/06 19:23:13 des Exp $ */ /* @@ -346,7 +346,10 @@ loioctl(ifp, cmd, data) break; case SIOCSIFMTU: - ifp->if_mtu = ifr->ifr_mtu; + if (ifr->ifr_mtu < IF_MINMTU || ifr->ifr_mtu > IF_MAXMTU) + error = EINVAL; + else + ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index a1490bb..9598d21 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -69,7 +69,7 @@ * Paul Mackerras (paulus@cs.anu.edu.au). */ -/* $Id: if_ppp.c,v 1.60 1999/04/27 11:17:00 phk Exp $ */ +/* $Id: if_ppp.c,v 1.61 1999/07/06 19:23:13 des Exp $ */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ @@ -618,9 +618,13 @@ pppsioctl(ifp, cmd, data) if (ifr->ifr_mtu > PPP_MAXMTU) error = EINVAL; else { - sc->sc_if.if_mtu = ifr->ifr_mtu; - if (sc->sc_setmtu) + if (ifr->ifr_mtu < IF_MINMTU || ifr->ifr_mtu > IF_MAXMTU) + error = EINVAL; + else { + sc->sc_if.if_mtu = ifr->ifr_mtu; + if (sc->sc_setmtu) (*sc->sc_setmtu)(sc); + } } break; diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 16542de..3cb8f6b 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -302,9 +302,12 @@ tunifioctl(ifp, cmd, data) ifp->if_name, ifp->if_unit); break; case SIOCSIFMTU: - ifp->if_mtu = ifr->ifr_mtu; - TUNDEBUG("%s%d: mtu set\n", - ifp->if_name, ifp->if_unit); + if (ifr->ifr_mtu < IF_MINMTU || ifr->ifr_mtu > IF_MAXMTU) + error = EINVAL; + else { + ifp->if_mtu = ifr->ifr_mtu; + TUNDEBUG("%s%d: mtu set\n", ifp->if_name, ifp->if_unit); + } break; case SIOCADDMULTI: case SIOCDELMULTI: @@ -435,6 +438,8 @@ tunioctl(dev, cmd, data, flag, p) switch (cmd) { case TUNSIFINFO: tunp = (struct tuninfo *)data; + if (tunp->mtu < IF_MINMTU || tunp->mtu > IF_MAXMTU) + return (EINVAL); tp->tun_if.if_mtu = tunp->mtu; tp->tun_if.if_type = tunp->type; tp->tun_if.if_baudrate = tunp->baudrate; diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 35780d6..8163f60 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * From: @(#)if.h 8.1 (Berkeley) 6/10/93 - * $Id: if_var.h,v 1.12 1999/05/06 18:12:55 peter Exp $ + * $Id: if_var.h,v 1.13 1999/05/16 17:09:20 pb Exp $ */ #ifndef _NET_IF_VAR_H_ @@ -231,6 +231,14 @@ int if_enq_drop __P((struct ifqueue *, struct mbuf *)); #endif #endif + +/* + * 72 was chosen below because it is the size of a TCP/IP + * header (40) + the minimum mss (32). + */ +#define IF_MINMTU 72 +#define IF_MAXMTU 65535 + #endif /* KERNEL */ /* |