|
@@ -70,6 +70,12 @@ const struct setting ifname_setting __setting ( SETTING_NETDEV, ifname ) = {
|
70
|
70
|
.description = "Interface name",
|
71
|
71
|
.type = &setting_type_string,
|
72
|
72
|
};
|
|
73
|
+const struct setting mtu_setting __setting ( SETTING_NETDEV, mtu ) = {
|
|
74
|
+ .name = "mtu",
|
|
75
|
+ .description = "MTU",
|
|
76
|
+ .type = &setting_type_int16,
|
|
77
|
+ .tag = DHCP_MTU,
|
|
78
|
+};
|
73
|
79
|
|
74
|
80
|
/**
|
75
|
81
|
* Store MAC address setting
|
|
@@ -377,3 +383,58 @@ static void netdev_redirect_settings_init ( void ) {
|
377
|
383
|
struct init_fn netdev_redirect_settings_init_fn __init_fn ( INIT_LATE ) = {
|
378
|
384
|
.initialise = netdev_redirect_settings_init,
|
379
|
385
|
};
|
|
386
|
+
|
|
387
|
+/**
|
|
388
|
+ * Apply network device settings
|
|
389
|
+ *
|
|
390
|
+ * @ret rc Return status code
|
|
391
|
+ */
|
|
392
|
+static int apply_netdev_settings ( void ) {
|
|
393
|
+ struct net_device *netdev;
|
|
394
|
+ struct settings *settings;
|
|
395
|
+ struct ll_protocol *ll_protocol;
|
|
396
|
+ size_t old_max_pkt_len;
|
|
397
|
+ size_t mtu;
|
|
398
|
+ int rc;
|
|
399
|
+
|
|
400
|
+ /* Process settings for each network device */
|
|
401
|
+ for_each_netdev ( netdev ) {
|
|
402
|
+
|
|
403
|
+ /* Get network device settings */
|
|
404
|
+ settings = netdev_settings ( netdev );
|
|
405
|
+
|
|
406
|
+ /* Get MTU */
|
|
407
|
+ mtu = fetch_uintz_setting ( settings, &mtu_setting );
|
|
408
|
+
|
|
409
|
+ /* Do nothing unless MTU is specified */
|
|
410
|
+ if ( ! mtu )
|
|
411
|
+ continue;
|
|
412
|
+
|
|
413
|
+ /* Update maximum packet length */
|
|
414
|
+ 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 ) {
|
|
418
|
+ DBGC ( netdev, "NETDEV %s MTU is %zd\n",
|
|
419
|
+ netdev->name, mtu );
|
|
420
|
+ }
|
|
421
|
+
|
|
422
|
+ /* Close and reopen network device if MTU has increased */
|
|
423
|
+ if ( netdev_is_open ( netdev ) &&
|
|
424
|
+ ( netdev->max_pkt_len > old_max_pkt_len ) ) {
|
|
425
|
+ netdev_close ( netdev );
|
|
426
|
+ if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
|
|
427
|
+ DBGC ( netdev, "NETDEV %s could not reopen: "
|
|
428
|
+ "%s\n", netdev->name, strerror ( rc ) );
|
|
429
|
+ return rc;
|
|
430
|
+ }
|
|
431
|
+ }
|
|
432
|
+ }
|
|
433
|
+
|
|
434
|
+ return 0;
|
|
435
|
+}
|
|
436
|
+
|
|
437
|
+/** Network device settings applicator */
|
|
438
|
+struct settings_applicator netdev_applicator __settings_applicator = {
|
|
439
|
+ .apply = apply_netdev_settings,
|
|
440
|
+};
|