Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
On Oct 22 Stefan Richter wrote: > On Oct 19 Jarod Wilson wrote: > > On Thu, Oct 20, 2016 at 12:38:46AM +0200, Stefan Richter wrote: > > > On Oct 19 Sabrina Dubroca wrote: > > > > 2016-10-18, 22:33:33 -0400, Jarod Wilson wrote: [...] > > > > > @@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, > > > > > max_mtu = (1 << (card->max_receive + 1)) > > > > > - sizeof(struct rfc2734_header) - > > > > > IEEE1394_GASP_HDR_SIZE; > > > > > net->mtu = min(1500U, max_mtu); > > > > > + net->min_mtu = ETH_MIN_MTU; > > > > > + net->max_mtu = net->mtu; > > > > > > > > But that will now prevent increasing the MTU above the initial value? > > > > > > Indeed, therefore NAK. > > > > However, there's an explicit calculation for 'max_mtu' right there that I > > glazed right over. It would seem perhaps *that* should be used for > > net->max_mtu here, no? > > No. This 'max_mtu' here is not the absolute maximum. It is only an > initial MTU which has the property that link fragmentation is not > going to happen (if all other peers will at least as capable as this > node). Besides, card->max_receive is about what the card can receive (at the IEEE 1394 link layer), not about what the card can send. -- Stefan Richter -==- =-=- =-==- http://arcgraph.de/sr/
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
On Oct 19 Jarod Wilson wrote: > On Thu, Oct 20, 2016 at 12:38:46AM +0200, Stefan Richter wrote: > > On Oct 19 Sabrina Dubroca wrote: > > > 2016-10-18, 22:33:33 -0400, Jarod Wilson wrote: > > > [...] > > > > diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c > > > > index 309311b..b5f125c 100644 > > > > --- a/drivers/firewire/net.c > > > > +++ b/drivers/firewire/net.c > > > > @@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, > > > > struct net_device *net) > > > > return NETDEV_TX_OK; > > > > } > > > > > > > > -static int fwnet_change_mtu(struct net_device *net, int new_mtu) > > > > -{ > > > > - if (new_mtu < 68) > > > > - return -EINVAL; > > > > - > > > > - net->mtu = new_mtu; > > > > - return 0; > > > > -} > > > > - > > > > > > This doesn't do any upper bound checking. > > > > I need to check more closely, but I think the RFC 2734 encapsulation spec > > and our implementation do not impose a particular upper limit. Though I > > guess it's bad to let userland set arbitrarily large values here. > > In which case, that would suggest using IP_MAX_MTU (65535) here. Probably. I (or somebody) need to check the spec and the code once more. [...] > > > > @@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, > > > > max_mtu = (1 << (card->max_receive + 1)) > > > > - sizeof(struct rfc2734_header) - > > > > IEEE1394_GASP_HDR_SIZE; > > > > net->mtu = min(1500U, max_mtu); > > > > + net->min_mtu = ETH_MIN_MTU; > > > > + net->max_mtu = net->mtu; > > > > > > But that will now prevent increasing the MTU above the initial value? > > > > Indeed, therefore NAK. > > However, there's an explicit calculation for 'max_mtu' right there that I > glazed right over. It would seem perhaps *that* should be used for > net->max_mtu here, no? No. This 'max_mtu' here is not the absolute maximum. It is only an initial MTU which has the property that link fragmentation is not going to happen (if all other peers will at least as capable as this node). -- Stefan Richter -==- =-=- =-==- http://arcgraph.de/sr/
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
On Thu, Oct 20, 2016 at 12:38:46AM +0200, Stefan Richter wrote: > On Oct 19 Sabrina Dubroca wrote: > > 2016-10-18, 22:33:33 -0400, Jarod Wilson wrote: > > [...] > > > diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c > > > index 309311b..b5f125c 100644 > > > --- a/drivers/firewire/net.c > > > +++ b/drivers/firewire/net.c > > > @@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, > > > struct net_device *net) > > > return NETDEV_TX_OK; > > > } > > > > > > -static int fwnet_change_mtu(struct net_device *net, int new_mtu) > > > -{ > > > - if (new_mtu < 68) > > > - return -EINVAL; > > > - > > > - net->mtu = new_mtu; > > > - return 0; > > > -} > > > - > > > > This doesn't do any upper bound checking. > > I need to check more closely, but I think the RFC 2734 encapsulation spec > and our implementation do not impose a particular upper limit. Though I > guess it's bad to let userland set arbitrarily large values here. In which case, that would suggest using IP_MAX_MTU (65535) here. > > > static const struct ethtool_ops fwnet_ethtool_ops = { > > > .get_link = ethtool_op_get_link, > > > }; > > > @@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops > > > = { > > > .ndo_open = fwnet_open, > > > .ndo_stop = fwnet_stop, > > > .ndo_start_xmit = fwnet_tx, > > > - .ndo_change_mtu = fwnet_change_mtu, > > > }; > > > > > > static void fwnet_init_dev(struct net_device *net) > > > @@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, > > > max_mtu = (1 << (card->max_receive + 1)) > > > - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE; > > > net->mtu = min(1500U, max_mtu); > > > + net->min_mtu = ETH_MIN_MTU; > > > + net->max_mtu = net->mtu; > > > > But that will now prevent increasing the MTU above the initial value? > > Indeed, therefore NAK. However, there's an explicit calculation for 'max_mtu' right there that I glazed right over. It would seem perhaps *that* should be used for net->max_mtu here, no? > PS: > If the IP packet plus encapsulation header fits into IEEE 1394 packet > payload, it is transported without link fragmentation. If it does not > fit, link fragmentation occurs (which reduces bandwidth a bit and > consumes additional buffering resources at the transmitter and the > receiver). > > Broadcast and multicast packets are transmitted via IEEE 1394 asynchronous > stream packets at a low bus speed (because our code does not attempt to > find the maximum speed and size that is supported by all potential > listeners). This limits the payload to 512 bytes. > > Unicast packets are transmitted via IEEE 1394 asynchronous write request > packets at optimum speed. In most cases, this means that 2048 bytes > payload is possible, in some cases 4096 bytes. Many CardBus FireWire > cards support only 1024 bytes payload of these packets though. > Furthermore, some low-speed long-haul cablings may cap the bus speed and > thereby the payload size to 1024 or 512 bytes, but this is uncommon in > practice. Thorough as always, Stefan! :) -- Jarod Wilson ja...@redhat.com
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
On Oct 19 Sabrina Dubroca wrote: > 2016-10-18, 22:33:33 -0400, Jarod Wilson wrote: > [...] > > diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c > > index 309311b..b5f125c 100644 > > --- a/drivers/firewire/net.c > > +++ b/drivers/firewire/net.c > > @@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, > > struct net_device *net) > > return NETDEV_TX_OK; > > } > > > > -static int fwnet_change_mtu(struct net_device *net, int new_mtu) > > -{ > > - if (new_mtu < 68) > > - return -EINVAL; > > - > > - net->mtu = new_mtu; > > - return 0; > > -} > > - > > This doesn't do any upper bound checking. I need to check more closely, but I think the RFC 2734 encapsulation spec and our implementation do not impose a particular upper limit. Though I guess it's bad to let userland set arbitrarily large values here. > > static const struct ethtool_ops fwnet_ethtool_ops = { > > .get_link = ethtool_op_get_link, > > }; > > @@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = > > { > > .ndo_open = fwnet_open, > > .ndo_stop = fwnet_stop, > > .ndo_start_xmit = fwnet_tx, > > - .ndo_change_mtu = fwnet_change_mtu, > > }; > > > > static void fwnet_init_dev(struct net_device *net) > > @@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, > > max_mtu = (1 << (card->max_receive + 1)) > > - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE; > > net->mtu = min(1500U, max_mtu); > > + net->min_mtu = ETH_MIN_MTU; > > + net->max_mtu = net->mtu; > > But that will now prevent increasing the MTU above the initial value? Indeed, therefore NAK. PS: If the IP packet plus encapsulation header fits into IEEE 1394 packet payload, it is transported without link fragmentation. If it does not fit, link fragmentation occurs (which reduces bandwidth a bit and consumes additional buffering resources at the transmitter and the receiver). Broadcast and multicast packets are transmitted via IEEE 1394 asynchronous stream packets at a low bus speed (because our code does not attempt to find the maximum speed and size that is supported by all potential listeners). This limits the payload to 512 bytes. Unicast packets are transmitted via IEEE 1394 asynchronous write request packets at optimum speed. In most cases, this means that 2048 bytes payload is possible, in some cases 4096 bytes. Many CardBus FireWire cards support only 1024 bytes payload of these packets though. Furthermore, some low-speed long-haul cablings may cap the bus speed and thereby the payload size to 1024 or 512 bytes, but this is uncommon in practice. -- Stefan Richter -==- =-=- =-=-- http://arcgraph.de/sr/
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
2016-10-18, 22:33:33 -0400, Jarod Wilson wrote: [...] > diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c > index 309311b..b5f125c 100644 > --- a/drivers/firewire/net.c > +++ b/drivers/firewire/net.c > @@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, > struct net_device *net) > return NETDEV_TX_OK; > } > > -static int fwnet_change_mtu(struct net_device *net, int new_mtu) > -{ > - if (new_mtu < 68) > - return -EINVAL; > - > - net->mtu = new_mtu; > - return 0; > -} > - This doesn't do any upper bound checking. > static const struct ethtool_ops fwnet_ethtool_ops = { > .get_link = ethtool_op_get_link, > }; > @@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { > .ndo_open = fwnet_open, > .ndo_stop = fwnet_stop, > .ndo_start_xmit = fwnet_tx, > - .ndo_change_mtu = fwnet_change_mtu, > }; > > static void fwnet_init_dev(struct net_device *net) > @@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, > max_mtu = (1 << (card->max_receive + 1)) > - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE; > net->mtu = min(1500U, max_mtu); > + net->min_mtu = ETH_MIN_MTU; > + net->max_mtu = net->mtu; But that will now prevent increasing the MTU above the initial value? -- Sabrina
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
On Tue, Oct 18, 2016 at 9:33 PM, Jarod Wilson wrote: > CC: net...@vger.kernel.org > CC: Stefan Richter > CC: Faisal Latif > CC: linux-r...@vger.kernel.org > CC: Cliff Whickman Acked-by: Robin Holt > CC: Jes Sorensen > CC: Marek Lindner > CC: Simon Wunderlich > CC: Antonio Quartulli > Signed-off-by: Jarod Wilson
[PATCH net-next 6/6] net: use core MTU range checking in misc drivers
firewire-net: - set min/max_mtu - remove fwnet_change_mtu nes: - set max_mtu - clean up nes_netdev_change_mtu xpnet: - set min/max_mtu - remove xpnet_dev_change_mtu hippi: - set min/max_mtu - remove hippi_change_mtu batman-adv: - set max_mtu - remove batadv_interface_change_mtu - initialization is a little async, not 100% certain that max_mtu is set in the optimal place, don't have hardware to test with rionet: - set min/max_mtu - remove rionet_change_mtu slip: - set min/max_mtu - streamline sl_change_mtu CC: net...@vger.kernel.org CC: Stefan Richter CC: Faisal Latif CC: linux-r...@vger.kernel.org CC: Cliff Whickman CC: Robin Holt CC: Jes Sorensen CC: Marek Lindner CC: Simon Wunderlich CC: Antonio Quartulli Signed-off-by: Jarod Wilson --- drivers/firewire/net.c | 12 ++-- drivers/infiniband/hw/nes/nes.c | 1 - drivers/infiniband/hw/nes/nes.h | 4 ++-- drivers/infiniband/hw/nes/nes_nic.c | 10 +++--- drivers/misc/sgi-xp/xpnet.c | 21 - drivers/net/hippi/rrunner.c | 1 - drivers/net/rionet.c| 15 +++ drivers/net/slip/slip.c | 11 +-- include/linux/hippidevice.h | 1 - net/802/hippi.c | 14 ++ net/batman-adv/soft-interface.c | 13 + 11 files changed, 22 insertions(+), 81 deletions(-) diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index 309311b..b5f125c 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c @@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net) return NETDEV_TX_OK; } -static int fwnet_change_mtu(struct net_device *net, int new_mtu) -{ - if (new_mtu < 68) - return -EINVAL; - - net->mtu = new_mtu; - return 0; -} - static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, }; @@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, }; static void fwnet_init_dev(struct net_device *net) @@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, max_mtu = (1 << (card->max_receive + 1)) - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE; net->mtu = min(1500U, max_mtu); + net->min_mtu = ETH_MIN_MTU; + net->max_mtu = net->mtu; /* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr; diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c index 35cbb17..2baa45a 100644 --- a/drivers/infiniband/hw/nes/nes.c +++ b/drivers/infiniband/hw/nes/nes.c @@ -65,7 +65,6 @@ MODULE_DESCRIPTION("NetEffect RNIC Low-level iWARP Driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_VERSION(DRV_VERSION); -int max_mtu = 9000; int interrupt_mod_interval = 0; /* Interoperability */ diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h index e7430c9..85acd08 100644 --- a/drivers/infiniband/hw/nes/nes.h +++ b/drivers/infiniband/hw/nes/nes.h @@ -83,6 +83,8 @@ #define NES_FIRST_QPN 64 #define NES_SW_CONTEXT_ALIGN1024 +#define NES_MAX_MTU9000 + #define NES_NIC_MAX_NICS16 #define NES_MAX_ARP_TABLE_SIZE 4096 @@ -169,8 +171,6 @@ do { \ #include "nes_cm.h" #include "nes_mgt.h" -extern int max_mtu; -#define max_frame_len (max_mtu+ETH_HLEN) extern int interrupt_mod_interval; extern int nes_if_count; extern int mpa_version; diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c index 2b27d13..7f8597d 100644 --- a/drivers/infiniband/hw/nes/nes_nic.c +++ b/drivers/infiniband/hw/nes/nes_nic.c @@ -981,20 +981,16 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) { struct nes_vnic *nesvnic = netdev_priv(netdev); struct nes_device *nesdev = nesvnic->nesdev; - int ret = 0; u8 jumbomode = 0; u32 nic_active; u32 nic_active_bit; u32 uc_all_active; u32 mc_all_active; - if ((new_mtu < ETH_ZLEN) || (new_mtu > max_mtu)) - return -EINVAL; - netdev->mtu = new_mtu; nesvnic->max_frame_size = new_mtu + VLAN_ETH_HLEN; - if (netdev->mtu > 1500) { + if (netdev->mtu > ETH_DATA_LEN) { jumbomode=1; } nes_nic_init_timer_defaults(nesdev, jumbomode); @@ -1020,7 +1016,7 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) nes_write_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL, nic_active); } - return ret; + return 0; } @@ -1658,7 +1654,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, netdev->watchdog_timeo = NES_TX_TIMEOUT; netdev->irq =