diff options
-rw-r--r-- | sbin/ping/ping.c | 40 | ||||
-rw-r--r-- | sbin/route/keywords.h | 10 | ||||
-rw-r--r-- | sbin/route/keywords.sh | 4 | ||||
-rw-r--r-- | sbin/route/route.c | 19 | ||||
-rw-r--r-- | sbin/route/show.c | 3 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 4 | ||||
-rw-r--r-- | sys/net/route.h | 3 | ||||
-rw-r--r-- | sys/net/rtsock.c | 8 | ||||
-rw-r--r-- | sys/netinet/in.h | 7 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 6 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 7 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 4 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 5 | ||||
-rw-r--r-- | sys/sys/socket.h | 3 | ||||
-rw-r--r-- | usr.bin/nc/netcat.c | 30 |
15 files changed, 106 insertions, 47 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 75db06c5a37..9902f6902cd 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.70 2005/01/19 13:40:47 mpf Exp $ */ +/* $OpenBSD: ping.c,v 1.71 2005/05/27 04:55:27 mcbride Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: ping.c,v 1.70 2005/01/19 13:40:47 mpf Exp $"; +static const char rcsid[] = "$OpenBSD: ping.c,v 1.71 2005/05/27 04:55:27 mcbride Exp $"; #endif #endif /* not lint */ @@ -107,18 +107,19 @@ struct tvi { /* various options */ int options; -#define F_FLOOD 0x001 -#define F_INTERVAL 0x002 -#define F_NUMERIC 0x004 -#define F_PINGFILLED 0x008 -#define F_QUIET 0x010 -#define F_RROUTE 0x020 -#define F_SO_DEBUG 0x040 -#define F_SO_DONTROUTE 0x080 -#define F_VERBOSE 0x100 -#define F_SADDR 0x200 -#define F_HDRINCL 0x400 -#define F_TTL 0x800 +#define F_FLOOD 0x0001 +#define F_INTERVAL 0x0002 +#define F_NUMERIC 0x0004 +#define F_PINGFILLED 0x0008 +#define F_QUIET 0x0010 +#define F_RROUTE 0x0020 +#define F_SO_DEBUG 0x0040 +#define F_SO_DONTROUTE 0x0080 +#define F_VERBOSE 0x0100 +#define F_SADDR 0x0200 +#define F_HDRINCL 0x0400 +#define F_TTL 0x0800 +#define F_SO_JUMBO 0x1000 /* multicast options */ int moptions; @@ -210,7 +211,8 @@ main(int argc, char *argv[]) preload = 0; datap = &outpack[8 + sizeof(struct tvi)]; - while ((ch = getopt(argc, argv, "DI:LRS:c:dfi:l:np:qrs:T:t:vw:")) != -1) + while ((ch = getopt(argc, argv, + "DI:LRS:c:dfi:jl:np:qrs:T:t:vw:")) != -1) switch(ch) { case 'c': npackets = strtonum(optarg, 1, INT_MAX, &errstr); @@ -258,6 +260,9 @@ main(int argc, char *argv[]) options |= F_INTERVAL; break; + case 'j': + options |= F_SO_JUMBO; + break; case 'L': moptions |= MULTICAST_NOLOOP; loop = 0; @@ -380,6 +385,9 @@ main(int argc, char *argv[]) if (options & F_SO_DONTROUTE) (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&hold, sizeof(hold)); + if (options & F_SO_JUMBO) + (void)setsockopt(s, SOL_SOCKET, SO_JUMBO, (char *)&hold, + sizeof(hold)); if (options & F_TTL) { if (IN_MULTICAST(ntohl(to->sin_addr.s_addr))) @@ -1336,7 +1344,7 @@ void usage(void) { (void)fprintf(stderr, - "usage: ping [-DdfLnqRrv] [-c count] [-I ifaddr] [-i wait]\n" + "usage: ping [-DdfjLnqRrv] [-c count] [-I ifaddr] [-i wait]\n" "\t[-l preload] [-p pattern] [-s packetsize] [-T tos] [-t ttl]\n" "\t[-w maxwait] host\n"); exit(1); diff --git a/sbin/route/keywords.h b/sbin/route/keywords.h index 5f065485cba..3c80f2693f8 100644 --- a/sbin/route/keywords.h +++ b/sbin/route/keywords.h @@ -1,10 +1,10 @@ -/* $OpenBSD: keywords.h,v 1.17 2005/03/30 08:04:16 henning Exp $ */ +/* $OpenBSD: keywords.h,v 1.18 2005/05/27 04:55:27 mcbride Exp $ */ /* WARNING! This file was generated by keywords.sh */ struct keytab { - char *kt_cp; - int kt_i; + char *kt_cp; + int kt_i; }; enum { @@ -29,6 +29,7 @@ enum { K_INET, K_INET6, K_IPX, + K_JUMBO, K_LABEL, K_LINK, K_LLINFO, @@ -39,6 +40,7 @@ enum { K_MTU, K_NET, K_NETMASK, + K_NOJUMBO, K_NOSTATIC, K_PREFIXLEN, K_PROTO1, @@ -76,6 +78,7 @@ struct keytab keywords[] = { { "inet", K_INET }, { "inet6", K_INET6 }, { "ipx", K_IPX }, + { "jumbo", K_JUMBO }, { "label", K_LABEL }, { "link", K_LINK }, { "llinfo", K_LLINFO }, @@ -86,6 +89,7 @@ struct keytab keywords[] = { { "mtu", K_MTU }, { "net", K_NET }, { "netmask", K_NETMASK }, + { "nojumbo", K_NOJUMBO }, { "nostatic", K_NOSTATIC }, { "prefixlen", K_PREFIXLEN }, { "proto1", K_PROTO1 }, diff --git a/sbin/route/keywords.sh b/sbin/route/keywords.sh index 348940ee660..e0544f9ce55 100644 --- a/sbin/route/keywords.sh +++ b/sbin/route/keywords.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: keywords.sh,v 1.16 2005/03/30 08:02:34 deraadt Exp $ +# $OpenBSD: keywords.sh,v 1.17 2005/05/27 04:55:27 mcbride Exp $ # $NetBSD: keywords.sh,v 1.2 1996/11/15 18:57:21 gwr Exp $ # @(#)keywords 8.2 (Berkeley) 3/19/94 # @@ -29,6 +29,7 @@ ifp inet inet6 ipx +jumbo label link llinfo @@ -39,6 +40,7 @@ mpath mtu net netmask +nojumbo nostatic prefixlen proto1 diff --git a/sbin/route/route.c b/sbin/route/route.c index 8eb3c9b9116..e190f028a77 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.87 2005/03/30 07:59:03 henning Exp $ */ +/* $OpenBSD: route.c,v 1.88 2005/05/27 04:55:27 mcbride Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -96,7 +96,7 @@ void bprintf(FILE *, int, char *); void mask_addr(union sockunion *, union sockunion *, int); int inet6_makenetandmask(struct sockaddr_in6 *); int getaddr(int, char *, struct hostent **); -int rtmsg(int, int); +int rtmsg(int, int, int); __dead void usage(char *); void set_metric(char *, int); void inet_makenetandmask(u_int32_t, struct sockaddr_in *, int); @@ -348,7 +348,7 @@ int newroute(int argc, char **argv) { char *cmd, *dest = "", *gateway = "", *error; - int ishost = 0, ret = 0, attempts, oerrno, flags = RTF_STATIC; + int ishost = 0, ret = 0, attempts, oerrno, flags = RTF_STATIC, use = 0; int key; struct hostent *hp = NULL; @@ -468,6 +468,14 @@ newroute(int argc, char **argv) case K_MPATH: flags |= RTF_MPATH; break; + case K_JUMBO: + flags |= RTF_JUMBO; + use |= RTF_JUMBO; + break; + case K_NOJUMBO: + flags &= ~RTF_JUMBO; + use |= RTF_JUMBO; + break; case K_MTU: case K_HOPCOUNT: case K_EXPIRE: @@ -528,7 +536,7 @@ newroute(int argc, char **argv) flags |= RTF_GATEWAY; for (attempts = 1; ; attempts++) { errno = 0; - if ((ret = rtmsg(*cmd, flags)) == 0) + if ((ret = rtmsg(*cmd, flags, use)) == 0) break; if (errno != ENETUNREACH && errno != ESRCH) break; @@ -938,7 +946,7 @@ struct { } m_rtmsg; int -rtmsg(int cmd, int flags) +rtmsg(int cmd, int flags, int use) { static int seq; char *cp = m_rtmsg.m_space; @@ -971,6 +979,7 @@ rtmsg(int cmd, int flags) #define rtm m_rtmsg.m_rtm rtm.rtm_type = cmd; rtm.rtm_flags = flags; + rtm.rtm_use = use; rtm.rtm_version = RTM_VERSION; rtm.rtm_seq = ++seq; rtm.rtm_addrs = rtm_addrs; diff --git a/sbin/route/show.c b/sbin/route/show.c index d82943384aa..a215921b540 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.42 2005/03/30 05:40:55 henning Exp $ */ +/* $OpenBSD: show.c,v 1.43 2005/05/27 04:55:27 mcbride Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -93,6 +93,7 @@ static const struct bits bits[] = { { RTF_PROTO2, '2' }, { RTF_PROTO3, '3' }, { RTF_CLONED, 'c' }, + { RTF_JUMBO, 'J' }, { 0 } }; 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. diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index 36d133a2bb4..d39cc0f9bf0 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.79 2005/05/24 20:13:28 avsm Exp $ */ +/* $OpenBSD: netcat.c,v 1.80 2005/05/27 04:55:28 mcbride Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -63,6 +63,7 @@ /* Command Line Options */ int dflag; /* detached, no stdin */ int iflag; /* Interval Flag */ +int jflag; /* use jumbo frames if we can */ int kflag; /* More than one connect */ int lflag; /* Bind to local port */ int nflag; /* Don't do name look up */ @@ -115,7 +116,8 @@ main(int argc, char *argv[]) endp = NULL; sv = NULL; - while ((ch = getopt(argc, argv, "46Ddhi:klnp:rSs:tUuvw:X:x:z")) != -1) { + while ((ch = getopt(argc, argv, + "46Ddhi:jklnp:rSs:tUuvw:X:x:z")) != -1) { switch (ch) { case '4': family = AF_INET; @@ -147,6 +149,9 @@ main(int argc, char *argv[]) if (iflag < 0 || *endp != '\0') errx(1, "interval cannot be negative"); break; + case 'j': + jflag = 1; + break; case 'k': kflag = 1; break; @@ -286,12 +291,13 @@ main(int argc, char *argv[]) * functions to talk to the caller. */ if (uflag) { - int rv; - char buf[1024]; + int rv, plen; + char buf[8192]; struct sockaddr_storage z; len = sizeof(z); - rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK, + plen = jflag ? 8192 : 1024; + rv = recvfrom(s, buf, plen, MSG_PEEK, (struct sockaddr *)&z, &len); if (rv < 0) err(1, "recvfrom"); @@ -501,6 +507,11 @@ remote_connect(const char *host, const char *port, struct addrinfo hints) &x, sizeof(x)) == -1) err(1, NULL); } + if (jflag) { + if (setsockopt(s, SOL_SOCKET, SO_JUMBO, + &x, sizeof(x)) == -1) + err(1, NULL); + } if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0) break; @@ -589,9 +600,12 @@ void readwrite(int nfd) { struct pollfd pfd[2]; - unsigned char buf[BUFSIZ]; + unsigned char buf[8192]; int n, wfd = fileno(stdin); int lfd = fileno(stdout); + int plen; + + plen = jflag ? 8192 : 1024; /* Setup Network FD */ pfd[0].fd = nfd; @@ -614,7 +628,7 @@ readwrite(int nfd) return; if (pfd[0].revents & POLLIN) { - if ((n = read(nfd, buf, sizeof(buf))) < 0) + if ((n = read(nfd, buf, plen)) < 0) return; else if (n == 0) { shutdown(nfd, SHUT_RD); @@ -629,7 +643,7 @@ readwrite(int nfd) } if (!dflag && pfd[1].revents & POLLIN) { - if ((n = read(wfd, buf, sizeof(buf))) < 0) + if ((n = read(wfd, buf, plen)) < 0) return; else if (n == 0) { shutdown(nfd, SHUT_WR); |