From e561507a1fc5c579aec8860ede9c22a614ff439e Mon Sep 17 00:00:00 2001 From: tron Date: Fri, 11 Mar 2005 13:28:25 +0000 Subject: [PATCH] Add support for changing the MTU to stf(4). --- sys/net/if_stf.c | 36 ++++++++++++++++++++++++++---------- sys/net/if_stf.h | 6 +++++- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 9b34be19b730..3dfada8af89d 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_stf.c,v 1.45 2005/02/26 22:45:09 perry Exp $ */ +/* $NetBSD: if_stf.c,v 1.46 2005/03/11 13:28:25 tron Exp $ */ /* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */ /* @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.45 2005/02/26 22:45:09 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.46 2005/03/11 13:28:25 tron Exp $"); #include "opt_inet.h" @@ -86,6 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.45 2005/02/26 22:45:09 perry Exp $"); #include #include #include +#include #include #include #include @@ -212,7 +213,7 @@ stf_clone_create(ifc, unit) return (EIO); /* XXX */ } - sc->sc_if.if_mtu = IPV6_MMTU; + sc->sc_if.if_mtu = STF_MTU; sc->sc_if.if_flags = 0; sc->sc_if.if_ioctl = stf_ioctl; sc->sc_if.if_output = stf_output; @@ -689,9 +690,12 @@ stf_rtrequest(cmd, rt, info) struct rtentry *rt; struct rt_addrinfo *info; { + if (rt != NULL) { + struct stf_softc *sc; - if (rt) - rt->rt_rmx.rmx_mtu = IPV6_MMTU; + sc = LIST_FIRST(&stf_softc_list); + rt->rt_rmx.rmx_mtu = (sc != NULL) ? sc->sc_if.if_mtu : STF_MTU; + } } static int @@ -700,10 +704,12 @@ stf_ioctl(ifp, cmd, data) u_long cmd; caddr_t data; { - struct ifaddr *ifa; - struct ifreq *ifr; - struct sockaddr_in6 *sin6; - int error; + struct proc *p = curproc; /* XXX */ + struct ifaddr *ifa; + struct ifreq *ifr; + struct sockaddr_in6 *sin6; + int error; + u_long mtu; error = 0; switch (cmd) { @@ -725,12 +731,22 @@ stf_ioctl(ifp, cmd, data) case SIOCADDMULTI: case SIOCDELMULTI: ifr = (struct ifreq *)data; - if (ifr && ifr->ifr_addr.sa_family == AF_INET6) + if (ifr != NULL && ifr->ifr_addr.sa_family == AF_INET6) ; else error = EAFNOSUPPORT; break; + case SIOCSIFMTU: + if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) + break; + ifr = (struct ifreq *)data; + mtu = ifr->ifr_mtu; + if (mtu < STF_MTU_MIN || mtu > STF_MTU_MAX) + return EINVAL; + ifp->if_mtu = mtu; + break; + default: error = EINVAL; break; diff --git a/sys/net/if_stf.h b/sys/net/if_stf.h index 8c0d6a2a7ebe..0175d4709663 100644 --- a/sys/net/if_stf.h +++ b/sys/net/if_stf.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_stf.h,v 1.1 2000/04/19 06:30:53 itojun Exp $ */ +/* $NetBSD: if_stf.h,v 1.2 2005/03/11 13:28:25 tron Exp $ */ /* $KAME: if_stf.h,v 1.3 2000/03/25 07:23:33 sumikawa Exp $ */ /* @@ -33,6 +33,10 @@ #ifndef _NET_IF_STF_H_ #define _NET_IF_STF_H_ +#define STF_MTU (1280) /* Default MTU */ +#define STF_MTU_MIN (1280) /* Minimum MTU */ +#define STF_MTU_MAX (8192) /* Maximum MTU */ + void in_stf_input __P((struct mbuf *, ...)); #endif /* _NET_IF_STF_H_ */