freebsd_network: Add another MTU to attempt to set devices to.
IEEE 802.11 has its own maximum MTU which is smaller than PAGESIZE but larger than the ETHERMTU default. So we now attempt to set this as well. In doing so, refactor the set into a loop based off an array of possible MTUs.
This commit is contained in:
@@ -237,15 +237,21 @@ compat_control(void *cookie, uint32 op, void *arg, size_t length)
|
|||||||
if (length < 4)
|
if (length < 4)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
const int MTUs[] = {
|
||||||
|
ETHERMTU_JUMBO,
|
||||||
|
PAGESIZE - (ETHER_HDR_LEN + ETHER_CRC_LEN),
|
||||||
|
2290, /* IEEE80211_MTU_MAX */
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
// This is (usually) only invoked during initialization to get the
|
// This is (usually) only invoked during initialization to get the
|
||||||
// maximum frame size. Thus we try to set the largest possible one,
|
// maximum frame size. Thus we try a few common possible values,
|
||||||
// as there is no way to determine what the driver might support.
|
// as there is no way to determine what is supported (or required).
|
||||||
struct ifreq ifr;
|
for (int i = 0; MTUs[i] != 0; i++) {
|
||||||
ifr.ifr_mtu = ETHERMTU_JUMBO;
|
struct ifreq ifr;
|
||||||
if (compat_control(cookie, SIOCSIFMTU, &ifr, sizeof(ifr)) != 0) {
|
ifr.ifr_mtu = MTUs[i];
|
||||||
// Try again with 4K at least.
|
if (compat_control(cookie, SIOCSIFMTU, &ifr, sizeof(ifr)) == 0)
|
||||||
ifr.ifr_mtu = 4096 - (ETHER_HDR_LEN + ETHER_CRC_LEN);
|
break;
|
||||||
compat_control(cookie, SIOCSIFMTU, &ifr, sizeof(ifr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frameSize = ifp->if_mtu + (ETHER_HDR_LEN + ETHER_CRC_LEN);
|
frameSize = ifp->if_mtu + (ETHER_HDR_LEN + ETHER_CRC_LEN);
|
||||||
|
|||||||
Reference in New Issue
Block a user