aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1994-08-08 10:45:06 +0000
committerDavid Greenman <dg@FreeBSD.org>1994-08-08 10:45:06 +0000
commit4db32b036d7656c4a5053feee33b72687a83e909 (patch)
tree4b7def14c346b4f261e2af6c77d26c200dd75b3d /sbin
parentf847d045bf04a9852610bd7abc890f61c753d6d0 (diff)
downloadsrc-4db32b036d7656c4a5053feee33b72687a83e909.tar.gz
src-4db32b036d7656c4a5053feee33b72687a83e909.zip
Added support for setting the per-interface MTU.
Notes
Notes: svn path=/head/; revision=1940
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ifconfig/ifconfig.88
-rw-r--r--sbin/ifconfig/ifconfig.c34
2 files changed, 34 insertions, 8 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 58a21638630e..378444ed779f 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -174,6 +174,14 @@ The routing metric is used by the routing protocol
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 ,
+default is interface specific.
+The mtu is used to limit the size of packets that are transmitted on an
+interface.
+Not all interfaces support setting the mtu, and some interfaces have
+range restrictions.
.It Cm netmask Ar mask
(Inet and ISO)
Specify how much of the address to reserve for subdividing
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index e9751b98e00b..194bc5c4c582 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -76,6 +76,7 @@ struct sockaddr_in netmask;
char name[30];
int flags;
int metric;
+int mtu;
int nsellength = 1;
int setaddr;
int setipdst;
@@ -86,7 +87,7 @@ int s;
extern int errno;
int setifflags(), setifaddr(), setifdstaddr(), setifnetmask();
-int setifmetric(), setifbroadaddr(), setifipdst();
+int setifmetric(), setifmtu(), setifbroadaddr(), setifipdst();
int notealias(), setsnpaoffset(), setnsellength(), notrailers();
#define NEXTARG 0xffffff
@@ -118,12 +119,13 @@ struct cmd {
{ "ipdst", NEXTARG, setifipdst },
{ "snpaoffset", NEXTARG, setsnpaoffset },
{ "nsellength", NEXTARG, setnsellength },
- { "link0", IFF_LINK0, setifflags } ,
- { "-link0", -IFF_LINK0, setifflags } ,
- { "link1", IFF_LINK1, setifflags } ,
- { "-link1", -IFF_LINK1, setifflags } ,
- { "link2", IFF_LINK2, setifflags } ,
- { "-link2", -IFF_LINK2, setifflags } ,
+ { "link0", IFF_LINK0, setifflags },
+ { "-link0", -IFF_LINK0, setifflags },
+ { "link1", IFF_LINK1, setifflags },
+ { "-link1", -IFF_LINK1, setifflags },
+ { "link2", IFF_LINK2, setifflags },
+ { "-link2", -IFF_LINK2, setifflags },
+ { "mtu", NEXTARG, setifmtu },
{ 0, 0, setifaddr },
{ 0, 0, setifdstaddr },
};
@@ -167,10 +169,11 @@ main(argc, argv)
register struct afswtch *rafp;
if (argc < 2) {
- fprintf(stderr, "usage: ifconfig interface\n%s%s%s%s%s",
+ fprintf(stderr, "usage: ifconfig interface\n%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");
exit(1);
@@ -203,6 +206,10 @@ main(argc, argv)
perror("ioctl (SIOCGIFMETRIC)");
else
metric = ifr.ifr_metric;
+ if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0)
+ perror("ioctl (SIOCGIFMTU)");
+ else
+ mtu = ifr.ifr_mtu;
if (argc == 0) {
status();
exit(0);
@@ -360,6 +367,15 @@ setifmetric(val)
perror("ioctl (set metric)");
}
+setifmtu(val)
+ char *val;
+{
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
+ ifr.ifr_mtu = atoi(val);
+ if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
+ perror("ioctl (set mtu)");
+}
+
setsnpaoffset(val)
char *val;
{
@@ -383,6 +399,8 @@ status()
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);