sometimes you want to avoid fragmentation of the encapsulated traffic, and this 
gives up the option to prevent fragmentation.

the diff includes updating etherip to show how it is used, but if
this goes through i'll update gre/egre, gif, and maybe vxlan.

# ifconfig etherip0
etherip0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr fe:e1:ba:d0:d4:dd
        index 8 priority 0 llprio 3
        groups: etherip
        media: Ethernet autoselect
        status: active
        tunnel: inet 192.168.0.1 -> 192.168.1.1 nodf

if you tcpdump that traffic:

12:22:07.929427 etherip 192.168.0.1 > 192.168.1.1 ver 3 len 44: arp who-has 
100.64.9.3 tell 100.64.9.1 (fe:e1:ba:d1:56:5d) [tos 0x10] [ttl 0]

# ifconfig etherip0 tunneldf
# ifconfig etherip0
etherip0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr fe:e1:ba:d0:d4:dd
        index 8 priority 0 llprio 3
        groups: etherip
        media: Ethernet autoselect
        status: active
        tunnel: inet 192.168.0.1 -> 192.168.1.1 df

note the DF flag in tcpdump now:

12:21:11.924485 etherip 192.168.0.1 > 192.168.1.1 ver 3 len 44: arp who-has 
100.64.9.2 tell 100.64.9.1 (fe:e1:ba:d1:56:5d) (DF) [tos 0x10] [ttl 0]

ok?

Index: sbin/ifconfig/ifconfig.8
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.299
diff -u -p -r1.299 ifconfig.8
--- sbin/ifconfig/ifconfig.8    15 Feb 2018 04:21:46 -0000      1.299
+++ sbin/ifconfig/ifconfig.8    15 Feb 2018 04:22:52 -0000
@@ -1603,6 +1603,7 @@ for a complete list of the available pro
 .Op Oo Fl Oc Ns Cm keepalive Ar period count
 .Op Oo Fl Oc Ns Cm tunnel Ar src_address dest_address
 .Op Cm tunneldomain Ar tableid
+.Op Oo Fl Oc Ns Cm tunneldf
 .Op Cm tunnelttl Ar ttl
 .Op Oo Fl Oc Ns Cm vnetid Ar network-id
 .Ek
@@ -1654,6 +1655,10 @@ interface itself.
 .Ar tableid
 can be set to any valid routing table ID;
 the corresponding routing domain is derived from this table.
+.It Cm tunneldf
+Do not allow fragmentation of encapsulated packets.
+.It Cm -tunneldf
+Allow fragmentation of the encapsulated packets. 
 .It Cm tunnelttl Ar ttl
 Set the IP or multicast TTL of the tunnel packets.
 If supported by the tunnel protocol,
Index: sbin/ifconfig/ifconfig.c
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.357
diff -u -p -r1.357 ifconfig.c
--- sbin/ifconfig/ifconfig.c    10 Feb 2018 05:55:26 -0000      1.357
+++ sbin/ifconfig/ifconfig.c    15 Feb 2018 04:22:52 -0000
@@ -252,6 +252,8 @@ void        setpfsync_syncpeer(const char *, in
 void   unsetpfsync_syncpeer(const char *, int);
 void   setpfsync_defer(const char *, int);
 void   pfsync_status(void);
+void   settunneldf(const char *, int);
+void   settunnelnodf(const char *, int);
 void   setpppoe_dev(const char *,int);
 void   setpppoe_svc(const char *,int);
 void   setpppoe_ac(const char *,int);
@@ -434,6 +436,8 @@ const struct        cmd {
        { "deletetunnel",  0,           0,              deletetunnel },
        { "tunneldomain", NEXTARG,      0,              settunnelinst },
        { "tunnelttl",  NEXTARG,        0,              settunnelttl },
+       { "tunneldf",   0,              0,              settunneldf },
+       { "-tunneldf",  0,              0,              settunnelnodf },
        { "pppoedev",   NEXTARG,        0,              setpppoe_dev },
        { "pppoesvc",   NEXTARG,        0,              setpppoe_svc },
        { "-pppoesvc",  1,              0,              setpppoe_svc },
@@ -2750,6 +2754,10 @@ phys_status(int force)
                else if (ifr.ifr_ttl > 0)
                        printf(" ttl %d", ifr.ifr_ttl);
        }
+
+       if (ioctl(s, SIOCGLIFPHYDF, (caddr_t)&ifr) == 0)
+               printf(" %s", ifr.ifr_df ? "df" : "nodf");
+
 #ifndef SMALL
        if (ioctl(s, SIOCGLIFPHYRTABLE, (caddr_t)&ifr) == 0 &&
            (rdomainid != 0 || ifr.ifr_rdomainid != 0))
@@ -3283,6 +3291,24 @@ settunnelttl(const char *id, int param)
        ifr.ifr_ttl = ttl;
        if (ioctl(s, SIOCSLIFPHYTTL, (caddr_t)&ifr) < 0)
                warn("SIOCSLIFPHYTTL");
+}
+
+void
+settunneldf(const char *ignored, int alsoignored)
+{
+       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       ifr.ifr_df = 1;
+       if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) < 0)
+               warn("SIOCSLIFPHYDF");
+}
+
+void
+settunnelnodf(const char *ignored, int alsoignored)
+{
+       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       ifr.ifr_df = 0;
+       if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) < 0)
+               warn("SIOCSLIFPHYDF");
 }
 
 void
Index: sys/net/if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.544
diff -u -p -r1.544 if.c
--- sys/net/if.c        10 Feb 2018 09:32:54 -0000      1.544
+++ sys/net/if.c        15 Feb 2018 04:22:52 -0000
@@ -2114,6 +2114,7 @@ ifioctl(struct socket *so, u_long cmd, c
        case SIOCSLIFPHYADDR:
        case SIOCSLIFPHYRTABLE:
        case SIOCSLIFPHYTTL:
+       case SIOCSLIFPHYDF:
        case SIOCADDMULTI:
        case SIOCDELMULTI:
        case SIOCSIFMEDIA:
Index: sys/net/if.h
===================================================================
RCS file: /cvs/src/sys/net/if.h,v
retrieving revision 1.191
diff -u -p -r1.191 if.h
--- sys/net/if.h        10 Feb 2018 05:52:08 -0000      1.191
+++ sys/net/if.h        15 Feb 2018 04:22:53 -0000
@@ -387,6 +387,7 @@ struct      ifreq {
 #define        ifr_rdomainid   ifr_ifru.ifru_metric    /* VRF instance 
(overload) */
 #define ifr_vnetid     ifr_ifru.ifru_vnetid    /* Virtual Net Id */
 #define ifr_ttl                ifr_ifru.ifru_metric    /* tunnel TTL 
(overload) */
+#define ifr_df         ifr_ifru.ifru_metric    /* tunnel DF (overload) */
 #define        ifr_data        ifr_ifru.ifru_data      /* for use by interface 
*/
 #define ifr_index      ifr_ifru.ifru_index     /* interface index */
 #define ifr_llprio     ifr_ifru.ifru_metric    /* link layer priority */
Index: sys/net/if_etherip.c
===================================================================
RCS file: /cvs/src/sys/net/if_etherip.c,v
retrieving revision 1.35
diff -u -p -r1.35 if_etherip.c
--- sys/net/if_etherip.c        12 Feb 2018 01:43:42 -0000      1.35
+++ sys/net/if_etherip.c        15 Feb 2018 04:22:53 -0000
@@ -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 *if
            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 
                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, str
 
        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;
 
@@ -639,6 +650,9 @@ ip6_etherip_output(struct ifnet *ifp, st
        eip->eip_ver = ETHERIP_VERSION;
        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;
Index: sys/sys/sockio.h
===================================================================
RCS file: /cvs/src/sys/sys/sockio.h,v
retrieving revision 1.73
diff -u -p -r1.73 sockio.h
--- sys/sys/sockio.h    8 Feb 2018 13:15:32 -0000       1.73
+++ sys/sys/sockio.h    15 Feb 2018 04:22:53 -0000
@@ -191,6 +191,9 @@
 #define        SIOCSUMBPARAM    _IOW('i', 191, struct ifreq)   /* set MBIM 
param */
 #define        SIOCGUMBPARAM   _IOWR('i', 192, struct ifreq)   /* get MBIM 
param */
 
+#define        SIOCSLIFPHYDF   _IOW('i', 193, struct ifreq)    /* set tunnel 
df/nodf */
+#define        SIOCGLIFPHYDF   _IOWR('i', 194, struct ifreq)   /* set tunnel 
df/nodf */
+
 #define        SIOCSVH         _IOWR('i', 245, struct ifreq)   /* set carp 
param */
 #define        SIOCGVH         _IOWR('i', 246, struct ifreq)   /* get carp 
param */
 

Reply via email to