aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-06-13 06:19:41 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-06-13 06:19:41 +0000
commit373ad245f9695cf0293aa2243896c79c4f3963be (patch)
treeb559d195eb15e50e4676bc2203fdc5062ecf15e2
parent2757e4b63b5ed5e8ee503858732dd29ee7a42bfc (diff)
downloadklibc-373ad245f9695cf0293aa2243896c79c4f3963be.tar.gz
If we receieve an MTU option through BOOTP/DHCP, accept it; this isklibc-0.140
critical on GigE networks on which jumbo frames are used - until we do this we can't handle large IP datagrams.
-rw-r--r--ipconfig/bootp_proto.c4
-rw-r--r--ipconfig/dhcp_proto.c3
-rw-r--r--ipconfig/main.c4
-rw-r--r--ipconfig/netdev.c10
-rw-r--r--ipconfig/netdev.h1
5 files changed, 21 insertions, 1 deletions
diff --git a/ipconfig/bootp_proto.c b/ipconfig/bootp_proto.c
index 7e2b02db4f873..7e6936c54f785 100644
--- a/ipconfig/bootp_proto.c
+++ b/ipconfig/bootp_proto.c
@@ -121,6 +121,10 @@ bootp_parse(struct netdev *dev, struct bootp_hdr *hdr, __u8 *exts, int extlen)
memcpy(&dev->bootpath, ext, len);
dev->bootpath[len] = '\0';
break;
+ case 26: /* interface MTU */
+ if ( len == 2 )
+ dev->mtu = (ext[0] << 8) + ext[1];
+ break;
case 28: /* broadcast addr */
if (len > 4)
len = 4;
diff --git a/ipconfig/dhcp_proto.c b/ipconfig/dhcp_proto.c
index a01b89dd6d0be..733f0b5e88410 100644
--- a/ipconfig/dhcp_proto.c
+++ b/ipconfig/dhcp_proto.c
@@ -24,8 +24,9 @@ static __u8 dhcp_params[] = {
12, /* host name */
15, /* domain name */
17, /* boot path */
+ 26, /* interface mtu */
28, /* broadcast addr */
- 40, /* NIS domain name */
+ 40, /* NIS domain name (why?) */
};
static __u8 dhcp_discover_hdr[] = {
diff --git a/ipconfig/main.c b/ipconfig/main.c
index 0b6d24bc517b5..57fb874b4e1b3 100644
--- a/ipconfig/main.c
+++ b/ipconfig/main.c
@@ -67,6 +67,10 @@ static void configure_device(struct netdev *dev)
if (do_not_config)
return;
+ if (netdev_setmtu(dev))
+ printf("IP-Config: failed to set MTU on %s to %u\n",
+ dev->name, dev->mtu);
+
if (netdev_setaddress(dev))
printf("IP-Config: failed to set addresses on %s\n", dev->name);
if (netdev_setdefaultroute(dev))
diff --git a/ipconfig/netdev.c b/ipconfig/netdev.c
index 1f0f1d4412a92..b732c460e66da 100644
--- a/ipconfig/netdev.c
+++ b/ipconfig/netdev.c
@@ -100,6 +100,16 @@ int netdev_setdefaultroute(struct netdev *dev)
return 0;
}
+int netdev_setmtu(struct netdev *dev)
+{
+ struct ifreq ifr;
+
+ copy_name(dev, &ifr);
+ ifr.ifr_mtu = dev->mtu;
+
+ return ioctl(cfd, SIOCSIFMTU, &ifr);
+}
+
static int netdev_gif_addr(struct ifreq *ifr, int cmd, __u32 *ptr)
{
struct sockaddr_in *sin = (struct sockaddr_in *)&ifr->ifr_addr;
diff --git a/ipconfig/netdev.h b/ipconfig/netdev.h
index b57d482398e75..5c56f09d7cfd2 100644
--- a/ipconfig/netdev.h
+++ b/ipconfig/netdev.h
@@ -64,6 +64,7 @@ int netdev_setdefaultroute(struct netdev *dev);
int netdev_up(struct netdev *dev);
int netdev_down(struct netdev *dev);
int netdev_init_if(struct netdev *dev);
+int netdev_setmtu(struct netdev *dev);
static inline int netdev_running(struct netdev *dev)
{