summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2018-02-09 09:22:46 +0000
committerdlg <dlg@openbsd.org>2018-02-09 09:22:46 +0000
commit4fc46bb8dc49c3db9200b7782530e2f06796a8d3 (patch)
treee1b921ccec4d9aa8e7d42514e6a39dc411d09331
parentCall socreate() before falloc() in sys_socket(). (diff)
downloadwireguard-openbsd-4fc46bb8dc49c3db9200b7782530e2f06796a8d3.tar.xz
wireguard-openbsd-4fc46bb8dc49c3db9200b7782530e2f06796a8d3.zip
add support for setting the ttl on the tunnel traffic.
-rw-r--r--sys/net/if_etherip.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c
index 0c59f9f649b..133443ab20c 100644
--- a/sys/net/if_etherip.c
+++ b/sys/net/if_etherip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_etherip.c,v 1.32 2018/02/09 04:05:58 dlg Exp $ */
+/* $OpenBSD: if_etherip.c,v 1.33 2018/02/09 09:22:46 dlg Exp $ */
/*
* Copyright (c) 2015 Kazuya GODA <goda@openbsd.org>
*
@@ -87,6 +87,7 @@ struct etherip_softc {
struct etherip_tunnel sc_tunnel; /* must be first */
struct arpcom sc_ac;
struct ifmedia sc_media;
+ uint8_t sc_ttl;
};
/*
@@ -135,6 +136,8 @@ etherip_clone_create(struct if_clone *ifc, int unit)
snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d",
ifc->ifc_name, unit);
+ sc->sc_ttl = ip_defttl;
+
ifp->if_softc = sc;
ifp->if_ioctl = etherip_ioctl;
ifp->if_start = etherip_start;
@@ -283,6 +286,19 @@ etherip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
error = etherip_del_tunnel(sc);
break;
+ case SIOCSLIFPHYTTL:
+ if (ifr->ifr_ttl < 1 || ifr->ifr_ttl > 0xff) {
+ error = EINVAL;
+ break;
+ }
+
+ /* commit */
+ sc->sc_ttl = (uint8_t)ifr->ifr_ttl;
+ break;
+ case SIOCGLIFPHYTTL:
+ ifr->ifr_ttl = (int)sc->sc_ttl;
+ break;
+
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
@@ -476,7 +492,7 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
ip->ip_tos = IPTOS_LOWDELAY;
ip->ip_p = IPPROTO_ETHERIP;
ip->ip_len = htons(m->m_pkthdr.len);
- ip->ip_ttl = IPDEFTTL;
+ ip->ip_ttl = sc->sc_ttl;
ip->ip_src = sc->sc_tunnel.t_src4;
ip->ip_dst = sc->sc_tunnel.t_dst4;