Re: Is it possible to set MTU for a vpn connection
- From: Dan Williams <dcbw redhat com>
- To: ritz <khadgaray gmail com>
- Cc: networkmanager-list gnome org
- Subject: Re: Is it possible to set MTU for a vpn connection
- Date: Thu, 10 Sep 2009 13:11:59 -0700
On Thu, 2009-09-03 at 02:31 +0530, ritz wrote:
> On Wed, 2009-09-02 at 10:56 -0400, Derek Atkins wrote:
> > ritz <khadgaray gmail com> writes:
> >
> > > Hello
> > >
> > > I do not see any option to set MTU under NMSettingVPN. All I could
> > > find was for ethernet, and wireless. Are there any plans to add this ?
> >
> > The way I do this is manipulating the helper script to reset the MTU
> > after the VPN comes up. It's a PITA.
> >
> > > reference:
> > > http://live.gnome.org/NetworkManagerConfiguration
> > > http://bugzilla.gnome.org/show_bug.cgi?id=584200
> >
> > -derek
>
>
> vpnc-console uses the the below to set MTU correctly
>
> if [ -n "$INTERNAL_IP4_MTU" ]; then
INTERNAL_IP4_MTU is pretty new I guess? Must be added in 0.5.x I guess.
In any case, the patch below is about what should get used, yes.
Applied, thanks!
259259b5bbb5686ee6fc6bcf2a12eedd7192a905 (master)
a0a10c623063df4d2cd4bde56054c30b77d94ed9 (0.7.x)
Dan
> MTU=$INTERNAL_IP4_MTU
> elif [ -n "$IPROUTE" ]; then
> DEV=$($IPROUTE route | grep ^default | sed 's/^.* dev
> \([[:alnum:]-]\+\).*$/\1/')
> MTU=$(($($IPROUTE link show "$DEV" | grep mtu | sed
> 's/^.* mtu \([[:digit:]]\+\).*$/\1/') - 88))
> else
> MTU=1412
> fi
>
>
>
> Which would roughly translate to the below. It seems I would have to use
> libnl magic. Is there an alternate method ?
>
> --- a/src/nm-vpnc-service-vpnc-helper.c
> +++ b/src/nm-vpnc-service-vpnc-helper.c
> @@ -368,10 +368,24 @@ main (int argc, char *argv[])
> if (val)
> g_hash_table_insert (config,
> NM_VPN_PLUGIN_IP4_CONFIG_BANNER, val);
>
> - /* Set MTU to 1412 */
> - val = uint_to_gvalue (1412);
> - if (val)
> - g_hash_table_insert (config,
> NM_VPN_PLUGIN_IP4_CONFIG_MTU, val);
> + /* MTU */
> + long int mtu ;
> + char *tmp = getenv ("INTERNAL_IP4_MTU");
> + if (tmp && strlen (tmp)) {
> + errno = 0;
> + mtu = strtol (tmp, NULL, 10);
> + if (errno || mtu < 0 || mtu > 20000) {
> + nm_warning ("Ignoring invalid tunnel MTU '%s'",
> tmp);
> + mtu = 1412;
> + }
> + } else {
> + // netlink magic to obtain mtu for default interface
> + // and set vpnc-mtu = default-mtu - 88
> + // if the above fails, set mtu = 1412
> + }
> + val = uint_to_gvalue ((guint32) mtu);
> + g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_MTU, val);
> +
>
> /* Send the config info to nm-vpnc-service */
> send_ip4_config (connection, config);
>
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]