summaryrefslogtreecommitdiff
path: root/src/ipcpd/eth/eth.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-05-07 17:27:07 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-05-07 17:55:07 +0200
commite68f30878384b6c13ea0cc3bb6681504c66ff712 (patch)
tree33895830ba73d2dacbd26195731f35243c3154e2 /src/ipcpd/eth/eth.c
parent9a262df133d8305c06b3f99f505e4d07a26cca9d (diff)
downloadouroboros-e68f30878384b6c13ea0cc3bb6681504c66ff712.tar.gz
ouroboros-e68f30878384b6c13ea0cc3bb6681504c66ff712.zip
ipcpd: Use correct MTU for eth-dix
The eth-dix IPCP was using a hardcoded MTU of 1500 bytes, but could support higher MTUs. Now jumbo frames are supported. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/ipcpd/eth/eth.c')
-rw-r--r--src/ipcpd/eth/eth.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c
index 25ecdffb..77a919ef 100644
--- a/src/ipcpd/eth/eth.c
+++ b/src/ipcpd/eth/eth.c
@@ -94,7 +94,13 @@
#endif
#define MAC_SIZE 6
+#if defined(__linux__) && defined(BUILD_ETH_DIX)
+#define ETH_MTU eth_data.mtu
+#define ETH_MTU_MAX ETH_MAX_MTU /* if_ether.h */
+#else
#define ETH_MTU 1500
+#define ETH_MTU_MAX ETH_MTU
+#endif
#define ETH_TYPE_LENGTH_SIZE sizeof(uint16_t)
#define ETH_HEADER_SIZE (2 * MAC_SIZE + ETH_TYPE_LENGTH_SIZE)
@@ -106,7 +112,7 @@
#define DIX_HEADER_SIZE (DIX_EID_SIZE + DIX_LENGTH_SIZE)
#define ETH_HEADER_TOT_SIZE (ETH_HEADER_SIZE + DIX_HEADER_SIZE)
#define MAX_EIDS (1 << (8 * DIX_EID_SIZE))
-#define ETH_MAX_SDU_SIZE (ETH_MTU - DIX_HEADER_SIZE)
+#define ETH_MAX_SDU_SIZE (ETH_MTU_MAX - DIX_HEADER_SIZE)
#define ETH_FRAME_SIZE (ETH_HEADER_TOT_SIZE + ETH_MAX_SDU_SIZE)
#elif defined(BUILD_ETH_LLC)
#define THIS_TYPE IPCP_ETH_LLC
@@ -114,7 +120,7 @@
#define LLC_HEADER_SIZE 3
#define ETH_HEADER_TOT_SIZE (ETH_HEADER_SIZE + LLC_HEADER_SIZE)
#define MAX_SAPS 64
-#define ETH_MAX_SDU_SIZE (ETH_MTU - LLC_HEADER_SIZE)
+#define ETH_MAX_SDU_SIZE (ETH_MTU_MAX - LLC_HEADER_SIZE)
#define ETH_FRAME_SIZE (ETH_HEADER_TOT_SIZE + ETH_MAX_SDU_SIZE)
#endif
@@ -174,7 +180,9 @@ struct mgmt_frame {
struct {
struct shim_data * shim_data;
-
+#ifdef __linux__
+ int mtu;
+#endif
#if defined(HAVE_NETMAP)
struct nm_desc * nmd;
uint8_t hw_addr[MAC_SIZE];
@@ -1218,11 +1226,23 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf)
}
if (ioctl(skfd, SIOCGIFHWADDR, &ifr)) {
- log_err("Failed to ioctl.");
+ log_err("Failed to get hwaddr.");
+ close(skfd);
+ return -1;
+ }
+
+ if (ioctl(skfd, SIOCGIFMTU, &ifr)) {
+ log_err("Failed to get MTU.");
close(skfd);
return -1;
}
+ log_dbg("Device MTU is %d.", ifr.ifr_mtu);
+
+ eth_data.mtu = MIN((int) ETH_MTU_MAX, ifr.ifr_mtu);
+
+ log_dbg("Layer MTU is %d.", eth_data.mtu);
+
close(skfd);
idx = if_nametoindex(conf->dev);