mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-01 23:20:55 +00:00
lib/vfs/lxip: support configuration of MTU
The MTU can be set via the "mtu" attribute like follows. <vfs> <lxip mtu="1200" dhcp="yes"/> </vfs>
This commit is contained in:
parent
96fa3ef28c
commit
d5518aa938
@ -54,7 +54,7 @@ append config {
|
|||||||
<sleep milliseconds="2500"/> <inline description="dynamic">
|
<sleep milliseconds="2500"/> <inline description="dynamic">
|
||||||
<config>
|
<config>
|
||||||
<vfs>
|
<vfs>
|
||||||
<lxip dhcp="yes"/>
|
<lxip mtu="1000" dhcp="yes"/>
|
||||||
</vfs>
|
</vfs>
|
||||||
</config>
|
</config>
|
||||||
</inline>
|
</inline>
|
||||||
|
@ -31,7 +31,7 @@ static int driver_net_open(struct net_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int driver_net_xmit(struct sk_buff *skb, struct net_device *dev)
|
static int driver_net_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct net_device_stats *stats = (struct net_device_stats*) netdev_priv(dev);
|
struct net_device_stats *stats = (struct net_device_stats*) netdev_priv(dev);
|
||||||
int len = skb->len;
|
int len = skb->len;
|
||||||
@ -56,10 +56,18 @@ int driver_net_xmit(struct sk_buff *skb, struct net_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int driver_change_mtu(struct net_device *dev, int new_mtu)
|
||||||
|
{
|
||||||
|
/* possible point to reflect successful MTU setting */
|
||||||
|
return eth_change_mtu(dev, new_mtu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const struct net_device_ops driver_net_ops =
|
static const struct net_device_ops driver_net_ops =
|
||||||
{
|
{
|
||||||
.ndo_open = driver_net_open,
|
.ndo_open = driver_net_open,
|
||||||
.ndo_start_xmit = driver_net_xmit,
|
.ndo_start_xmit = driver_net_xmit,
|
||||||
|
.ndo_change_mtu = driver_change_mtu,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ extern "C" void lxip_configure_static(char const *addr,
|
|||||||
char const *gateway,
|
char const *gateway,
|
||||||
char const *nameserver);
|
char const *nameserver);
|
||||||
extern "C" void lxip_configure_dhcp();
|
extern "C" void lxip_configure_dhcp();
|
||||||
|
extern "C" void lxip_configure_mtu(unsigned mtu);
|
||||||
|
|
||||||
extern "C" bool lxip_do_dhcp();
|
extern "C" bool lxip_do_dhcp();
|
||||||
|
|
||||||
|
@ -528,6 +528,22 @@ static void lxip_configure(char const *address_config)
|
|||||||
static bool dhcp_configured = false;
|
static bool dhcp_configured = false;
|
||||||
static bool dhcp_pending = false;
|
static bool dhcp_pending = false;
|
||||||
|
|
||||||
|
void lxip_configure_mtu(unsigned mtu)
|
||||||
|
{
|
||||||
|
/* zero mtu means reset to default */
|
||||||
|
unsigned new_mtu = mtu ? mtu : ETH_DATA_LEN;
|
||||||
|
|
||||||
|
struct net *net;
|
||||||
|
struct net_device *dev;
|
||||||
|
|
||||||
|
for_each_net(net) {
|
||||||
|
for_each_netdev(net, dev) {
|
||||||
|
dev_set_mtu(dev, new_mtu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void lxip_configure_static(char const *addr, char const *netmask,
|
void lxip_configure_static(char const *addr, char const *netmask,
|
||||||
char const *gateway, char const *nameserver)
|
char const *gateway, char const *nameserver)
|
||||||
{
|
{
|
||||||
|
@ -1393,15 +1393,19 @@ class Vfs::Lxip_file_system : public Vfs::File_system,
|
|||||||
{
|
{
|
||||||
typedef String<16> Addr;
|
typedef String<16> Addr;
|
||||||
|
|
||||||
try {
|
unsigned const mtu = config.attribute_value("mtu", 0U);
|
||||||
|
if (mtu) {
|
||||||
|
log("Setting MTU to ", mtu);
|
||||||
|
lxip_configure_mtu(mtu);
|
||||||
|
} else {
|
||||||
|
lxip_configure_mtu(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.attribute_value("dhcp", false)) {
|
if (config.attribute_value("dhcp", false)) {
|
||||||
log("Using DHCP for interface configuration.");
|
log("Using DHCP for interface configuration.");
|
||||||
lxip_configure_dhcp();
|
lxip_configure_dhcp();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (...) { }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -1426,7 +1430,7 @@ class Vfs::Lxip_file_system : public Vfs::File_system,
|
|||||||
|
|
||||||
lxip_configure_static(ip_addr.string(), netmask.string(),
|
lxip_configure_static(ip_addr.string(), netmask.string(),
|
||||||
gateway.string(), nameserver.string());
|
gateway.string(), nameserver.string());
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
assert_spec x86
|
assert_spec x86
|
||||||
|
|
||||||
|
proc use_dynamic_rom { } { return true }
|
||||||
|
|
||||||
set build_components {
|
set build_components {
|
||||||
core init
|
core init
|
||||||
drivers/timer drivers/nic server/ram_fs server/vfs
|
drivers/timer drivers/nic server/vfs
|
||||||
lib/vfs/lxip
|
lib/vfs/lxip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lappend_if [use_dynamic_rom] build_components server/dynamic_rom
|
||||||
|
|
||||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||||
append_platform_drv_build_components
|
append_platform_drv_build_components
|
||||||
|
|
||||||
@ -39,12 +43,51 @@ append config {
|
|||||||
<binary name="} [nic_drv_binary] {"/>
|
<binary name="} [nic_drv_binary] {"/>
|
||||||
<resource name="RAM" quantum="4M"/>
|
<resource name="RAM" quantum="4M"/>
|
||||||
<provides> <service name="Nic"/> </provides>
|
<provides> <service name="Nic"/> </provides>
|
||||||
</start>
|
</start>}
|
||||||
|
|
||||||
|
append_if [use_dynamic_rom] config {
|
||||||
|
<start name="dynamic_rom">
|
||||||
|
<resource name="RAM" quantum="4M"/>
|
||||||
|
<provides><service name="ROM"/> </provides>
|
||||||
|
<config verbose="yes">
|
||||||
|
<rom name="socket_fs.config"> <inline description="MTU default">
|
||||||
|
<config ld_verbose="yes">
|
||||||
|
<vfs>
|
||||||
|
<dir name="socket">
|
||||||
|
<lxip ip_addr="10.0.2.55" netmask="255.255.255.0" gateway="10.0.2.1" nameserver="8.8.8.8"/>
|
||||||
|
</dir>
|
||||||
|
</vfs>
|
||||||
|
<default-policy root="/socket" writeable="yes" />
|
||||||
|
</config>
|
||||||
|
</inline>
|
||||||
|
<sleep milliseconds="3000"/> <inline description="MTU 400">
|
||||||
|
<config ld_verbose="yes">
|
||||||
|
<vfs>
|
||||||
|
<dir name="socket">
|
||||||
|
<lxip mtu="400" ip_addr="10.0.2.55" netmask="255.255.255.0" gateway="10.0.2.1" nameserver="8.8.8.8"/>
|
||||||
|
</dir>
|
||||||
|
</vfs>
|
||||||
|
<default-policy root="/socket" writeable="yes" />
|
||||||
|
</config>
|
||||||
|
</inline>
|
||||||
|
<sleep milliseconds="3000"/>
|
||||||
|
</rom>
|
||||||
|
</config>
|
||||||
|
</start>}
|
||||||
|
|
||||||
|
append config {
|
||||||
<start name="socket_fs" caps="200">
|
<start name="socket_fs" caps="200">
|
||||||
<binary name="vfs"/>
|
<binary name="vfs"/>
|
||||||
<resource name="RAM" quantum="32M"/>
|
<resource name="RAM" quantum="32M"/>
|
||||||
<provides> <service name="File_system"/> </provides>
|
<provides> <service name="File_system"/> </provides>}
|
||||||
|
|
||||||
|
if {[use_dynamic_rom]} { append config {
|
||||||
|
<configfile name="socket_fs.config"/>
|
||||||
|
<route>
|
||||||
|
<service name="ROM" label="socket_fs.config"> <child name="dynamic_rom"/> </service>
|
||||||
|
<any-service> <parent/> <any-child/> </any-service>
|
||||||
|
</route>}
|
||||||
|
} else { append config {
|
||||||
<config ld_verbose="yes">
|
<config ld_verbose="yes">
|
||||||
<vfs>
|
<vfs>
|
||||||
<dir name="socket">
|
<dir name="socket">
|
||||||
@ -53,16 +96,20 @@ append config {
|
|||||||
</dir>
|
</dir>
|
||||||
</vfs>
|
</vfs>
|
||||||
<default-policy root="/socket" writeable="yes" />
|
<default-policy root="/socket" writeable="yes" />
|
||||||
</config>
|
</config>}
|
||||||
|
}
|
||||||
|
|
||||||
|
append config {
|
||||||
</start>
|
</start>
|
||||||
}
|
}
|
||||||
|
|
||||||
append boot_modules {
|
append boot_modules {
|
||||||
core init timer } [nic_drv_binary] { ram_fs vfs
|
core init timer } [nic_drv_binary] { vfs
|
||||||
ld.lib.so libc.lib.so libm.lib.so posix.lib.so
|
ld.lib.so libc.lib.so vfs_lxip.lib.so lxip.lib.so
|
||||||
vfs_lxip.lib.so lxip.lib.so
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lappend_if [use_dynamic_rom] boot_modules dynamic_rom
|
||||||
|
|
||||||
append_platform_drv_boot_modules
|
append_platform_drv_boot_modules
|
||||||
|
|
||||||
append qemu_args " -nographic -net nic,model=e1000 -net tap,ifname=tap0,downscript=no,script=no "
|
append qemu_args " -nographic -net nic,model=e1000 -net tap,ifname=tap0,downscript=no,script=no "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user