summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2018-02-19 00:26:26 +0000
committerdlg <dlg@openbsd.org>2018-02-19 00:26:26 +0000
commited7a9f2e2f0458ae2b83b7071c6201cc42459560 (patch)
treec94fe5a8770c56d78a5daab08c1f18b91cf8075a
parentmake sure only root can configure an interface with SIOCSLIFPHYDF. (diff)
downloadwireguard-openbsd-ed7a9f2e2f0458ae2b83b7071c6201cc42459560.tar.xz
wireguard-openbsd-ed7a9f2e2f0458ae2b83b7071c6201cc42459560.zip
add code to support configuration of tunnel traffic fragmentation
-rw-r--r--sys/net/if_etherip.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c
index 301dc221d42..3c09a675ac0 100644
--- a/sys/net/if_etherip.c
+++ b/sys/net/if_etherip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_etherip.c,v 1.35 2018/02/12 01:43:42 dlg Exp $ */
+/* $OpenBSD: if_etherip.c,v 1.36 2018/02/19 00:26:26 dlg Exp $ */
/*
* Copyright (c) 2015 Kazuya GODA <goda@openbsd.org>
*
@@ -85,6 +85,7 @@ struct etherip_softc {
struct etherip_tunnel sc_tunnel; /* must be first */
struct arpcom sc_ac;
struct ifmedia sc_media;
+ uint16_t sc_df;
uint8_t sc_ttl;
};
@@ -136,6 +137,7 @@ etherip_clone_create(struct if_clone *ifc, int unit)
ifc->ifc_name, unit);
sc->sc_ttl = ip_defttl;
+ sc->sc_ttl = htons(0);
ifp->if_softc = sc;
ifp->if_ioctl = etherip_ioctl;
@@ -293,6 +295,14 @@ etherip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
ifr->ifr_ttl = (int)sc->sc_ttl;
break;
+ case SIOCSLIFPHYDF:
+ /* commit */
+ sc->sc_df = ifr->ifr_df ? htons(IP_DF) : htons(0);
+ break;
+ case SIOCGLIFPHYDF:
+ ifr->ifr_df = sc->sc_df ? 1 : 0;
+ break;
+
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
@@ -476,11 +486,12 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
ip->ip_v = IPVERSION;
ip->ip_hl = sizeof(*ip) >> 2;
- ip->ip_id = htons(ip_randomid());
ip->ip_tos = IPTOS_LOWDELAY;
- ip->ip_p = IPPROTO_ETHERIP;
ip->ip_len = htons(m->m_pkthdr.len);
+ ip->ip_id = htons(ip_randomid());
+ ip->ip_off = sc->sc_df;
ip->ip_ttl = sc->sc_ttl;
+ ip->ip_p = IPPROTO_ETHERIP;
ip->ip_src = sc->sc_tunnel.t_src4;
ip->ip_dst = sc->sc_tunnel.t_dst4;
@@ -640,6 +651,9 @@ ip6_etherip_output(struct ifnet *ifp, struct mbuf *m)
eip->eip_res = 0;
eip->eip_pad = 0;
+ if (sc->sc_df)
+ SET(m->m_pkthdr.csum_flags, M_IPV6_DF_OUT);
+
m->m_flags &= ~(M_BCAST|M_MCAST);
m->m_pkthdr.ph_rtableid = sc->sc_tunnel.t_rtableid;