From owner-svn-src-projects@FreeBSD.ORG Sat Nov 8 07:26:46 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 995212F2; Sat, 8 Nov 2014 07:26:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 81F76C4B; Sat, 8 Nov 2014 07:26:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA87QkoJ047351; Sat, 8 Nov 2014 07:26:46 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA87QeFR047299; Sat, 8 Nov 2014 07:26:40 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201411080726.sA87QeFR047299@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Sat, 8 Nov 2014 07:26:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r274275 - in projects/ifnet: . bin/sh sbin/ifconfig share/man/man4 sys/cam/ctl sys/conf sys/dev/hyperv/netvsc sys/dev/ofw sys/dev/random sys/modules sys/modules/if_gre sys/modules/if_me... X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Nov 2014 07:26:46 -0000 Author: glebius Date: Sat Nov 8 07:26:39 2014 New Revision: 274275 URL: https://svnweb.freebsd.org/changeset/base/274275 Log: Merge head r256150 through r274274. Added: projects/ifnet/share/man/man4/me.4 - copied unchanged from r274274, head/share/man/man4/me.4 projects/ifnet/sys/modules/if_me/ - copied from r274274, head/sys/modules/if_me/ projects/ifnet/sys/net/if_me.c - copied unchanged from r274274, head/sys/net/if_me.c projects/ifnet/sys/netinet6/ip6_gre.c - copied unchanged from r274274, head/sys/netinet6/ip6_gre.c Deleted: projects/ifnet/sys/netinet/ip_gre.h Modified: projects/ifnet/Makefile.inc1 projects/ifnet/bin/sh/sh.1 projects/ifnet/sbin/ifconfig/ifgre.c projects/ifnet/share/man/man4/Makefile projects/ifnet/share/man/man4/gre.4 projects/ifnet/sys/cam/ctl/ctl_backend_block.c projects/ifnet/sys/conf/NOTES projects/ifnet/sys/conf/files projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.c projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.h projects/ifnet/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c projects/ifnet/sys/dev/ofw/ofwbus.c projects/ifnet/sys/dev/random/ivy.c projects/ifnet/sys/dev/random/nehemiah.c projects/ifnet/sys/dev/random/randomdev.c projects/ifnet/sys/dev/random/randomdev_soft.c projects/ifnet/sys/modules/Makefile projects/ifnet/sys/modules/if_gre/Makefile projects/ifnet/sys/modules/random/Makefile projects/ifnet/sys/net/if.c projects/ifnet/sys/net/if_arp.h projects/ifnet/sys/net/if_bridge.c projects/ifnet/sys/net/if_ethersubr.c projects/ifnet/sys/net/if_fddisubr.c projects/ifnet/sys/net/if_gre.c projects/ifnet/sys/net/if_gre.h projects/ifnet/sys/net/if_iso88025subr.c projects/ifnet/sys/netgraph/ng_ether.c projects/ifnet/sys/netinet/ip_gre.c projects/ifnet/sys/netinet6/in6_proto.c projects/ifnet/sys/netipsec/ipsec_input.c projects/ifnet/sys/sys/conf.h projects/ifnet/tests/sys/netinet/Makefile projects/ifnet/usr.sbin/ctld/ctld.c Directory Properties: projects/ifnet/ (props changed) projects/ifnet/sbin/ (props changed) projects/ifnet/share/ (props changed) projects/ifnet/share/man/man4/ (props changed) projects/ifnet/sys/ (props changed) projects/ifnet/sys/conf/ (props changed) projects/ifnet/sys/dev/hyperv/ (props changed) Modified: projects/ifnet/Makefile.inc1 ============================================================================== --- projects/ifnet/Makefile.inc1 Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/Makefile.inc1 Sat Nov 8 07:26:39 2014 (r274275) @@ -1671,7 +1671,7 @@ _lib_libypclnt= lib/libypclnt lib/libradius__L: lib/libmd__L .endif -gnu/lib/libdialog__L: lib/ncurses/ncursesw__L +gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L .for _lib in ${_prereq_libs} ${_lib}__PL: .PHONY .MAKE Modified: projects/ifnet/bin/sh/sh.1 ============================================================================== --- projects/ifnet/bin/sh/sh.1 Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/bin/sh/sh.1 Sat Nov 8 07:26:39 2014 (r274275) @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd September 21, 2014 +.Dd November 7, 2014 .Dt SH 1 .Os .Sh NAME @@ -2522,7 +2522,8 @@ and so on, decreasing the value of .Li $# by one. -If there are zero positional parameters, shifting does not do anything. +For portability, shifting if there are zero positional parameters +should be avoided, since the shell may abort. .It Ic test A built-in equivalent of .Xr test 1 . Modified: projects/ifnet/sbin/ifconfig/ifgre.c ============================================================================== --- projects/ifnet/sbin/ifconfig/ifgre.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sbin/ifconfig/ifgre.c Sat Nov 8 07:26:39 2014 (r274275) @@ -23,52 +23,50 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef lint -static const char rcsid[] = - "$FreeBSD$"; -#endif +#include +__FBSDID("$FreeBSD$"); #include #include #include #include - -#include -#include - -#include #include #include -#include #include +#include #include -#include #include -#include +#include #include -#include #include "ifconfig.h" +#define GREBITS "\020\01ENABLE_CSUM\02ENABLE_SEQ" + static void gre_status(int s); static void gre_status(int s) { - int grekey = 0; + uint32_t opts = 0; - ifr.ifr_data = (caddr_t)&grekey; + ifr.ifr_data = (caddr_t)&opts; if (ioctl(s, GREGKEY, &ifr) == 0) - if (grekey != 0) - printf("\tgrekey: %d\n", grekey); + if (opts != 0) + printf("\tgrekey: 0x%x (%u)\n", opts, opts); + opts = 0; + if (ioctl(s, GREGOPTS, &ifr) != 0 || opts == 0) + return; + printb("\toptions", opts, GREBITS); + putchar('\n'); } static void setifgrekey(const char *val, int dummy __unused, int s, const struct afswtch *afp) { - uint32_t grekey = atol(val); + uint32_t grekey = strtol(val, NULL, 0); strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_data = (caddr_t)&grekey; @@ -76,8 +74,35 @@ setifgrekey(const char *val, int dummy _ warn("ioctl (set grekey)"); } +static void +setifgreopts(const char *val, int d, int s, const struct afswtch *afp) +{ + uint32_t opts; + + ifr.ifr_data = (caddr_t)&opts; + if (ioctl(s, GREGOPTS, &ifr) == -1) { + warn("ioctl(GREGOPTS)"); + return; + } + + if (d < 0) + opts &= ~(-d); + else + opts |= d; + + if (ioctl(s, GRESOPTS, &ifr) == -1) { + warn("ioctl(GIFSOPTS)"); + return; + } +} + + static struct cmd gre_cmds[] = { DEF_CMD_ARG("grekey", setifgrekey), + DEF_CMD("enable_csum", GRE_ENABLE_CSUM, setifgreopts), + DEF_CMD("-enable_csum",-GRE_ENABLE_CSUM,setifgreopts), + DEF_CMD("enable_seq", GRE_ENABLE_SEQ, setifgreopts), + DEF_CMD("-enable_seq",-GRE_ENABLE_SEQ, setifgreopts), }; static struct afswtch af_gre = { .af_name = "af_gre", Modified: projects/ifnet/share/man/man4/Makefile ============================================================================== --- projects/ifnet/share/man/man4/Makefile Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/share/man/man4/Makefile Sat Nov 8 07:26:39 2014 (r274275) @@ -252,6 +252,7 @@ MAN= aac.4 \ malo.4 \ mcd.4 \ md.4 \ + me.4 \ mem.4 \ meteor.4 \ mfi.4 \ Modified: projects/ifnet/share/man/man4/gre.4 ============================================================================== --- projects/ifnet/share/man/man4/gre.4 Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/share/man/man4/gre.4 Sat Nov 8 07:26:39 2014 (r274275) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 20, 2008 +.Dd November 7, 2014 .Dt GRE 4 .Os .Sh NAME @@ -68,162 +68,30 @@ and .Cm destroy subcommands. .Pp -This driver currently supports the following modes of operation: -.Bl -tag -width indent -.It "GRE encapsulation (IP protocol number 47)" -Encapsulated datagrams are -prepended an outer datagram and a GRE header. +This driver corresponds to RFC 2784. +Encapsulated datagrams are prepended an outer datagram and a GRE header. The GRE header specifies the type of the encapsulated datagram and thus allows for tunneling other protocols than IP. GRE mode is also the default tunnel mode on Cisco routers. -This is also the default mode of operation of the -.Nm -interfaces. -As part of the GRE mode, .Nm also supports Cisco WCCP protocol, both version 1 and version 2. -Since there is no reliable way to distinguish between WCCP versions, it -should be configured manually using the -.Cm link2 -flag. -If the -.Cm link2 -flag is not set (default), then WCCP version 1 is selected. -.It "MOBILE encapsulation (IP protocol number 55)" -Datagrams are -encapsulated into IP, but with a shorter encapsulation. -The original -IP header is modified and the modifications are inserted between the -so modified header and the original payload. -Like -.Xr gif 4 , -only for IP-in-IP encapsulation. -.El .Pp The .Nm -interfaces support a number of -.Xr ioctl 2 Ns s , -such as: -.Bl -tag -width ".Dv GRESADDRS" -.It Dv GRESADDRS -Set the IP address of the local tunnel end. -This is the source address -set by or displayed by -.Xr ifconfig 8 -for the -.Nm -interface. -.It Dv GRESADDRD -Set the IP address of the remote tunnel end. -This is the destination address -set by or displayed by -.Xr ifconfig 8 -for the -.Nm -interface. -.It Dv GREGADDRS -Query the IP address that is set for the local tunnel end. -This is the -address the encapsulation header carries as local address (i.e., the real -address of the tunnel start point). -.It Dv GREGADDRD -Query the IP address that is set for the remote tunnel end. -This is the -address the encapsulated packets are sent to (i.e., the real address of -the remote tunnel endpoint). -.It Dv GRESPROTO -Set the operation mode to the specified IP protocol value. -The -protocol is passed to the interface in -.Po Vt "struct ifreq" Pc Ns Li -> Ns Va ifr_flags . -The operation mode can also be given as -.Pp -.Bl -tag -width ".Cm -link0" -compact -.It Cm link0 -.Dv IPPROTO_GRE -.It Cm -link0 -.Dv IPPROTO_MOBILE -.El -.Pp -to -.Xr ifconfig 8 . -.Pp -The -.Cm link1 -flag is not used to choose encapsulation, but to modify the -internal route search for the remote tunnel endpoint, see the -.Sx BUGS -section below. -.It Dv GREGPROTO -Query operation mode. -.It Dv GRESKEY +interfaces support a number of additional parameters to the +.Xr ifconfig 8 : +.Bl -tag -width "enable_csum" +.It Ar grekey Set the GRE key used for outgoing packets. A value of 0 disables the key option. -.It Dv GREGKEY -Get the GRE key currently used for outgoing packets. -0 means no outgoing key. +.It Ar enable_csum +Enables checksum calculation for outgoing packets. +.It Ar enable_seq +Enables use of sequence number field in the GRE header for outgoing packets. .El -.Pp -Note that the IP addresses of the tunnel endpoints may be the same as the -ones defined with -.Xr ifconfig 8 -for the interface (as if IP is encapsulated), but need not be. .Sh EXAMPLES -Configuration example: -.Bd -literal -Host X-- Host A ----------------tunnel---------- Cisco D------Host E - \\ | - \\ / - +------Host B----------Host C----------+ -.Ed .Pp -On host A -.Pq Fx : -.Bd -literal -offset indent -route add default B -ifconfig greN create -ifconfig greN A D netmask 0xffffffff linkX up -ifconfig greN tunnel A D -route add E D -.Ed -.Pp -On Host D (Cisco): -.Bd -literal -offset indent -Interface TunnelX - ip unnumbered D ! e.g. address from Ethernet interface - tunnel source D ! e.g. address from Ethernet interface - tunnel destination A -ip route C -ip route A mask C -ip route X mask tunnelX -.Ed -.Pp -OR -.Pp -On Host D -.Pq Fx : -.Bd -literal -offset indent -route add default C -ifconfig greN create -ifconfig greN D A -ifconfig greN tunnel D A -.Ed -.Pp -If all goes well, you should see packets flowing ;-) -.Pp -If you want to reach Host A over the tunnel (from Host D (Cisco)), then -you have to have an alias on Host A for e.g.\& the Ethernet interface like: -.Pp -.Dl "ifconfig alias Y" -.Pp -and on the Cisco: -.Pp -.Dl "ip route Y mask tunnelX" -.Pp -A similar setup can be used to create a link between two private networks -(for example in the 192.168 subnet) over the Internet: .Bd -literal 192.168.1.* --- Router A -------tunnel-------- Router B --- 192.168.2.* \\ / @@ -238,29 +106,22 @@ Assuming router A has the (external) IP On router A: .Bd -literal -offset indent ifconfig greN create -ifconfig greN 192.168.1.1 192.168.2.1 link1 -ifconfig greN tunnel A B +ifconfig greN inet 192.168.1.1 192.168.2.1 +ifconfig greN inet tunnel A B route add -net 192.168.2 -netmask 255.255.255.0 192.168.2.1 .Ed .Pp On router B: .Bd -literal -offset indent ifconfig greN create -ifconfig greN 192.168.2.1 192.168.1.1 link1 -ifconfig greN tunnel B A +ifconfig greN inet 192.168.2.1 192.168.1.1 +ifconfig greN inet tunnel B A route add -net 192.168.1 -netmask 255.255.255.0 192.168.1.1 .Ed -.Pp -Note that this is a safe situation where the -.Cm link1 -flag (as discussed in the -.Sx BUGS -section below) may (and probably should) be set. .Sh NOTES The MTU of .Nm interfaces is set to 1476 by default, to match the value used by Cisco routers. -If grekey is set this is lowered to 1472. This may not be an optimal value, depending on the link between the two tunnel endpoints. It can be adjusted via @@ -268,25 +129,8 @@ It can be adjusted via .Pp For correct operation, the .Nm -device needs a route to the destination that is less specific than the -one over the tunnel. -(Basically, there needs to be a route to the decapsulating host that -does not run over the tunnel, as this would be a loop.) -If the addresses are ambiguous, doing the -.Nm ifconfig Cm tunnel -step before the -.Xr ifconfig 8 -call to set the -.Nm -IP addresses will help to find a route outside the tunnel. -.Pp -In order to tell -.Xr ifconfig 8 -to actually mark the interface as -.Dq up , -the keyword -.Cm up -must be given last on its command line. +device needs a route to the decapsulating host that does not run over the tunnel, +as this would be a loop. .Pp The kernel must be set to forward datagrams by setting the .Va net.inet.ip.forwarding @@ -296,41 +140,20 @@ variable to non-zero. .Xr gif 4 , .Xr inet 4 , .Xr ip 4 , +.Xr me 4 , .Xr netintro 4 , -.\" Xr options 4 , .Xr protocols 5 , .Xr ifconfig 8 , .Xr sysctl 8 .Pp -A description of GRE encapsulation can be found in RFC 1701 and RFC 1702. -.Pp -A description of MOBILE encapsulation can be found in RFC 2004. +A description of GRE encapsulation can be found in RFC 2784 and RFC 2890. .Sh AUTHORS +.An Andrey V. Elsukov Aq Mt ae@FreeBSD.org .An Heiko W.Rupp Aq Mt hwr@pilhuhn.de .Sh BUGS -The -.Fn compute_route -code in -.Pa if_gre.c -toggles the last bit of the -IP-address to provoke the search for a less specific route than the -one directly over the tunnel to prevent loops. -This is possibly not the best solution. -.Pp -To avoid the address munging described above, turn on the -.Cm link1 -flag on the -.Xr ifconfig 8 -command line. -This implies that the GRE packet destination and the ifconfig remote host -are not the same IP addresses, and that the GRE destination does not route -over the -.Nm -interface itself. .Pp The current implementation uses the key only for outgoing packets. Incoming packets with a different key or without a key will be treated as if they would belong to this interface. .Pp -RFC1701 is not fully supported, however all unsupported features have been -deprecated in RFC2784. +The sequence number field also used only for outgoing packets. Copied: projects/ifnet/share/man/man4/me.4 (from r274274, head/share/man/man4/me.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/ifnet/share/man/man4/me.4 Sat Nov 8 07:26:39 2014 (r274275, copy of r274274, head/share/man/man4/me.4) @@ -0,0 +1,85 @@ +.\" Copyright (c) Andrey V. Elsukov +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 7, 2014 +.Dt ME 4 +.Os +.Sh NAME +.Nm me +.Nd encapsulating network device +.Sh SYNOPSIS +To compile the +driver into the kernel, place the following line in the kernel +configuration file: +.Bd -ragged -offset indent +.Cd "device me" +.Ed +.Pp +Alternatively, to load the +driver as a module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_me_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +network interface pseudo device encapsulates datagrams +into IP. +These encapsulated datagrams are routed to a destination host, +where they are decapsulated and further routed to their final destination. +.Pp +.Nm +interfaces are dynamically created and destroyed with the +.Xr ifconfig 8 +.Cm create +and +.Cm destroy +subcommands. +.Pp +This driver corresponds to RFC 2004. +Datagrams are encapsulated into IP with a shorter encapsulation. +The original +IP header is modified and the modifications are inserted between the +so modified header and the original payload. +The protocol number 55 is used for outer header. +.Sh NOTES +.Pp +For correct operation, the +.Nm +device needs a route to the decapsulating host that does not run over the tunnel, +as this would be a loop. +.Sh SEE ALSO +.Xr gif 4 , +.Xr gre 4 , +.Xr inet 4 , +.Xr ip 4 , +.Xr netintro 4 , +.Xr protocols 5 , +.Xr ifconfig 8 , +.Xr sysctl 8 +.Sh AUTHORS +.An Andrey V. Elsukov Aq Mt ae@FreeBSD.org Modified: projects/ifnet/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- projects/ifnet/sys/cam/ctl/ctl_backend_block.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/cam/ctl/ctl_backend_block.c Sat Nov 8 07:26:39 2014 (r274275) @@ -2392,7 +2392,7 @@ ctl_be_block_modify(struct ctl_be_block_ be_lun->params.lun_size_bytes = params->lun_size_bytes; - oldsize = be_lun->size_blocks; + oldsize = be_lun->size_bytes; if (be_lun->vn == NULL) error = ctl_be_block_open(softc, be_lun, req); else if (be_lun->vn->v_type == VREG) @@ -2400,7 +2400,7 @@ ctl_be_block_modify(struct ctl_be_block_ else error = ctl_be_block_modify_dev(be_lun, req); - if (error == 0 && be_lun->size_blocks != oldsize) { + if (error == 0 && be_lun->size_bytes != oldsize) { be_lun->size_blocks = be_lun->size_bytes >> be_lun->blocksize_shift; Modified: projects/ifnet/sys/conf/NOTES ============================================================================== --- projects/ifnet/sys/conf/NOTES Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/conf/NOTES Sat Nov 8 07:26:39 2014 (r274275) @@ -879,12 +879,15 @@ device tun # The `gif' device implements IPv6 over IP4 tunneling, # IPv4 over IPv6 tunneling, IPv4 over IPv4 tunneling and # IPv6 over IPv6 tunneling. -# The `gre' device implements two types of IP4 over IP4 tunneling: -# GRE and MOBILE, as specified in the RFC1701 and RFC2004. +# The `gre' device implements GRE (Generic Routing Encapsulation) tunneling, +# as specified in the RFC 2784 and RFC 2890. +# The `me' device implements Minimal Encapsulation within IPv4 as +# specified in the RFC 2004. # The XBONEHACK option allows the same pair of addresses to be configured on # multiple gif interfaces. device gif device gre +device me options XBONEHACK # The `faith' device captures packets sent to it and diverts them Modified: projects/ifnet/sys/conf/files ============================================================================== --- projects/ifnet/sys/conf/files Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/conf/files Sat Nov 8 07:26:39 2014 (r274275) @@ -3234,11 +3234,12 @@ net/if_fddisubr.c optional fddi net/if_fwsubr.c optional fwip net/if_gif.c optional gif inet | gif inet6 | \ netgraph_gif inet | netgraph_gif inet6 -net/if_gre.c optional gre inet +net/if_gre.c optional gre inet | gre inet6 net/if_iso88025subr.c optional token net/if_lagg.c optional lagg net/if_loop.c optional loop net/if_llatbl.c standard +net/if_me.c optional me inet net/if_media.c standard net/if_mib.c standard net/if_spppfr.c optional sppp | netgraph_sppp @@ -3473,6 +3474,7 @@ netinet6/in6_proto.c optional inet6 netinet6/in6_rmx.c optional inet6 netinet6/in6_src.c optional inet6 netinet6/ip6_forward.c optional inet6 +netinet6/ip6_gre.c optional gre inet6 netinet6/ip6_id.c optional inet6 netinet6/ip6_input.c optional inet6 netinet6/ip6_mroute.c optional mrouting inet6 Modified: projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.c Sat Nov 8 07:26:39 2014 (r274275) @@ -529,7 +529,7 @@ hv_nv_connect_to_vsp(struct hv_device *d int ret = 0; device_t dev = device->device; hn_softc_t *sc = device_get_softc(dev); - struct ifnet *ifp = sc->arpcom.ac_ifp; + struct ifnet *ifp = sc->hn_ifp; net_dev = hv_nv_get_outbound_net_device(device); if (!net_dev) { Modified: projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.h Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/hyperv/netvsc/hv_net_vsc.h Sat Nov 8 07:26:39 2014 (r274275) @@ -965,7 +965,6 @@ typedef struct { */ typedef struct hn_softc { struct ifnet *hn_ifp; - struct arpcom arpcom; device_t hn_dev; uint8_t hn_unit; int hn_carrier; Modified: projects/ifnet/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- projects/ifnet/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Sat Nov 8 07:26:39 2014 (r274275) @@ -255,7 +255,7 @@ netvsc_attach(device_t dev) sc->hn_dev_obj = device_ctx; - ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER); + ifp = sc->hn_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -634,8 +634,6 @@ netvsc_recv(struct hv_device *device_ctx } ifp = sc->hn_ifp; - - ifp = sc->arpcom.ac_ifp; if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { return (0); Modified: projects/ifnet/sys/dev/ofw/ofwbus.c ============================================================================== --- projects/ifnet/sys/dev/ofw/ofwbus.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/ofw/ofwbus.c Sat Nov 8 07:26:39 2014 (r274275) @@ -399,11 +399,17 @@ ofwbus_adjust_resource(device_t bus, dev } static int -ofwbus_release_resource(device_t bus __unused, device_t child, int type, +ofwbus_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + struct resource_list_entry *rle; int error; + /* Clean resource list entry */ + rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), type, rid); + if (rle != NULL) + rle->res = NULL; + if ((rman_get_flags(r) & RF_ACTIVE) != 0) { error = bus_deactivate_resource(child, type, rid, r); if (error) Modified: projects/ifnet/sys/dev/random/ivy.c ============================================================================== --- projects/ifnet/sys/dev/random/ivy.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/random/ivy.c Sat Nov 8 07:26:39 2014 (r274275) @@ -61,42 +61,41 @@ static struct live_entropy_source random }; static inline int -ivy_rng_store(long *buf) +ivy_rng_store(u_long *buf) { #ifdef __GNUCLIKE_ASM - long tmp; + u_long rndval; int retry; retry = RETRY_COUNT; __asm __volatile( "1:\n\t" - "rdrand %2\n\t" /* read randomness into tmp */ - "jb 2f\n\t" /* CF is set on success, exit retry loop */ + "rdrand %1\n\t" /* read randomness into tmp */ + "jc 2f\n\t" /* CF is set on success, exit retry loop */ "dec %0\n\t" /* otherwise, retry-- */ "jne 1b\n\t" /* and loop if retries are not exhausted */ - "jmp 3f\n" /* failure, retry is 0, used as return value */ - "2:\n\t" - "mov %2,%1\n\t" /* *buf = tmp */ - "3:" - : "+q" (retry), "=m" (*buf), "+q" (tmp) : : "cc"); + "2:" + : "+r" (retry), "=r" (rndval) : : "cc"); + *buf = rndval; return (retry); #else /* __GNUCLIKE_ASM */ return (0); #endif } -/* It is specifically allowed that buf is a multiple of sizeof(long) */ +/* It is required that buf length is a multiple of sizeof(u_long). */ static u_int random_ivy_read(void *buf, u_int c) { - long *b; + u_long *b, rndval; u_int count; KASSERT(c % sizeof(*b) == 0, ("partial read %d", c)); b = buf; for (count = c; count > 0; count -= sizeof(*b)) { - if (ivy_rng_store(b++) == 0) + if (ivy_rng_store(&rndval) == 0) break; + *b++ = rndval; } return (c - count); } @@ -133,4 +132,4 @@ rdrand_modevent(module_t mod, int type, DEV_MODULE(rdrand, rdrand_modevent, NULL); MODULE_VERSION(rdrand, 1); -MODULE_DEPEND(rdrand, random_adaptors, 1, 1, 1); +MODULE_DEPEND(rdrand, randomdev, 1, 1, 1); Modified: projects/ifnet/sys/dev/random/nehemiah.c ============================================================================== --- projects/ifnet/sys/dev/random/nehemiah.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/random/nehemiah.c Sat Nov 8 07:26:39 2014 (r274275) @@ -157,4 +157,4 @@ nehemiah_modevent(module_t mod, int type DEV_MODULE(nehemiah, nehemiah_modevent, NULL); MODULE_VERSION(nehemiah, 1); -MODULE_DEPEND(nehemiah, random_adaptors, 1, 1, 1); +MODULE_DEPEND(nehemiah, randomdev, 1, 1, 1); Modified: projects/ifnet/sys/dev/random/randomdev.c ============================================================================== --- projects/ifnet/sys/dev/random/randomdev.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/random/randomdev.c Sat Nov 8 07:26:39 2014 (r274275) @@ -159,15 +159,7 @@ randomdev_modevent(module_t mod __unused return (error); } -#define EARLY_2_DEV_MODULE(name, evh, arg) \ -static moduledata_t name##_mod = { \ - #name, \ - evh, \ - arg \ -}; \ -DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND) - -EARLY_2_DEV_MODULE(randomdev, randomdev_modevent, NULL); +DEV_MODULE_ORDERED(randomdev, randomdev_modevent, NULL, SI_ORDER_SECOND); MODULE_VERSION(randomdev, 1); /* ================ Modified: projects/ifnet/sys/dev/random/randomdev_soft.c ============================================================================== --- projects/ifnet/sys/dev/random/randomdev_soft.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/dev/random/randomdev_soft.c Sat Nov 8 07:26:39 2014 (r274275) @@ -153,21 +153,13 @@ randomdev_soft_modevent(module_t mod __u return (error); } -#define MID_DEV_MODULE(name, evh, arg) \ -static moduledata_t name##_mod = { \ - #name, \ - evh, \ - arg \ -}; \ -DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE) - #if defined(RANDOM_YARROW) -MID_DEV_MODULE(yarrow, randomdev_soft_modevent, NULL); +DEV_MODULE(yarrow, randomdev_soft_modevent, NULL); MODULE_VERSION(yarrow, 1); -MODULE_DEPEND(yarrow, random_adaptors, 1, 1, 1); +MODULE_DEPEND(yarrow, randomdev, 1, 1, 1); #endif #if defined(RANDOM_FORTUNA) -MID_DEV_MODULE(fortuna, randomdev_soft_modevent, NULL); +DEV_MODULE(fortuna, randomdev_soft_modevent, NULL); MODULE_VERSION(fortuna, 1); -MODULE_DEPEND(fortuna, random_adaptors, 1, 1, 1); +MODULE_DEPEND(fortuna, randomdev, 1, 1, 1); #endif Modified: projects/ifnet/sys/modules/Makefile ============================================================================== --- projects/ifnet/sys/modules/Makefile Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/modules/Makefile Sat Nov 8 07:26:39 2014 (r274275) @@ -146,8 +146,9 @@ SUBDIR= \ if_edsc \ if_epair \ if_faith \ - if_gif \ + ${_if_gif} \ ${_if_gre} \ + ${_if_me} \ if_lagg \ ${_if_ndis} \ if_stf \ @@ -403,10 +404,12 @@ _random= random defined(ALL_MODULES) _carp= carp _toecore= toecore +_if_gif= if_gif +_if_gre= if_gre .endif .if ${MK_INET_SUPPORT} != "no" || defined(ALL_MODULES) -_if_gre= if_gre +_if_me= if_me _ipdivert= ipdivert _ipfw= ipfw .endif Modified: projects/ifnet/sys/modules/if_gre/Makefile ============================================================================== --- projects/ifnet/sys/modules/if_gre/Makefile Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/modules/if_gre/Makefile Sat Nov 8 07:26:39 2014 (r274275) @@ -1,8 +1,17 @@ # $FreeBSD$ .PATH: ${.CURDIR}/../../net ${.CURDIR}/../../netinet ${.CURDIR}/../../netinet6 +.include "${.CURDIR}/../../conf/kern.opts.mk" KMOD= if_gre -SRCS= if_gre.c ip_gre.c opt_inet.h opt_inet6.h +SRCS= if_gre.c opt_inet.h opt_inet6.h + +.if ${MK_INET_SUPPORT} != "no" +SRCS+= ip_gre.c +.endif + +.if ${MK_INET6_SUPPORT} != "no" +SRCS+= ip6_gre.c +.endif .include Modified: projects/ifnet/sys/modules/random/Makefile ============================================================================== --- projects/ifnet/sys/modules/random/Makefile Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/modules/random/Makefile Sat Nov 8 07:26:39 2014 (r274275) @@ -6,8 +6,7 @@ KMOD= random SRCS= randomdev_soft.c -SRCS+= yarrow.c hash.c -SRCS+= random_harvestq.c live_entropy_sources.c +SRCS+= yarrow.c fortuna.c hash.c SRCS+= rijndael-alg-fst.c rijndael-api-fst.c sha2.c sha256c.c SRCS+= bus_if.h device_if.h vnode_if.h opt_cpu.h opt_random.h Modified: projects/ifnet/sys/net/if.c ============================================================================== --- projects/ifnet/sys/net/if.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/net/if.c Sat Nov 8 07:26:39 2014 (r274275) @@ -265,13 +265,12 @@ ifnet_byindex_ref(u_short idx) * Allocate an ifindex array entry; return 0 on success or an error on * failure. */ -static int -ifindex_alloc_locked(u_short *idxp) +static u_short +ifindex_alloc(void) { u_short idx; IFNET_WLOCK_ASSERT(); - retry: /* * Try to find an empty slot below V_if_index. If we fail, take the @@ -289,8 +288,7 @@ retry: } if (idx > V_if_index) V_if_index = idx; - *idxp = idx; - return (0); + return (idx); } static void @@ -431,11 +429,7 @@ if_alloc(u_char type) ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); IFNET_WLOCK(); - if (ifindex_alloc_locked(&idx) != 0) { - IFNET_WUNLOCK(); - free(ifp, M_IFNET); - return (NULL); - } + idx = ifindex_alloc(); ifnet_setbyindex_locked(idx, IFNET_HOLD); IFNET_WUNLOCK(); ifp->if_index = idx; @@ -1022,7 +1016,6 @@ if_detach_internal(struct ifnet *ifp, in void if_vmove(struct ifnet *ifp, struct vnet *new_vnet) { - u_short idx; /* * Detach from current vnet, but preserve LLADDR info, do not @@ -1054,11 +1047,7 @@ if_vmove(struct ifnet *ifp, struct vnet CURVNET_SET_QUIET(new_vnet); IFNET_WLOCK(); - if (ifindex_alloc_locked(&idx) != 0) { - IFNET_WUNLOCK(); - panic("if_index overflow"); - } - ifp->if_index = idx; + ifp->if_index = ifindex_alloc(); ifnet_setbyindex_locked(ifp->if_index, ifp); IFNET_WUNLOCK(); @@ -2136,7 +2125,7 @@ do_link_state_change(void *arg, int pend (*vlan_link_state_p)(ifp); if ((ifp->if_type == IFT_ETHER || ifp->if_type == IFT_L2VLAN) && - IFP2AC(ifp)->ac_netgraph != NULL) + ifp->if_l2com != NULL) (*ng_ether_link_state_p)(ifp, link_state); if (ifp->if_carp) (*carp_linkstate_p)(ifp); Modified: projects/ifnet/sys/net/if_arp.h ============================================================================== --- projects/ifnet/sys/net/if_arp.h Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/net/if_arp.h Sat Nov 8 07:26:39 2014 (r274275) @@ -97,20 +97,6 @@ struct arpreq { #define ATF_PUBL 0x08 /* publish entry (respond for other host) */ #define ATF_USETRAILERS 0x10 /* has requested trailers */ -#ifdef _KERNEL -/* - * Structure shared between the ethernet driver modules and - * the address resolution code. - */ -struct arpcom { - struct ifnet *ac_ifp; /* network-visible interface */ - void *ac_netgraph; /* ng_ether(4) netgraph node info */ -}; -#define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com)) -#define AC2IFP(ac) ((ac)->ac_ifp) - -#endif /* _KERNEL */ - struct arpstat { /* Normal things that happen: */ uint64_t txrequests; /* # of ARP requests sent by this host. */ Modified: projects/ifnet/sys/net/if_bridge.c ============================================================================== --- projects/ifnet/sys/net/if_bridge.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/net/if_bridge.c Sat Nov 8 07:26:39 2014 (r274275) @@ -111,7 +111,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include /* for struct arpcom */ +#include #include #include #include @@ -125,7 +125,7 @@ __FBSDID("$FreeBSD$"); #include #endif #include -#include /* for struct arpcom */ +#include #include #include #include Modified: projects/ifnet/sys/net/if_ethersubr.c ============================================================================== --- projects/ifnet/sys/net/if_ethersubr.c Sat Nov 8 07:23:01 2014 (r274274) +++ projects/ifnet/sys/net/if_ethersubr.c Sat Nov 8 07:26:39 2014 (r274275) @@ -119,9 +119,6 @@ static int ether_resolvemulti(struct ifn static void ether_reassign(struct ifnet *, struct vnet *, char *); #endif -/* XXX: should be in an arp support file, not here */ -static MALLOC_DEFINE(M_ARPCOM, "arpcom", "802.* interface internals"); - #define ETHER_IS_BROADCAST(addr) \ (bcmp(etherbroadcastaddr, (addr), ETHER_ADDR_LEN) == 0) @@ -330,7 +327,7 @@ ether_output(struct ifnet *ifp, struct m #endif /* Handle ng_ether(4) processing, if any */ - if (IFP2AC(ifp)->ac_netgraph != NULL) { + if (ifp->if_l2com != NULL) { KASSERT(ng_ether_output_p != NULL, ("ng_ether_output_p is NULL")); if ((error = (*ng_ether_output_p)(ifp, &m)) != 0) { @@ -521,7 +518,7 @@ ether_input_internal(struct ifnet *ifp, M_SETFIB(m, ifp->if_fib); /* Allow ng_ether(4) to claim this frame. */ - if (IFP2AC(ifp)->ac_netgraph != NULL) { + if (ifp->if_l2com != NULL) { KASSERT(ng_ether_input_p != NULL, ("%s: ng_ether_input_p is NULL", __func__)); m->m_flags &= ~M_PROMISC; @@ -780,7 +777,7 @@ discard: * hand the packet to it for last chance processing; * otherwise dispose of it. */ - if (IFP2AC(ifp)->ac_netgraph != NULL) { + if (ifp->if_l2com != NULL) { KASSERT(ng_ether_input_orphan_p != NULL, ("ng_ether_input_orphan_p is NULL")); /* @@ -866,7 +863,7 @@ ether_ifdetach(struct ifnet *ifp) sdl = (struct sockaddr_dl *)(ifp->if_addr->ifa_addr); uuid_ether_del(LLADDR(sdl)); - if (IFP2AC(ifp)->ac_netgraph != NULL) { + if (ifp->if_l2com != NULL) { KASSERT(ng_ether_detach_p != NULL, ("ng_ether_detach_p is NULL")); (*ng_ether_detach_p)(ifp); @@ -881,7 +878,7 @@ void ether_reassign(struct ifnet *ifp, struct vnet *new_vnet, char *unused __unused) { - if (IFP2AC(ifp)->ac_netgraph != NULL) { + if (ifp->if_l2com != NULL) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***