summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormcbride <mcbride@openbsd.org>2005-05-27 04:55:27 +0000
committermcbride <mcbride@openbsd.org>2005-05-27 04:55:27 +0000
commitce12ce87d291522f11dbdffa40853d35e0846adc (patch)
tree8fb5cc20fd7e3be798cbcea2a5613c3935641cbf /sys
parenthandle SIOCSIFMTU ioctl (diff)
downloadwireguard-openbsd-ce12ce87d291522f11dbdffa40853d35e0846adc.tar.xz
wireguard-openbsd-ce12ce87d291522f11dbdffa40853d35e0846adc.zip
Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them. This adds a new socket option, SO_JUMBO, and a new route flag, RTF_JUMBO. If _both_ the socket option is set and the route for the host has RTF_JUMBO set, ip_output will fragment the packet to the largest possible size for the link, ignoring the card's MTU. The semantics of this feature will be evolving rapidly; talk to us if you intend to use it. ok deraadt@ marius@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_socket.c4
-rw-r--r--sys/net/route.h3
-rw-r--r--sys/net/rtsock.c8
-rw-r--r--sys/netinet/in.h7
-rw-r--r--sys/netinet/ip_output.c6
-rw-r--r--sys/netinet/ip_var.h7
-rw-r--r--sys/netinet/raw_ip.c4
-rw-r--r--sys/netinet/udp_usrreq.c5
-rw-r--r--sys/sys/socket.h3
9 files changed, 34 insertions, 13 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index cddf0d3452f..14fa544fd84 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.56 2004/11/18 15:09:07 markus Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.57 2005/05/27 04:55:27 mcbride Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1026,6 +1026,7 @@ sosetopt(so, level, optname, m0)
case SO_REUSEADDR:
case SO_REUSEPORT:
case SO_OOBINLINE:
+ case SO_JUMBO:
if (m == NULL || m->m_len < sizeof (int)) {
error = EINVAL;
goto bad;
@@ -1164,6 +1165,7 @@ sogetopt(so, level, optname, mp)
case SO_REUSEPORT:
case SO_BROADCAST:
case SO_OOBINLINE:
+ case SO_JUMBO:
*mtod(m, int *) = so->so_options & optname;
break;
diff --git a/sys/net/route.h b/sys/net/route.h
index 8f4260dd23b..db6058e186d 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.27 2005/05/26 22:37:34 henning Exp $ */
+/* $OpenBSD: route.h,v 1.28 2005/05/27 04:55:27 mcbride Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -139,6 +139,7 @@ struct rtentry {
#define RTF_CLONED 0x10000 /* this is a cloned route */
#define RTF_SOURCE 0x20000 /* this route has a source selector */
#define RTF_MPATH 0x40000 /* multipath route or operation */
+#define RTF_JUMBO 0x80000 /* try to use jumbo frames */
#ifndef _KERNEL
/* obsoleted */
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index f19aabbf2cd..2085dd99568 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.43 2004/09/16 22:31:29 henning Exp $ */
+/* $OpenBSD: rtsock.c,v 1.44 2005/05/27 04:55:27 mcbride Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -396,6 +396,12 @@ report:
rt->rt_ifp = ifp;
}
}
+
+ /* XXX Hack to allow the jumbo flag to be toggled */
+ if (rtm->rtm_flags & RTF_JUMBO)
+ rt->rt_flags = (rt->rt_flags & ~rtm->rtm_use) |
+ (rtm->rtm_flags & rtm->rtm_use);
+
rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
&rt->rt_rmx);
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index a0d14d5878f..84985ed987a 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.65 2005/05/24 04:20:25 markus Exp $ */
+/* $OpenBSD: in.h,v 1.66 2005/05/27 04:55:28 mcbride Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -320,6 +320,11 @@ struct ip_mreq {
#define INET_ADDRSTRLEN 16
/*
+ * JUMBO MTU
+ */
+#define IP_JUMBO_MTU 9000
+
+/*
* Definitions for inet sysctl operations.
*
* Third level is protocol number.
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index cdb0fa48949..724d481f022 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.170 2005/04/25 17:55:52 brad Exp $ */
+/* $OpenBSD: ip_output.c,v 1.171 2005/05/27 04:55:28 mcbride Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -693,6 +693,10 @@ sendit:
}
#endif
+ /* Try to use jumbograms? */
+ if (flags & IP_JUMBO && ro->ro_rt && ro->ro_rt->rt_flags & RTF_JUMBO)
+ mtu = IP_JUMBO_MTU;
+
/*
* If small enough for interface, can just send directly.
*/
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index 4697fe53824..33b34eb54f8 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_var.h,v 1.32 2004/06/22 07:35:20 cedric Exp $ */
+/* $OpenBSD: ip_var.h,v 1.33 2005/05/27 04:55:28 mcbride Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@@ -152,8 +152,9 @@ struct ipstat {
#define IP_RAWOUTPUT 0x2 /* raw ip header exists */
#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
-#define IP_MTUDISC 0x0400 /* pmtu discovery, set DF */
-#define IP_ROUTETOETHER 0x0800 /* ether addresses given */
+#define IP_JUMBO SO_JUMBO /* try to use the jumbo mtu */
+#define IP_MTUDISC 0x0800 /* pmtu discovery, set DF */
+#define IP_ROUTETOETHER 0x1000 /* ether addresses given */
extern struct ipstat ipstat;
extern LIST_HEAD(ipqhead, ipq) ipq; /* ip reass. queue */
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 1aa90898f3b..5791bc7f7ec 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.36 2005/01/14 14:51:28 mcbride Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.37 2005/05/27 04:55:28 mcbride Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -187,7 +187,7 @@ rip_output(struct mbuf *m, ...)
va_end(ap);
inp = sotoinpcb(so);
- flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST;
+ flags = (so->so_options & (SO_DONTROUTE|SO_JUMBO)) | IP_ALLOWBROADCAST;
/*
* If the user handed us a complete IP packet, use it.
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 3c449120b65..587ae62f5c3 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.103 2005/04/25 17:55:52 brad Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.104 2005/05/27 04:55:28 mcbride Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -1002,7 +1002,8 @@ udp_output(struct mbuf *m, ...)
udpstat.udps_opackets++;
error = ip_output(m, inp->inp_options, &inp->inp_route,
- inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
+ inp->inp_socket->so_options &
+ (SO_DONTROUTE | SO_BROADCAST | SO_JUMBO),
inp->inp_moptions, inp, (void *)NULL);
bail:
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index a429a775b41..2ef396b5947 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: socket.h,v 1.51 2005/04/04 22:18:47 hshoexer Exp $ */
+/* $OpenBSD: socket.h,v 1.52 2005/05/27 04:55:28 mcbride Exp $ */
/* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */
/*
@@ -66,6 +66,7 @@
#define SO_LINGER 0x0080 /* linger on close if data present */
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
+#define SO_JUMBO 0x0400 /* try to use jumbograms */
/*
* Additional options, not kept in so_options.