Add support for changing the MTU to stf(4).

This commit is contained in:
tron 2005-03-11 13:28:25 +00:00
parent 1a27add367
commit e561507a1f
2 changed files with 31 additions and 11 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/mbuf.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/queue.h>
#include <sys/syslog.h>
@ -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;

View File

@ -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_ */