Skip to content

Commit

Permalink
fixup! Add "pipe to external program" device
Browse files Browse the repository at this point in the history
  • Loading branch information
bendlas committed Jul 25, 2023
1 parent 8e304dd commit 135563a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/openvpn/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,17 +1049,17 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu,
#endif

#if defined(TARGET_LINUX)
if (net_iface_mtu_set(ctx, ifname, tun_mtu) < 0)
if (! tt->is_pipe && net_iface_mtu_set(ctx, ifname, tun_mtu) < 0)
{
msg(M_FATAL, "Linux can't set mtu (%d) on %s", tun_mtu, ifname);
}

if (net_iface_up(ctx, ifname, true) < 0)
if (! tt->is_pipe && net_iface_up(ctx, ifname, true) < 0)
{
msg(M_FATAL, "Linux can't bring %s up", ifname);
}

if (net_addr_v6_add(ctx, ifname, &tt->local_ipv6,
if (! tt->is_pipe && net_addr_v6_add(ctx, ifname, &tt->local_ipv6,
tt->netbits_ipv6) < 0)
{
msg(M_FATAL, "Linux can't add IPv6 to interface %s", ifname);
Expand Down Expand Up @@ -1267,27 +1267,29 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu,
#endif

#if defined(TARGET_LINUX)
if (net_iface_mtu_set(ctx, ifname, tun_mtu) < 0)
if (! tt->is_pipe && net_iface_mtu_set(ctx, ifname, tun_mtu) < 0)
{
msg(M_FATAL, "Linux can't set mtu (%d) on %s", tun_mtu, ifname);
}

if (net_iface_up(ctx, ifname, true) < 0)
if (! tt->is_pipe && net_iface_up(ctx, ifname, true) < 0)
{
msg(M_FATAL, "Linux can't bring %s up", ifname);
}

if (tun)
{
if (net_addr_ptp_v4_add(ctx, ifname, &tt->local,
if (! tt->is_pipe &&
net_addr_ptp_v4_add(ctx, ifname, &tt->local,
&tt->remote_netmask) < 0)
{
msg(M_FATAL, "Linux can't add IP to interface %s", ifname);
}
}
else
{
if (net_addr_v4_add(ctx, ifname, &tt->local,
if (! tt->is_pipe &&
net_addr_v4_add(ctx, ifname, &tt->local,
netmask_to_netbits2(tt->remote_netmask)) < 0)
{
msg(M_FATAL, "Linux can't add IP to interface %s", ifname);
Expand Down

0 comments on commit 135563a

Please sign in to comment.