Ticket #481: 0001-Fix-FreeBSD-ifconfig-for-topology-subnet-tunnels.patch

File 0001-Fix-FreeBSD-ifconfig-for-topology-subnet-tunnels.patch, 1.9 KB (added by Gert Döring, 9 years ago)

Create arbitrary but-in-self-subnet remote for point-to-point use

  • src/openvpn/tun.c

    From b8f70b0f25c44e6d6a17b9f76756de87146a55d9 Mon Sep 17 00:00:00 2001
    From: Gert Doering <gert@greenie.muc.de>
    Date: Sun, 26 Apr 2015 18:16:39 +0200
    Subject: [PATCH] Fix FreeBSD ifconfig for topology subnet tunnels.
    
    For "topology subnet", we only pretend to have a subnet and keep
    using the tun if in point-to-point mode - but for that to fully
    work, the "remote" address needs to be different from the "local"
    address.  So just arbitrarily construct one from the on-link
    subnet - base+1, if "that is not us", base+2, otherwise.
    
    Fix trac #481
    
    Signed-off-by: Gert Doering <gert@greenie.muc.de>
    ---
     src/openvpn/tun.c | 24 +++++++++++++++++++++++-
     1 file changed, 23 insertions(+), 1 deletion(-)
    
    diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
    index 11a6d71..aa7a9f0 100644
    a b void delete_route_connected_v6_net(struct tuntap * tt, 
    626626}
    627627#endif
    628628
     629#if defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY)
     630/* we can't use true subnet mode on tun on all platforms, as that
     631 * conflicts with IPv6 (wants to use ND then, which we don't do),
     632 * but the OSes want "a remote address that is different from ours"
     633 * - so we construct one, normally the first in the subnet, but if
     634 * this is the same as ours, use the second one.
     635 * The actual address does not matter at all, as the tun interface
     636 * is still point to point and no layer 2 resolution is done...
     637 */
     638
     639char *
     640create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc )
     641{
     642  in_addr_t remote;
     643
     644  remote = (tt->local & tt->remote_netmask) +1;
     645
     646  if ( remote == tt->local ) remote ++;
     647
     648  return print_in_addr_t (remote, 0, &gc);
     649}
     650#endif
    629651
    630652/* execute the ifconfig command through the shell */
    631653void
    do_ifconfig (struct tuntap *tt, 
    11501172                          IFCONFIG_PATH,
    11511173                          actual,
    11521174                          ifconfig_local,
    1153                           ifconfig_local,
     1175                          create_arbitrary_remote( tt, &gc ),
    11541176                          tun_mtu,
    11551177                          ifconfig_remote_netmask
    11561178                          );