sim/net: Support to set the MTU of the sim netdevice.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
This commit is contained in:
parent
e3056c781e
commit
45fc68e904
@ -223,6 +223,14 @@ config SIM_NETDEV_VPNKIT
|
|||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
config SIM_NETDEV_MTU
|
||||||
|
int "The MTU of Simulated Network Device"
|
||||||
|
default 1500
|
||||||
|
range 1280 65535 if NET_IPv6
|
||||||
|
range 576 65535 if !NET_IPv6
|
||||||
|
---help---
|
||||||
|
The MTU of the network devices.
|
||||||
|
|
||||||
config SIM_NETDEV_NUMBER
|
config SIM_NETDEV_NUMBER
|
||||||
int "Number of Simulated Network Device"
|
int "Number of Simulated Network Device"
|
||||||
default 1
|
default 1
|
||||||
|
@ -249,10 +249,20 @@ void sim_tapdev_init(int devidx, void *priv,
|
|||||||
close(tapdevfd);
|
close(tapdevfd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
strncpy(ifr.ifr_name, gdevname[devidx], IFNAMSIZ);
|
strncpy(ifr.ifr_name, gdevname[devidx], IFNAMSIZ);
|
||||||
#endif
|
ifr.ifr_mtu = CONFIG_SIM_NETDEV_MTU;
|
||||||
|
ret = ioctl(sockfd, SIOCSIFMTU, &ifr);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "TAPDEV: ioctl failed (can't set MTU "
|
||||||
|
"for %s): %d\n", gdevname[devidx], -ret);
|
||||||
|
close(sockfd);
|
||||||
|
close(tapdevfd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ret = ioctl(sockfd, SIOCGIFMTU, &ifr);
|
ret = ioctl(sockfd, SIOCGIFMTU, &ifr);
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
|
@ -71,7 +71,8 @@
|
|||||||
|
|
||||||
#include "sim_internal.h"
|
#include "sim_internal.h"
|
||||||
|
|
||||||
#define SIM_NETDEV_BUFSIZE (MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE)
|
#define SIM_NETDEV_BUFSIZE (CONFIG_SIM_NETDEV_MTU + ETH_HDRLEN + \
|
||||||
|
CONFIG_NET_GUARDSIZE)
|
||||||
|
|
||||||
/* We don't know packet length before receiving, so we can only offload it
|
/* We don't know packet length before receiving, so we can only offload it
|
||||||
* when netpkt's buffer is long enough.
|
* when netpkt's buffer is long enough.
|
||||||
|
Loading…
Reference in New Issue
Block a user