Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Add support for changing the MTU to stf(4).



details:   https://anonhg.NetBSD.org/src/rev/37b40b24d400
branches:  trunk
changeset: 574751:37b40b24d400
user:      tron <tron%NetBSD.org@localhost>
date:      Fri Mar 11 13:28:25 2005 +0000

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

diffstat:

 sys/net/if_stf.c |  36 ++++++++++++++++++++++++++----------
 sys/net/if_stf.h |   6 +++++-
 2 files changed, 31 insertions(+), 11 deletions(-)

diffs (111 lines):

diff -r 0b74e90ce450 -r 37b40b24d400 sys/net/if_stf.c
--- a/sys/net/if_stf.c  Fri Mar 11 13:16:10 2005 +0000
+++ b/sys/net/if_stf.c  Fri Mar 11 13:28:25 2005 +0000
@@ -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 @@
 #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 @@
                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 @@
        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 @@
        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 @@
        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 -r 0b74e90ce450 -r 37b40b24d400 sys/net/if_stf.h
--- a/sys/net/if_stf.h  Fri Mar 11 13:16:10 2005 +0000
+++ b/sys/net/if_stf.h  Fri Mar 11 13:28:25 2005 +0000
@@ -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_ */



Home | Main Index | Thread Index | Old Index