summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1994-08-08 10:45:06 +0000
committerdg <dg@FreeBSD.org>1994-08-08 10:45:06 +0000
commit475bdabd4d7858d65fef64d51de810440cd7959c (patch)
tree4b7def14c346b4f261e2af6c77d26c200dd75b3d /sbin/ifconfig
parent02aff34c6c3a5a3f4c3ebee75453d49a9fee1ac6 (diff)
downloadFreeBSD-src-475bdabd4d7858d65fef64d51de810440cd7959c.zip
FreeBSD-src-475bdabd4d7858d65fef64d51de810440cd7959c.tar.gz
Added support for setting the per-interface MTU.
Diffstat (limited to 'sbin/ifconfig')
-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 58a2163..378444e 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 e9751b9..194bc5c 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);
OpenPOWER on IntegriCloud