|
@@ -393,7 +393,8 @@ static int apply_netdev_settings ( void ) {
|
393
|
393
|
struct net_device *netdev;
|
394
|
394
|
struct settings *settings;
|
395
|
395
|
struct ll_protocol *ll_protocol;
|
396
|
|
- size_t old_max_pkt_len;
|
|
396
|
+ size_t max_mtu;
|
|
397
|
+ size_t old_mtu;
|
397
|
398
|
size_t mtu;
|
398
|
399
|
int rc;
|
399
|
400
|
|
|
@@ -410,18 +411,25 @@ static int apply_netdev_settings ( void ) {
|
410
|
411
|
if ( ! mtu )
|
411
|
412
|
continue;
|
412
|
413
|
|
413
|
|
- /* Update maximum packet length */
|
|
414
|
+ /* Limit MTU to maximum supported by hardware */
|
414
|
415
|
ll_protocol = netdev->ll_protocol;
|
415
|
|
- old_max_pkt_len = netdev->max_pkt_len;
|
416
|
|
- netdev->max_pkt_len = ( mtu + ll_protocol->ll_header_len );
|
417
|
|
- if ( netdev->max_pkt_len != old_max_pkt_len ) {
|
|
416
|
+ max_mtu = ( netdev->max_pkt_len - ll_protocol->ll_header_len );
|
|
417
|
+ if ( mtu > max_mtu ) {
|
|
418
|
+ DBGC ( netdev, "NETDEV %s cannot support MTU %zd (max "
|
|
419
|
+ "%zd)\n", netdev->name, mtu, max_mtu );
|
|
420
|
+ mtu = max_mtu;
|
|
421
|
+ }
|
|
422
|
+
|
|
423
|
+ /* Update maximum packet length */
|
|
424
|
+ old_mtu = netdev->mtu;
|
|
425
|
+ netdev->mtu = mtu;
|
|
426
|
+ if ( mtu != old_mtu ) {
|
418
|
427
|
DBGC ( netdev, "NETDEV %s MTU is %zd\n",
|
419
|
428
|
netdev->name, mtu );
|
420
|
429
|
}
|
421
|
430
|
|
422
|
431
|
/* Close and reopen network device if MTU has increased */
|
423
|
|
- if ( netdev_is_open ( netdev ) &&
|
424
|
|
- ( netdev->max_pkt_len > old_max_pkt_len ) ) {
|
|
432
|
+ if ( netdev_is_open ( netdev ) && ( mtu > old_mtu ) ) {
|
425
|
433
|
netdev_close ( netdev );
|
426
|
434
|
if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
|
427
|
435
|
DBGC ( netdev, "NETDEV %s could not reopen: "
|