Added support for setting the per-interface MTU.
This commit is contained in:
parent
f847d045bf
commit
4db32b036d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=1940
@ -174,6 +174,14 @@ The routing metric is used by the routing protocol
|
|||||||
Higher metrics have the effect of making a route
|
Higher metrics have the effect of making a route
|
||||||
less favorable; metrics are counted as addition hops
|
less favorable; metrics are counted as addition hops
|
||||||
to the destination network or host.
|
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
|
.It Cm netmask Ar mask
|
||||||
(Inet and ISO)
|
(Inet and ISO)
|
||||||
Specify how much of the address to reserve for subdividing
|
Specify how much of the address to reserve for subdividing
|
||||||
|
@ -76,6 +76,7 @@ struct sockaddr_in netmask;
|
|||||||
char name[30];
|
char name[30];
|
||||||
int flags;
|
int flags;
|
||||||
int metric;
|
int metric;
|
||||||
|
int mtu;
|
||||||
int nsellength = 1;
|
int nsellength = 1;
|
||||||
int setaddr;
|
int setaddr;
|
||||||
int setipdst;
|
int setipdst;
|
||||||
@ -86,7 +87,7 @@ int s;
|
|||||||
extern int errno;
|
extern int errno;
|
||||||
|
|
||||||
int setifflags(), setifaddr(), setifdstaddr(), setifnetmask();
|
int setifflags(), setifaddr(), setifdstaddr(), setifnetmask();
|
||||||
int setifmetric(), setifbroadaddr(), setifipdst();
|
int setifmetric(), setifmtu(), setifbroadaddr(), setifipdst();
|
||||||
int notealias(), setsnpaoffset(), setnsellength(), notrailers();
|
int notealias(), setsnpaoffset(), setnsellength(), notrailers();
|
||||||
|
|
||||||
#define NEXTARG 0xffffff
|
#define NEXTARG 0xffffff
|
||||||
@ -118,12 +119,13 @@ struct cmd {
|
|||||||
{ "ipdst", NEXTARG, setifipdst },
|
{ "ipdst", NEXTARG, setifipdst },
|
||||||
{ "snpaoffset", NEXTARG, setsnpaoffset },
|
{ "snpaoffset", NEXTARG, setsnpaoffset },
|
||||||
{ "nsellength", NEXTARG, setnsellength },
|
{ "nsellength", NEXTARG, setnsellength },
|
||||||
{ "link0", IFF_LINK0, setifflags } ,
|
{ "link0", IFF_LINK0, setifflags },
|
||||||
{ "-link0", -IFF_LINK0, setifflags } ,
|
{ "-link0", -IFF_LINK0, setifflags },
|
||||||
{ "link1", IFF_LINK1, setifflags } ,
|
{ "link1", IFF_LINK1, setifflags },
|
||||||
{ "-link1", -IFF_LINK1, setifflags } ,
|
{ "-link1", -IFF_LINK1, setifflags },
|
||||||
{ "link2", IFF_LINK2, setifflags } ,
|
{ "link2", IFF_LINK2, setifflags },
|
||||||
{ "-link2", -IFF_LINK2, setifflags } ,
|
{ "-link2", -IFF_LINK2, setifflags },
|
||||||
|
{ "mtu", NEXTARG, setifmtu },
|
||||||
{ 0, 0, setifaddr },
|
{ 0, 0, setifaddr },
|
||||||
{ 0, 0, setifdstaddr },
|
{ 0, 0, setifdstaddr },
|
||||||
};
|
};
|
||||||
@ -167,10 +169,11 @@ main(argc, argv)
|
|||||||
register struct afswtch *rafp;
|
register struct afswtch *rafp;
|
||||||
|
|
||||||
if (argc < 2) {
|
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 ]",
|
"\t[ af [ address [ dest_addr ] ] [ up ] [ down ]",
|
||||||
"[ netmask mask ] ]\n",
|
"[ netmask mask ] ]\n",
|
||||||
"\t[ metric n ]\n",
|
"\t[ metric n ]\n",
|
||||||
|
"\t[ mtu n ]\n",
|
||||||
"\t[ arp | -arp ]\n",
|
"\t[ arp | -arp ]\n",
|
||||||
"\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ] \n");
|
"\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ] \n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -203,6 +206,10 @@ main(argc, argv)
|
|||||||
perror("ioctl (SIOCGIFMETRIC)");
|
perror("ioctl (SIOCGIFMETRIC)");
|
||||||
else
|
else
|
||||||
metric = ifr.ifr_metric;
|
metric = ifr.ifr_metric;
|
||||||
|
if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0)
|
||||||
|
perror("ioctl (SIOCGIFMTU)");
|
||||||
|
else
|
||||||
|
mtu = ifr.ifr_mtu;
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
status();
|
status();
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -360,6 +367,15 @@ setifmetric(val)
|
|||||||
perror("ioctl (set metric)");
|
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)
|
setsnpaoffset(val)
|
||||||
char *val;
|
char *val;
|
||||||
{
|
{
|
||||||
@ -383,6 +399,8 @@ status()
|
|||||||
printb("flags", flags, IFFBITS);
|
printb("flags", flags, IFFBITS);
|
||||||
if (metric)
|
if (metric)
|
||||||
printf(" metric %d", metric);
|
printf(" metric %d", metric);
|
||||||
|
if (mtu)
|
||||||
|
printf(" mtu %d", mtu);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if ((p = afp) != NULL) {
|
if ((p = afp) != NULL) {
|
||||||
(*p->af_status)(1);
|
(*p->af_status)(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user