Re: [PATCH] Support for openvpn --fragment option
- From: Dan Williams <dcbw redhat com>
- To: Jochen Friedrich <jochen scram de>
- Cc: Alexander Sack <asac ubuntu com>, networkmanager-list gnome org
- Subject: Re: [PATCH] Support for openvpn --fragment option
- Date: Fri, 19 Dec 2008 19:54:54 -0500
On Tue, 2008-11-25 at 15:21 +0100, Jochen Friedrich wrote:
> Alexander Sack schrieb:
>
> > Openvpn improvements and new features are definitly much appreciated
> > ... its just that NM 0.7 is supposed to be released any day and hence
> > the tree is pretty much locked down.
>
> Here is yet another patch implementing the fragment option.
The fragment option is only applicable with UDP, so if we could rework
the UI a bit that would be great. Instead of having a checkbox for "Use
TCP", lets move that option to the bottom of the list and make it a
popup menu, like so:
[ ] Use LZO data compression
[ ] Use a TAP device
.-----------------.
Connection protocol: | UDP (default) | (<---- menu has TCP too)
`-----------------'
.--------.
[ ] Custom fragmentation threshold: | 1300 |X|
`--------'
Where, of course, the custom fragmentation threshold would be disabled
(gtk_widget_set_sensitive (..., FALSE);) when TCP was selected. The
spinbox should also have sensible upper and lower bounds, like maybe >=
500 and <= 1492.
Sound OK? Mind whipping up that patch? The rest of it looks good.
Dan
> Thanks,
> Jochen
>
> Index: vpn-daemons/openvpn/src/nm-openvpn-service.h
> ===================================================================
> --- vpn-daemons/openvpn/src/nm-openvpn-service.h (Revision 4323)
> +++ vpn-daemons/openvpn/src/nm-openvpn-service.h (Arbeitskopie)
> @@ -43,6 +43,7 @@
> #define NM_OPENVPN_KEY_CIPHER "cipher"
> #define NM_OPENVPN_KEY_COMP_LZO "comp-lzo"
> #define NM_OPENVPN_KEY_CONNECTION_TYPE "connection-type"
> +#define NM_OPENVPN_KEY_FRAGMENT "fragment"
> #define NM_OPENVPN_KEY_TAP_DEV "tap-dev"
> #define NM_OPENVPN_KEY_KEY "key"
> #define NM_OPENVPN_KEY_LOCAL_IP "local-ip"
> Index: vpn-daemons/openvpn/src/nm-openvpn-service.c
> ===================================================================
> --- vpn-daemons/openvpn/src/nm-openvpn-service.c (Revision 4323)
> +++ vpn-daemons/openvpn/src/nm-openvpn-service.c (Arbeitskopie)
> @@ -88,6 +88,7 @@
> { NM_OPENVPN_KEY_CIPHER, G_TYPE_STRING, 0, 0, FALSE },
> { NM_OPENVPN_KEY_COMP_LZO, G_TYPE_BOOLEAN, 0, 0, FALSE },
> { NM_OPENVPN_KEY_CONNECTION_TYPE, G_TYPE_STRING, 0, 0, FALSE },
> + { NM_OPENVPN_KEY_FRAGMENT, G_TYPE_INT, 600, 1500, FALSE },
> { NM_OPENVPN_KEY_TAP_DEV, G_TYPE_BOOLEAN, 0, 0, FALSE },
> { NM_OPENVPN_KEY_KEY, G_TYPE_STRING, 0, 0, FALSE },
> { NM_OPENVPN_KEY_LOCAL_IP, G_TYPE_STRING, 0, 0, TRUE },
> @@ -651,6 +652,21 @@
> add_openvpn_arg (args, "1194");
> }
>
> + /* Fragment */
> + tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_FRAGMENT);
> + if (tmp && strlen (tmp)) {
> + add_openvpn_arg (args, "--fragment");
> + if (!add_openvpn_arg_int (args, tmp)) {
> + g_set_error (error,
> + NM_VPN_PLUGIN_ERROR,
> + NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
> + "Invalid fragment size '%s'.",
> + tmp);
> + free_openvpn_args (args);
> + return FALSE;
> + }
> + }
> +
> /* Cipher */
> tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_CIPHER);
> if (tmp && strlen (tmp)) {
> Index: vpn-daemons/openvpn/properties/auth-helpers.c
> ===================================================================
> --- vpn-daemons/openvpn/properties/auth-helpers.c (Revision 4323)
> +++ vpn-daemons/openvpn/properties/auth-helpers.c (Arbeitskopie)
> @@ -720,6 +720,7 @@
> NM_OPENVPN_KEY_COMP_LZO,
> NM_OPENVPN_KEY_TAP_DEV,
> NM_OPENVPN_KEY_PROTO_TCP,
> + NM_OPENVPN_KEY_FRAGMENT,
> NM_OPENVPN_KEY_CIPHER,
> NM_OPENVPN_KEY_TA_DIR,
> NM_OPENVPN_KEY_TA,
> @@ -764,6 +765,16 @@
> gtk_widget_set_sensitive (widget, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
> }
>
> +static void
> +frag_toggled_cb (GtkWidget *check, gpointer user_data)
> +{
> + GladeXML *xml = (GladeXML *) user_data;
> + GtkWidget *widget;
> +
> + widget = glade_xml_get_widget (xml, "frag_spinbutton");
> + gtk_widget_set_sensitive (widget, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
> +}
> +
> static const char *
> nm_find_openvpn (void)
> {
> @@ -959,6 +970,31 @@
> gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
> }
>
> + widget = glade_xml_get_widget (xml, "frag_checkbutton");
> + g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (frag_toggled_cb), xml);
> +
> + value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_FRAGMENT);
> + if (value && strlen (value)) {
> + long int tmp;
> +
> + errno = 0;
> + tmp = strtol (value, NULL, 10);
> + if (errno == 0 && tmp >= 600 && tmp <= 1500) {
> + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
> +
> + widget = glade_xml_get_widget (xml, "frag_spinbutton");
> + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget),
> + (gdouble) tmp);
> + }
> + gtk_widget_set_sensitive (widget, TRUE);
> + } else {
> + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
> +
> + widget = glade_xml_get_widget (xml, "frag_spinbutton");
> + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 1300.0);
> + gtk_widget_set_sensitive (widget, FALSE);
> + }
> +
> if ( !strcmp (contype, NM_OPENVPN_CONTYPE_TLS)
> || !strcmp (contype, NM_OPENVPN_CONTYPE_PASSWORD_TLS)
> || !strcmp (contype, NM_OPENVPN_CONTYPE_PASSWORD)) {
> @@ -1058,6 +1094,15 @@
> if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
> g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_TAP_DEV), g_strdup ("yes"));
>
> + widget = glade_xml_get_widget (xml, "frag_checkbutton");
> + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
> + int frag;
> +
> + widget = glade_xml_get_widget (xml, "frag_spinbutton");
> + frag = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
> + g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_FRAGMENT), g_strdup_printf ("%d", frag));
> + }
> +
> contype = g_object_get_data (G_OBJECT (dialog), "connection-type");
> if (!strcmp (contype, NM_OPENVPN_CONTYPE_TLS) || !strcmp (contype, NM_OPENVPN_CONTYPE_PASSWORD_TLS)) {
> GtkTreeModel *model;
> Index: vpn-daemons/openvpn/properties/nm-openvpn-dialog.glade
> ===================================================================
> --- vpn-daemons/openvpn/properties/nm-openvpn-dialog.glade (Revision 4323)
> +++ vpn-daemons/openvpn/properties/nm-openvpn-dialog.glade (Arbeitskopie)
> @@ -935,6 +935,40 @@
> <property name="position">3</property>
> </packing>
> </child>
> + <child>
> + <widget class="GtkHBox" id="hbox4">
> + <property name="visible">True</property>
> + <property name="spacing">6</property>
> + <child>
> + <widget class="GtkCheckButton" id="frag_checkbutton">
> + <property name="visible">True</property>
> + <property name="can_focus">True</property>
> + <property name="label" translatable="yes">Use fragmentation: </property>
> + <property name="use_underline">True</property>
> + <property name="response_id">0</property>
> + <property name="draw_indicator">True</property>
> + </widget>
> + <packing>
> + <property name="expand">False</property>
> + </packing>
> + </child>
> + <child>
> + <widget class="GtkSpinButton" id="frag_spinbutton">
> + <property name="visible">True</property>
> + <property name="can_focus">True</property>
> + <property name="adjustment">1300 600 1500 1 10 10</property>
> + </widget>
> + <packing>
> + <property name="expand">False</property>
> + <property name="position">1</property>
> + </packing>
> + </child>
> + </widget>
> + <packing>
> + <property name="expand">False</property>
> + <property name="position">4</property>
> + </packing>
> + </child>
> </widget>
> </child>
> <child>
> _______________________________________________
> NetworkManager-list mailing list
> NetworkManager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]