[network-manager-sstp/set-mtu] Adding in processing of MTU setting, default is to now use 1400 unless it is overriden



commit 06173be2a2506cdcf27cd2977e62b66265870471
Author: Eivind Naess <eivnaes yahoo com>
Date:   Sun Sep 18 13:03:22 2022 -0700

    Adding in processing of MTU setting, default is to now use 1400 unless it is overriden
    
    Signed-off-by: Eivind Naess <eivnaes yahoo com>

 properties/advanced-dialog.c | 35 +++++++++++++++++++++++++++++++++++
 properties/nm-sstp-dialog.ui | 21 ++++++++++++++-------
 shared/nm-service-defines.h  |  1 +
 src/nm-sstp-service.c        | 12 ++++++++++++
 4 files changed, 62 insertions(+), 7 deletions(-)
---
diff --git a/properties/advanced-dialog.c b/properties/advanced-dialog.c
index 81a2165..0fb9451 100644
--- a/properties/advanced-dialog.c
+++ b/properties/advanced-dialog.c
@@ -68,6 +68,7 @@ static const char *advanced_keys[] = {
     NM_SSTP_KEY_LCP_ECHO_FAILURE,
     NM_SSTP_KEY_LCP_ECHO_INTERVAL,
     NM_SSTP_KEY_UNIT_NUM,
+    NM_SSTP_KEY_MTU,
     NM_SSTP_KEY_PROXY_SERVER,
     NM_SSTP_KEY_PROXY_PORT,
     NM_SSTP_KEY_PROXY_USER,
@@ -800,6 +801,30 @@ advanced_dialog_new (GHashTable *hash, gboolean is_tls, gchar *subject)
         gtk_widget_set_sensitive (widget, FALSE);
     }
 
+    widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mtu_checkbutton"));
+    spin = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mtu_spinbutton"));
+    g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (checkbox_toggled_update_widget_cb), spin);
+
+    value = g_hash_table_lookup (hash, NM_SSTP_KEY_MTU);
+    if (value && *value) {
+        long int tmp;
+
+        errno = 0;
+        tmp = strtol (value, NULL, 10);
+        if (errno == 0 && tmp >= 0 && tmp <= 1500) {
+            gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), TRUE);
+
+            widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mtu_spinbutton"));
+            gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble) tmp);
+            gtk_widget_set_sensitive (widget, TRUE);
+        }
+    } else {
+        gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
+
+        widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mtu_spinbutton"));
+        gtk_widget_set_sensitive (widget, FALSE);
+    }
+
     return dialog;
 }
 
@@ -945,6 +970,16 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
                              g_strdup_printf ("%d", unit_num));
     }
 
+    widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mtu_checkbutton"));
+    if (gtk_check_button_get_active (GTK_CHECK_BUTTON (widget))) {
+        int mtu;
+
+        widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mtu_spinbutton"));
+        mtu = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
+        g_hash_table_insert (hash, g_strdup (NM_SSTP_KEY_MTU),
+                             g_strdup_printf ("%d", mtu));
+    }
+
     /* TLS Authentication */
     widget = GTK_WIDGET (gtk_builder_get_object (builder, "tls_identity"));
     value = gtk_editable_get_text (GTK_EDITABLE (widget));
diff --git a/properties/nm-sstp-dialog.ui b/properties/nm-sstp-dialog.ui
index 87b1895..399e644 100644
--- a/properties/nm-sstp-dialog.ui
+++ b/properties/nm-sstp-dialog.ui
@@ -14,6 +14,7 @@
   </object>
   <object class="GtkAdjustment" id="adjustment3">
     <property name="upper">1500</property>
+    <property name="value">1400</property>
     <property name="step-increment">1</property>
     <property name="page-increment">10</property>
   </object>
@@ -1097,8 +1098,8 @@ config: unit &lt;n&gt;</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
                           </packing>
                         </child>
                       </object>
@@ -1115,11 +1116,11 @@ config: unit &lt;n&gt;</property>
                         <property name="spacing">6</property>
                         <child>
                           <object class="GtkCheckButton" id="ppp_mtu_checkbutton">
-                            <property name="label" translatable="yes">Set maximum receive unit 
(MRU):</property>
+                            <property name="label" translatable="yes">Set maximum transmission unit 
(MTU):</property>
                             <property name="visible">True</property>
                             <property name="can-focus">True</property>
                             <property name="receives-default">False</property>
-                            <property name="tooltip-text" translatable="yes">Specify the maximum size of the 
network packets that can be received by this ppp&lt;n&gt; device. The default for Microsoft servers is 
1400.</property>
+                            <property name="tooltip-text" translatable="yes">Specify the maximum size of the 
network packets that can be transmitted by this ppp&lt;n&gt; device. The default for Microsoft servers is 
1400.</property>
                             <property name="halign">start</property>
                             <property name="hexpand">False</property>
                             <property name="use-underline">True</property>
@@ -1135,10 +1136,10 @@ config: unit &lt;n&gt;</property>
                           <object class="GtkSpinButton" id="ppp_mtu_spinbutton">
                             <property name="visible">True</property>
                             <property name="can-focus">True</property>
-                            <property name="tooltip-text" translatable="yes">Specify the maximum size of the 
network packets that can be received by this ppp&lt;n&gt; device. The default for Microsoft servers is 
1400.</property>
+                            <property name="tooltip-text" translatable="yes">Specify the maximum size of the 
network packets that can be transmitted by this ppp&lt;n&gt; device. The default for Microsoft servers is 
1400.</property>
                             <property name="numeric">True</property>
-                            <property name="text" translatable="yes">1400</property>
-                            <property name="adjustment">adjustment2</property>
+                            <property name="adjustment">adjustment3</property>
+                            <property name="climb-rate">1</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -1788,4 +1789,10 @@ or just the Common Name (CN field).
       <widget name="ppp_unit_checkbutton"/>
     </widgets>
   </object>
+  <object class="GtkSizeGroup" id="spinbutton_group_7">
+    <widgets>
+      <widget name="ppp_mtu_spinbutton"/>
+      <widget name="ppp_unit_spinbutton"/>
+    </widgets>
+  </object>
 </interface>
diff --git a/shared/nm-service-defines.h b/shared/nm-service-defines.h
index 40c4569..98e5950 100644
--- a/shared/nm-service-defines.h
+++ b/shared/nm-service-defines.h
@@ -59,6 +59,7 @@
 #define NM_SSTP_KEY_LCP_ECHO_FAILURE            "lcp-echo-failure"
 #define NM_SSTP_KEY_LCP_ECHO_INTERVAL           "lcp-echo-interval"
 #define NM_SSTP_KEY_UNIT_NUM                    "unit"
+#define NM_SSTP_KEY_MTU                         "mtu"
 #define NM_SSTP_KEY_PROXY_SERVER                "proxy-server"
 #define NM_SSTP_KEY_PROXY_PORT                  "proxy-port"
 #define NM_SSTP_KEY_PROXY_USER                  "proxy-user"
diff --git a/src/nm-sstp-service.c b/src/nm-sstp-service.c
index 9ff17af..61b3b96 100644
--- a/src/nm-sstp-service.c
+++ b/src/nm-sstp-service.c
@@ -74,6 +74,7 @@ typedef struct {
 
 #define NM_SSTP_PPPD_PLUGIN PLUGINDIR "/nm-sstp-pppd-plugin.so"
 #define NM_SSTP_WAIT_PPPD 10000 /* 10 seconds */
+#define NM_SSTP_MTU_DEFAULT "1400"
 #define SSTP_SERVICE_SECRET_TRIES "sstp-service-secret-tries"
 
 /*****************************************************************************/
@@ -115,6 +116,7 @@ static const ValidProperty valid_properties[] = {
     { NM_SSTP_KEY_CA_CERT,                   G_TYPE_STRING,  FALSE },
     { NM_SSTP_KEY_IGN_CERT_WARN,             G_TYPE_BOOLEAN, FALSE },
     { NM_SSTP_KEY_TLS_EXT_ENABLE,            G_TYPE_BOOLEAN, FALSE },
+    { NM_SSTP_KEY_MTU,                       G_TYPE_UINT,    FALSE },
     { NM_SSTP_KEY_REFUSE_EAP,                G_TYPE_BOOLEAN, FALSE },
     { NM_SSTP_KEY_REFUSE_PAP,                G_TYPE_BOOLEAN, FALSE },
     { NM_SSTP_KEY_REFUSE_CHAP,               G_TYPE_BOOLEAN, FALSE },
@@ -780,6 +782,16 @@ construct_pppd_args (NMSstpPlugin *plugin,
         g_ptr_array_add (args, (gpointer) g_strdup ("need-peer-eap"));
     }
 
+    value = nm_setting_vpn_get_data_item (s_vpn, NM_SSTP_KEY_MTU) ? : NM_SSTP_MTU_DEFAULT;
+    if (value && *value) {
+        long int tmp_int;
+        if (str_to_int (value, &tmp_int)) {
+            g_ptr_array_add (args, (gpointer) g_strdup ("mtu"));
+            g_ptr_array_add (args, (gpointer) g_strdup_printf("%ld", tmp_int));
+        } else
+            _LOGW ("failed to convert mtu value “%s”", value);
+    }
+
     /* Allow EAP */
     value = nm_setting_vpn_get_data_item (s_vpn, NM_SSTP_KEY_REFUSE_EAP);
     if (value && !strcmp (value, "yes"))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]