Subject: bin/1648: changing the mtu is not possible with ifconfig
To: None <gnats-bugs@gnats.netbsd.org>
From: None <leo@dachau.marco.de>
List: netbsd-bugs
Date: 10/18/1995 17:11:00
>Number: 1648
>Category: bin
>Synopsis: changing the mtu is not possible with ifconfig
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Oct 18 12:35:02 1995
>Last-Modified:
>Originator: Matthias Pfaller
>Organization:
leo@dachau.marco.de in real life: Matthias Pfaller
marco GmbH, 85221 Dachau, Germany tel: +49 8131 516142
>Release: 951014
>Environment:
System: NetBSD robin 1.0A NetBSD 1.0A (ROBIN) #10: Thu Oct 12 10:34:15 MET 1995 leo@robin:/usr/src/sys/arch/i386/compile/ROBIN i386
>Description:
Changing the MTU of an interface is not possible with ifconfig.
>How-To-Repeat:
>Fix:
The following patch allows ifconfig to change the MTU and documents the
new option.
--- ifconfig.8.orig Fri Jun 23 13:48:52 1995
+++ ifconfig.8 Fri Jun 23 13:47:35 1995
@@ -176,6 +176,10 @@
Higher metrics have the effect of making a route
less favorable; metrics are counted as addition hops
to the destination network or host.
+.It Cm mtu Ar n
+Set the maximum transmission unit of the interface to
+.Ar n .
+Most interfaces don't support this option.
.It Cm netmask Ar mask
(Inet and ISO)
Specify how much of the address to reserve for subdividing
--- ifconfig.c.orig Sat Oct 14 02:10:15 1995
+++ ifconfig.c Wed Oct 18 17:09:36 1995
@@ -79,7 +79,7 @@
struct iso_aliasreq iso_addreq;
struct sockaddr_in netmask;
char name[30];
-int flags, metric, setaddr, setipdst, doalias;
+int flags, metric, mtu, setaddr, setipdst, doalias;
int clearaddr, s;
int newaddr = 1;
int nsellength = 1;
@@ -93,6 +93,7 @@
void setifbroadaddr __P((char *));
void setifipdst __P((char *));
void setifmetric __P((char *));
+void setifmtu __P((char *));
void setifnetmask __P((char *));
void setnsellength __P((char *));
void setsnpaoffset __P((char *));
@@ -311,6 +312,10 @@
metric = 0;
} else
metric = ifr->ifr_metric;
+ if (ioctl(s, SIOCGIFMTU, (caddr_t)ifr) < 0)
+ mtu = 0;
+ else
+ mtu = ifr->ifr_metric;
return (0);
}
@@ -475,6 +480,8 @@
printb("flags", flags, IFFBITS);
if (metric)
printf(" metric %d", metric);
+ if (mtu)
+ printf(" mtu %d", mtu);
putchar('\n');
if ((p = afp) != NULL) {
(*p->af_status)(1);
@@ -746,6 +753,16 @@
}
void
+setifmtu(val)
+ char *val;
+{
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
+ ifr.ifr_metric = atoi(val);
+ if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
+ warn("SIOCSIFMTU");
+}
+
+void
setsnpaoffset(val)
char *val;
{
@@ -785,10 +802,11 @@
void
usage()
{
- fprintf(stderr, "usage: ifconfig interface\n%s%s%s%s%s%s",
+ fprintf(stderr, "usage: ifconfig interface\n%s%s%s%s%s%s%s",
"\t[ af [ address [ dest_addr ] ] [ up ] [ down ] ",
"[ netmask mask ] ]\n",
"\t[ metric n ]\n",
+ "\t[ mtu n ]\n",
"\t[ arp | -arp ]\n",
"\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n",
" ifconfig -a [ af ]\n");
>Audit-Trail:
>Unformatted: