svn commit: r365375 - in stable/11: share/man/man4 sys/conf sys/dev/sume sys/modules sys/modules/sume

2020-09-06 Thread Marko Zec
Author: zec
Date: Sun Sep  6 10:23:13 2020
New Revision: 365375
URL: https://svnweb.freebsd.org/changeset/base/365375

Log:
  MFC r364973:
  
  Driver for 4x10Gb Ethernet reference NIC FPGA design for NetFPGA SUME
  development board.
  
  Submitted by: Denis Salopek 
  Reviewed by:  zec, bz (src); rgrimes, bcr (manpages)
  Sponsored by: Google Summer of Code 2020
  Differential Revision: https://reviews.freebsd.org/D26074

Added:
  stable/11/share/man/man4/sume.4
 - copied unchanged from r364973, head/share/man/man4/sume.4
  stable/11/sys/dev/sume/
 - copied from r364973, head/sys/dev/sume/
  stable/11/sys/modules/sume/
 - copied from r364973, head/sys/modules/sume/
Modified:
  stable/11/share/man/man4/Makefile
  stable/11/sys/conf/files.amd64
  stable/11/sys/modules/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man4/Makefile
==
--- stable/11/share/man/man4/Makefile   Sun Sep  6 10:18:59 2020
(r365374)
+++ stable/11/share/man/man4/Makefile   Sun Sep  6 10:23:13 2020
(r365375)
@@ -533,6 +533,7 @@ MAN=aac.4 \
stf.4 \
stg.4 \
stge.4 \
+   ${_sume.4} \
sym.4 \
syncache.4 \
syncer.4 \
@@ -884,12 +885,14 @@ _qlxgbe.4=qlxgbe.4
 _qlnxe.4=  qlnxe.4
 _sfxge.4=  sfxge.4
 _smartpqi.4=   smartpqi.4
+_sume.4=   sume.4
 
 MLINKS+=qlxge.4 if_qlxge.4
 MLINKS+=qlxgb.4 if_qlxgb.4
 MLINKS+=qlxgbe.4 if_qlxgbe.4
 MLINKS+=qlnxe.4 if_qlnxe.4
 MLINKS+=sfxge.4 if_sfxge.4
+MLINKS+=sume.4 if_sume.4
 
 .if ${MK_BHYVE} != "no"
 _bhyve.4=  bhyve.4

Copied: stable/11/share/man/man4/sume.4 (from r364973, 
head/share/man/man4/sume.4)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/11/share/man/man4/sume.4 Sun Sep  6 10:23:13 2020
(r365375, copy of r364973, head/share/man/man4/sume.4)
@@ -0,0 +1,98 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\"
+.\" Copyright (c) 2020 Denis Salopek
+.\"
+.\" 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 August 30, 2020
+.Dt SUME 4
+.Os
+.Sh NAME
+.Nm sume
+.Nd "NetFPGA SUME 4x10Gb Ethernet driver"
+.Sh SYNOPSIS
+To compile this driver into the kernel, place the following lines
+in your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device sume"
+.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_sume_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for NetFPGA SUME Virtex-7 FPGA Development Board
+with the reference NIC bitstream loaded onto it.
+The HDL design for the reference NIC project uses the RIFFA based DMA
+engine to communicate with the host machine over PCIe.
+Every packet is transmitted to / from the board via a single DMA
+transaction, taking up to two or three interrupts per one transaction
+which yields low performance.
+.Pp
+There is no support for Jumbo frames as the hardware is capable of
+dealing only with frames with maximum size of 1514 bytes.
+The hardware does not support multicast filtering, provides no checksums,
+and offers no other offloading.
+.Sh SEE ALSO
+.Xr arp 4 ,
+.Xr netgraph 4 ,
+.Xr netintro 4 ,
+.Xr ng_ether 4 ,
+.Xr vlan 4 ,
+.Xr ifconfig 8
+.Sh AUTHORS
+The Linux
+.Nm
+driver was originally written by
+.An -nosplit
+.An Bjoern A. Zeeb .
+The
+.Fx version and this manual page were written by
+.An Denis Salopek
+as a GSoC project.
+More information about the project can be 

svn commit: r365374 - in stable/12: share/man/man4 sys/conf sys/dev/sume sys/modules sys/modules/sume

2020-09-06 Thread Marko Zec
Author: zec
Date: Sun Sep  6 10:18:59 2020
New Revision: 365374
URL: https://svnweb.freebsd.org/changeset/base/365374

Log:
  MFC r364973:
  
  Driver for 4x10Gb Ethernet reference NIC FPGA design for NetFPGA SUME
  development board.
  
  Submitted by: Denis Salopek 
  Reviewed by: zec, bz (src); rgrimes, bcr (manpages)
  Sponsored by: Google Summer of Code 2020
  Differential Revision: https://reviews.freebsd.org/D26074

Added:
  stable/12/share/man/man4/sume.4
 - copied unchanged from r364973, head/share/man/man4/sume.4
  stable/12/sys/dev/sume/
 - copied from r364973, head/sys/dev/sume/
  stable/12/sys/modules/sume/
 - copied from r364973, head/sys/modules/sume/
Modified:
  stable/12/share/man/man4/Makefile
  stable/12/sys/conf/files.amd64
  stable/12/sys/modules/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/Makefile
==
--- stable/12/share/man/man4/Makefile   Sun Sep  6 09:08:06 2020
(r365373)
+++ stable/12/share/man/man4/Makefile   Sun Sep  6 10:18:59 2020
(r365374)
@@ -532,6 +532,7 @@ MAN=aac.4 \
stf.4 \
stg.4 \
stge.4 \
+   ${_sume.4} \
${_superio.4} \
sym.4 \
syncache.4 \
@@ -881,12 +882,14 @@ _qlxgbe.4=qlxgbe.4
 _qlnxe.4=  qlnxe.4
 _sfxge.4=  sfxge.4
 _smartpqi.4=   smartpqi.4
+_sume.4=   sume.4
 
 MLINKS+=qlxge.4 if_qlxge.4
 MLINKS+=qlxgb.4 if_qlxgb.4
 MLINKS+=qlxgbe.4 if_qlxgbe.4
 MLINKS+=qlnxe.4 if_qlnxe.4
 MLINKS+=sfxge.4 if_sfxge.4
+MLINKS+=sume.4 if_sume.4
 
 .if ${MK_BHYVE} != "no"
 _bhyve.4=  bhyve.4

Copied: stable/12/share/man/man4/sume.4 (from r364973, 
head/share/man/man4/sume.4)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/12/share/man/man4/sume.4 Sun Sep  6 10:18:59 2020
(r365374, copy of r364973, head/share/man/man4/sume.4)
@@ -0,0 +1,98 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\"
+.\" Copyright (c) 2020 Denis Salopek
+.\"
+.\" 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 August 30, 2020
+.Dt SUME 4
+.Os
+.Sh NAME
+.Nm sume
+.Nd "NetFPGA SUME 4x10Gb Ethernet driver"
+.Sh SYNOPSIS
+To compile this driver into the kernel, place the following lines
+in your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device sume"
+.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_sume_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for NetFPGA SUME Virtex-7 FPGA Development Board
+with the reference NIC bitstream loaded onto it.
+The HDL design for the reference NIC project uses the RIFFA based DMA
+engine to communicate with the host machine over PCIe.
+Every packet is transmitted to / from the board via a single DMA
+transaction, taking up to two or three interrupts per one transaction
+which yields low performance.
+.Pp
+There is no support for Jumbo frames as the hardware is capable of
+dealing only with frames with maximum size of 1514 bytes.
+The hardware does not support multicast filtering, provides no checksums,
+and offers no other offloading.
+.Sh SEE ALSO
+.Xr arp 4 ,
+.Xr netgraph 4 ,
+.Xr netintro 4 ,
+.Xr ng_ether 4 ,
+.Xr vlan 4 ,
+.Xr ifconfig 8
+.Sh AUTHORS
+The Linux
+.Nm
+driver was originally written by
+.An -nosplit
+.An Bjoern A. Zeeb .
+The
+.Fx version and this manual page were written by
+.An Denis Salopek
+as a GSoC project.
+More information about the project can

Re: svn commit: r364973 - in head: share/man/man4 sys/conf sys/dev/sume sys/modules sys/modules/sume

2020-08-30 Thread Marko Zec
On Sun, 30 Aug 2020 07:34:32 + (UTC)
Marko Zec  wrote:

> Author: zec
> Date: Sun Aug 30 07:34:32 2020
> New Revision: 364973
> URL: https://svnweb.freebsd.org/changeset/base/364973
> 
> Log:
>   Driver for 4x10Gb Ethernet reference NIC FPGA design for NetFPGA
> SUME development board.
>   
>   Submitted by:   Denis Salopek 
>   Reported by:zec, bz (src); rgrimes, bcr (manpages)

Should have been "Reviewed by:", sorry...

Marko

>   MFC after:  7 days
>   Sponsored by:   Google Summer of Code 2020
>   Differential Revision:  https://reviews.freebsd.org/D26074
> 
> Added:
>   head/share/man/man4/sume.4   (contents, props changed)
>   head/sys/dev/sume/
>   head/sys/dev/sume/adapter.h   (contents, props changed)
>   head/sys/dev/sume/if_sume.c   (contents, props changed)
>   head/sys/modules/sume/
>   head/sys/modules/sume/Makefile   (contents, props changed)
> Modified:
>   head/share/man/man4/Makefile
>   head/sys/conf/files.amd64
>   head/sys/modules/Makefile
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364973 - in head: share/man/man4 sys/conf sys/dev/sume sys/modules sys/modules/sume

2020-08-30 Thread Marko Zec
Author: zec
Date: Sun Aug 30 07:34:32 2020
New Revision: 364973
URL: https://svnweb.freebsd.org/changeset/base/364973

Log:
  Driver for 4x10Gb Ethernet reference NIC FPGA design for NetFPGA SUME
  development board.
  
  Submitted by: Denis Salopek 
  Reported by:  zec, bz (src); rgrimes, bcr (manpages)
  MFC after:7 days
  Sponsored by: Google Summer of Code 2020
  Differential Revision:https://reviews.freebsd.org/D26074

Added:
  head/share/man/man4/sume.4   (contents, props changed)
  head/sys/dev/sume/
  head/sys/dev/sume/adapter.h   (contents, props changed)
  head/sys/dev/sume/if_sume.c   (contents, props changed)
  head/sys/modules/sume/
  head/sys/modules/sume/Makefile   (contents, props changed)
Modified:
  head/share/man/man4/Makefile
  head/sys/conf/files.amd64
  head/sys/modules/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileSun Aug 30 02:26:43 2020
(r364972)
+++ head/share/man/man4/MakefileSun Aug 30 07:34:32 2020
(r364973)
@@ -514,6 +514,7 @@ MAN=aac.4 \
ste.4 \
stf.4 \
stge.4 \
+   ${_sume.4} \
${_superio.4} \
sym.4 \
syncache.4 \
@@ -851,6 +852,7 @@ _qlxgbe.4=  qlxgbe.4
 _qlnxe.4=  qlnxe.4
 _sfxge.4=  sfxge.4
 _smartpqi.4=   smartpqi.4
+_sume.4=   sume.4
 _vmd.4=vmd.4
 
 MLINKS+=qlxge.4 if_qlxge.4
@@ -858,6 +860,7 @@ MLINKS+=qlxgb.4 if_qlxgb.4
 MLINKS+=qlxgbe.4 if_qlxgbe.4
 MLINKS+=qlnxe.4 if_qlnxe.4
 MLINKS+=sfxge.4 if_sfxge.4
+MLINKS+=sume.4 if_sume.4
 
 .if ${MK_BHYVE} != "no"
 _bhyve.4=  bhyve.4

Added: head/share/man/man4/sume.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/sume.4  Sun Aug 30 07:34:32 2020(r364973)
@@ -0,0 +1,98 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\"
+.\" Copyright (c) 2020 Denis Salopek
+.\"
+.\" 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 August 30, 2020
+.Dt SUME 4
+.Os
+.Sh NAME
+.Nm sume
+.Nd "NetFPGA SUME 4x10Gb Ethernet driver"
+.Sh SYNOPSIS
+To compile this driver into the kernel, place the following lines
+in your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device sume"
+.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_sume_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for NetFPGA SUME Virtex-7 FPGA Development Board
+with the reference NIC bitstream loaded onto it.
+The HDL design for the reference NIC project uses the RIFFA based DMA
+engine to communicate with the host machine over PCIe.
+Every packet is transmitted to / from the board via a single DMA
+transaction, taking up to two or three interrupts per one transaction
+which yields low performance.
+.Pp
+There is no support for Jumbo frames as the hardware is capable of
+dealing only with frames with maximum size of 1514 bytes.
+The hardware does not support multicast filtering, provides no checksums,
+and offers no other offloading.
+.Sh SEE ALSO
+.Xr arp 4 ,
+.Xr netgraph 4 ,
+.Xr netintro 4 ,
+.Xr ng_ether 4 ,
+.Xr vlan 4 ,
+.Xr ifconfig 8
+.Sh AUTHORS
+The Linux
+.Nm
+driver was originally written by
+.An -nosplit
+.An Bjoern A. Zeeb .
+The
+.Fx version and this manual page were written by
+.An Denis Salopek
+as a GSoC project.
+More information about the project can be found here:
+.Pa https://wiki.freebsd.org/SummerOfCode2020Projects/NetFPGA_SUME_Driver
+.Sh 

svn commit: r364368 - head/sys/netgraph

2020-08-18 Thread Marko Zec
Author: zec
Date: Tue Aug 18 22:46:46 2020
New Revision: 364368
URL: https://svnweb.freebsd.org/changeset/base/364368

Log:
  Increase BER to PER lookup table size in an attempt to mitigate panics
  with LRO and TSO.
  
  Reported by:rstone

Modified:
  head/sys/netgraph/ng_pipe.h

Modified: head/sys/netgraph/ng_pipe.h
==
--- head/sys/netgraph/ng_pipe.h Tue Aug 18 22:15:51 2020(r364367)
+++ head/sys/netgraph/ng_pipe.h Tue Aug 18 22:46:46 2020(r364368)
@@ -43,7 +43,7 @@
 #define NG_PIPE_HOOK_UPPER "upper"
 #define NG_PIPE_HOOK_LOWER "lower"
 
-#define MAX_FSIZE 16384/* Largest supported frame size, in bytes, for 
BER */
+#define MAX_FSIZE 65536/* Largest supported frame size, in bytes, for 
BER */
 #define MAX_OHSIZE 256 /* Largest supported dummy-framing size, in bytes */
 
 /* Statistics structure for one hook */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r364367 - head/share/man/man4

2020-08-18 Thread Marko Zec
Author: zec
Date: Tue Aug 18 22:15:51 2020
New Revision: 364367
URL: https://svnweb.freebsd.org/changeset/base/364367

Log:
  Fix ber parameter description.

Modified:
  head/share/man/man4/ng_pipe.4

Modified: head/share/man/man4/ng_pipe.4
==
--- head/share/man/man4/ng_pipe.4   Tue Aug 18 22:04:22 2020
(r364366)
+++ head/share/man/man4/ng_pipe.4   Tue Aug 18 22:15:51 2020
(r364367)
@@ -130,7 +130,7 @@ struct ng_pipe_cfg {
 /* Config structure for one hook */
 struct ng_pipe_hookcfg {
   u_int64_t  bandwidth;   /* bits per second */
-  u_int64_t  ber; /* errors per 2^48 bits */
+  u_int64_t  ber; /* avg. interval between bit errors (1 / BER) */
   u_int32_t  qin_size_limit;  /* number of queue items */
   u_int32_t  qout_size_limit; /* number of queue items */
   u_int32_t  duplicate;   /* probability in % */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r362009 - stable/12/sys/net

2020-06-12 Thread Marko Zec
On Wed, 10 Jun 2020 13:06:13 + (UTC)
"Andrey V. Elsukov"  wrote:

> Author: ae
> Date: Wed Jun 10 13:06:13 2020
> New Revision: 362009
> URL: https://svnweb.freebsd.org/changeset/base/362009
> 
> Log:
>   MFC r361749:
> Add if_reassign method to all tunneling interfaces.
>   
> After r339550 tunneling interfaces have started handle appearing
> and disappearing of ingress IP address on the host system.
> When such interfaces are moving into VNET jail, they lose ability
> to properly handle ifaddr_event_ext event. And this leads to need to
> reconfigure tunnel to make it working again.
>   
> Since moving an interface into VNET jail leads to removing of all
> IP addresses, it looks consistent, that tunnel configuration should
> also be cleared. This is what will do if_reassign method.

Sorry for not noticing this one before, but albeit jumping in late, I
have to state two objections:

1) what exactly is the use-case / purpose of moving clonable interfaces
from one vnet to another while removing their tunnel configs?
Apparently gif / gre already have virtualized cloners, so if a vnet
owner needs a new instance of gif / gre, it can create it there?  We
should either entirely prohibit moving such ifnets to child vnets, or
allow their tunnel endpoints to exist in the parent vnet space, while
permitting the traffic from child vnets to be encapsulated.

2) the behavior introduced by this change is inconsistent with how other
clonable interfaces have worked since 8.0, e.g if_vlan instances can be
moved (loaned) to a child vnet, and in such cases they remain tied to
their parent (physical) ethernet ifnets. Similarly, ng_eiface can be
loaned to a chiled vnet, but its netgraph part remains in the parent
vnet.

So now we got a confusion++, perhaps for a good reason, but I fail to
see the proper justification (execpt that someone wanted to see this
patch commited).

Cheers,

Marko


>   
> Reported by:  John W. O'Brien 
> 
> Modified:
>   stable/12/sys/net/if_gif.c
>   stable/12/sys/net/if_gre.c
>   stable/12/sys/net/if_ipsec.c
>   stable/12/sys/net/if_me.c
> Directory Properties:
>   stable/12/   (props changed)
> 
> Modified: stable/12/sys/net/if_gif.c
> ==
> --- stable/12/sys/net/if_gif.cWed Jun 10 09:31:37 2020
> (r362008) +++ stable/12/sys/net/if_gif.c  Wed Jun 10 13:06:13
> 2020  (r362009) @@ -104,6 +104,9 @@ void
> (*ng_gif_input_orphan_p)(struct ifnet *ifp, struc void
> (*ng_gif_attach_p)(struct ifnet *ifp); void
> (*ng_gif_detach_p)(struct ifnet *ifp); 
> +#ifdef VIMAGE
> +static void  gif_reassign(struct ifnet *, struct vnet *, char
> *); +#endif
>  static void  gif_delete_tunnel(struct gif_softc *);
>  static int   gif_ioctl(struct ifnet *, u_long, caddr_t);
>  static int   gif_transmit(struct ifnet *, struct mbuf *);
> @@ -150,6 +153,9 @@ gif_clone_create(struct if_clone *ifc, int unit,
> caddr GIF2IFP(sc)->if_transmit = gif_transmit;
>   GIF2IFP(sc)->if_qflush = gif_qflush;
>   GIF2IFP(sc)->if_output = gif_output;
> +#ifdef VIMAGE
> + GIF2IFP(sc)->if_reassign = gif_reassign;
> +#endif
>   GIF2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
>   GIF2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
>   if_attach(GIF2IFP(sc));
> @@ -159,6 +165,21 @@ gif_clone_create(struct if_clone *ifc, int unit,
> caddr 
>   return (0);
>  }
> +
> +#ifdef VIMAGE
> +static void
> +gif_reassign(struct ifnet *ifp, struct vnet *new_vnet __unused,
> +char *unused __unused)
> +{
> + struct gif_softc *sc;
> +
> + sx_xlock(&gif_ioctl_sx);
> + sc = ifp->if_softc;
> + if (sc != NULL)
> + gif_delete_tunnel(sc);
> + sx_xunlock(&gif_ioctl_sx);
> +}
> +#endif /* VIMAGE */
>  
>  static void
>  gif_clone_destroy(struct ifnet *ifp)
> 
> Modified: stable/12/sys/net/if_gre.c
> ==
> --- stable/12/sys/net/if_gre.cWed Jun 10 09:31:37 2020
> (r362008) +++ stable/12/sys/net/if_gre.c  Wed Jun 10 13:06:13
> 2020  (r362009) @@ -107,6 +107,9 @@ static void
> gre_clone_destroy(struct ifnet *); VNET_DEFINE_STATIC(struct if_clone
> *, gre_cloner); #define   V_gre_clonerVNET(gre_cloner)
>  
> +#ifdef VIMAGE
> +static void  gre_reassign(struct ifnet *, struct vnet *, char
> *); +#endif
>  static void  gre_qflush(struct ifnet *);
>  static int   gre_transmit(struct ifnet *, struct mbuf *);
>  static int   gre_ioctl(struct ifnet *, u_long, caddr_t);
> @@ -183,12 +186,30 @@ gre_clone_create(struct if_clone *ifc, int
> unit, caddr GRE2IFP(sc)->if_ioctl = gre_ioctl;
>   GRE2IFP(sc)->if_transmit = gre_transmit;
>   GRE2IFP(sc)->if_qflush = gre_qflush;
> +#ifdef VIMAGE
> + GRE2IFP(sc)->if_reassign = gre_reassign;
> +#endif
>   GRE2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
>   GRE2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
>   if_attach(GRE2IFP(sc));
>   bpfattach(GRE2IF

svn commit: r349371 - head/usr.bin/calendar/calendars/hr_HR.ISO8859-2

2019-06-25 Thread Marko Zec
Author: zec
Date: Tue Jun 25 14:50:03 2019
New Revision: 349371
URL: https://svnweb.freebsd.org/changeset/base/349371

Log:
  Croatian calendar: update / fix names, dates, group national public
  holidays, sort by date.
  
  MFC after:3 days

Modified:
  head/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici

Modified: head/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici
==
--- head/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici   Tue Jun 
25 13:15:29 2019(r349370)
+++ head/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici   Tue Jun 
25 14:50:03 2019(r349371)
@@ -10,31 +10,31 @@
 LANG=hr_HR.ISO8859-2
 
 /* dr�avni praznici */
-01/01  Nova godina
-05/01  Praznik rada
-05/30  Tjelovo
-06/22  Dan antifa�isti�ke borbe
-06/25  Dan dr�avnosti
-08/05  Dan domovinske zahvalnosti
-10/08  Dan neovisnosti
- 
-/* katoli�ki blagdani */
-01/06  Sveta tri kralja
-Easter-2   Veliki petak
+01/01  Nova godina
+01/06  Bogojavljenje ili Sveta tri kralja
 Easter Uskrs
 Easter+1   Uskrsni ponedjeljak
-Easter+49  Duhovi
-Easter+50  Duhovni ponedjeljak
-Easter+39  Uza�a��e
+05/01  Praznik rada
+Easter+60  Tijelovo
+06/22  Dan antifa�isti�ke borbe
+06/25  Dan dr�avnosti
+08/05  Dan pobjede i domovinske zahvalnosti i Dan hrvatskih branitelja
 08/15  Velika Gospa
+10/08  Dan neovisnosti
 11/01  Svi sveti
 12/25  Bo�i�
-12/26  Stjepandan
+12/26  Sveti Stjepan
+ 
+/* katoli�ki blagdani */
+Easter-2   Veliki petak
+Easter+39  Uza�a��e
+Easter+49  Duhovi
+Easter+50  Duhovni ponedjeljak
 
 /* godi�nja doba */
 03/21* Po�etak prolje�a
 06/21* Po�etak ljeta
-09/21* Po�etak jesena
+09/23* Po�etak jeseni
 12/21* Po�etak zime
  
 /* ljetno vrijeme */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r349186 - head/sys/net

2019-06-19 Thread Marko Zec
Author: zec
Date: Wed Jun 19 08:49:24 2019
New Revision: 349186
URL: https://svnweb.freebsd.org/changeset/base/349186

Log:
  V_ip6_forwarding and V_ipforwarding have been defined in ip6_var.h /
  ip_var.h since at least 2008, so make use of those definitions here.
  
  MFC after:3 days

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed Jun 19 08:39:19 2019(r349185)
+++ head/sys/net/iflib.cWed Jun 19 08:49:24 2019(r349186)
@@ -2688,10 +2688,10 @@ iflib_get_ip_forwarding(struct lro_ctrl *lc, bool *v4,
 {
CURVNET_SET(lc->ifp->if_vnet);
 #if defined(INET6)
-   *v6 = VNET(ip6_forwarding);
+   *v6 = V_ip6_forwarding;
 #endif
 #if defined(INET)
-   *v4 = VNET(ipforwarding);
+   *v4 = V_ipforwarding;
 #endif
CURVNET_RESTORE();
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r349185 - head/sys/net

2019-06-19 Thread Marko Zec
Author: zec
Date: Wed Jun 19 08:39:19 2019
New Revision: 349185
URL: https://svnweb.freebsd.org/changeset/base/349185

Log:
  Evaluating htons() at compile time is more efficient than doing ntohs()
  at runtime.  This change removes a dependency on a barrel shifter pass
  before branch resolution, while reducing the instruction stream size
  by 9 bytes on amd64.
  
  MFC after:3 days

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed Jun 19 06:41:07 2019(r349184)
+++ head/sys/net/iflib.cWed Jun 19 08:39:19 2019(r349185)
@@ -2705,18 +2705,16 @@ static bool
 iflib_check_lro_possible(struct mbuf *m, bool v4_forwarding, bool 
v6_forwarding)
 {
struct ether_header *eh;
-   uint16_t eh_type;
 
eh = mtod(m, struct ether_header *);
-   eh_type = ntohs(eh->ether_type);
-   switch (eh_type) {
+   switch (eh->ether_type) {
 #if defined(INET6)
-   case ETHERTYPE_IPV6:
-   return !v6_forwarding;
+   case htons(ETHERTYPE_IPV6):
+   return (!v6_forwarding);
 #endif
 #if defined (INET)
-   case ETHERTYPE_IP:
-   return !v4_forwarding;
+   case htons(ETHERTYPE_IP):
+   return (!v4_forwarding);
 #endif
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r345151 - head/sys/net

2019-03-15 Thread Marko Zec
On Thu, 14 Mar 2019 20:14:14 +
"Bjoern A. Zeeb"  wrote:

> On 14 Mar 2019, at 19:48, Kyle Evans wrote:
> 
> > Author: kevans
> > Date: Thu Mar 14 19:48:43 2019
> > New Revision: 345151
> > URL: https://svnweb.freebsd.org/changeset/base/345151
> >
> > Log:
> >   ether_fakeaddr: Use 'b' 's' 'd' for the prefix
...
> epair(4) is yet another one of the cloned interfaces which does magic 
> for the ethernet addresses, not sure what else.

ng_eiface(4) currently does not autogenerate a fake MAC address
(defaults to all zeros), but it could be useful if it would, in a
way consistent to the rest of the clonable fake ethernet ifcs...

Marko
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r343527 - in stable/12/sys/riscv: include riscv

2019-01-29 Thread Marko Zec
On Mon, 28 Jan 2019 16:14:53 +
Mark Johnston  wrote:

> Author: markj
> Date: Mon Jan 28 16:14:53 2019
> New Revision: 343527
> URL: https://svnweb.freebsd.org/changeset/base/343527
> 
> Log:
>   MFC r343274, r343275:
>   Optimize RISC-V copyin(9)/copyout(9) routines.

Was this subjected to any benchmarks?  I'd bet that placing

addia2, a2, -XLEN_BYTES

before

sd  a4, 0(a1)

instead of being scheduled after (the same goes for the byte copy loop)
would make the loops run faster on most in-order RV cores out there...

Marko


> 
> Modified:
>   stable/12/sys/riscv/include/riscvreg.h
>   stable/12/sys/riscv/riscv/copyinout.S
> Directory Properties:
>   stable/12/   (props changed)
> 
> Modified: stable/12/sys/riscv/include/riscvreg.h
> ==
> --- stable/12/sys/riscv/include/riscvreg.hMon Jan 28 14:34:59
> 2019  (r343526) +++
> stable/12/sys/riscv/include/riscvreg.hMon Jan 28 16:14:53
> 2019  (r343527) @@ -155,7 +155,8 @@ #define
> SATP_MODE_SV39(8ULL << SATP_MODE_S) #define
> SATP_MODE_SV48(9ULL << SATP_MODE_S) 
> -#define  XLEN8
> +#define  XLEN__riscv_xlen
> +#define  XLEN_BYTES  (XLEN / 8)
>  #define  INSN_SIZE   4
>  #define  INSN_C_SIZE 2
>  
> 
> Modified: stable/12/sys/riscv/riscv/copyinout.S
> ==
> --- stable/12/sys/riscv/riscv/copyinout.S Mon Jan 28 14:34:59
> 2019  (r343526) +++
> stable/12/sys/riscv/riscv/copyinout.S Mon Jan 28 16:14:53
> 2019  (r343527) @@ -1,5 +1,6 @@ /*-
>   * Copyright (c) 2015-2018 Ruslan Bukin 
> + * Copyright (c) 2019 Mitchell Horne
>   * All rights reserved.
>   *
>   * Portions of this software were developed by SRI International and
> the @@ -52,60 +53,94 @@ copyio_fault_nopcb:
>  END(copyio_fault)
>  
>  /*
> + * copycommon - common copy routine
> + *
> + * a0 - Source address
> + * a1 - Destination address
> + * a2 - Size of copy
> + */
> + .macro copycommon
> + la  a6, copyio_fault/* Get the handler address
> */
> + SET_FAULT_HANDLER(a6, a7)   /* Set the handler */
> + ENTER_USER_ACCESS(a7)
> +
> + li  t2, XLEN_BYTES
> + blt a2, t2, 3f  /* Byte-copy if len <
> XLEN_BYTES */ +
> + /*
> +  * Compare lower bits of src and dest.
> +  * If they are aligned with each other, we can do word copy.
> +  */
> + andit0, a0, (XLEN_BYTES-1)  /* Low bits of src
> */
> + andit1, a1, (XLEN_BYTES-1)  /* Low bits of
> dest */
> + bne t0, t1, 3f  /* Misaligned. Go to
> byte copy */
> + beqzt0, 2f  /* Already
> word-aligned, skip ahead */ +
> + /* Byte copy until the first word-aligned address */
> +1:   lb  a4, 0(a0)   /* Load byte from src */
> + addia0, a0, 1
> + sb  a4, 0(a1)   /* Store byte in dest */
> + addia1, a1, 1
> + addia2, a2, -1  /* len-- */
> + andit0, a0, (XLEN_BYTES-1)
> + bnezt0, 1b
> +
> + /* Copy words */
> +2:   ld  a4, 0(a0)   /* Load word from src */
> + addia0, a0, XLEN_BYTES
> + sd  a4, 0(a1)   /* Store word in dest */
> + addia1, a1, XLEN_BYTES
> + addia2, a2, -XLEN_BYTES /* len -= XLEN_BYTES
> */
> + bgeua2, t2, 2b  /* Again if len >=
> XLEN_BYTES */ +
> + /* Check if we're finished */
> + beqza2, 4f
> +
> + /* Copy any remaining bytes */
> +3:   lb  a4, 0(a0)   /* Load byte from src */
> + addia0, a0, 1
> + sb  a4, 0(a1)   /* Store byte in dest */
> + addia1, a1, 1
> + addia2, a2, -1  /* len-- */
> + bneza2, 3b
> +
> +4:   EXIT_USER_ACCESS(a7)
> + SET_FAULT_HANDLER(x0, a7)   /* Clear the handler */
> + .endm
> +
> +/*
>   * Copies from a kernel to user address
>   *
>   * int copyout(const void *kaddr, void *udaddr, size_t len)
>   */
>  ENTRY(copyout)
> - beqza2, 2f  /* If len == 0 then skip
> loop */
> + beqza2, copyout_end /* If len == 0 then skip
> loop */ add   a3, a1, a2
>   li  a4, VM_MAXUSER_ADDRESS
>   bgt a3, a4, copyio_fault_nopcb
>  
> - la  a6, copyio_fault /* Get the handler address */
> - SET_FAULT_HANDLER(a6, a7) /* Set the handler */
> - ENTER_USER_ACCESS(a7)
> + copycommon
>  
> -1:   lb  a4, 0(a0)   /* Load from kaddr */
> - addia0, a0, 1
> - sb  a4, 0(a1)   /* Store in uaddr */
> - addia1, a1, 1
> - addia2, a2, -1  /* len-- */
> - bneza2, 1b
> -
> - EXIT_USER_ACCESS(a7)
> - SET_FAULT_HANDLER(x0, a7) /* Clear the handler */
> -
> -2:   li  a0, 0   /* return 0 */
> +copyout_end:
> + li  a0, 0   /* return 0 */
>   ret
>  END(copyo

Re: svn commit: r333968 - in head/sys: netinet netinet6

2018-05-21 Thread Marko Zec
On Mon, 21 May 2018 08:34:10 +
Matt Macy  wrote:

> Author: mmacy
> Date: Mon May 21 08:34:10 2018
> New Revision: 333968
> URL: https://svnweb.freebsd.org/changeset/base/333968
> 
> Log:
>   in(6)_mcast: Expand out vnet set / restore macro so that they work
> in a conditional block 
>   Reported by:zec at fer.hr
> 
> Modified:
>   head/sys/netinet/in_mcast.c
>   head/sys/netinet6/in6_mcast.c
> 
> Modified: head/sys/netinet/in_mcast.c
> ==
> --- head/sys/netinet/in_mcast.c   Mon May 21 07:12:06
> 2018  (r333967) +++ head/sys/netinet/in_mcast.c   Mon May
> 21 08:34:10 2018  (r333968) @@ -653,6 +653,7 @@
> inm_release(struct in_multi *inm) {
>   struct ifmultiaddr *ifma;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>  
>   CTR2(KTR_IGMPV3, "%s: refcount is %d", __func__,
> inm->inm_refcount); MPASS(inm->inm_refcount == 0);
> @@ -663,14 +664,16 @@ inm_release(struct in_multi *inm)
>  
>   /* XXX this access is not covered by IF_ADDR_LOCK */
>   CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }

Uhmm...  please don't do this, for at least two reasons:

1) so far we could identify all VNET context switches by tracking
CURVNET_SET / _RESTORE macros.  With this change a non-standard hack is
introduced, opening the door for more alternative / creative variations
to come, thus increasing the entropy

2) CURVNET_* macros provide elementary capability of tracking vnet
recursions, and much more importantly, forgotten or missed context
restores.  Your change breaks this tracking chain.

Is there a reason one could not extend struct in_multi with a struct
vnet *inm_vnet entry, populate it on struct in_multi creation, and be
done with all curvnet woes in a clean way?

Marko


>   inm_purge(inm);
>   free(inm, M_IPMADDR);
>  
>   if_delmulti_ifma_flags(ifma, 1);
>   if (ifp) {
> - CURVNET_RESTORE();
> + curvnet = saved_vnet;
>   if_rele(ifp);
>   }
>  }
> @@ -1666,6 +1669,7 @@ inp_gcmoptions(epoch_context_t ctx)
>   struct in_mfilter   *imf;
>   struct in_multi *inm;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>   size_t   idx, nmships;
>  
>   imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
> @@ -1677,11 +1681,13 @@ inp_gcmoptions(epoch_context_t ctx)
>   imf_leave(imf);
>   inm = imo->imo_membership[idx];
>   ifp = inm->inm_ifp;
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }
>   (void)in_leavegroup(inm, imf);
>   if (ifp)
> - CURVNET_RESTORE();
> + curvnet = saved_vnet;
>   if (imf)
>   imf_purge(imf);
>   }
> 
> Modified: head/sys/netinet6/in6_mcast.c
> ==
> --- head/sys/netinet6/in6_mcast.c Mon May 21 07:12:06
> 2018  (r333967) +++ head/sys/netinet6/in6_mcast.c Mon
> May 21 08:34:10 2018  (r333968) @@ -524,6 +524,7 @@
> in6m_release(struct in6_multi *inm) {
>   struct ifmultiaddr *ifma;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>  
>   CTR2(KTR_MLD, "%s: refcount is %d", __func__,
> inm->in6m_refcount); 
> @@ -539,14 +540,16 @@ in6m_release(struct in6_multi *inm)
>   KASSERT(ifma->ifma_protospec == NULL,
>   ("%s: ifma_protospec != NULL", __func__));
>  
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }
>   in6m_purge(inm);
>   free(inm, M_IP6MADDR);
>  
>   if_delmulti_ifma_flags(ifma, 1);
>   if (ifp) {
> - CURVNET_RESTORE();
> + curvnet = saved_vnet;
>   if_rele(ifp);
>   }
>  }
> @@ -1628,6 +1631,7 @@ inp_gcmoptions(epoch_context_t ctx)
>   struct in6_mfilter  *imf;
>   struct in6_multi *inm;
>   struct ifnet *ifp;
> + struct vnet *saved_vnet;
>   size_t   idx, nmships;
>  
>   imo =  __containerof(ctx, struct ip6_moptions,
> imo6_epoch_ctx); @@ -1639,11 +1643,13 @@
> inp_gcmoptions(epoch_context_t ctx) im6f_leave(imf);
>   inm = imo->im6o_membership[idx];
>   ifp = inm->in6m_ifp;
> - if (ifp)
> - CURVNET_SET(ifp->if_vnet);
> + if (ifp) {
> + saved_vnet = curvnet;
> + curvnet = ifp->if_vnet;
> + }   
>   (vo

Re: svn commit: r333967 - head/sys/netinet

2018-05-21 Thread Marko Zec
On Mon, 21 May 2018 01:03:53 -0700
Matthew Macy  wrote:
> On Mon, May 21, 2018 at 00:47 Marko Zec  wrote:
> > On Mon, 21 May 2018 07:12:06 + Matt Macy  wrote:
...
> > > + if (ifp)
> > > + CURVNET_SET(ifp->if_vnet);  
> >
> > Unfortunately, this won't work because CURVNET_SET() expands to a
> > sequence of declarations and assignments which are NOT enclosed in a
> > single block.  Instead, only the first statement in CURVNET_SET()
> > sequence, which is an assert, will be executed conditionally only if
> > ifp != NULL, while the rest of the CURVNET_SET() body will fall out
> > of the scope of the if (ifp) conditional.
> 
> That's pretty counter to the way macros are done _everywhere_ else in
> the kernel. 

Agreed, unfortunately it is.

> You should probably fix that.

This problem was discussed on numerous occasions but no better / more
convenient and workable proposals come up so far.

Bjoern clearly documented and emphasized this problem in vnet(9).

Marko

> 
> 
> > I'd recommend backing out this patch, and instead extending the
> > struct ip_moptions with an struct vnet * entry, which would be
> > populated before scheduling inp_gcmoptions().  Then
> > CURVNET_SET(imo->imo_vnet) could be called only once (and
> > unconditionally) in gcmoptions(), instead of (attempts at) doing
> > this multiple times in a for loop.
> >
> > Marko
> >
> >  
> > > + (void)in_leavegroup(inm, imf);
> > > + if (ifp)
> > > + CURVNET_RESTORE();
> > >   if (imf)
> > >   imf_purge(imf);
> > >   }
> > >  
> >
> >  

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r333967 - head/sys/netinet

2018-05-21 Thread Marko Zec
On Mon, 21 May 2018 07:12:06 +
Matt Macy  wrote:

> Author: mmacy
> Date: Mon May 21 07:12:06 2018
> New Revision: 333967
> URL: https://svnweb.freebsd.org/changeset/base/333967
> 
> Log:
>   ensure that vnet is set when doing in_leavegroup
> 
> Modified:
>   head/sys/netinet/in_mcast.c
> 
> Modified: head/sys/netinet/in_mcast.c
> ==
> --- head/sys/netinet/in_mcast.c   Mon May 21 05:20:23
> 2018  (r333966) +++ head/sys/netinet/in_mcast.c   Mon May
> 21 07:12:06 2018  (r333967) @@ -1664,6 +1664,8 @@
> inp_gcmoptions(epoch_context_t ctx) {
>   struct ip_moptions *imo;
>   struct in_mfilter   *imf;
> + struct in_multi *inm;
> + struct ifnet *ifp;
>   size_t   idx, nmships;
>  
>   imo =  __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
> @@ -1673,7 +1675,13 @@ inp_gcmoptions(epoch_context_t ctx)
>   imf = imo->imo_mfilters ? &imo->imo_mfilters[idx] :
> NULL; if (imf)
>   imf_leave(imf);
> - (void)in_leavegroup(imo->imo_membership[idx], imf);
> + inm = imo->imo_membership[idx];
> + ifp = inm->inm_ifp;
> + if (ifp)
> + CURVNET_SET(ifp->if_vnet);

Unfortunately, this won't work because CURVNET_SET() expands to a
sequence of declarations and assignments which are NOT enclosed in a
single block.  Instead, only the first statement in CURVNET_SET()
sequence, which is an assert, will be executed conditionally only if
ifp != NULL, while the rest of the CURVNET_SET() body will fall out of
the scope of the if (ifp) conditional.

I'd recommend backing out this patch, and instead extending the struct
ip_moptions with an struct vnet * entry, which would be populated
before scheduling inp_gcmoptions().  Then CURVNET_SET(imo->imo_vnet)
could be called only once (and unconditionally) in gcmoptions(),
instead of (attempts at) doing this multiple times in a for loop.

Marko


> + (void)in_leavegroup(inm, imf);
> + if (ifp)
> + CURVNET_RESTORE();
>   if (imf)
>   imf_purge(imf);
>   }
> 

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r333680 - head/share/man/man9

2018-05-16 Thread Marko Zec
Author: zec
Date: Wed May 16 16:57:11 2018
New Revision: 333680
URL: https://svnweb.freebsd.org/changeset/base/333680

Log:
  A belated note crediting the FreeBSD Foundation for sponsoring
  technical work circa ten years ago...
  
  MFC after:3 days

Modified:
  head/share/man/man9/vnet.9

Modified: head/share/man/man9/vnet.9
==
--- head/share/man/man9/vnet.9  Wed May 16 16:56:35 2018(r333679)
+++ head/share/man/man9/vnet.9  Wed May 16 16:57:11 2018(r333680)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 20, 2014
+.Dd May 16, 2018
 .Dt VNET 9
 .Os
 .Sh NAME
@@ -488,10 +488,24 @@ context of the caller.
 .Xr KASSERT 9 ,
 .Xr sysctl 9
 .\" .Xr SYSINIT 9
+.Pp
+Marko Zec, Implementing a Clonable Network Stack in the FreeBSD Kernel,
+USENIX ATC'03, June 2003, Boston
 .Sh HISTORY
 The virtual network stack implementation first appeared in
 .Fx 8.0 .
 .Sh AUTHORS
+.An -nosplit
+The
+.Nm
+framework has been designed and implemented at the University of Zagreb by
+.An Marko Zec ,
+and later extended and refined by
+.An Bjoern A. Zeeb
+and
+.An Robert Watson ,
+under contract to the FreeBSD Foundation.
+.Pp
 This manual page was written by
 .An Bjoern A. Zeeb, CK Software GmbH,
 under sponsorship from the FreeBSD Foundation.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r317400 - head/sys/netpfil/pf

2017-04-25 Thread Marko Zec
Author: zec
Date: Tue Apr 25 08:34:39 2017
New Revision: 317400
URL: https://svnweb.freebsd.org/changeset/base/317400

Log:
  Fix VNET leakages in PF by V_irtualizing pfr_ktables and friends.
  Apparently this resolves a PF-triggered panic when destroying VNET jails.
  
  Submitted by: Peter Blok 
  Reviewed by:  kp

Modified:
  head/sys/netpfil/pf/pf_table.c

Modified: head/sys/netpfil/pf/pf_table.c
==
--- head/sys/netpfil/pf/pf_table.c  Tue Apr 25 08:30:28 2017
(r317399)
+++ head/sys/netpfil/pf/pf_table.c  Tue Apr 25 08:34:39 2017
(r317400)
@@ -184,9 +184,14 @@ static struct pfr_kentry
 static RB_PROTOTYPE(pfr_ktablehead, pfr_ktable, pfrkt_tree, 
pfr_ktable_compare);
 static RB_GENERATE(pfr_ktablehead, pfr_ktable, pfrkt_tree, pfr_ktable_compare);
 
-struct pfr_ktablehead   pfr_ktables;
-struct pfr_tablepfr_nulltable;
-int pfr_ktable_cnt;
+static VNET_DEFINE(struct pfr_ktablehead, pfr_ktables);
+#defineV_pfr_ktables   VNET(pfr_ktables)
+
+static VNET_DEFINE(struct pfr_table, pfr_nulltable);
+#defineV_pfr_nulltable VNET(pfr_nulltable)
+
+static VNET_DEFINE(int, pfr_ktable_cnt);
+#define V_pfr_ktable_cnt   VNET(pfr_ktable_cnt)
 
 void
 pfr_initialize(void)
@@ -256,7 +261,7 @@ pfr_add_addrs(struct pfr_table *tbl, str
return (ESRCH);
if (kt->pfrkt_flags & PFR_TFLAG_CONST)
return (EPERM);
-   tmpkt = pfr_create_ktable(&pfr_nulltable, 0, 0);
+   tmpkt = pfr_create_ktable(&V_pfr_nulltable, 0, 0);
if (tmpkt == NULL)
return (ENOMEM);
SLIST_INIT(&workq);
@@ -408,7 +413,7 @@ pfr_set_addrs(struct pfr_table *tbl, str
return (ESRCH);
if (kt->pfrkt_flags & PFR_TFLAG_CONST)
return (EPERM);
-   tmpkt = pfr_create_ktable(&pfr_nulltable, 0, 0);
+   tmpkt = pfr_create_ktable(&V_pfr_nulltable, 0, 0);
if (tmpkt == NULL)
return (ENOMEM);
pfr_mark_addrs(kt);
@@ -1083,7 +1088,7 @@ pfr_clr_tables(struct pfr_table *filter,
return (ENOENT);
 
SLIST_INIT(&workq);
-   RB_FOREACH(p, pfr_ktablehead, &pfr_ktables) {
+   RB_FOREACH(p, pfr_ktablehead, &V_pfr_ktables) {
if (pfr_skip_table(filter, p, flags))
continue;
if (!strcmp(p->pfrkt_anchor, PF_RESERVED_ANCHOR))
@@ -1118,7 +1123,7 @@ pfr_add_tables(struct pfr_table *tbl, in
flags & PFR_FLAG_USERIOCTL))
senderr(EINVAL);
key.pfrkt_flags |= PFR_TFLAG_ACTIVE;
-   p = RB_FIND(pfr_ktablehead, &pfr_ktables, &key);
+   p = RB_FIND(pfr_ktablehead, &V_pfr_ktables, &key);
if (p == NULL) {
p = pfr_create_ktable(&key.pfrkt_t, tzero, 1);
if (p == NULL)
@@ -1134,7 +1139,7 @@ pfr_add_tables(struct pfr_table *tbl, in
 
/* find or create root table */
bzero(key.pfrkt_anchor, sizeof(key.pfrkt_anchor));
-   r = RB_FIND(pfr_ktablehead, &pfr_ktables, &key);
+   r = RB_FIND(pfr_ktablehead, &V_pfr_ktables, &key);
if (r != NULL) {
p->pfrkt_root = r;
goto _skip;
@@ -1190,7 +1195,7 @@ pfr_del_tables(struct pfr_table *tbl, in
if (pfr_validate_table(&key.pfrkt_t, 0,
flags & PFR_FLAG_USERIOCTL))
return (EINVAL);
-   p = RB_FIND(pfr_ktablehead, &pfr_ktables, &key);
+   p = RB_FIND(pfr_ktablehead, &V_pfr_ktables, &key);
if (p != NULL && (p->pfrkt_flags & PFR_TFLAG_ACTIVE)) {
SLIST_FOREACH(q, &workq, pfrkt_workq)
if (!pfr_ktable_compare(p, q))
@@ -1229,7 +1234,7 @@ pfr_get_tables(struct pfr_table *filter,
*size = n;
return (0);
}
-   RB_FOREACH(p, pfr_ktablehead, &pfr_ktables) {
+   RB_FOREACH(p, pfr_ktablehead, &V_pfr_ktables) {
if (pfr_skip_table(filter, p, flags))
continue;
if (n-- <= 0)
@@ -1264,7 +1269,7 @@ pfr_get_tstats(struct pfr_table *filter,
return (0);
}
SLIST_INIT(&workq);
-   RB_FOREACH(p, pfr_ktablehead, &pfr_ktables) {
+   RB_FOREACH(p, pfr_ktablehead, &V_pfr_ktables) {
if (pfr_skip_table(filter, p, flags))
continue;
if (n-- <= 0)
@@ -1296,7 +1301,7 @@ pfr_clr_tstats(struct pfr_table *tbl, in
bcopy(tbl + i, &key.pfrkt_t, sizeof(key.pfrkt_t));
if (pfr_validate_table(&key.pfrkt_t, 0, 0))
return (EINVAL);
-   p = RB_FIND(pfr_ktablehead, &pfr_ktables, &key);
+   p = RB_FIND

svn commit: r317399 - head/sys/netpfil/pf

2017-04-25 Thread Marko Zec
Author: zec
Date: Tue Apr 25 08:30:28 2017
New Revision: 317399
URL: https://svnweb.freebsd.org/changeset/base/317399

Log:
  Since curvnet is already properly set on entry to event handlers,
  there's no need to override it, particularly not unconditionally with
  vnet0.
  
  Submitted by: Peter Blok 
  Reviewed by:  kp

Modified:
  head/sys/netpfil/pf/pf_if.c

Modified: head/sys/netpfil/pf/pf_if.c
==
--- head/sys/netpfil/pf/pf_if.c Tue Apr 25 03:43:06 2017(r317398)
+++ head/sys/netpfil/pf/pf_if.c Tue Apr 25 08:30:28 2017(r317399)
@@ -89,9 +89,9 @@ static int pfi_skip_if(const char *, st
 static int  pfi_unmask(void *);
 static void pfi_attach_ifnet_event(void * __unused, struct ifnet *);
 static void pfi_detach_ifnet_event(void * __unused, struct ifnet *);
-static void pfi_attach_group_event(void *, struct ifg_group *);
-static void pfi_change_group_event(void *, char *);
-static void pfi_detach_group_event(void *, struct ifg_group *);
+static void pfi_attach_group_event(void * __unused, struct ifg_group *);
+static void pfi_change_group_event(void * __unused, char *);
+static void pfi_detach_group_event(void * __unused, struct ifg_group *);
 static void pfi_ifaddr_event(void * __unused, struct ifnet *);
 
 RB_HEAD(pfi_ifhead, pfi_kif);
@@ -143,11 +143,11 @@ pfi_initialize(void)
pfi_detach_cookie = EVENTHANDLER_REGISTER(ifnet_departure_event,
pfi_detach_ifnet_event, NULL, EVENTHANDLER_PRI_ANY);
pfi_attach_group_cookie = EVENTHANDLER_REGISTER(group_attach_event,
-   pfi_attach_group_event, curvnet, EVENTHANDLER_PRI_ANY);
+   pfi_attach_group_event, NULL, EVENTHANDLER_PRI_ANY);
pfi_change_group_cookie = EVENTHANDLER_REGISTER(group_change_event,
-   pfi_change_group_event, curvnet, EVENTHANDLER_PRI_ANY);
+   pfi_change_group_event, NULL, EVENTHANDLER_PRI_ANY);
pfi_detach_group_cookie = EVENTHANDLER_REGISTER(group_detach_event,
-   pfi_detach_group_event, curvnet, EVENTHANDLER_PRI_ANY);
+   pfi_detach_group_event, NULL, EVENTHANDLER_PRI_ANY);
pfi_ifaddr_event_cookie = EVENTHANDLER_REGISTER(ifaddr_event,
pfi_ifaddr_event, NULL, EVENTHANDLER_PRI_ANY);
 }
@@ -800,10 +800,8 @@ static void
 pfi_attach_ifnet_event(void *arg __unused, struct ifnet *ifp)
 {
 
-   CURVNET_SET(ifp->if_vnet);
if (V_pf_vnet_active == 0) {
/* Avoid teardown race in the least expensive way. */
-   CURVNET_RESTORE();
return;
}
pfi_attach_ifnet(ifp);
@@ -812,7 +810,6 @@ pfi_attach_ifnet_event(void *arg __unuse
pf_altq_ifnet_event(ifp, 0);
PF_RULES_WUNLOCK();
 #endif
-   CURVNET_RESTORE();
 }
 
 static void
@@ -823,10 +820,8 @@ pfi_detach_ifnet_event(void *arg __unuse
if (kif == NULL)
return;
 
-   CURVNET_SET(ifp->if_vnet);
if (V_pf_vnet_active == 0) {
/* Avoid teardown race in the least expensive way. */
-   CURVNET_RESTORE();
return;
}
PF_RULES_WLOCK();
@@ -839,32 +834,26 @@ pfi_detach_ifnet_event(void *arg __unuse
pf_altq_ifnet_event(ifp, 1);
 #endif
PF_RULES_WUNLOCK();
-   CURVNET_RESTORE();
 }
 
 static void
-pfi_attach_group_event(void *arg , struct ifg_group *ifg)
+pfi_attach_group_event(void *arg __unused, struct ifg_group *ifg)
 {
 
-   CURVNET_SET((struct vnet *)arg);
if (V_pf_vnet_active == 0) {
/* Avoid teardown race in the least expensive way. */
-   CURVNET_RESTORE();
return;
}
pfi_attach_ifgroup(ifg);
-   CURVNET_RESTORE();
 }
 
 static void
-pfi_change_group_event(void *arg, char *gname)
+pfi_change_group_event(void *arg __unused, char *gname)
 {
struct pfi_kif *kif;
 
-   CURVNET_SET((struct vnet *)arg);
if (V_pf_vnet_active == 0) {
/* Avoid teardown race in the least expensive way. */
-   CURVNET_RESTORE();
return;
}
 
@@ -874,21 +863,18 @@ pfi_change_group_event(void *arg, char *
kif = pfi_kif_attach(kif, gname);
pfi_kif_update(kif);
PF_RULES_WUNLOCK();
-   CURVNET_RESTORE();
 }
 
 static void
-pfi_detach_group_event(void *arg, struct ifg_group *ifg)
+pfi_detach_group_event(void *arg __unused, struct ifg_group *ifg)
 {
struct pfi_kif *kif = (struct pfi_kif *)ifg->ifg_pf_kif;
 
if (kif == NULL)
return;
 
-   CURVNET_SET((struct vnet *)arg);
if (V_pf_vnet_active == 0) {
/* Avoid teardown race in the least expensive way. */
-   CURVNET_RESTORE();
return;
}
PF_RULES_WLOCK();
@@ -897,7 +883,6 @@ pfi_detach_group_event(void *arg, struct
kif->pfik_group = NULL;
ifg->ifg_pf_kif = NULL;
  

svn commit: r304548 - head/sys/netinet

2016-08-20 Thread Marko Zec
Author: zec
Date: Sat Aug 20 22:12:26 2016
New Revision: 304548
URL: https://svnweb.freebsd.org/changeset/base/304548

Log:
  Permit disabling net.inet.udp.require_l2_bcast in VIMAGE kernels.
  
  The default value of the tunable introduced in r304436 couldn't be
  effectively overrided on VIMAGE kernels, because instead of being
  accessed via the appropriate VNET() accessor macro, it was accessed
  via the VNET_NAME() macro, which resolves to the (should-be) read-only
  master template of initial values of per-VNET data.  Hence, while the
  value of udp_require_l2_bcast could be altered on per-VNET basis, the
  code in udp_input() would ignore it as it would always read the default
  value (one) from the VNET master template.
  
  Silence from: rstone

Modified:
  head/sys/netinet/udp_usrreq.c

Modified: head/sys/netinet/udp_usrreq.c
==
--- head/sys/netinet/udp_usrreq.c   Sat Aug 20 21:34:41 2016
(r304547)
+++ head/sys/netinet/udp_usrreq.c   Sat Aug 20 22:12:26 2016
(r304548)
@@ -127,6 +127,7 @@ SYSCTL_INT(_net_inet_udp, OID_AUTO, blac
 "Do not send port unreachables for refused connects");
 
 static VNET_DEFINE(int, udp_require_l2_bcast) = 1;
+#defineV_udp_require_l2_bcast  VNET(udp_require_l2_bcast)
 SYSCTL_INT(_net_inet_udp, OID_AUTO, require_l2_bcast, CTLFLAG_VNET | 
CTLFLAG_RW,
 &VNET_NAME(udp_require_l2_bcast), 0,
 "Only treat packets sent to an L2 broadcast address as broadcast packets");
@@ -528,7 +529,7 @@ udp_input(struct mbuf **mp, int *offp, i
 
pcbinfo = udp_get_inpcbinfo(proto);
if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
-   ((!VNET_NAME(udp_require_l2_bcast) || m->m_flags & M_BCAST) &&
+   ((!V_udp_require_l2_bcast || m->m_flags & M_BCAST) &&
in_broadcast(ip->ip_dst, ifp))) {
struct inpcb *last;
struct inpcbhead *pcblist;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r304436 - in head: . sys/netinet

2016-08-18 Thread Marko Zec
On Thu, 18 Aug 2016 22:59:05 +
Ryan Stone  wrote:

> Author: rstone
> Date: Thu Aug 18 22:59:05 2016
> New Revision: 304436
> URL: https://svnweb.freebsd.org/changeset/base/304436
> 
> Log:
>   Don't check for broadcast IPs on non-bcast pkts
>   
>   in_broadcast() can be quite expensive, so skip calling it if the
>   incoming mbuf wasn't sent to a broadcast L2 address in the first
>   place.
>   
>   Reviewed by: gnn
>   MFC after: 2 months
>   Sponsored by: EMC / Isilon Storage Division
>   Differential Revision: https://reviews.freebsd.org/D7309
> 
> Modified:
>   head/UPDATING
>   head/sys/netinet/udp_usrreq.c
> 
> Modified: head/UPDATING
> ==
> --- head/UPDATING Thu Aug 18 22:59:00 2016(r304435)
> +++ head/UPDATING Thu Aug 18 22:59:05 2016(r304436)
> @@ -32,6 +32,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12
>   "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
>  
>  20160818:
> + The UDP receive code has been updated to only treat incoming
> UDP
> + packets that were addressed to an L2 broadcast address as L3
> + broadcast packets.  It is not expected that this will affect
> any
> + standards-conforming UDP application.  The new behaviour can
> be
> + disabled by setting the sysctl net.inet.udp.require_l2_bcast
> to
> + 0.
> +
> +20160818:
>   Remove the openbsd_poll system call.
>  __FreeBSD_version has been bumped because of this.
>  
> 
> Modified: head/sys/netinet/udp_usrreq.c
> ==
> --- head/sys/netinet/udp_usrreq.c Thu Aug 18 22:59:00
> 2016  (r304435) +++ head/sys/netinet/udp_usrreq.c Thu
> Aug 18 22:59:05 2016  (r304436) @@ -126,6 +126,11 @@
> SYSCTL_INT(_net_inet_udp, OID_AUTO, blac &VNET_NAME(udp_blackhole), 0,
>  "Do not send port unreachables for refused connects");
>  
> +static VNET_DEFINE(int, udp_require_l2_bcast) = 1;
> +SYSCTL_INT(_net_inet_udp, OID_AUTO, require_l2_bcast, CTLFLAG_VNET |
> CTLFLAG_RW,
> +&VNET_NAME(udp_require_l2_bcast), 0,
> +"Only treat packets sent to an L2 broadcast address as broadcast
> packets"); +
>  u_long   udp_sendspace = 9216;   /* really max
> datagram size */ SYSCTL_ULONG(_net_inet_udp, UDPCTL_MAXDGRAM,
> maxdgram, CTLFLAG_RW, &udp_sendspace, 0, "Maximum outgoing UDP
> datagram size"); @@ -523,7 +528,8 @@ udp_input(struct mbuf **mp, int
> *offp, i 
>   pcbinfo = udp_get_inpcbinfo(proto);
>   if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
> - in_broadcast(ip->ip_dst, ifp)) {
> + ((!VNET_NAME(udp_require_l2_bcast) || m->m_flags &
> M_BCAST) &&
> + in_broadcast(ip->ip_dst, ifp))) {
>   struct inpcb *last;
>   struct inpcbhead *pcblist;
>   struct ip_moptions *imo;
> 

VNET_NAME() macros should be used only within SYSCTL_* macros,
otherwise (if I recall it correctly) this won't work with options
VIMAGE enabled, so please don't use VNET_NAME() inside function
bodies, or anywhere else.  An accessor macro needs to resolve the
variable inside the curvnet, and VNET() is the macro which accomplishes
that, while VNET_NAME() doesn't.  The norm is to declare an abbreviated
accessor macro along the VNET_DEFINE() variable declaration, such as:

#define V_udp_require_l2_bcast VNET(udp_require_l2_bcast)

and then to use that accessor macro throught the rest of the code.

Marko
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r302099 - head/sys/netinet

2016-06-23 Thread Marko Zec
On Thu, 23 Jun 2016 00:34:03 +
"Bjoern A. Zeeb"  wrote:

> Author: bz
> Date: Thu Jun 23 00:34:03 2016
> New Revision: 302099
> URL: https://svnweb.freebsd.org/changeset/base/302099
> 
> Log:
>   Check the V_tcbinfo.ipi_count to hit 0 before doing the full TCP
> cleanup. That way timers can finish cleanly and we do not gamble with
> a DELAY(). 
>   Reviewed by:gnn, jtl
>   Approved by:re (gjb)
>   Obtained from:  projects/vnet
>   MFC after:  2 weeks
>   Sponsored by:   The FreeBSD Foundation
>   Differential Revision:  https://reviews.freebsd.org/D6923

As much as this change is welcome, it unnecesarily introduces a
mandatory 100 ms delay on each vnet teardown, which I already pointed
out in a comment to r301601 two weeks ago, which remained unanswered,
along with the question why a delay of 100 ms was introduced here, when
before r302099 the delay was only a single clock tick?  And furthermore
the delay computation expresion here is not style(9) compliant...

Hence, please rectify the above objections, perhaps by something like:

===
--- tcp_subr.c  (revision 302126)
+++ tcp_subr.c  (working copy)
@@ -739,10 +739,11 @@
 * Sleep to let all tcpcb timers really disappear and cleanup.
 */
do {
-   pause("tcpdes", hz/10);
INP_LIST_RLOCK(&V_tcbinfo);
n = V_tcbinfo.ipi_count;
INP_LIST_RUNLOCK(&V_tcbinfo);
+   if (n != 0)
+   pause("tcpdes", hz / 100);
} while (n != 0);
tcp_hc_destroy();
syncache_destroy();

Thanks,

Marko


> 
> Modified:
>   head/sys/netinet/tcp_subr.c
> 
> Modified: head/sys/netinet/tcp_subr.c
> ==
> --- head/sys/netinet/tcp_subr.c   Thu Jun 23 00:32:58
> 2016  (r302098) +++ head/sys/netinet/tcp_subr.c   Thu Jun
> 23 00:34:03 2016  (r302099) @@ -731,18 +731,19 @@ tcp_init(void)
>  static void
>  tcp_destroy(void *unused __unused)
>  {
> - int error;
> + int error, n;
>  
>   /*
>* All our processes are gone, all our sockets should be
> cleaned
>* up, which means, we should be past the tcp_discardcb()
> calls.
> -  * Sleep to let all tcpcb timers really disappear and then
> cleanup.
> -  * Timewait will cleanup its queue and will be ready to go.
> -  * XXX-BZ In theory a few ticks should be good enough to
> make sure
> -  * the timers are all really gone.  We should see if we
> could use a
> -  * better metric here and, e.g., check a tcbcb count as an
> optimization?
> +  * Sleep to let all tcpcb timers really disappear and
> cleanup. */
> - DELAY(100 / hz);
> + do {
> + pause("tcpdes", hz/10);
> + INP_LIST_RLOCK(&V_tcbinfo);
> + n = V_tcbinfo.ipi_count;
> + INP_LIST_RUNLOCK(&V_tcbinfo);
> + } while (n != 0);
>   tcp_hc_destroy();
>   syncache_destroy();
>   tcp_tw_destroy();
> 

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r298477 - in head/sys: conf riscv/riscv

2016-04-22 Thread Marko Zec
On Fri, 22 Apr 2016 16:15:59 +
Ruslan Bukin  wrote:

> Author: br
> Date: Fri Apr 22 16:15:58 2016
> New Revision: 298477
> URL: https://svnweb.freebsd.org/changeset/base/298477
> 
> Log:
>   Clear the DDR memory. This should be done by bootloaders,
>   but they have no such feature yet.
>   
>   This fixes operation on Rocket Core and lowRISC.
> 
> Modified:
>   head/sys/conf/options.riscv
>   head/sys/riscv/riscv/locore.S
> 
> Modified: head/sys/conf/options.riscv
> ==
> --- head/sys/conf/options.riscv   Fri Apr 22 15:12:05
> 2016  (r298476) +++ head/sys/conf/options.riscv   Fri Apr
> 22 16:15:58 2016  (r298477) @@ -2,3 +2,4 @@
>  
>  RISCVopt_global.h
>  VFP  opt_global.h
> +DDR_CLEAR_SIZE   opt_global.h
> 
> Modified: head/sys/riscv/riscv/locore.S
> ==
> --- head/sys/riscv/riscv/locore.S Fri Apr 22 15:12:05
> 2016  (r298476) +++ head/sys/riscv/riscv/locore.S Fri
> Apr 22 16:15:58 2016  (r298477) @@ -126,6 +126,17 @@ _start:
>   csrra0, mhartid
>   bneza0, mpentry
>  
> +#if defined(DDR_CLEAR_SIZE)
> + /* Clear DDR memory */
> + la  t0, _end
> + li  t1, DDR_CLEAR_SIZE
> +1:
> + sd  zero, 0(t0)
> + addit0, t0, 8
> + bltut0, t1, 1b

Usually _end appears to be (double) word aligned, but that happens out
of pure luck, since compilers do not provide firm guarantees about
_end's alignment (at least gcc doesn't, as far as I know).

So depending on which kind of RV this code would run, sometimes it may
end up doing a lot of traps emulating unaligned access in software, or
worse...

Hence it would't hurt to check for _end's alignment first and do a few
byte-by-byte bzero()ing if needed, before proceeding a dword pace.


> + /* End */
> +#endif
> +
>   /* Build event queue for current core */
>   build_ring
>  
> 

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r297742 - head/sys/netinet

2016-04-11 Thread Marko Zec
On Sat, 9 Apr 2016 18:31:24 +
"Bjoern A. Zeeb"  wrote:

> On Sat, 9 Apr 2016, John Baldwin wrote:
> 
> > On Saturday, April 09, 2016 12:05:24 PM Bjoern A. Zeeb wrote:  
> >> Author: bz
> >> Date: Sat Apr  9 12:05:23 2016
> >> New Revision: 297742
> >> URL: https://svnweb.freebsd.org/changeset/base/297742
> >>
> >> Log:
> >>   Mfp: r296310,r296343
> >>
> >>   It looks like as with the safety belt of DELAY() fastened (*) we
> >> can completely tear down and free all memory for TCP (after
> >> r281599).
> >>
> >>   (*) in theory a few ticks should be good enough to make sure the
> >> timers are all really gone. Could we use a better matric here and
> >> check a tcbcb count as an optimization?  
> >
> > In theory, no amount of DELAY() is ever enough to close a
> > theoretical race window.  In practice you might get lucky, but you
> > might also panic and  
> 
> Yes I do understand.  Thus saying a better metric should do the right
> thing.  I am aware of the consequences of removing type stability.
> Should there be reports I'll make sure that DELAY becomes something
> more proper sooner than later.
> 
> 
> > trash user data.  In the rest of the tree, we tend to prefer
> > marking items as NOFREE instead of this approach putting a priority
> > on stability and reliability over memory efficiency.
> >
> > For all of the zones that you removed NOFREE from, do you know why
> > that was added in the first place (e.g. which stale pointers to
> > pcbs could be referenced after free)?  Did you verify that those
> > conditions have been fixed?  
> 
> I did check.  I did check a few years ago (and I think you had
> reviewed that; maybe it was trouble).  And the TCP bits here were
> the last ones that were problematic back then.  With the changes from
> r281599 this should no longer be a problem.
> 
> As for the others, a few years ago Andre already removed the NOFREE
> and we unconditionally made him back the change out, which was a
> mistake as otherwise some of these zones would have been "clean" for
> years.  Others have had KASSERTs ensuring that on VNET stack they were
> actually empty.

Just for the record, another proposal which could have solved this
cleanly years ago but was swiftly rejected short of proper discussion,
was to de-virtualize memory zones used throughout the network stack.

The original thrust behind my decision to virtualize the zones was to
catch any inter-vnet leaks during the initial VNETization efforts.
Today, roughly 10 years after the vnet / vimage changes hit the tree,
during which period no inter-vnet zone leaks have been identified, I
see no reason to keep (most of) the zones separated in multiple
instances.

I've heard arguments that maintaining separate zones may be good for
parallelization due to separation of pcbinfo locks, but such claims
have never been supported by benchmark runs or real-life anecdotal
evidence.  Another argument which was brought up to reject my
proposal, that separate zones provide or could provide inherent
per-vnet resource limiting was also and still is extremely thin,
since the number of items in most networking zones is limited to
maxsockets, which is a shared / global OS limit.

OTOH, it's obvious that maintaining separate zones is not only wasteful
on memory, but likely can contribute to increased D-cache trashing with
traffic spread among multiple vnets.

And finally, as John pointed out, the DELAY(tick) commited here and
deemed a "safety belt" is highly dubious, since sleeping for a single
tick provides no real guarantees against potential races, but rather
works as an umbrella to mask them in some (un)lucky cases.

Nevertheless, I'm glad Bjoern took time to push the vnet framework
further to the point where it could be finally enabled by default, for
which I hope was the main objective behind this sweep, since I find it
absurd that Linux has had vnet-like capability available by default for
years, while we not only pioneered the concept but had it merged in the
main tree years before Linux folks even started their efforts.

Marko
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r294747 - head/sys/net

2016-01-25 Thread Marko Zec
Author: zec
Date: Mon Jan 25 20:35:15 2016
New Revision: 294747
URL: https://svnweb.freebsd.org/changeset/base/294747

Log:
  Prune a definition which is / was never used.

Modified:
  head/sys/net/vnet.c

Modified: head/sys/net/vnet.c
==
--- head/sys/net/vnet.c Mon Jan 25 20:04:06 2016(r294746)
+++ head/sys/net/vnet.c Mon Jan 25 20:35:15 2016(r294747)
@@ -171,7 +171,6 @@ static MALLOC_DEFINE(M_VNET_DATA, "vnet_
  */
 #defineVNET_MODMIN 8192
 #defineVNET_SIZE   roundup2(VNET_BYTES, PAGE_SIZE)
-#defineVNET_MODSIZE(VNET_SIZE - (VNET_BYTES - VNET_MODMIN))
 
 /*
  * Space to store virtualized global variables from loadable kernel modules,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285713 - head/sys/net

2015-07-20 Thread Marko Zec
Author: zec
Date: Mon Jul 20 08:21:51 2015
New Revision: 285713
URL: https://svnweb.freebsd.org/changeset/base/285713

Log:
  Prevent null-pointer dereferencing.
  
  MFC after:3 days

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Mon Jul 20 07:26:31 2015(r285712)
+++ head/sys/net/if.c   Mon Jul 20 08:21:51 2015(r285713)
@@ -335,11 +335,12 @@ ifnet_setbyindex(u_short idx, struct ifn
 struct ifaddr *
 ifaddr_byindex(u_short idx)
 {
-   struct ifaddr *ifa;
+   struct ifnet *ifp;
+   struct ifaddr *ifa = NULL;
 
IFNET_RLOCK_NOSLEEP();
-   ifa = ifnet_byindex_locked(idx)->if_addr;
-   if (ifa != NULL)
+   ifp = ifnet_byindex_locked(idx);
+   if (ifp != NULL && (ifa = ifp->if_addr) != NULL)
ifa_ref(ifa);
IFNET_RUNLOCK_NOSLEEP();
return (ifa);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r275599 - in head/sys/ofed/include: linux net

2014-12-08 Thread Marko Zec
On Mon, 8 Dec 2014 07:26:00 +
Craig Rodrigues  wrote:

> Author: rodrigc
> Date: Mon Dec  8 07:25:59 2014
> New Revision: 275599
> URL: https://svnweb.freebsd.org/changeset/base/275599
> 
> Log:
>   Use CURVNET macros inside inet_get_local_port_range() function.
>   Without this fix, a kernel with VIMAGE + Infiniband will panic on
> bootup.

Why is CURVNET_SET_QUIET() used here instead of plain CURVNET_SET()?

inet_get_local_port_range() seems to be called from only two functions:
cma_alloc_any_port() and cma_init().  Did the panic ocur in both, or
only in cma_init()?  If so, then CURVNET_SET() should have been placed
only inside cma_init() and not in inet_get_local_port_range().

And perhaps all of this stuff could have been completely avoided if
cma_init() was scheduled to fire with curvnet contex already set to
vnet0, using proper SYSINIT scheduling instead of module_init(), i.e.
after SI_SUB_VNET and before SI_SUB_VNET_DONE?

Finally, the comment re. extra #includes and LIST_HEAD seems confusing
since TD_TO_VNET() macro requires both sys/jail.h and net/vnet.h, and
this dependency is unrelated to the LIST_HEAD macro cited in commit log.

Marko


>   Certain necessary #include statements require LIST_HEAD.
>   Add these includes to ofed/include/linux/list.h, because
>   LIST_HEAD is specifically overridden in this file.
>   
>   PR: 191468
>   Differential Revision: D1279
>   Reviewed by: hselasky
> 
> Modified:
>   head/sys/ofed/include/linux/list.h
>   head/sys/ofed/include/net/ip.h
> 
> Modified: head/sys/ofed/include/linux/list.h
> ==
> --- head/sys/ofed/include/linux/list.hMon Dec  8 07:14:25
> 2014  (r275598) +++ head/sys/ofed/include/linux/list.h
> Mon Dec  8 07:25:59 2014  (r275599) @@ -40,6 +40,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -53,6 +54,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> 
> Modified: head/sys/ofed/include/net/ip.h
> ==
> --- head/sys/ofed/include/net/ip.hMon Dec  8 07:14:25
> 2014  (r275598) +++ head/sys/ofed/include/net/ip.hMon
> Dec  8 07:25:59 2014  (r275599) @@ -45,8 +45,10 @@
>  #ifdef INET
>  static inline void inet_get_local_port_range(int *low, int *high)
>  {
> + CURVNET_SET_QUIET(TD_TO_VNET(curthread));
>   *low = V_ipport_firstauto;
>   *high = V_ipport_lastauto;
> + CURVNET_RESTORE();
>  }
>  
>  static inline void
> 

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r272695 - head/sys/net

2014-10-07 Thread Marko Zec
On Tue, 7 Oct 2014 18:17:18 +0400
"Andrey V. Elsukov"  wrote:

> On 07.10.2014 18:04, Marko Zec wrote:
> > On Tue, 7 Oct 2014 13:31:05 +
> > "Andrey V. Elsukov"  wrote:
> > 
> >> Author: ae
> >> Date: Tue Oct  7 13:31:04 2014
> >> New Revision: 272695
> >> URL: https://svnweb.freebsd.org/changeset/base/272695
> >>
> >> Log:
> >>   Our packet filters use mbuf's rcvif pointer to determine incoming
> >> interface. Change mbuf's rcvif to enc0 and restore it after pfil
> >> processing.
> > 
> > Will this work / was this tested with options VIMAGE, where
> > m_pkthdr.rcvif->if_vnet will no longer match curvnet, except in
> > vnet0?
> 
> I tested only without VIMAGE. ipfw and pf use if_xname field to
> compare interfaces. So will this work?

I have no idea whether this would work now, but this change implies that
no pfil consumer should reference m_pkthdr.rcvif->if_vnet from now on,
ever.  Which doesn't seem right to me.

If changing m_pkthdr.rcvif to enc0 in ipsec_filter() is really
unavoidable, perhaps we could introduce enc0 for each vnet, maybe in a
similar manner how hrs@ virtualized gif (271917) and gre (271918)
cloners, which (gif) apparently seem to be at the root of the PR 110959
referenced here.

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r272695 - head/sys/net

2014-10-07 Thread Marko Zec
On Tue, 7 Oct 2014 13:31:05 +
"Andrey V. Elsukov"  wrote:

> Author: ae
> Date: Tue Oct  7 13:31:04 2014
> New Revision: 272695
> URL: https://svnweb.freebsd.org/changeset/base/272695
> 
> Log:
>   Our packet filters use mbuf's rcvif pointer to determine incoming
> interface. Change mbuf's rcvif to enc0 and restore it after pfil
> processing.

Will this work / was this tested with options VIMAGE, where
m_pkthdr.rcvif->if_vnet will no longer match curvnet, except in vnet0?

Marko



>   PR: 110959
>   Sponsored by:   Yandex LLC
> 
> Modified:
>   head/sys/net/if_enc.c
> 
> Modified: head/sys/net/if_enc.c
> ==
> --- head/sys/net/if_enc.c Tue Oct  7 13:30:42 2014
> (r272694) +++ head/sys/net/if_enc.c   Tue Oct  7 13:31:04
> 2014  (r272695) @@ -230,6 +230,7 @@ ipsec_filter(struct mbuf
> **mp, int dir, {
>   int error, i;
>   struct ip *ip;
> + struct ifnet *rcvif;
>  
>   KASSERT(encif != NULL, ("%s: encif is null", __func__));
>   KASSERT(flags & (ENC_IN|ENC_OUT),
> @@ -268,6 +269,8 @@ ipsec_filter(struct mbuf **mp, int dir, 
>   }
>  
>   error = 0;
> + rcvif = (*mp)->m_pkthdr.rcvif;
> + (*mp)->m_pkthdr.rcvif = encif;
>   ip = mtod(*mp, struct ip *);
>   switch (ip->ip_v) {
>  #ifdef INET
> @@ -298,6 +301,7 @@ ipsec_filter(struct mbuf **mp, int dir, 
>   if (error != 0)
>   goto bad;
>  
> + (*mp)->m_pkthdr.rcvif = rcvif;
>   return (error);
>  
>  bad:
> 

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r268083 - head/sys/netipsec

2014-07-01 Thread Marko Zec
Author: zec
Date: Tue Jul  1 08:02:25 2014
New Revision: 268083
URL: http://svnweb.freebsd.org/changeset/base/268083

Log:
  The assumption in ipsec4_process_packet() that the payload may be
  only IPv4 is wrong, so check the IP version before mangling the
  payload header.

Modified:
  head/sys/netipsec/ipsec_output.c

Modified: head/sys/netipsec/ipsec_output.c
==
--- head/sys/netipsec/ipsec_output.cTue Jul  1 07:56:07 2014
(r268082)
+++ head/sys/netipsec/ipsec_output.cTue Jul  1 08:02:25 2014
(r268083)
@@ -498,9 +498,11 @@ ipsec4_process_packet(
goto bad;
}
ip = mtod(m, struct ip *);
-   ip->ip_len = htons(m->m_pkthdr.len);
-   ip->ip_sum = 0;
-   ip->ip_sum = in_cksum(m, ip->ip_hl << 2);
+   if (ip->ip_v == IPVERSION) {
+   ip->ip_len = htons(m->m_pkthdr.len);
+   ip->ip_sum = 0;
+   ip->ip_sum = in_cksum(m, ip->ip_hl << 2);
+   }
 
/* Encapsulate the packet */
error = ipip_output(m, isr, &mp, 0, 0);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r268081 - head/sys/netgraph

2014-07-01 Thread Marko Zec
Author: zec
Date: Tue Jul  1 07:54:12 2014
New Revision: 268081
URL: http://svnweb.freebsd.org/changeset/base/268081

Log:
  Remove any stale mbuf tags from packets being injected into a netgraph
  graph.  In particular, this solves some issues with (probably leaked)
  IPSec-related tags being looped back through netgraph to the inbound
  path which then misinterpreted the stale tags.
  
  MFC after:7 days

Modified:
  head/sys/netgraph/ng_eiface.c

Modified: head/sys/netgraph/ng_eiface.c
==
--- head/sys/netgraph/ng_eiface.c   Tue Jul  1 07:30:29 2014
(r268080)
+++ head/sys/netgraph/ng_eiface.c   Tue Jul  1 07:54:12 2014
(r268081)
@@ -236,6 +236,9 @@ ng_eiface_start2(node_p node, hook_p hoo
if (m == NULL)
break;
 
+   /* Peel the mbuf off any stale tags */
+   m_tag_delete_chain(m, NULL);
+
/*
 * Berkeley packet filter.
 * Pass packet to bpf if there is a listener.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r262215 - head/sys/net

2014-02-19 Thread Marko Zec
Author: zec
Date: Wed Feb 19 08:29:07 2014
New Revision: 262215
URL: http://svnweb.freebsd.org/changeset/base/262215

Log:
  V_irtualize rtsock refcounting, which reduces the chances for panics
  on teardown of vnets without active routing sockets while at least
  one routing socket is active elsewhere.
  
  Tested by:Vijay Singh
  MFC after:3 days

Modified:
  head/sys/net/rtsock.c

Modified: head/sys/net/rtsock.c
==
--- head/sys/net/rtsock.c   Wed Feb 19 08:15:09 2014(r262214)
+++ head/sys/net/rtsock.c   Wed Feb 19 08:29:07 2014(r262215)
@@ -154,12 +154,14 @@ int   (*carp_get_vhid_p)(struct ifaddr *);
  */
 #defineRTS_FILTER_FIB  M_PROTO8
 
-static struct {
+typedef struct {
int ip_count;   /* attached w/ AF_INET */
int ip6_count;  /* attached w/ AF_INET6 */
int ipx_count;  /* attached w/ AF_IPX */
int any_count;  /* total attached */
-} route_cb;
+} route_cb_t;
+static VNET_DEFINE(route_cb_t, route_cb);
+#defineV_route_cb VNET(route_cb)
 
 struct mtx rtsock_mtx;
 MTX_SYSINIT(rtsock, &rtsock_mtx, "rtsock route_cb lock", MTX_DEF);
@@ -317,16 +319,16 @@ rts_attach(struct socket *so, int proto,
RTSOCK_LOCK();
switch(rp->rcb_proto.sp_protocol) {
case AF_INET:
-   route_cb.ip_count++;
+   V_route_cb.ip_count++;
break;
case AF_INET6:
-   route_cb.ip6_count++;
+   V_route_cb.ip6_count++;
break;
case AF_IPX:
-   route_cb.ipx_count++;
+   V_route_cb.ipx_count++;
break;
}
-   route_cb.any_count++;
+   V_route_cb.any_count++;
RTSOCK_UNLOCK();
soisconnected(so);
so->so_options |= SO_USELOOPBACK;
@@ -360,16 +362,16 @@ rts_detach(struct socket *so)
RTSOCK_LOCK();
switch(rp->rcb_proto.sp_protocol) {
case AF_INET:
-   route_cb.ip_count--;
+   V_route_cb.ip_count--;
break;
case AF_INET6:
-   route_cb.ip6_count--;
+   V_route_cb.ip6_count--;
break;
case AF_IPX:
-   route_cb.ipx_count--;
+   V_route_cb.ipx_count--;
break;
}
-   route_cb.any_count--;
+   V_route_cb.any_count--;
RTSOCK_UNLOCK();
raw_usrreqs.pru_detach(so);
 }
@@ -943,7 +945,7 @@ flush:
 * Check to see if we don't want our own messages.
 */
if ((so->so_options & SO_USELOOPBACK) == 0) {
-   if (route_cb.any_count <= 1) {
+   if (V_route_cb.any_count <= 1) {
if (rtm)
Free(rtm);
m_freem(m);
@@ -1274,7 +1276,7 @@ rt_missmsg_fib(int type, struct rt_addri
struct mbuf *m;
struct sockaddr *sa = rtinfo->rti_info[RTAX_DST];
 
-   if (route_cb.any_count == 0)
+   if (V_route_cb.any_count == 0)
return;
m = rt_msg1(type, rtinfo);
if (m == NULL)
@@ -1312,7 +1314,7 @@ rt_ifmsg(struct ifnet *ifp)
struct mbuf *m;
struct rt_addrinfo info;
 
-   if (route_cb.any_count == 0)
+   if (V_route_cb.any_count == 0)
return;
bzero((caddr_t)&info, sizeof(info));
m = rt_msg1(RTM_IFINFO, &info);
@@ -1342,7 +1344,7 @@ rtsock_addrmsg(int cmd, struct ifaddr *i
struct ifa_msghdr *ifam;
struct ifnet *ifp = ifa->ifa_ifp;
 
-   if (route_cb.any_count == 0)
+   if (V_route_cb.any_count == 0)
return (0);
 
ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR;
@@ -1390,7 +1392,7 @@ rtsock_routemsg(int cmd, struct ifnet *i
struct mbuf *m;
struct rt_msghdr *rtm;
 
-   if (route_cb.any_count == 0)
+   if (V_route_cb.any_count == 0)
return (0);
 
bzero((caddr_t)&info, sizeof(info));
@@ -1428,7 +1430,7 @@ rt_newmaddrmsg(int cmd, struct ifmultiad
struct ifnet *ifp = ifma->ifma_ifp;
struct ifma_msghdr *ifmam;
 
-   if (route_cb.any_count == 0)
+   if (V_route_cb.any_count == 0)
return;
 
bzero((caddr_t)&info, sizeof(info));
@@ -1457,7 +1459,7 @@ rt_makeifannouncemsg(struct ifnet *ifp, 
struct if_announcemsghdr *ifan;
struct mbuf *m;
 
-   if (route_cb.any_count == 0)
+   if (V_route_cb.any_count == 0)
return NULL;
bzero((caddr_t)info, sizeof(*info));
m = rt_msg1(type, info);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r257868 - head/sys/netgraph

2013-11-08 Thread Marko Zec
Author: zec
Date: Fri Nov  8 22:40:33 2013
New Revision: 257868
URL: http://svnweb.freebsd.org/changeset/base/257868

Log:
  Eliminate duplicated & dead code.
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_pipe.c

Modified: head/sys/netgraph/ng_pipe.c
==
--- head/sys/netgraph/ng_pipe.c Fri Nov  8 22:29:07 2013(r257867)
+++ head/sys/netgraph/ng_pipe.c Fri Nov  8 22:40:33 2013(r257868)
@@ -705,35 +705,6 @@ ngp_rcvdata(hook_p hook, item_p item)
}
hinfo->run.qin_frames--;
hinfo->stats.in_disc_frames++;
-   } else if (hinfo->run.qin_frames > hinfo->cfg.qin_size_limit) {
-   struct mbuf *m1;
-   int longest = 0;
-
-   /* Find the longest queue */
-   TAILQ_FOREACH(ngp_f1, &hinfo->fifo_head, fifo_le)
-   if (ngp_f1->packets > longest) {
-   longest = ngp_f1->packets;
-   ngp_f = ngp_f1;
-   }
-
-   /* Drop a frame from the queue head/tail, depending on cfg */
-   if (hinfo->cfg.drophead) 
-   ngp_h = TAILQ_FIRST(&ngp_f->packet_head);
-   else 
-   ngp_h = TAILQ_LAST(&ngp_f->packet_head, p_head);
-   TAILQ_REMOVE(&ngp_f->packet_head, ngp_h, ngp_link);
-   m1 = ngp_h->m;
-   uma_zfree(ngp_zone, ngp_h);
-   hinfo->run.qin_octets -= m1->m_pkthdr.len;
-   hinfo->stats.in_disc_octets += m1->m_pkthdr.len;
-   m_freem(m1);
-   if (--(ngp_f->packets) == 0) {
-   TAILQ_REMOVE(&hinfo->fifo_head, ngp_f, fifo_le);
-   uma_zfree(ngp_zone, ngp_f);
-   hinfo->run.fifo_queues--;
-   }
-   hinfo->run.qin_frames--;
-   hinfo->stats.in_disc_frames++;
}
 
/*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r228969 - head/sys/netinet

2013-10-18 Thread Marko Zec
On Friday 18 October 2013 12:09:16 Gleb Smirnoff wrote:
> On Fri, Oct 18, 2013 at 12:07:35AM +0200, Marko Zec wrote:
> M> > Concerning this more general solution from Gleb, with storing the
> vnet M> > pointer in the task, I wander how it is safe when the vnet is
> being M> > removed?
> M> >
> M> > In vnet_destroy() the vnet interfaces are moved back to their parent
> M> > vnets, so setting the vnet context from the interface looks safer.
> M>
> M> +1
> M>
> M> Gleb,
> M>
> M> what exactly was the justification for embedding a vnet context inside
> M> struct task, when it could have been easily embedded, directly or
> M> indirectly, inside the object pointed to by ta_context?
> M>
> M> What is / was your plan to garbage collect such stale pointers?
> M>
> M> At least in the early days of VIMAGE / VNET hacking, all the people
> involved M> strived very hard to store backpointers to vnets in as few
> structs as M> possible, and for quite a while we managed to constrain
> this to only ifnets M> and sockets, and both of those references are
> refcounted in struct vnet.
>
> And my change is in the same direction, isn't it?

No, it is not.

1) you're not refcounting tasks in struct vnet, so when a vnet is freed you 
can't be sure (in a generic way) that there are no pending tasks referencig 
that vnet;

2) taskqueue is a general-purpose facility, not network-stack specialized, 
so you can't afford a luxury to keep non-refcounted references to vnets in 
struct task, since there's no guarantee a task will go away before the 
referenced vnet is destroyed.  In your particular example you're probably 
doing the right thing in pf cleanup code, but then the reference to a vnet 
should be kept in a pf-related object, not struct task.

> We will store vnet 
> pointer only in the struct task, not in all structs that ta_context may
> point at.
>
> M> Now, more (unreferenced) backpointers to struct vnet seem to be
> popping up M> here and there, but in most cases they are embedded in
> objects which are M> guaranteed to persist only as long as the referenced
> vnet is alive.  One M> notable exception to this rule is struct tcpcb
> which apparently can outlive M> vnet teardowns under certain conditions,
> but this is a known issue which M> needs to be fixed, not a precedent
> which calls for more timebombs to be M> scattered around the source tree.
> M>
> M> So pls. reconsider solving the issue at hand using a different
> approach, and M> back out r256587.
>
> I don't see problem here. When a vnet is destroyed, every facility is
> notified to tear down its vnet related data. In pf(4) that would mean,
> that the task is freed, and would never be put again on taskqueue. So I
> don't see any leaks or dereferences of dead vnet here.

Just as you described here, it is the pf(4) code which gets notified on vnet 
teardowns, not some generic taskqueue subroutine, so the right place to 
hold a vnet pointer is in a pf-related struct, not struct task.

I'm also surprised noone else chimed in to object to this obviously 
unnecessary layering violation, since up to this point there were no 
inherent dependencies between taskqueues and vnets, and now you are 
introducing one for no good reason.

Again, please remove vnet references from struct task.

Thanks,

Marko


> I have just looked into multicast code and see that it takes another
> approach. The task is single and global, and it sets vnet context
> per-option. Well, my patch won't hurt its operation. Just orthogonal
> approach.


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r228969 - head/sys/netinet

2013-10-17 Thread Marko Zec
On Thursday 17 October 2013 21:35:46 Mikolaj Golub wrote:
> On Wed, Oct 16, 2013 at 05:09:04PM -0400, John Baldwin wrote:
> ...
>
> > >  >> #10 0x80b6f1fd in igmp_change_state (inm=0x8ae70480)
> > >  >> at /home/golub/freebsd/base/head/sys/netinet/igmp.c:2595
> > >  >> #11 0x80b76f68 in in_leavegroup_locked (inm=0x8ae70480,
> > >  >> imf=0x8a655a00) at
> > >  >> /home/golub/freebsd/base/head/sys/netinet/in_mcast.c:1239 #12
> > >  >> 0x80b76fbd in in_leavegroup (inm=0x8ae70480, imf=0x8a655a00) at
> > >  >> /home/golub/freebsd/base/head/sys/netinet/in_mcast.c:1184 #13
> > >  >> 0x80b770b4 in inp_gcmoptions (context=0x0, pending=1) at
> > >  >> /home/golub/freebsd/base/head/sys/netinet/in_mcast.c:1554 #14
> > >  >> 0x80a8ff2b in taskqueue_run_locked (queue=0x87594880) at
> > >  >> /home/golub/freebsd/base/head/sys/kern/subr_taskqueue.c:308 #15
> > >  >> 0x80a90987 in taskqueue_thread_loop (arg=0x81186bcc) at
> > >  >> /home/golub/freebsd/base/head/sys/kern/subr_taskqueue.c:497 #16
> > >  >> 0x80a1b2d8 in fork_exit (callout=0x80a90920
> > >  >> , arg=0x81186bcc,
> > >  >> frame=0x872b2d28) at
> > >  >> /home/golub/freebsd/base/head/sys/kern/kern_fork.c:992
>
> ...
>
> > >  >> VNET context is not set at that point.
>
> ...
>
> > I think this was just fixed by glebius@ in r256587:
> >
> > Author: glebius
> > Date: Wed Oct 16 05:02:01 2013
> > New Revision: 256587
> > URL: http://svnweb.freebsd.org/changeset/base/256587
> >
> > Log:
> >   For VIMAGE kernels store vnet in the struct task, and set vnet
> > context during task processing.
> >
> >   Reported & tested by: mm
>
> I think that particular issue was fixed earlier by hrs in r252510:
>
>   Fix a panic when leaving MC group in a kernel with VIMAGE enabled.
>   in_leavegroup() is called from an asynchronous task, and
>   igmp_change_state() requires that curvnet is set by the caller.
>
> Concerning this more general solution from Gleb, with storing the vnet
> pointer in the task, I wander how it is safe when the vnet is being
> removed?
>
> In vnet_destroy() the vnet interfaces are moved back to their parent
> vnets, so setting the vnet context from the interface looks safer.

+1

Gleb,

what exactly was the justification for embedding a vnet context inside 
struct task, when it could have been easily embedded, directly or 
indirectly, inside the object pointed to by ta_context?

What is / was your plan to garbage collect such stale pointers?

At least in the early days of VIMAGE / VNET hacking, all the people involved 
strived very hard to store backpointers to vnets in as few structs as 
possible, and for quite a while we managed to constrain this to only ifnets 
and sockets, and both of those references are refcounted in struct vnet.

Now, more (unreferenced) backpointers to struct vnet seem to be popping up 
here and there, but in most cases they are embedded in objects which are 
guaranteed to persist only as long as the referenced vnet is alive.  One 
notable exception to this rule is struct tcpcb which apparently can outlive 
vnet teardowns under certain conditions, but this is a known issue which 
needs to be fixed, not a precedent which calls for more timebombs to be 
scattered around the source tree.

So pls. reconsider solving the issue at hand using a different approach, and 
back out r256587.

Thanks,

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253346 - in head/sys: kern net netgraph netgraph/bluetooth/socket

2013-07-25 Thread Marko Zec
On Thursday 25 July 2013 16:27:43 Marius Strobl wrote:
> On Thu, Jul 25, 2013 at 12:24:53PM +0200, Marko Zec wrote:
> > On Thursday 25 July 2013 11:36:46 Craig Rodrigues wrote:
> > > On Thu, Jul 25, 2013 at 1:07 AM, Marius Strobl
> >
> > wrote:
> > > > Uhm - do we really need to have that layering violation in
> > > > subr_bus.c? Wouldn't it be sufficient to set curthread->td_vnet to
> > > > vnet0 in if_alloc(9) or if_attach(9) at least instead?
> > >
> > > There was some discussion about this involving Marko Zec,  Adrian
> > > Chadd, and myself
> > > starting in this thread:
> > >
> > > http://lists.freebsd.org/pipermail/svn-src-all/2013-July/071798.html
> > >
> > > Adrian and Marko converged on similar patches:
> > >
> > > http://lists.freebsd.org/pipermail/freebsd-hackers/2012-November/0411
> > >20.h tml
> > > http://people.freebsd.org/~adrian/ath/20130712-vimage-default-attach-
> > >deta ch.diff
> > >
> > >
> > > As Marko mentioned in another e-mail on this thread, the patch as it
> > > is necessary in
> > > order to fix VIMAGE related kernel panics in many different
> > > scenarios, including
> > > ones involving Netgraph nodes.
> >
> > Moreover, unconditionally setting curvnet to vnet0 in if_alloc(),
> > if_attach() or similar places as suggested my Marius simply couldn't
> > work, because that would break creation of pseudo-interfaces inside
> > non-vnet0 contexts (such as vlan, ng_ether, ng_eiface etc.).
>
> Well, I didn't say that it shall be unconditional; in a previous
> version of the patch Adrian also set it conditionally only in case
> vnet isn't vnet0 in device_probe_and_attach() so it seems viable to
> check whether that's needed in a particular context.

When a function which is expected to be called with curvnet properly set is 
called with curvnet being NULL, it should panic (or crash), not guess which 
vnet the caller should have set, but failed to do.  Otherwise, we would 
have tons of subtle inter-vnet leaks (towards vnet0) which could be very 
difficult to track and nail down.  Hell, why not set curvnet to vnet0 at 
boot time and NEVER revert it back to NULL, while only occasionally 
switching to non-default vnets - how would we swim in that kind of mud?

> As for Netgraph nodes I don't know how these are attached to devices
> but a quick look at the code suggests that f. e. ng_make_node_common()
> would be a good candidate for setting vnet to vnet0 if necessary.
> Moving this network specific stuff out of the generic device layer
> would also make things consistent and symmetric given that r253346
> added setting vnet to if_detach(), if_free() and ng_unref_node().

In all the functions you're refering to here, vnet context is unambiguously 
defined by the object passed as function's argument, so it is perfectly 
safe to do CURVNET_SET(ifp->if_vnet) or CURVNET_SET(ng_node->nd_vnet), 
which is very different from the proposal for pure guessing in if_attach() 
etc. which I am strongly opposed to.

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253346 - in head/sys: kern net netgraph netgraph/bluetooth/socket

2013-07-25 Thread Marko Zec
On Thursday 25 July 2013 11:36:46 Craig Rodrigues wrote:
> On Thu, Jul 25, 2013 at 1:07 AM, Marius Strobl 
wrote:
> > Uhm - do we really need to have that layering violation in subr_bus.c?
> > Wouldn't it be sufficient to set curthread->td_vnet to vnet0 in
> > if_alloc(9) or if_attach(9) at least instead?
>
> There was some discussion about this involving Marko Zec,  Adrian Chadd,
> and myself
> starting in this thread:
>
> http://lists.freebsd.org/pipermail/svn-src-all/2013-July/071798.html
>
> Adrian and Marko converged on similar patches:
>
> http://lists.freebsd.org/pipermail/freebsd-hackers/2012-November/041120.h
>tml
> http://people.freebsd.org/~adrian/ath/20130712-vimage-default-attach-deta
>ch.diff
>
>
> As Marko mentioned in another e-mail on this thread, the patch as it is
> necessary in
> order to fix VIMAGE related kernel panics in many different scenarios,
> including
> ones involving Netgraph nodes.

Moreover, unconditionally setting curvnet to vnet0 in if_alloc(), 
if_attach() or similar places as suggested my Marius simply couldn't work, 
because that would break creation of pseudo-interfaces inside non-vnet0 
contexts (such as vlan, ng_ether, ng_eiface etc.).

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253346 - in head/sys: kern net netgraph netgraph/bluetooth/socket

2013-07-25 Thread Marko Zec
On Thursday 25 July 2013 10:07:58 Marius Strobl wrote:
> On Mon, Jul 15, 2013 at 01:32:55AM +, Craig Rodrigues wrote:
> > Author: rodrigc
> > Date: Mon Jul 15 01:32:55 2013
> > New Revision: 253346
> > URL: http://svnweb.freebsd.org/changeset/base/253346
> >
> > Log:
> >   PR: 168520 170096
> >   Submitted by: adrian, zec
> >
> >   Fix multiple kernel panics when VIMAGE is enabled in the kernel.
> >   These fixes are based on patches submitted by Adrian Chadd and Marko
> > Zec.
> >
> >   (1)  Set curthread->td_vnet to vnet0 in device_probe_and_attach()
> > just before calling device_attach().  This fixes multiple VIMAGE
> > related kernel panics when trying to attach Bluetooth or USB Ethernet
> > devices because curthread->td_vnet is NULL.
> >
> >   (2)  Set curthread->td_vnet in if_detach().  This fixes kernel panics
> > when detaching networking interfaces, especially USB Ethernet devices.
> >
> >   (3)  Use VNET_DOMAIN_SET() in ng_btsocket.c
> >
> >   (4)  In ng_unref_node() set curthread->td_vnet.  This fixes kernel
> > panics when detaching Netgraph nodes.
> >
> > Modified:
> >   head/sys/kern/subr_bus.c
> >   head/sys/net/if.c
> >   head/sys/netgraph/bluetooth/socket/ng_btsocket.c
> >   head/sys/netgraph/ng_base.c
> >
> > Modified: head/sys/kern/subr_bus.c
> > ===
> >=== --- head/sys/kern/subr_bus.c Mon Jul 15 00:49:10 2013
> >(r253345)
> > +++ head/sys/kern/subr_bus.cMon Jul 15 01:32:55 2013
> > (r253346) @@
> > -53,6 +53,8 @@ __FBSDID("$FreeBSD$");
> >  #include 
> >  #include 
> >
> > +#include 
> > +
> >  #include 
> >
> >  #include 
> > @@ -2735,7 +2737,11 @@ device_probe_and_attach(device_t dev)
> > return (0);
> > else if (error != 0)
> > return (error);
> > -   return (device_attach(dev));
> > +
> > +   CURVNET_SET_QUIET(vnet0);
> > +   error = device_attach(dev);
> > +   CURVNET_RESTORE();
> > +   return error;
> >  }
>
> Uhm - do we really need to have that layering violation in subr_bus.c?
> Wouldn't it be sufficient to set curthread->td_vnet to vnet0 in
> if_alloc(9) or if_attach(9) at least instead?

That wouldn't solve the issues with attaching netgraph node(s) to the 
arriving device, nor potentially other issues unrelated to if_alloc or 
if_attach.

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r253255 - head/sys/netgraph/bluetooth/drivers/ubt

2013-07-13 Thread Marko Zec
On Saturday 13 July 2013 09:31:19 Mikolaj Golub wrote:
> On Fri, Jul 12, 2013 at 10:40:08PM -0700, Adrian Chadd wrote:
> > Here's what I have running on my stable/9 VIMAGE laptop.
> >
> > http://people.freebsd.org/~adrian/ath/20130712-vimage-default-attach-de
> >tach.diff
> >
> > How's this look to put into -HEAD?
>
> Your patch looks similar to Marko's:
>
> http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20121115/0
>824ca85/attachment.diff
>
> Marko took your idea of setting vnet0 context in
> device_probe_and_attach(), although there is no is_default_vnet check,
> and I also think it is not necessary here -- just unconditionally set
> vnet0 is ok.
>
> Also, as I understand, after handling vnet context in
> device_probe_and_attach(), there is no need in curvnet setting in
> kldload/kldunload, and Marko removed it.
>
> In net/if.c, similarly to you, Marko sets vnet context in if_detach(),
> but also in if_free(), so this would be good to commit too (I suppose
> Marko had good reasons to do this).
>
> I can't comment the netgraph related parts of your patch as I have no
> idea what is going on here. Though I think this could be committed
> separately if it is needed.

I fear both Adrian's and my patch fall short of addressing the issue of 
generic USB device attach handling in VIMAGE kernels, i.e. the patches 
discussed in this thread might be OK for preventing panics with ng_ubt, but 
what about USB ethernet or wifi devices?  If I recall correctly the USB 
stack has a separate thread which handles device attach events, and IMO the 
curvnet context should be set there to cover a broader set of different 
devices.

I might be able to find an USB ethernet device for testing next week, but 
ATM I don't have any piece of USB hardware I could experiment with...

Marko

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r250744 - stable/9/sys/netinet

2013-05-17 Thread Marko Zec
Author: zec
Date: Fri May 17 17:45:00 2013
New Revision: 250744
URL: http://svnweb.freebsd.org/changeset/base/250744

Log:
  MFC 233601:
Permit tcpdrop in VNET jails.

Modified:
  stable/9/sys/netinet/tcp_subr.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/tcp_subr.c
==
--- stable/9/sys/netinet/tcp_subr.c Fri May 17 17:16:29 2013
(r250743)
+++ stable/9/sys/netinet/tcp_subr.c Fri May 17 17:45:00 2013
(r250744)
@@ -2192,7 +2192,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS)
return (error);
 }
 
-SYSCTL_PROC(_net_inet_tcp, TCPCTL_DROP, drop,
+SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_DROP, drop,
 CTLTYPE_STRUCT|CTLFLAG_WR|CTLFLAG_SKIP, NULL,
 0, sysctl_drop, "", "Drop TCP connection");
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r246245 - head/sys/netgraph

2013-02-04 Thread Marko Zec
On Monday 04 February 2013 10:42:31 Andriy Gapon wrote:
> on 04/02/2013 10:27 Marko Zec said the following:
> > On Monday 04 February 2013 08:41:32 Andriy Gapon wrote:
> >> +  /* Only ethernet interfaces are of interest. */
> >> +  if (ifp->if_type != IFT_ETHER)
> >> +  return;
> >
> > And what about IFT_FDDI, IFT_XETHER, IFT_ISO88025, IFT_L2VLAN,
> > IFT_BRIDGE, IFT_ARCNET, IFT_IEEE8023ADLAG, IFT_IEEE80211?
>
> Oh, I didn't realize that many drivers changed if_type after if_alloc.
> Honestly, the networking code is not my strong skill, I ventured here
> only because nobody else did...
>
> So what do you suggest?  if_alloctype or a different approach?
> I'd like to prevent if_l2com being mis-interpreted as struct arpcom.

We already have this in vnet_ng_ether_init():

865 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
866 if (ifp->if_type == IFT_ETHER
867 || ifp->if_type == IFT_L2VLAN)
868 ng_ether_attach(ifp);
869 }

So at least in ng_ether_ifnet_arrival_event() we should do a check 
consistent to the above code.  OTOH we don't check for interface types on 
entry into ng_ether_attach(), and perhaps a better strategy would be to 
move your ifp->if_type check there.  Perhaps the check could be #defined as 
a macro to ensure consistency between vnet_ng_ether_init() and 
ng_ether_attach()?

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r246245 - head/sys/netgraph

2013-02-04 Thread Marko Zec
On Monday 04 February 2013 08:41:32 Andriy Gapon wrote:
> on 04/02/2013 02:37 Mark Johnston said the following:
> > On Sat, Feb 02, 2013 at 11:54:00AM +, Andriy Gapon wrote:
> >> Author: avg
> >> Date: Sat Feb  2 11:54:00 2013
> >> New Revision: 246245
> >> URL: http://svnweb.freebsd.org/changeset/base/246245
> >>
> >> Log:
> >>   ng_ether: track interface renaming
> >>
> >>   Also sanitize interface names that can potentially contain
> >> characters that are prohibited in netgraph names.
> >>
> >>   PR:  kern/154850 (sanitizing of names)
> >>   Discussed with:  eri, melifaro
> >>   Submitted by:Nikolay Denev  (sanitizing code)
> >>   Reviewed by: eri, glebius
> >>   MFC after:   17 days
> >>
> >> Modified:
> >>   head/sys/netgraph/ng_ether.c
> >
> > Hi Andriy,
> >
> > This commit seems to cause a panic during boot when creating the
> > loopback interface. I couldn't get a core dump but the problem seems to
> > happen when dereferencing ifp->if_l2com in the IFP2NG macro in
> > ng_ether_ifnet_arrival_event(). In the case of lo(4) this pointer seems
> > to be NULL (I suppose because lo(4) doesn't register itself in the
> > if_com_alloc/free tables).
> >
> > The patch below fixes the panic for me.
>
> Mark,
>
> thank you for the report and sorry for the breakage.
> Could you please try the following patch (slightly different from your
> patch)?
>
> diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
> index 6266f40..05ea402 100644
> --- a/sys/netgraph/ng_ether.c
> +++ b/sys/netgraph/ng_ether.c
> @@ -410,11 +410,16 @@ static void
>  ng_ether_ifnet_arrival_event(void *arg __unused, struct ifnet *ifp)
>  {
>   char name[IFNAMSIZ];
> - node_p node = IFP2NG(ifp);
> + node_p node;
> +
> + /* Only ethernet interfaces are of interest. */
> + if (ifp->if_type != IFT_ETHER)
> + return;


And what about IFT_FDDI, IFT_XETHER, IFT_ISO88025, IFT_L2VLAN, IFT_BRIDGE, 
IFT_ARCNET, IFT_IEEE8023ADLAG, IFT_IEEE80211?

Marko


>   /*
>* Just return if it's a new interface without an ng_ether companion.
>*/
> + node = IFP2NG(ifp);
>   if (node == NULL)
>   return;
>
> > diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
> > index 6266f40..f566346 100644
> > --- a/sys/netgraph/ng_ether.c
> > +++ b/sys/netgraph/ng_ether.c
> > @@ -410,7 +410,12 @@ static void
> >  ng_ether_ifnet_arrival_event(void *arg __unused, struct ifnet *ifp)
> >  {
> > char name[IFNAMSIZ];
> > -   node_p node = IFP2NG(ifp);
> > +   node_p node;
> > +
> > +   if (ifp->if_l2com == NULL)
> > +   return;
> > +
> > +   node = IFP2NG(ifp);
> >
> > /*
> >  * Just return if it's a new interface without an ng_ether companion.


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r234341 - head/sys/netgraph

2012-04-16 Thread Marko Zec
Author: zec
Date: Mon Apr 16 13:41:46 2012
New Revision: 234341
URL: http://svn.freebsd.org/changeset/base/234341

Log:
  #include  is no longer needed here.
  
  Spotted by:   Ed Maste
  MFC after:3 days.

Modified:
  head/sys/netgraph/ng_source.c

Modified: head/sys/netgraph/ng_source.c
==
--- head/sys/netgraph/ng_source.c   Mon Apr 16 12:49:19 2012
(r234340)
+++ head/sys/netgraph/ng_source.c   Mon Apr 16 13:41:46 2012
(r234341)
@@ -68,7 +68,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r233605 - in stable/8/sys: i386/conf netinet

2012-03-28 Thread Marko Zec
Author: zec
Date: Wed Mar 28 12:46:12 2012
New Revision: 233605
URL: http://svn.freebsd.org/changeset/base/233605

Log:
  MFC r232517:
Change SYSINIT priorities so that ip_mroute_modevent() is executed
before vnet_mroute_init(), since vnet_mroute_init() depends on mfchashsize
tunable to be set, and that is done in in ip_mroute_modevent().
Apparently I broke that ordering with r208744 almost 2 years ago...
  
PR:   kern/162201
Submitted by: Stevan Markovic (mcafee.com)
MFC after:3 days

Modified:
  stable/8/sys/netinet/ip_mroute.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/boot/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/e1000/   (props changed)
  stable/8/sys/i386/conf/XENHVM   (props changed)

Modified: stable/8/sys/netinet/ip_mroute.c
==
--- stable/8/sys/netinet/ip_mroute.cWed Mar 28 12:45:35 2012
(r233604)
+++ stable/8/sys/netinet/ip_mroute.cWed Mar 28 12:46:12 2012
(r233605)
@@ -2822,7 +2822,7 @@ vnet_mroute_init(const void *unused __un
callout_init(&V_bw_meter_ch, CALLOUT_MPSAFE);
 }
 
-VNET_SYSINIT(vnet_mroute_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, 
vnet_mroute_init,
+VNET_SYSINIT(vnet_mroute_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_mroute_init,
NULL);
 
 static void
@@ -2945,4 +2945,4 @@ static moduledata_t ip_mroutemod = {
 0
 };
 
-DECLARE_MODULE(ip_mroute, ip_mroutemod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(ip_mroute, ip_mroutemod, SI_SUB_PSEUDO, SI_ORDER_MIDDLE);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r233604 - in stable/9/sys: i386/conf netinet

2012-03-28 Thread Marko Zec
Author: zec
Date: Wed Mar 28 12:45:35 2012
New Revision: 233604
URL: http://svn.freebsd.org/changeset/base/233604

Log:
  MFC r232517:
Change SYSINIT priorities so that ip_mroute_modevent() is executed
before vnet_mroute_init(), since vnet_mroute_init() depends on mfchashsize
tunable to be set, and that is done in in ip_mroute_modevent().
Apparently I broke that ordering with r208744 almost 2 years ago...
  
PR:   kern/162201
Submitted by: Stevan Markovic (mcafee.com)
MFC after:3 days

Modified:
  stable/9/sys/netinet/ip_mroute.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/i386/conf/XENHVM   (props changed)

Modified: stable/9/sys/netinet/ip_mroute.c
==
--- stable/9/sys/netinet/ip_mroute.cWed Mar 28 12:41:17 2012
(r233603)
+++ stable/9/sys/netinet/ip_mroute.cWed Mar 28 12:45:35 2012
(r233604)
@@ -2822,7 +2822,7 @@ vnet_mroute_init(const void *unused __un
callout_init(&V_bw_meter_ch, CALLOUT_MPSAFE);
 }
 
-VNET_SYSINIT(vnet_mroute_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, 
vnet_mroute_init,
+VNET_SYSINIT(vnet_mroute_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_mroute_init,
NULL);
 
 static void
@@ -2945,4 +2945,4 @@ static moduledata_t ip_mroutemod = {
 0
 };
 
-DECLARE_MODULE(ip_mroute, ip_mroutemod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(ip_mroute, ip_mroutemod, SI_SUB_PSEUDO, SI_ORDER_MIDDLE);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r233603 - in stable/8/sys: i386/conf net

2012-03-28 Thread Marko Zec
Author: zec
Date: Wed Mar 28 12:41:17 2012
New Revision: 233603
URL: http://svn.freebsd.org/changeset/base/233603

Log:
  MFC 232487:
Properly restore curvnet context when returning early from
ether_input_internal().
  
This change only affects options VIMAGE kernel builds.
  
PR:   kern/165643
Submitted by: Vijay Singh
MFC after:3 days

Modified:
  stable/8/sys/net/if_ethersubr.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/boot/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/e1000/   (props changed)
  stable/8/sys/i386/conf/XENHVM   (props changed)

Modified: stable/8/sys/net/if_ethersubr.c
==
--- stable/8/sys/net/if_ethersubr.c Wed Mar 28 12:40:30 2012
(r233602)
+++ stable/8/sys/net/if_ethersubr.c Wed Mar 28 12:41:17 2012
(r233603)
@@ -660,8 +660,10 @@ ether_input(struct ifnet *ifp, struct mb
m = (*lagg_input_p)(ifp, m);
if (m != NULL)
ifp = m->m_pkthdr.rcvif;
-   else 
+   else {
+   CURVNET_RESTORE();
return;
+   }
}
 
/*
@@ -680,6 +682,7 @@ ether_input(struct ifnet *ifp, struct mb
 #endif
ifp->if_ierrors++;
m_freem(m);
+   CURVNET_RESTORE();
return;
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r233602 - in stable/9/sys: i386/conf net

2012-03-28 Thread Marko Zec
Author: zec
Date: Wed Mar 28 12:40:30 2012
New Revision: 233602
URL: http://svn.freebsd.org/changeset/base/233602

Log:
  MFC: 232487
Properly restore curvnet context when returning early from
ether_input_internal().
  
This change only affects options VIMAGE kernel builds.
  
PR:   kern/165643
Submitted by: Vijay Singh
MFC after:3 days

Modified:
  stable/9/sys/net/if_ethersubr.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/i386/conf/XENHVM   (props changed)

Modified: stable/9/sys/net/if_ethersubr.c
==
--- stable/9/sys/net/if_ethersubr.c Wed Mar 28 12:30:16 2012
(r233601)
+++ stable/9/sys/net/if_ethersubr.c Wed Mar 28 12:40:30 2012
(r233602)
@@ -661,8 +661,10 @@ ether_input_internal(struct ifnet *ifp, 
m = (*lagg_input_p)(ifp, m);
if (m != NULL)
ifp = m->m_pkthdr.rcvif;
-   else 
+   else {
+   CURVNET_RESTORE();
return;
+   }
}
 
/*
@@ -681,6 +683,7 @@ ether_input_internal(struct ifnet *ifp, 
 #endif
ifp->if_ierrors++;
m_freem(m);
+   CURVNET_RESTORE();
return;
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r233601 - head/sys/netinet

2012-03-28 Thread Marko Zec
Author: zec
Date: Wed Mar 28 12:30:16 2012
New Revision: 233601
URL: http://svn.freebsd.org/changeset/base/233601

Log:
  Permit tcpdrop in VNET jails.
  
  Submitted by: Miljenko Mikuc
  MFC after:3 days

Modified:
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Wed Mar 28 12:11:54 2012(r233600)
+++ head/sys/netinet/tcp_subr.c Wed Mar 28 12:30:16 2012(r233601)
@@ -2184,7 +2184,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS)
return (error);
 }
 
-SYSCTL_PROC(_net_inet_tcp, TCPCTL_DROP, drop,
+SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_DROP, drop,
 CTLTYPE_STRUCT|CTLFLAG_WR|CTLFLAG_SKIP, NULL,
 0, sysctl_drop, "", "Drop TCP connection");
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r232868 - head/sys/netinet/ipfw

2012-03-12 Thread Marko Zec
On Monday 12 March 2012 16:41:36 Alexander V. Chernikov wrote:
> Author: melifaro
> Date: Mon Mar 12 15:41:36 2012
> New Revision: 232868
> URL: http://svn.freebsd.org/changeset/base/232868
>
> Log:
>   Fix VNET build broken by r232865.
>   Temporary remove the ability to assign different number of tables per
> VNET instance.

Please don't let your code remain in this state for too long.  You've declared 
V_fw_tables_max to unconditionally resolve to a true global variable, which 
violates the convention of using V_ prefix in networking code exclusively for 
the purpose of denoting VNET-virtualized state.

Thanks,

Marko


> Modified:
>   head/sys/netinet/ipfw/ip_fw2.c
>   head/sys/netinet/ipfw/ip_fw_private.h
>
> Modified: head/sys/netinet/ipfw/ip_fw2.c
> ===
>=== --- head/sys/netinet/ipfw/ip_fw2.c Mon Mar 12 15:13:17 2012
>(r232867)
> +++ head/sys/netinet/ipfw/ip_fw2.cMon Mar 12 15:41:36 2012
> (r232868) @@
> -117,7 +117,7 @@ VNET_DEFINE(int, autoinc_step);
>  VNET_DEFINE(int, fw_one_pass) = 1;
>
>  /* Use 128 tables by default */
> -VNET_DEFINE(int, fw_tables_max) = IPFW_TABLES_MAX;
> +int fw_tables_max = IPFW_TABLES_MAX;
>
>  /*
>   * Each rule belongs to one of 32 different sets (0..31).
>
> Modified: head/sys/netinet/ipfw/ip_fw_private.h
> ===
>=== --- head/sys/netinet/ipfw/ip_fw_private.h  Mon Mar 12 15:13:17
> 2012  (r232867) +++ head/sys/netinet/ipfw/ip_fw_private.h Mon Mar 12
> 15:41:36 2012 (r232868) @@ -209,8 +209,8 @@ VNET_DECLARE(u_int32_t,
> set_disable);
>  VNET_DECLARE(int, autoinc_step);
>  #define V_autoinc_step   VNET(autoinc_step)
>
> -VNET_DECLARE(int, fw_tables_max);
> -#define V_fw_tables_max  VNET(fw_tables_max)
> +extern int fw_tables_max;
> +#define V_fw_tables_max  fw_tables_max
>
>  struct ip_fw_chain {
>   struct ip_fw*rules; /* list of rules */


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r232517 - head/sys/netinet

2012-03-04 Thread Marko Zec
Author: zec
Date: Sun Mar  4 18:59:38 2012
New Revision: 232517
URL: http://svn.freebsd.org/changeset/base/232517

Log:
  Change SYSINIT priorities so that ip_mroute_modevent() is executed
  before vnet_mroute_init(), since vnet_mroute_init() depends on mfchashsize
  tunable to be set, and that is done in in ip_mroute_modevent().
  Apparently I broke that ordering with r208744 almost 2 years ago...
  
  PR:   kern/162201
  Submitted by: Stevan Markovic (mcafee.com)
  MFC after:3 days

Modified:
  head/sys/netinet/ip_mroute.c

Modified: head/sys/netinet/ip_mroute.c
==
--- head/sys/netinet/ip_mroute.cSun Mar  4 18:55:33 2012
(r232516)
+++ head/sys/netinet/ip_mroute.cSun Mar  4 18:59:38 2012
(r232517)
@@ -2822,7 +2822,7 @@ vnet_mroute_init(const void *unused __un
callout_init(&V_bw_meter_ch, CALLOUT_MPSAFE);
 }
 
-VNET_SYSINIT(vnet_mroute_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, 
vnet_mroute_init,
+VNET_SYSINIT(vnet_mroute_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_mroute_init,
NULL);
 
 static void
@@ -2945,4 +2945,4 @@ static moduledata_t ip_mroutemod = {
 0
 };
 
-DECLARE_MODULE(ip_mroute, ip_mroutemod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(ip_mroute, ip_mroutemod, SI_SUB_PSEUDO, SI_ORDER_MIDDLE);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r232487 - head/sys/net

2012-03-04 Thread Marko Zec
Author: zec
Date: Sun Mar  4 11:11:03 2012
New Revision: 232487
URL: http://svn.freebsd.org/changeset/base/232487

Log:
  Properly restore curvnet context when returning early from
  ether_input_internal().
  
  This change only affects options VIMAGE kernel builds.
  
  PR:   kern/165643
  Submitted by: Vijay Singh
  MFC after:3 days

Modified:
  head/sys/net/if_ethersubr.c

Modified: head/sys/net/if_ethersubr.c
==
--- head/sys/net/if_ethersubr.c Sun Mar  4 10:37:26 2012(r232486)
+++ head/sys/net/if_ethersubr.c Sun Mar  4 11:11:03 2012(r232487)
@@ -661,8 +661,10 @@ ether_input_internal(struct ifnet *ifp, 
m = (*lagg_input_p)(ifp, m);
if (m != NULL)
ifp = m->m_pkthdr.rcvif;
-   else 
+   else {
+   CURVNET_RESTORE();
return;
+   }
}
 
/*
@@ -681,6 +683,7 @@ ether_input_internal(struct ifnet *ifp, 
 #endif
ifp->if_ierrors++;
m_freem(m);
+   CURVNET_RESTORE();
return;
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r224215 - stable/8/sys/netgraph

2011-07-19 Thread Marko Zec
Author: zec
Date: Tue Jul 19 11:04:58 2011
New Revision: 224215
URL: http://svn.freebsd.org/changeset/base/224215

Log:
  MFC r224107:
Clear pending ifnet events, in an attempt at preventing
ng_ether_link_state() from being dispatched after we have
cleared our IFP2NG(ifp).

Modified:
  stable/8/sys/netgraph/ng_ether.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/netgraph/ng_ether.c
==
--- stable/8/sys/netgraph/ng_ether.cTue Jul 19 10:53:47 2011
(r224214)
+++ stable/8/sys/netgraph/ng_ether.cTue Jul 19 11:04:58 2011
(r224215)
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -336,6 +337,7 @@ ng_ether_detach(struct ifnet *ifp)
const node_p node = IFP2NG(ifp);
const priv_p priv = NG_NODE_PRIVATE(node);
 
+   taskqueue_drain(taskqueue_swi, &ifp->if_linktask);
NG_NODE_REALLY_DIE(node);   /* Force real removal of node */
/*
 * We can't assume the ifnet is still around when we run shutdown
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r224107 - head/sys/netgraph

2011-07-16 Thread Marko Zec
Author: zec
Date: Sat Jul 16 19:11:45 2011
New Revision: 224107
URL: http://svn.freebsd.org/changeset/base/224107

Log:
  Clear pending ifnet events, in an attempt at preventing
  ng_ether_link_state() from being dispatched after we have
  cleared our IFP2NG(ifp).
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_ether.c

Modified: head/sys/netgraph/ng_ether.c
==
--- head/sys/netgraph/ng_ether.cSat Jul 16 19:01:09 2011
(r224106)
+++ head/sys/netgraph/ng_ether.cSat Jul 16 19:11:45 2011
(r224107)
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -336,6 +337,7 @@ ng_ether_detach(struct ifnet *ifp)
const node_p node = IFP2NG(ifp);
const priv_p priv = NG_NODE_PRIVATE(node);
 
+   taskqueue_drain(taskqueue_swi, &ifp->if_linktask);
NG_NODE_REALLY_DIE(node);   /* Force real removal of node */
/*
 * We can't assume the ifnet is still around when we run shutdown
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r223948 - in stable/8/sys: net netinet netinet6

2011-07-12 Thread Marko Zec
Author: zec
Date: Tue Jul 12 12:29:32 2011
New Revision: 223948
URL: http://svn.freebsd.org/changeset/base/223948

Log:
  MFC r223862:
Permit ARP to proceed for IPv4 host routes for which the gateway is the
same as the host address.  This already works fine for INET6 and ND6.
  
While here, remove two function pointers from struct lltable which are
only initialized but never used.

Modified:
  stable/8/sys/net/if_llatbl.h
  stable/8/sys/netinet/in.c
  stable/8/sys/netinet6/in6.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/net/if_llatbl.h
==
--- stable/8/sys/net/if_llatbl.hTue Jul 12 11:47:08 2011
(r223947)
+++ stable/8/sys/net/if_llatbl.hTue Jul 12 12:29:32 2011
(r223948)
@@ -146,15 +146,12 @@ struct lltable {
int llt_af;
struct ifnet*llt_ifp;
 
-   struct llentry *(*llt_new)(const struct sockaddr *, u_int);
void(*llt_free)(struct lltable *, struct llentry *);
void(*llt_prefix_free)(struct lltable *,
const struct sockaddr *prefix,
const struct sockaddr *mask);
struct llentry *(*llt_lookup)(struct lltable *, u_int flags,
const struct sockaddr *l3addr);
-   int (*llt_rtcheck)(struct ifnet *, u_int flags,
-   const struct sockaddr *);
int (*llt_dump)(struct lltable *,
 struct sysctl_req *);
 };

Modified: stable/8/sys/netinet/in.c
==
--- stable/8/sys/netinet/in.c   Tue Jul 12 11:47:08 2011(r223947)
+++ stable/8/sys/netinet/in.c   Tue Jul 12 12:29:32 2011(r223948)
@@ -1399,6 +1399,18 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
 
/* XXX rtalloc1 should take a const param */
rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0);
+
+   /*
+* If the gateway for an existing host route matches the target L3
+* address, allow for ARP to proceed.
+*/
+   if (rt != NULL && (rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) &&
+   rt->rt_gateway->sa_family == AF_INET &&
+   memcmp(rt->rt_gateway->sa_data, l3addr->sa_data, 4) == 0) {
+   RTFREE_LOCKED(rt);
+   return (0);
+   }
+
if (rt == NULL || (!(flags & LLE_PUB) &&
   ((rt->rt_flags & RTF_GATEWAY) || 
(rt->rt_ifp != ifp {
@@ -1581,10 +1593,8 @@ in_domifattach(struct ifnet *ifp)
 
llt = lltable_init(ifp, AF_INET);
if (llt != NULL) {
-   llt->llt_new = in_lltable_new;
llt->llt_free = in_lltable_free;
llt->llt_prefix_free = in_lltable_prefix_free;
-   llt->llt_rtcheck = in_lltable_rtcheck;
llt->llt_lookup = in_lltable_lookup;
llt->llt_dump = in_lltable_dump;
}

Modified: stable/8/sys/netinet6/in6.c
==
--- stable/8/sys/netinet6/in6.c Tue Jul 12 11:47:08 2011(r223947)
+++ stable/8/sys/netinet6/in6.c Tue Jul 12 12:29:32 2011(r223948)
@@ -2581,10 +2581,8 @@ in6_domifattach(struct ifnet *ifp)
ext->scope6_id = scope6_ifattach(ifp);
ext->lltable = lltable_init(ifp, AF_INET6);
if (ext->lltable != NULL) {
-   ext->lltable->llt_new = in6_lltable_new;
ext->lltable->llt_free = in6_lltable_free;
ext->lltable->llt_prefix_free = in6_lltable_prefix_free;
-   ext->lltable->llt_rtcheck = in6_lltable_rtcheck;
ext->lltable->llt_lookup = in6_lltable_lookup;
ext->lltable->llt_dump = in6_lltable_dump;
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r223862 - in head/sys: net netinet netinet6

2011-07-08 Thread Marko Zec
On Friday 08 July 2011 12:08:49 Andre Oppermann wrote:
> On 08.07.2011 11:38, Marko Zec wrote:
> > Author: zec
> > Date: Fri Jul  8 09:38:33 2011
> > New Revision: 223862
> > URL: http://svn.freebsd.org/changeset/base/223862
> >
> > Log:
> >Permit ARP to proceed for IPv4 host routes for which the gateway is
> > the same as the host address.  This already works fine for INET6 and ND6.
>
> Can you give an example what this does? Is it some sort of proxy ARP?


It is a bugfix.  Consider this example on a pre-223862 kernel:

cp12# ifconfig re0 10.0.0.2/24

cp12# ping -c 1 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=0.335 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.285/0.285/0.285/0.000 ms

So far, so good, but:

cp12# arp -da
10.0.0.2 (10.0.0.2) deleted
10.0.0.1 (10.0.0.1) deleted

cp12# route add 10.0.0.1 10.0.0.1
add host 10.0.0.1: gateway 10.0.0.1

cp12# netstat -rnf inet
DestinationGatewayFlagsRefs  Use  Netif Expire
10.0.0.0/24link#1 U   01re0
10.0.0.1   10.0.0.1   UGHS00re0
10.0.0.2   link#1 UHS 00lo0
127.0.0.1  link#11UH  05lo0

cp12# ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
ping: sendto: Invalid argument
ping: sendto: Invalid argument
^C
--- 10.0.0.1 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss

cp12# dmesg | tail -2
arpresolve: can't allocate llinfo for 10.0.0.1
arpresolve: can't allocate llinfo for 10.0.0.1


With 223862 this scenario is no longer a problem:

cp12# ifconfig re0 10.0.0.2/24

cp12# route add 10.0.0.1 10.0.0.1
add host 10.0.0.1: gateway 10.0.0.1

cp12# netstat -rnf inet
DestinationGatewayFlagsRefs  Use  Netif Expire
10.0.0.0/24link#1 U   00re0
10.0.0.1   10.0.0.1   UGHS00re0
10.0.0.2   link#1 UHS 00lo0
127.0.0.1  link#11UH  04lo0

cp12# ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=0.578 ms  <-- ARP pingpong here
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.134 ms
^C
--- 10.0.0.1 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.134/0.356/0.578/0.222 ms


> >While here, remove two function pointers from struct lltable which are
> >only initialized but never used.
>
> Ideally this would have been a separate commit because it has nothing to
> do with primary functional change.


You're right, sorry for the noise...

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r223862 - in head/sys: net netinet netinet6

2011-07-08 Thread Marko Zec
Author: zec
Date: Fri Jul  8 09:38:33 2011
New Revision: 223862
URL: http://svn.freebsd.org/changeset/base/223862

Log:
  Permit ARP to proceed for IPv4 host routes for which the gateway is the
  same as the host address.  This already works fine for INET6 and ND6.
  
  While here, remove two function pointers from struct lltable which are
  only initialized but never used.
  
  MFC after:3 days

Modified:
  head/sys/net/if_llatbl.h
  head/sys/netinet/in.c
  head/sys/netinet6/in6.c

Modified: head/sys/net/if_llatbl.h
==
--- head/sys/net/if_llatbl.hFri Jul  8 09:20:32 2011(r223861)
+++ head/sys/net/if_llatbl.hFri Jul  8 09:38:33 2011(r223862)
@@ -151,7 +151,6 @@ struct lltable {
int llt_af;
struct ifnet*llt_ifp;
 
-   struct llentry *(*llt_new)(const struct sockaddr *, u_int);
void(*llt_free)(struct lltable *, struct llentry *);
void(*llt_prefix_free)(struct lltable *,
const struct sockaddr *prefix,
@@ -159,8 +158,6 @@ struct lltable {
u_int flags);
struct llentry *(*llt_lookup)(struct lltable *, u_int flags,
const struct sockaddr *l3addr);
-   int (*llt_rtcheck)(struct ifnet *, u_int flags,
-   const struct sockaddr *);
int (*llt_dump)(struct lltable *,
 struct sysctl_req *);
 };

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Fri Jul  8 09:20:32 2011(r223861)
+++ head/sys/netinet/in.c   Fri Jul  8 09:38:33 2011(r223862)
@@ -1416,6 +1416,18 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
 
/* XXX rtalloc1 should take a const param */
rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0);
+
+   /*
+* If the gateway for an existing host route matches the target L3
+* address, allow for ARP to proceed.
+*/
+   if (rt != NULL && (rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) &&
+   rt->rt_gateway->sa_family == AF_INET &&
+   memcmp(rt->rt_gateway->sa_data, l3addr->sa_data, 4) == 0) {
+   RTFREE_LOCKED(rt);
+   return (0);
+   }
+
if (rt == NULL || (!(flags & LLE_PUB) &&
   ((rt->rt_flags & RTF_GATEWAY) || 
(rt->rt_ifp != ifp {
@@ -1599,10 +1611,8 @@ in_domifattach(struct ifnet *ifp)
 
llt = lltable_init(ifp, AF_INET);
if (llt != NULL) {
-   llt->llt_new = in_lltable_new;
llt->llt_free = in_lltable_free;
llt->llt_prefix_free = in_lltable_prefix_free;
-   llt->llt_rtcheck = in_lltable_rtcheck;
llt->llt_lookup = in_lltable_lookup;
llt->llt_dump = in_lltable_dump;
}

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Fri Jul  8 09:20:32 2011(r223861)
+++ head/sys/netinet6/in6.c Fri Jul  8 09:38:33 2011(r223862)
@@ -2636,10 +2636,8 @@ in6_domifattach(struct ifnet *ifp)
ext->scope6_id = scope6_ifattach(ifp);
ext->lltable = lltable_init(ifp, AF_INET6);
if (ext->lltable != NULL) {
-   ext->lltable->llt_new = in6_lltable_new;
ext->lltable->llt_free = in6_lltable_free;
ext->lltable->llt_prefix_free = in6_lltable_prefix_free;
-   ext->lltable->llt_rtcheck = in6_lltable_rtcheck;
ext->lltable->llt_lookup = in6_lltable_lookup;
ext->lltable->llt_dump = in6_lltable_dump;
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r223860 - stable/8/sys/net

2011-07-08 Thread Marko Zec
Author: zec
Date: Fri Jul  8 09:18:50 2011
New Revision: 223860
URL: http://svn.freebsd.org/changeset/base/223860

Log:
  MFC r222834:
Set curvnet context in a callout-trigerred code path.

Modified:
  stable/8/sys/net/bridgestp.c
  stable/8/sys/net/bridgestp.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/net/bridgestp.c
==
--- stable/8/sys/net/bridgestp.cFri Jul  8 09:17:25 2011
(r223859)
+++ stable/8/sys/net/bridgestp.cFri Jul  8 09:18:50 2011
(r223860)
@@ -1860,6 +1860,8 @@ bstp_tick(void *arg)
if (bs->bs_running == 0)
return;
 
+   CURVNET_SET(bs->bs_vnet);
+
/* slow timer to catch missed link events */
if (bstp_timer_expired(&bs->bs_link_timer)) {
LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
@@ -1893,6 +1895,8 @@ bstp_tick(void *arg)
bp->bp_txcount--;
}
 
+   CURVNET_RESTORE();
+
callout_reset(&bs->bs_bstpcallout, hz, bstp_tick, bs);
 }
 
@@ -2126,6 +2130,7 @@ bstp_attach(struct bstp_state *bs, struc
bs->bs_protover = BSTP_PROTO_RSTP;
bs->bs_state_cb = cb->bcb_state;
bs->bs_rtage_cb = cb->bcb_rtage;
+   bs->bs_vnet = curvnet;
 
getmicrotime(&bs->bs_last_tc_time);
 

Modified: stable/8/sys/net/bridgestp.h
==
--- stable/8/sys/net/bridgestp.hFri Jul  8 09:17:25 2011
(r223859)
+++ stable/8/sys/net/bridgestp.hFri Jul  8 09:18:50 2011
(r223860)
@@ -358,6 +358,7 @@ struct bstp_state {
LIST_HEAD(, bstp_port)  bs_bplist;
bstp_state_cb_t bs_state_cb;
bstp_rtage_cb_t bs_rtage_cb;
+   struct vnet *bs_vnet;
 };
 
 #defineBSTP_LOCK_INIT(_bs) mtx_init(&(_bs)->bs_mtx, "bstp", NULL, 
MTX_DEF)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r222834 - head/sys/net

2011-06-07 Thread Marko Zec
Author: zec
Date: Tue Jun  7 20:46:03 2011
New Revision: 222834
URL: http://svn.freebsd.org/changeset/base/222834

Log:
  Set curvnet context in a callout-trigerred code path.
  
  MFC after:3 days

Modified:
  head/sys/net/bridgestp.c
  head/sys/net/bridgestp.h

Modified: head/sys/net/bridgestp.c
==
--- head/sys/net/bridgestp.cTue Jun  7 19:39:34 2011(r222833)
+++ head/sys/net/bridgestp.cTue Jun  7 20:46:03 2011(r222834)
@@ -1860,6 +1860,8 @@ bstp_tick(void *arg)
if (bs->bs_running == 0)
return;
 
+   CURVNET_SET(bs->bs_vnet);
+
/* slow timer to catch missed link events */
if (bstp_timer_expired(&bs->bs_link_timer)) {
LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
@@ -1893,6 +1895,8 @@ bstp_tick(void *arg)
bp->bp_txcount--;
}
 
+   CURVNET_RESTORE();
+
callout_reset(&bs->bs_bstpcallout, hz, bstp_tick, bs);
 }
 
@@ -2126,6 +2130,7 @@ bstp_attach(struct bstp_state *bs, struc
bs->bs_protover = BSTP_PROTO_RSTP;
bs->bs_state_cb = cb->bcb_state;
bs->bs_rtage_cb = cb->bcb_rtage;
+   bs->bs_vnet = curvnet;
 
getmicrotime(&bs->bs_last_tc_time);
 

Modified: head/sys/net/bridgestp.h
==
--- head/sys/net/bridgestp.hTue Jun  7 19:39:34 2011(r222833)
+++ head/sys/net/bridgestp.hTue Jun  7 20:46:03 2011(r222834)
@@ -358,6 +358,7 @@ struct bstp_state {
LIST_HEAD(, bstp_port)  bs_bplist;
bstp_state_cb_t bs_state_cb;
bstp_rtage_cb_t bs_rtage_cb;
+   struct vnet *bs_vnet;
 };
 
 #defineBSTP_LOCK_INIT(_bs) mtx_init(&(_bs)->bs_mtx, "bstp", NULL, 
MTX_DEF)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r222347 - stable/8/sys/netgraph

2011-05-27 Thread Marko Zec
Author: zec
Date: Fri May 27 08:43:59 2011
New Revision: 222347
URL: http://svn.freebsd.org/changeset/base/222347

Log:
  MFC r57:
Assume the link to be dead if bit error rate (BER) parameter is set to 1.
When a transition from link alive to link dead configuration or vice
versa occurs, notify any upstream and / or downstream peers using
NGM_FLOW messagges.
  
Link state notification using NGM_FLOW messages is modelled around
around already existing code in ng_ether.c.

Modified:
  stable/8/sys/netgraph/ng_pipe.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/netgraph/ng_pipe.c
==
--- stable/8/sys/netgraph/ng_pipe.c Fri May 27 08:43:03 2011
(r222346)
+++ stable/8/sys/netgraph/ng_pipe.c Fri May 27 08:43:59 2011
(r222347)
@@ -300,11 +300,12 @@ ngp_rcvmsg(node_p node, item_p item, hoo
 {
const priv_p priv = NG_NODE_PRIVATE(node);
struct ng_mesg *resp = NULL;
-   struct ng_mesg *msg;
+   struct ng_mesg *msg, *flow_msg;
struct ng_pipe_stats *stats;
struct ng_pipe_run *run;
struct ng_pipe_cfg *cfg;
int error = 0;
+   int prev_down, now_down, cmd;
 
NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
@@ -405,10 +406,38 @@ ngp_rcvmsg(node_p node, item_p item, hoo
cfg->header_offset < 64)
priv->header_offset = cfg->header_offset;
 
+   prev_down = priv->upper.cfg.ber == 1 ||
+   priv->lower.cfg.ber == 1;
parse_cfg(&priv->upper.cfg, &cfg->downstream,
&priv->upper, priv);
parse_cfg(&priv->lower.cfg, &cfg->upstream,
&priv->lower, priv);
+   now_down = priv->upper.cfg.ber == 1 ||
+   priv->lower.cfg.ber == 1;
+
+   if (prev_down != now_down) {
+   if (now_down)
+   cmd = NGM_LINK_IS_DOWN;
+   else
+   cmd = NGM_LINK_IS_UP;
+
+   if (priv->lower.hook != NULL) {
+   NG_MKMESSAGE(flow_msg, NGM_FLOW_COOKIE,
+   cmd, 0, M_NOWAIT);
+   if (flow_msg != NULL)
+   NG_SEND_MSG_HOOK(error, node,
+   flow_msg, priv->lower.hook,
+   0);
+   }
+   if (priv->upper.hook != NULL) {
+   NG_MKMESSAGE(flow_msg, NGM_FLOW_COOKIE,
+   cmd, 0, M_NOWAIT);
+   if (flow_msg != NULL)
+   NG_SEND_MSG_HOOK(error, node,
+   flow_msg, priv->upper.hook,
+   0);
+   }
+   }
break;
default:
error = EINVAL;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r222346 - stable/8/sys/netgraph

2011-05-27 Thread Marko Zec
Author: zec
Date: Fri May 27 08:43:03 2011
New Revision: 222346
URL: http://svn.freebsd.org/changeset/base/222346

Log:
  MFC r55:
Provide fake link status information in an attempt to let ng_eiface(4)
virtual ifnets more realistically mimic physical ethernet interfaces.
The main motivation behind this change is to allow for ng_eiface(4)
interfaces to participate in STP if_bridge(4) configurations.
  
When announcing link status changes, switch to the vnet to which the
ifnet belongs, since it is possible for ng_eiface ifnets to be assigned
to a vnet different from the one in which its netgraph node resides.

Modified:
  stable/8/sys/netgraph/ng_eiface.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/netgraph/ng_eiface.c
==
--- stable/8/sys/netgraph/ng_eiface.c   Fri May 27 08:41:57 2011
(r222345)
+++ stable/8/sys/netgraph/ng_eiface.c   Fri May 27 08:43:03 2011
(r222346)
@@ -41,6 +41,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -76,6 +77,8 @@ static const struct ng_cmdlist ng_eiface
 /* Node private data */
 struct ng_eiface_private {
struct ifnet*ifp;   /* per-interface network data */
+   struct ifmedia  media;  /* (fake) media information */
+   int link_status;/* fake */
int unit;   /* Interface unit number */
node_p  node;   /* Our netgraph node */
hook_p  ether;  /* Hook for ethernet stream */
@@ -127,6 +130,7 @@ static VNET_DEFINE(struct unrhdr *, ng_e
 static int
 ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 {
+   const priv_p priv = (priv_p)ifp->if_softc;
struct ifreq *const ifr = (struct ifreq *)data;
int s, error = 0;
 
@@ -170,6 +174,12 @@ ng_eiface_ioctl(struct ifnet *ifp, u_lon
ifp->if_mtu = ifr->ifr_mtu;
break;
 
+   /* (Fake) media type manipulation */
+   case SIOCSIFMEDIA:
+   case SIOCGIFMEDIA:
+   error = ifmedia_ioctl(ifp, ifr, &priv->media, command);
+   break;
+
/* Stuff that's not supported */
case SIOCADDMULTI:
case SIOCDELMULTI:
@@ -280,7 +290,6 @@ ng_eiface_start2(node_p node, hook_p hoo
 static void
 ng_eiface_start(struct ifnet *ifp)
 {
-
const priv_p priv = (priv_p)ifp->if_softc;
 
/* Don't do anything if output is active */
@@ -328,6 +337,41 @@ ng_eiface_print_ioctl(struct ifnet *ifp,
 }
 #endif /* DEBUG */
 
+/*
+ * ifmedia stuff
+ */
+static int
+ng_eiface_mediachange(struct ifnet *ifp)
+{
+   const priv_p priv = (priv_p)ifp->if_softc;
+   struct ifmedia *ifm = &priv->media;
+
+   if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
+   return (EINVAL);
+   if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO)
+   ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T);
+   else
+   ifp->if_baudrate = ifmedia_baudrate(ifm->ifm_media);
+
+   return (0);
+}
+
+static void
+ng_eiface_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
+{
+   const priv_p priv = (priv_p)ifp->if_softc;
+   struct ifmedia *ifm = &priv->media;
+
+   if (ifm->ifm_cur->ifm_media == (IFM_ETHER | IFM_AUTO) &&
+   (priv->link_status & IFM_ACTIVE))
+   ifmr->ifm_active = IFM_ETHER | IFM_1000_T | IFM_FDX;
+   else
+   ifmr->ifm_active = ifm->ifm_cur->ifm_media;
+   ifmr->ifm_status = priv->link_status;
+
+   return;
+}
+
 /
NETGRAPH NODE STUFF
  /
@@ -373,6 +417,18 @@ ng_eiface_constructor(node_p node)
ifp->if_flags = (IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST);
ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
ifp->if_capenable = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
+   ifmedia_init(&priv->media, 0, ng_eiface_mediachange,
+   ng_eiface_mediastatus);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
+   ifm

svn commit: r222345 - stable/8/sys/net

2011-05-27 Thread Marko Zec
Author: zec
Date: Fri May 27 08:41:57 2011
New Revision: 222345
URL: http://svn.freebsd.org/changeset/base/222345

Log:
  MFC r47:
Allow for vlan(4) interfaces with MTU of 1500 bytes to be configured
on top of epair(4) virtual interfaces, since there's no physical
hardware associated with epair interfaces which would imply any
constraints on MTU sizes.

Modified:
  stable/8/sys/net/if_epair.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/net/if_epair.c
==
--- stable/8/sys/net/if_epair.c Fri May 27 08:40:26 2011(r222344)
+++ stable/8/sys/net/if_epair.c Fri May 27 08:41:57 2011(r222345)
@@ -810,6 +810,8 @@ epair_clone_create(struct if_clone *ifc,
ifp->if_dname = ifc->ifc_name;
ifp->if_dunit = unit;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+   ifp->if_capabilities = IFCAP_VLAN_MTU;
+   ifp->if_capenable = IFCAP_VLAN_MTU;
ifp->if_start = epair_start;
ifp->if_ioctl = epair_ioctl;
ifp->if_init  = epair_init;
@@ -834,6 +836,8 @@ epair_clone_create(struct if_clone *ifc,
ifp->if_dname = ifc->ifc_name;
ifp->if_dunit = unit;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+   ifp->if_capabilities = IFCAP_VLAN_MTU;
+   ifp->if_capenable = IFCAP_VLAN_MTU;
ifp->if_start = epair_start;
ifp->if_ioctl = epair_ioctl;
ifp->if_init  = epair_init;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r222344 - stable/8/sys/net

2011-05-27 Thread Marko Zec
Author: zec
Date: Fri May 27 08:40:26 2011
New Revision: 222344
URL: http://svn.freebsd.org/changeset/base/222344

Log:
  MFC r46:
Let epair(4) virtual interfaces report fake link / media status,
by borrowing the skeleton of if_media manipulation and reporting
code from if_lagg(4).  The main motivation behind this change is
to allow for epair(4) interfaces to participate in STP if_bridge(4)
configurations.
  
Reviewed by:  bz

Modified:
  stable/8/sys/net/if_epair.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/net/if_epair.c
==
--- stable/8/sys/net/if_epair.c Fri May 27 08:34:31 2011(r222343)
+++ stable/8/sys/net/if_epair.c Fri May 27 08:40:26 2011(r222344)
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -92,6 +93,8 @@ static struct mbuf *epair_nh_m2cpuid(str
 static void epair_nh_drainedcpu(u_int);
 
 static void epair_start_locked(struct ifnet *);
+static int epair_media_change(struct ifnet *);
+static void epair_media_status(struct ifnet *, struct ifmediareq *);
 
 static int epair_clone_match(struct if_clone *, const char *);
 static int epair_clone_create(struct if_clone *, char *, size_t, caddr_t);
@@ -127,6 +130,7 @@ SYSCTL_PROC(_net_link_epair, OID_AUTO, n
 struct epair_softc {
struct ifnet*ifp;   /* This ifp. */
struct ifnet*oifp;  /* other ifp of pair. */
+   struct ifmedia  media;  /* Media config (fake). */
u_int   refcount;   /* # of mbufs in flight. */
u_int   cpuid;  /* CPU ID assigned upon creation. */
void(*if_qflush)(struct ifnet *);
@@ -611,8 +615,25 @@ epair_qflush(struct ifnet *ifp)
 }
 
 static int
+epair_media_change(struct ifnet *ifp __unused)
+{
+
+   /* Do nothing. */
+   return (0);
+}
+
+static void
+epair_media_status(struct ifnet *ifp __unused, struct ifmediareq *imr)
+{
+
+   imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
+   imr->ifm_active = IFM_ETHER | IFM_10G_T | IFM_FDX;
+}
+
+static int
 epair_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
+   struct epair_softc *sc;
struct ifreq *ifr;
int error;
 
@@ -624,6 +645,12 @@ epair_ioctl(struct ifnet *ifp, u_long cm
error = 0;
break;
 
+   case SIOCSIFMEDIA:
+   case SIOCGIFMEDIA:
+   sc = ifp->if_softc;
+   error = ifmedia_ioctl(ifp, ifr, &sc->media, cmd);
+   break;
+
case SIOCSIFMTU:
/* We basically allow all kinds of MTUs. */
ifp->if_mtu = ifr->ifr_mtu;
@@ -829,6 +856,14 @@ epair_clone_create(struct if_clone *ifc,
strlcpy(name, sca->ifp->if_xname, len);
DPRINTF("name='%s/%db' created sca=%p scb=%p\n", name, unit, sca, scb);
 
+   /* Initialise pseudo media types. */
+   ifmedia_init(&sca->media, 0, epair_media_change, epair_media_status);
+   ifmedia_add(&sca->media, IFM_ETHER | IFM_10G_T, 0, NULL);
+   ifmedia_set(&sca->media, IFM_ETHER | IFM_10G_T);
+   ifmedia_init(&scb->media, 0, epair_media_change, epair_media_status);
+   ifmedia_add(&scb->media, IFM_ETHER | IFM_10G_T, 0, NULL);
+   ifmedia_set(&scb->media, IFM_ETHER | IFM_10G_T);
+
/* Tell the world, that we are ready to rock. */
sca->ifp->if_drv_flags |= IFF_DRV_RUNNING;
scb->ifp->if_drv_flags |= IFF_DRV_RUNNING;
@@ -895,6 +930,8 @@ epair_clone_destroy(struct if_clone *ifc
if_free(oifp);
CURVNET_RESTORE();
if_free(ifp);
+   ifmedia_removeall(&sca->media);
+   ifmedia_removeall(&scb->media);
free(scb, M_EPAIR);
free(sca, M_EPAIR);
ifc_free_unit(ifc, unit);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r222257 - head/sys/netgraph

2011-05-24 Thread Marko Zec
Author: zec
Date: Tue May 24 14:36:32 2011
New Revision: 57
URL: http://svn.freebsd.org/changeset/base/57

Log:
  Assume the link to be dead if bit error rate (BER) parameter is set to 1.
  When a transition from link alive to link dead configuration or vice
  versa occurs, notify any upstream and / or downstream peers using
  NGM_FLOW messagges.
  
  Link state notification using NGM_FLOW messages is modelled around
  around already existing code in ng_ether.c.
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_pipe.c

Modified: head/sys/netgraph/ng_pipe.c
==
--- head/sys/netgraph/ng_pipe.c Tue May 24 14:12:31 2011(r56)
+++ head/sys/netgraph/ng_pipe.c Tue May 24 14:36:32 2011(r57)
@@ -298,11 +298,12 @@ ngp_rcvmsg(node_p node, item_p item, hoo
 {
const priv_p priv = NG_NODE_PRIVATE(node);
struct ng_mesg *resp = NULL;
-   struct ng_mesg *msg;
+   struct ng_mesg *msg, *flow_msg;
struct ng_pipe_stats *stats;
struct ng_pipe_run *run;
struct ng_pipe_cfg *cfg;
int error = 0;
+   int prev_down, now_down, cmd;
 
NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
@@ -403,10 +404,38 @@ ngp_rcvmsg(node_p node, item_p item, hoo
cfg->header_offset < 64)
priv->header_offset = cfg->header_offset;
 
+   prev_down = priv->upper.cfg.ber == 1 ||
+   priv->lower.cfg.ber == 1;
parse_cfg(&priv->upper.cfg, &cfg->downstream,
&priv->upper, priv);
parse_cfg(&priv->lower.cfg, &cfg->upstream,
&priv->lower, priv);
+   now_down = priv->upper.cfg.ber == 1 ||
+   priv->lower.cfg.ber == 1;
+
+   if (prev_down != now_down) {
+   if (now_down)
+   cmd = NGM_LINK_IS_DOWN;
+   else
+   cmd = NGM_LINK_IS_UP;
+
+   if (priv->lower.hook != NULL) {
+   NG_MKMESSAGE(flow_msg, NGM_FLOW_COOKIE,
+   cmd, 0, M_NOWAIT);
+   if (flow_msg != NULL)
+   NG_SEND_MSG_HOOK(error, node,
+   flow_msg, priv->lower.hook,
+   0);
+   }
+   if (priv->upper.hook != NULL) {
+   NG_MKMESSAGE(flow_msg, NGM_FLOW_COOKIE,
+   cmd, 0, M_NOWAIT);
+   if (flow_msg != NULL)
+   NG_SEND_MSG_HOOK(error, node,
+   flow_msg, priv->upper.hook,
+   0);
+   }
+   }
break;
default:
error = EINVAL;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r222255 - head/sys/netgraph

2011-05-24 Thread Marko Zec
Author: zec
Date: Tue May 24 14:10:33 2011
New Revision: 55
URL: http://svn.freebsd.org/changeset/base/55

Log:
  Provide fake link status information in an attempt to let ng_eiface(4)
  virtual ifnets more realistically mimic physical ethernet interfaces.
  The main motivation behind this change is to allow for ng_eiface(4)
  interfaces to participate in STP if_bridge(4) configurations.
  
  When announcing link status changes, switch to the vnet to which the
  ifnet belongs, since it is possible for ng_eiface ifnets to be assigned
  to a vnet different from the one in which its netgraph node resides.
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_eiface.c

Modified: head/sys/netgraph/ng_eiface.c
==
--- head/sys/netgraph/ng_eiface.c   Tue May 24 13:36:41 2011
(r54)
+++ head/sys/netgraph/ng_eiface.c   Tue May 24 14:10:33 2011
(r55)
@@ -41,6 +41,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -76,6 +77,8 @@ static const struct ng_cmdlist ng_eiface
 /* Node private data */
 struct ng_eiface_private {
struct ifnet*ifp;   /* per-interface network data */
+   struct ifmedia  media;  /* (fake) media information */
+   int link_status;/* fake */
int unit;   /* Interface unit number */
node_p  node;   /* Our netgraph node */
hook_p  ether;  /* Hook for ethernet stream */
@@ -127,6 +130,7 @@ static VNET_DEFINE(struct unrhdr *, ng_e
 static int
 ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 {
+   const priv_p priv = (priv_p)ifp->if_softc;
struct ifreq *const ifr = (struct ifreq *)data;
int s, error = 0;
 
@@ -170,6 +174,12 @@ ng_eiface_ioctl(struct ifnet *ifp, u_lon
ifp->if_mtu = ifr->ifr_mtu;
break;
 
+   /* (Fake) media type manipulation */
+   case SIOCSIFMEDIA:
+   case SIOCGIFMEDIA:
+   error = ifmedia_ioctl(ifp, ifr, &priv->media, command);
+   break;
+
/* Stuff that's not supported */
case SIOCADDMULTI:
case SIOCDELMULTI:
@@ -280,7 +290,6 @@ ng_eiface_start2(node_p node, hook_p hoo
 static void
 ng_eiface_start(struct ifnet *ifp)
 {
-
const priv_p priv = (priv_p)ifp->if_softc;
 
/* Don't do anything if output is active */
@@ -328,6 +337,41 @@ ng_eiface_print_ioctl(struct ifnet *ifp,
 }
 #endif /* DEBUG */
 
+/*
+ * ifmedia stuff
+ */
+static int
+ng_eiface_mediachange(struct ifnet *ifp)
+{
+   const priv_p priv = (priv_p)ifp->if_softc;
+   struct ifmedia *ifm = &priv->media;
+
+   if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
+   return (EINVAL);
+   if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO)
+   ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T);
+   else
+   ifp->if_baudrate = ifmedia_baudrate(ifm->ifm_media);
+
+   return (0);
+}
+
+static void
+ng_eiface_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
+{
+   const priv_p priv = (priv_p)ifp->if_softc;
+   struct ifmedia *ifm = &priv->media;
+
+   if (ifm->ifm_cur->ifm_media == (IFM_ETHER | IFM_AUTO) &&
+   (priv->link_status & IFM_ACTIVE))
+   ifmr->ifm_active = IFM_ETHER | IFM_1000_T | IFM_FDX;
+   else
+   ifmr->ifm_active = ifm->ifm_cur->ifm_media;
+   ifmr->ifm_status = priv->link_status;
+
+   return;
+}
+
 /
NETGRAPH NODE STUFF
  /
@@ -371,6 +415,18 @@ ng_eiface_constructor(node_p node)
ifp->if_flags = (IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST);
ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
ifp->if_capenable = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
+   ifmedia_init(&priv->media, 0, ng_eiface_mediachange,
+   ng_eiface_mediastatus);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL);
+   ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
+   ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO);
+   priv->link_status = IFM_AVALID;
 
/* Give this node the same name as the interface (if possible) */
if (ng_name_node(node, ifp->if_xname) != 0)
@@ -379,6 +435,7 @@ ng_eiface_constructor(node_p node)
 
 

svn commit: r222247 - head/sys/net

2011-05-24 Thread Marko Zec
Author: zec
Date: Tue May 24 08:02:55 2011
New Revision: 47
URL: http://svn.freebsd.org/changeset/base/47

Log:
  Allow for vlan(4) interfaces with MTU of 1500 bytes to be configured
  on top of epair(4) virtual interfaces, since there's no physical
  hardware associated with epair interfaces which would imply any
  constraints on MTU sizes.
  
  MFC after:3 days

Modified:
  head/sys/net/if_epair.c

Modified: head/sys/net/if_epair.c
==
--- head/sys/net/if_epair.c Tue May 24 07:57:28 2011(r46)
+++ head/sys/net/if_epair.c Tue May 24 08:02:55 2011(r47)
@@ -810,6 +810,8 @@ epair_clone_create(struct if_clone *ifc,
ifp->if_dname = ifc->ifc_name;
ifp->if_dunit = unit;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+   ifp->if_capabilities = IFCAP_VLAN_MTU;
+   ifp->if_capenable = IFCAP_VLAN_MTU;
ifp->if_start = epair_start;
ifp->if_ioctl = epair_ioctl;
ifp->if_init  = epair_init;
@@ -834,6 +836,8 @@ epair_clone_create(struct if_clone *ifc,
ifp->if_dname = ifc->ifc_name;
ifp->if_dunit = unit;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+   ifp->if_capabilities = IFCAP_VLAN_MTU;
+   ifp->if_capenable = IFCAP_VLAN_MTU;
ifp->if_start = epair_start;
ifp->if_ioctl = epair_ioctl;
ifp->if_init  = epair_init;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r222246 - head/sys/net

2011-05-24 Thread Marko Zec
Author: zec
Date: Tue May 24 07:57:28 2011
New Revision: 46
URL: http://svn.freebsd.org/changeset/base/46

Log:
  Let epair(4) virtual interfaces report fake link / media status,
  by borrowing the skeleton of if_media manipulation and reporting
  code from if_lagg(4).  The main motivation behind this change is
  to allow for epair(4) interfaces to participate in STP if_bridge(4)
  configurations.
  
  Reviewed by:  bz
  MFC after:3 days

Modified:
  head/sys/net/if_epair.c

Modified: head/sys/net/if_epair.c
==
--- head/sys/net/if_epair.c Tue May 24 06:56:40 2011(r45)
+++ head/sys/net/if_epair.c Tue May 24 07:57:28 2011(r46)
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -92,6 +93,8 @@ static struct mbuf *epair_nh_m2cpuid(str
 static void epair_nh_drainedcpu(u_int);
 
 static void epair_start_locked(struct ifnet *);
+static int epair_media_change(struct ifnet *);
+static void epair_media_status(struct ifnet *, struct ifmediareq *);
 
 static int epair_clone_match(struct if_clone *, const char *);
 static int epair_clone_create(struct if_clone *, char *, size_t, caddr_t);
@@ -127,6 +130,7 @@ SYSCTL_PROC(_net_link_epair, OID_AUTO, n
 struct epair_softc {
struct ifnet*ifp;   /* This ifp. */
struct ifnet*oifp;  /* other ifp of pair. */
+   struct ifmedia  media;  /* Media config (fake). */
u_int   refcount;   /* # of mbufs in flight. */
u_int   cpuid;  /* CPU ID assigned upon creation. */
void(*if_qflush)(struct ifnet *);
@@ -611,8 +615,25 @@ epair_qflush(struct ifnet *ifp)
 }
 
 static int
+epair_media_change(struct ifnet *ifp __unused)
+{
+
+   /* Do nothing. */
+   return (0);
+}
+
+static void
+epair_media_status(struct ifnet *ifp __unused, struct ifmediareq *imr)
+{
+
+   imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
+   imr->ifm_active = IFM_ETHER | IFM_10G_T | IFM_FDX;
+}
+
+static int
 epair_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
+   struct epair_softc *sc;
struct ifreq *ifr;
int error;
 
@@ -624,6 +645,12 @@ epair_ioctl(struct ifnet *ifp, u_long cm
error = 0;
break;
 
+   case SIOCSIFMEDIA:
+   case SIOCGIFMEDIA:
+   sc = ifp->if_softc;
+   error = ifmedia_ioctl(ifp, ifr, &sc->media, cmd);
+   break;
+
case SIOCSIFMTU:
/* We basically allow all kinds of MTUs. */
ifp->if_mtu = ifr->ifr_mtu;
@@ -829,6 +856,14 @@ epair_clone_create(struct if_clone *ifc,
strlcpy(name, sca->ifp->if_xname, len);
DPRINTF("name='%s/%db' created sca=%p scb=%p\n", name, unit, sca, scb);
 
+   /* Initialise pseudo media types. */
+   ifmedia_init(&sca->media, 0, epair_media_change, epair_media_status);
+   ifmedia_add(&sca->media, IFM_ETHER | IFM_10G_T, 0, NULL);
+   ifmedia_set(&sca->media, IFM_ETHER | IFM_10G_T);
+   ifmedia_init(&scb->media, 0, epair_media_change, epair_media_status);
+   ifmedia_add(&scb->media, IFM_ETHER | IFM_10G_T, 0, NULL);
+   ifmedia_set(&scb->media, IFM_ETHER | IFM_10G_T);
+
/* Tell the world, that we are ready to rock. */
sca->ifp->if_drv_flags |= IFF_DRV_RUNNING;
scb->ifp->if_drv_flags |= IFF_DRV_RUNNING;
@@ -895,6 +930,8 @@ epair_clone_destroy(struct if_clone *ifc
if_free(oifp);
CURVNET_RESTORE();
if_free(ifp);
+   ifmedia_removeall(&sca->media);
+   ifmedia_removeall(&scb->media);
free(scb, M_EPAIR);
free(sca, M_EPAIR);
ifc_free_unit(ifc, unit);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r221985 - stable/8/sys/netgraph

2011-05-16 Thread Marko Zec
Author: zec
Date: Mon May 16 12:11:29 2011
New Revision: 221985
URL: http://svn.freebsd.org/changeset/base/221985

Log:
  MFC r220416:
  
Properly unref ng_hub nodes on shutdown, so that we don't leak them.

Modified:
  stable/8/sys/netgraph/ng_hub.c
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/netgraph/ng_hub.c
==
--- stable/8/sys/netgraph/ng_hub.c  Mon May 16 12:00:32 2011
(r221984)
+++ stable/8/sys/netgraph/ng_hub.c  Mon May 16 12:11:29 2011
(r221985)
@@ -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
const priv_p priv = NG_NODE_PRIVATE(node);
 
free(priv, M_NETGRAPH_HUB);
+   NG_NODE_SET_PRIVATE(node, NULL);
+   NG_NODE_UNREF(node);
return (0);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r220416 - head/sys/netgraph

2011-04-07 Thread Marko Zec
On Thursday 07 April 2011 15:54:40 Gleb Smirnoff wrote:
> On Thu, Apr 07, 2011 at 11:40:10AM +0000, Marko Zec wrote:
> M> Author: zec
> M> Date: Thu Apr  7 11:40:10 2011
> M> New Revision: 220416
> M> URL: http://svn.freebsd.org/changeset/base/220416
> M>
> M> Log:
> M>   Properly unref ng_hub nodes on shutdown, so that we don't leak them.
> M>
> M>   MFC after:   3 days
> M>
> M> Modified:
> M>   head/sys/netgraph/ng_hub.c
> M>
> M> Modified: head/sys/netgraph/ng_hub.c
> M>
> ===
>=== M> --- head/sys/netgraph/ng_hub.c  Thu Apr  7 11:13:50 2011
>(r220415) M>
> +++ head/sys/netgraph/ng_hub.cThu Apr  7 11:40:10 2011
> (r220416) M> @@
> -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
> M>const priv_p priv = NG_NODE_PRIVATE(node);
> M>
> M>free(priv, M_NETGRAPH_HUB);
> M> +  NG_NODE_SET_PRIVATE(node, NULL);
> M> +  NG_NODE_UNREF(node);
> M>return (0);
> M>  }
>
> Do we really need NG_NODE_SET_PRIVATE()?

Most probably not, though the majority of .shutdown method implementations in 
sys/netgraph do include a call to NG_NODE_SET_PRIVATE(node, NULL), so I did a 
C/P from one of those for consistency.  If there's a consensus that 
NG_NODE_SET_PRIVATE(node, NULL) in shutdown methods serves no useful purpose 
then we should do a sweep across all the existing nodes...

Marko
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r220416 - head/sys/netgraph

2011-04-07 Thread Marko Zec
Author: zec
Date: Thu Apr  7 11:40:10 2011
New Revision: 220416
URL: http://svn.freebsd.org/changeset/base/220416

Log:
  Properly unref ng_hub nodes on shutdown, so that we don't leak them.
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_hub.c

Modified: head/sys/netgraph/ng_hub.c
==
--- head/sys/netgraph/ng_hub.c  Thu Apr  7 11:13:50 2011(r220415)
+++ head/sys/netgraph/ng_hub.c  Thu Apr  7 11:40:10 2011(r220416)
@@ -157,6 +157,8 @@ ng_hub_shutdown(node_p node)
const priv_p priv = NG_NODE_PRIVATE(node);
 
free(priv, M_NETGRAPH_HUB);
+   NG_NODE_SET_PRIVATE(node, NULL);
+   NG_NODE_UNREF(node);
return (0);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215958 - stable/8/sys/netgraph

2010-11-27 Thread Marko Zec
Author: zec
Date: Sat Nov 27 23:48:53 2010
New Revision: 215958
URL: http://svn.freebsd.org/changeset/base/215958

Log:
  MFC r215800:
  
Simplify ng_pipe locking model by relying on the netgraph framework
to provide serialization of calls into the node, which is accomplished
by markng the node as single-threaded (NGF_FORCE_WRITER).
  
The price we pay is that each ng_pipe instance now has its own callout
handler which polls for queued frames on each clock tick, as long as
the pipe has any frames in its internal queues.  OTOH, we got rid of
the global ng_pipe mutex, so from now on multiple ng_pipe instances
can operate in parallel.  This change also fixes counting of forwarded
frames when an ng_pipe node is not enforcing any packet impairments.
  
While here, attempt to improve adherance to style(9) throughout
otherwise mostly unreadable code.

Modified:
  stable/8/sys/netgraph/ng_pipe.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/mips/alchemy/   (props changed)
  stable/8/sys/mips/atheros/   (props changed)
  stable/8/sys/mips/cavium/   (props changed)
  stable/8/sys/mips/cavium/dev/   (props changed)
  stable/8/sys/mips/rmi/   (props changed)
  stable/8/sys/mips/rmi/dev/   (props changed)
  stable/8/sys/mips/sibyte/   (props changed)

Modified: stable/8/sys/netgraph/ng_pipe.c
==
--- stable/8/sys/netgraph/ng_pipe.c Sat Nov 27 22:42:41 2010
(r215957)
+++ stable/8/sys/netgraph/ng_pipe.c Sat Nov 27 23:48:53 2010
(r215958)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004-2008 University of Zagreb
+ * Copyright (c) 2004-2010 University of Zagreb
  * Copyright (c) 2007-2008 FreeBSD Foundation
  *
  * This software was developed by the University of Zagreb and the
@@ -62,8 +62,6 @@
 
 static MALLOC_DEFINE(M_NG_PIPE, "ng_pipe", "ng_pipe");
 
-struct mtx ng_pipe_giant;
-
 /* Packet header struct */
 struct ngp_hdr {
TAILQ_ENTRY(ngp_hdr)ngp_link;   /* next pkt in queue */
@@ -88,7 +86,6 @@ struct hookinfo {
int noqueue;/* bypass any processing */
TAILQ_HEAD(, ngp_fifo)  fifo_head;  /* FIFO queues */
TAILQ_HEAD(, ngp_hdr)   qout_head;  /* delay queue head */
-   LIST_ENTRY(hookinfo)active_le;  /* active hooks */
struct timeval  qin_utime;
struct ng_pipe_hookcfg  cfg;
struct ng_pipe_hookrun  run;
@@ -103,6 +100,8 @@ struct node_priv {
u_int32_t   header_offset;
struct hookinfo lower;
struct hookinfo upper;
+   struct callout  timer;
+   int timer_scheduled;
 };
 typedef struct node_priv *priv_p;
 
@@ -131,17 +130,9 @@ typedef struct node_priv *priv_p;
 static voidparse_cfg(struct ng_pipe_hookcfg *, struct ng_pipe_hookcfg *,
struct hookinfo *, priv_p);
 static voidpipe_dequeue(struct hookinfo *, struct timeval *);
-static voidpipe_scheduler(void *);
-static voidpipe_poll(void);
+static voidngp_callout(node_p, hook_p, void *, int);
 static int ngp_modevent(module_t, int, void *);
 
-/* linked list of active "pipe" hooks */
-static LIST_HEAD(, hookinfo) active_head;
-static int active_gen_id = 0;
-
-/* timeout handle for pipe_scheduler */
-static struct callout polling_timer;
-
 /* zone for storing ngp_hdr-s */
 static uma_zone_t ngp_zone;
 
@@ -267,6 +258,11 @@ ngp_constructor(node_p node)
return (ENOMEM);
NG_NODE_SET_PRIVATE(node, priv);
 
+   /* Mark node as single-threaded */
+   NG_NODE_FORCE_WRITER(node);
+
+   ng_callout_init(&priv->timer);
+
return (0);
 }
 
@@ -310,8 +306,6 @@ ngp_rcvmsg(node_p node, item_p item, hoo
struct ng_pipe_cfg *cfg;
int error = 0;
 
-   mtx_lock(&ng_pipe_giant);
-
NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
case NGM_PIPE_COOKIE:
@@ -326,7 +320,7 @@ ngp_rcvmsg(node_p node, item_p item, hoo
error = ENOMEM;
break;
}
-   stats = (struct ng_pipe_stats *)resp->data;
+   stats = (struct ng_pipe_stats *) resp->data;
bcopy(&priv->upper.stats, &stats->downstream,
sizeof(stats->downstream));
bcopy(&priv->lower.stats, &stats->upstream,
@@ -345,7 +339,7 @@ ngp_rcvmsg(node_p node, item_p item, hoo
error = ENOMEM;
break;
}
-

svn commit: r215871 - stable/8/sys/net

2010-11-26 Thread Marko Zec
Author: zec
Date: Fri Nov 26 15:46:49 2010
New Revision: 215871
URL: http://svn.freebsd.org/changeset/base/215871

Log:
  MFC r215726:
  
Allow for vlan(4) ifnets to have overlapping unit numbers if they are
created in separated vnets.  As a side-effect of having a separated
if_cloner instance for each vnet, all vlan ifnets created in a vnet
will be automatically destroyed when vnet teardown is initiated.
  
Disallow SIOCSETVLAN and SIOCGETVLAN ioctls on vlan ifnets which are
associated with physical ifnets residing in parent vnets.
  
This is an interim vlan-specific solution which will be superseded by a
more generic if_cloner V_irtualization change from p4.  For nooptions
VIMAGE builds, this should be a no-op change.
  
Discussed with:   bz

Modified:
  stable/8/sys/net/if_vlan.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/net/if_vlan.c
==
--- stable/8/sys/net/if_vlan.c  Fri Nov 26 15:45:34 2010(r215870)
+++ stable/8/sys/net/if_vlan.c  Fri Nov 26 15:46:49 2010(r215871)
@@ -206,6 +206,11 @@ static  void vlan_iflladdr(void *arg, st
 static struct if_clone vlan_cloner = IFC_CLONE_INITIALIZER(VLANNAME, NULL,
 IF_MAXUNIT, NULL, vlan_clone_match, vlan_clone_create, vlan_clone_destroy);
 
+#ifdef VIMAGE
+static VNET_DEFINE(struct if_clone, vlan_cloner);
+#defineV_vlan_cloner   VNET(vlan_cloner)
+#endif
+
 #ifndef VLAN_ARRAY
 #define HASH(n, m) n) >> 8) ^ ((n) >> 4) ^ (n)) & (m))
 
@@ -588,7 +593,9 @@ vlan_modevent(module_t mod, int type, vo
vlan_input_p = vlan_input;
vlan_link_state_p = vlan_link_state;
vlan_trunk_cap_p = vlan_trunk_capabilities;
+#ifndef VIMAGE
if_clone_attach(&vlan_cloner);
+#endif
if (bootverbose)
printf("vlan: initialized, using "
 #ifdef VLAN_ARRAY
@@ -600,7 +607,9 @@ vlan_modevent(module_t mod, int type, vo
   "\n");
break;
case MOD_UNLOAD:
+#ifndef VIMAGE
if_clone_detach(&vlan_cloner);
+#endif
EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag);
EVENTHANDLER_DEREGISTER(iflladdr_event, iflladdr_tag);
vlan_input_p = NULL;
@@ -625,6 +634,27 @@ static moduledata_t vlan_mod = {
 DECLARE_MODULE(if_vlan, vlan_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 MODULE_VERSION(if_vlan, 3);
 
+#ifdef VIMAGE
+static void
+vnet_vlan_init(const void *unused __unused)
+{
+
+   V_vlan_cloner = vlan_cloner;
+   if_clone_attach(&V_vlan_cloner);
+}
+VNET_SYSINIT(vnet_vlan_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
+vnet_vlan_init, NULL);
+
+static void
+vnet_vlan_uninit(const void *unused __unused)
+{
+
+   if_clone_detach(&V_vlan_cloner);
+}
+VNET_SYSUNINIT(vnet_vlan_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST,
+vnet_vlan_uninit, NULL);
+#endif
+
 static struct ifnet *
 vlan_clone_match_ethertag(struct if_clone *ifc, const char *name, int *tag)
 {
@@ -1427,6 +1457,12 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
break;
 
case SIOCSETVLAN:
+#ifdef VIMAGE
+   if (ifp->if_vnet != ifp->if_home_vnet) {
+   error = EPERM;
+   break;
+   }
+#endif
error = copyin(ifr->ifr_data, &vlr, sizeof(vlr));
if (error)
break;
@@ -1456,6 +1492,12 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
break;
 
case SIOCGETVLAN:
+#ifdef VIMAGE
+   if (ifp->if_vnet != ifp->if_home_vnet) {
+   error = EPERM;
+   break;
+   }
+#endif
bzero(&vlr, sizeof(vlr));
VLAN_LOCK();
if (TRUNK(ifv) != NULL) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215870 - stable/8/sys/netinet

2010-11-26 Thread Marko Zec
Author: zec
Date: Fri Nov 26 15:45:34 2010
New Revision: 215870
URL: http://svn.freebsd.org/changeset/base/215870

Log:
  MFC r215677:
  
 Remove an apparently redundant CURVNET_SET() / CURVNET_RESTORE() pair.

Modified:
  stable/8/sys/netinet/if_ether.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/netinet/if_ether.c
==
--- stable/8/sys/netinet/if_ether.c Fri Nov 26 15:44:16 2010
(r215869)
+++ stable/8/sys/netinet/if_ether.c Fri Nov 26 15:45:34 2010
(r215870)
@@ -145,12 +145,10 @@ arp_ifscrub(struct ifnet *ifp, uint32_t 
addr4.sin_len= sizeof(addr4);
addr4.sin_family = AF_INET;
addr4.sin_addr.s_addr = addr;
-   CURVNET_SET(ifp->if_vnet);
IF_AFDATA_LOCK(ifp);
lla_lookup(LLTABLE(ifp), (LLE_DELETE | LLE_IFADDR),
(struct sockaddr *)&addr4);
IF_AFDATA_UNLOCK(ifp);
-   CURVNET_RESTORE();
 }
 #endif
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215869 - stable/8/sys/netgraph

2010-11-26 Thread Marko Zec
Author: zec
Date: Fri Nov 26 15:44:16 2010
New Revision: 215869
URL: http://svn.freebsd.org/changeset/base/215869

Log:
  MFC r215673:
  
Allow for MTU sizes of up to ETHER_MAX_LEN_JUMBO (i.e. 9018) bytes to be
configured on ng_eiface ifnets.  The default MTU remains unchanged at
1500 bytes.
  
Mark ng_eiface ifnets as IFCAP_VLAN_MTU capable, so that the associated
vlan(4) ifnets may use full-sized Ethernet MTUs (1500 bytes).

Modified:
  stable/8/sys/netgraph/ng_eiface.c
  stable/8/sys/netgraph/ng_eiface.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/netgraph/ng_eiface.c
==
--- stable/8/sys/netgraph/ng_eiface.c   Fri Nov 26 15:35:08 2010
(r215868)
+++ stable/8/sys/netgraph/ng_eiface.c   Fri Nov 26 15:44:16 2010
(r215869)
@@ -371,6 +371,8 @@ ng_eiface_constructor(node_p node)
ifp->if_ioctl = ng_eiface_ioctl;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_flags = (IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST);
+   ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
+   ifp->if_capenable = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
 
/* Give this node the same name as the interface (if possible) */
if (ng_name_node(node, ifp->if_xname) != 0)

Modified: stable/8/sys/netgraph/ng_eiface.h
==
--- stable/8/sys/netgraph/ng_eiface.h   Fri Nov 26 15:35:08 2010
(r215868)
+++ stable/8/sys/netgraph/ng_eiface.h   Fri Nov 26 15:44:16 2010
(r215869)
@@ -46,7 +46,7 @@
 
 /* MTU bounds */
 #define NG_EIFACE_MTU_MIN  72
-#define NG_EIFACE_MTU_MAX  2312
+#define NG_EIFACE_MTU_MAX  ETHER_MAX_LEN_JUMBO
 #define NG_EIFACE_MTU_DEFAULT  1500
 
 /* Netgraph commands */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215800 - head/sys/netgraph

2010-11-24 Thread Marko Zec
Author: zec
Date: Wed Nov 24 16:02:58 2010
New Revision: 215800
URL: http://svn.freebsd.org/changeset/base/215800

Log:
  Simplify ng_pipe locking model by relying on the netgraph framework
  to provide serialization of calls into the node, which is accomplished
  by markng the node as single-threaded (NGF_FORCE_WRITER).
  
  The price we pay is that each ng_pipe instance now has its own callout
  handler which polls for queued frames on each clock tick, as long as
  the pipe has any frames in its internal queues.  OTOH, we got rid of
  the global ng_pipe mutex, so from now on multiple ng_pipe instances
  can operate in parallel.  This change also fixes counting of forwarded
  frames when an ng_pipe node is not enforcing any packet impairments.
  
  While here, attempt to improve adherance to style(9) throughout
  otherwise mostly unreadable code.
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_pipe.c

Modified: head/sys/netgraph/ng_pipe.c
==
--- head/sys/netgraph/ng_pipe.c Wed Nov 24 15:25:17 2010(r215799)
+++ head/sys/netgraph/ng_pipe.c Wed Nov 24 16:02:58 2010(r215800)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2004-2008 University of Zagreb
+ * Copyright (c) 2004-2010 University of Zagreb
  * Copyright (c) 2007-2008 FreeBSD Foundation
  *
  * This software was developed by the University of Zagreb and the
@@ -62,8 +62,6 @@
 
 static MALLOC_DEFINE(M_NG_PIPE, "ng_pipe", "ng_pipe");
 
-struct mtx ng_pipe_giant;
-
 /* Packet header struct */
 struct ngp_hdr {
TAILQ_ENTRY(ngp_hdr)ngp_link;   /* next pkt in queue */
@@ -88,7 +86,6 @@ struct hookinfo {
int noqueue;/* bypass any processing */
TAILQ_HEAD(, ngp_fifo)  fifo_head;  /* FIFO queues */
TAILQ_HEAD(, ngp_hdr)   qout_head;  /* delay queue head */
-   LIST_ENTRY(hookinfo)active_le;  /* active hooks */
struct timeval  qin_utime;
struct ng_pipe_hookcfg  cfg;
struct ng_pipe_hookrun  run;
@@ -103,6 +100,8 @@ struct node_priv {
u_int32_t   header_offset;
struct hookinfo lower;
struct hookinfo upper;
+   struct callout  timer;
+   int timer_scheduled;
 };
 typedef struct node_priv *priv_p;
 
@@ -131,17 +130,9 @@ typedef struct node_priv *priv_p;
 static voidparse_cfg(struct ng_pipe_hookcfg *, struct ng_pipe_hookcfg *,
struct hookinfo *, priv_p);
 static voidpipe_dequeue(struct hookinfo *, struct timeval *);
-static voidpipe_scheduler(void *);
-static voidpipe_poll(void);
+static voidngp_callout(node_p, hook_p, void *, int);
 static int ngp_modevent(module_t, int, void *);
 
-/* linked list of active "pipe" hooks */
-static LIST_HEAD(, hookinfo) active_head;
-static int active_gen_id = 0;
-
-/* timeout handle for pipe_scheduler */
-static struct callout polling_timer;
-
 /* zone for storing ngp_hdr-s */
 static uma_zone_t ngp_zone;
 
@@ -267,6 +258,11 @@ ngp_constructor(node_p node)
return (ENOMEM);
NG_NODE_SET_PRIVATE(node, priv);
 
+   /* Mark node as single-threaded */
+   NG_NODE_FORCE_WRITER(node);
+
+   ng_callout_init(&priv->timer);
+
return (0);
 }
 
@@ -310,8 +306,6 @@ ngp_rcvmsg(node_p node, item_p item, hoo
struct ng_pipe_cfg *cfg;
int error = 0;
 
-   mtx_lock(&ng_pipe_giant);
-
NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
case NGM_PIPE_COOKIE:
@@ -326,7 +320,7 @@ ngp_rcvmsg(node_p node, item_p item, hoo
error = ENOMEM;
break;
}
-   stats = (struct ng_pipe_stats *)resp->data;
+   stats = (struct ng_pipe_stats *) resp->data;
bcopy(&priv->upper.stats, &stats->downstream,
sizeof(stats->downstream));
bcopy(&priv->lower.stats, &stats->upstream,
@@ -345,7 +339,7 @@ ngp_rcvmsg(node_p node, item_p item, hoo
error = ENOMEM;
break;
}
-   run = (struct ng_pipe_run *)resp->data;
+   run = (struct ng_pipe_run *) resp->data;
bcopy(&priv->upper.run, &run->downstream,
sizeof(run->downstream));
bcopy(&priv->lower.run, &run->upstream,
@@ -357,7 +351,7 @@ ngp_rcvmsg(node_p node, item_p item, hoo
error = ENOMEM;
break;
}
-   cfg = (struct ng_pipe_cfg *)resp->data;
+   cfg = (struct ng_pipe_cfg *) resp->data;

svn commit: r215746 - stable/8/sbin/sysctl

2010-11-23 Thread Marko Zec
Author: zec
Date: Tue Nov 23 13:37:42 2010
New Revision: 215746
URL: http://svn.freebsd.org/changeset/base/215746

Log:
  MFC 212726:
  
Make the format of "Real Memory" and "Virtual Memory" lines more
consistent with the rest of sysctl vm.vmtotal output.
  
MFC after:3 days

Modified:
  stable/8/sbin/sysctl/sysctl.c
Directory Properties:
  stable/8/sbin/sysctl/   (props changed)

Modified: stable/8/sbin/sysctl/sysctl.c
==
--- stable/8/sbin/sysctl/sysctl.c   Tue Nov 23 13:28:45 2010
(r215745)
+++ stable/8/sbin/sysctl/sysctl.c   Tue Nov 23 13:37:42 2010
(r215746)
@@ -403,9 +403,9 @@ S_vmtotal(int l2, void *p)
"%hd Sleep: %hd)\n",
v->t_rq, v->t_dw, v->t_pw, v->t_sl);
printf(
-   "Virtual Memory:\t\t(Total: %dK, Active %dK)\n",
+   "Virtual Memory:\t\t(Total: %dK Active: %dK)\n",
v->t_vm * pageKilo, v->t_avm * pageKilo);
-   printf("Real Memory:\t\t(Total: %dK Active %dK)\n",
+   printf("Real Memory:\t\t(Total: %dK Active: %dK)\n",
v->t_rm * pageKilo, v->t_arm * pageKilo);
printf("Shared Virtual Memory:\t(Total: %dK Active: %dK)\n",
v->t_vmshr * pageKilo, v->t_avmshr * pageKilo);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215745 - stable/8/sys/netgraph

2010-11-23 Thread Marko Zec
Author: zec
Date: Tue Nov 23 13:28:45 2010
New Revision: 215745
URL: http://svn.freebsd.org/changeset/base/215745

Log:
  MFC 209723:
  
 Fix a double-free bug which can occur if both bit error rate and
 packet duplication probability are configured on a ng_pipe node.
  
 Submitted by:   Jeffrey Ahrenholtz
 MFC after:3 days

Modified:
  stable/8/sys/netgraph/ng_pipe.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/netgraph/ng_pipe.c
==
--- stable/8/sys/netgraph/ng_pipe.c Tue Nov 23 13:26:59 2010
(r215744)
+++ stable/8/sys/netgraph/ng_pipe.c Tue Nov 23 13:28:45 2010
(r215745)
@@ -779,8 +779,9 @@ pipe_dequeue(struct hookinfo *hinfo, str
random() % 100 <= hinfo->cfg.duplicate) {
ngp_h = uma_zalloc(ngp_zone, M_NOWAIT);
KASSERT(ngp_h != NULL, ("ngp_h zalloc failed (3)"));
-   ngp_h->m = m_dup(m, M_NOWAIT);
-   KASSERT(ngp_h->m != NULL, ("m_dup failed"));
+   m = m_dup(m, M_NOWAIT);
+   KASSERT(m != NULL, ("m_dup failed"));
+   ngp_h->m = m;
} else {
TAILQ_REMOVE(&ngp_f->packet_head, ngp_h, ngp_link);
hinfo->run.qin_frames--;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215744 - stable/8/sys/netgraph

2010-11-23 Thread Marko Zec
Author: zec
Date: Tue Nov 23 13:26:59 2010
New Revision: 215744
URL: http://svn.freebsd.org/changeset/base/215744

Log:
  MFC 207426:
  
 Avoid undefined behaviour.

Modified:
  stable/8/sys/netgraph/ng_pipe.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/netgraph/ng_pipe.c
==
--- stable/8/sys/netgraph/ng_pipe.c Tue Nov 23 13:25:27 2010
(r215743)
+++ stable/8/sys/netgraph/ng_pipe.c Tue Nov 23 13:26:59 2010
(r215744)
@@ -816,14 +816,17 @@ pipe_dequeue(struct hookinfo *hinfo, str
}
 
/* Randomly discard the frame, according to BER setting */
-   if (hinfo->cfg.ber && 
-   ((oldrand = rand) ^ (rand = random())<<17) >=
-   hinfo->ber_p[priv->overhead + m->m_pkthdr.len] ) {
-   hinfo->stats.out_disc_frames++;
-   hinfo->stats.out_disc_octets += m->m_pkthdr.len;
-   uma_zfree(ngp_zone, ngp_h);
-   m_freem(m);
-   continue;
+   if (hinfo->cfg.ber) {
+   oldrand = rand;
+   rand = random();
+   if (((oldrand ^ rand) << 17) >=
+   hinfo->ber_p[priv->overhead + m->m_pkthdr.len]) {
+   hinfo->stats.out_disc_frames++;
+   hinfo->stats.out_disc_octets += m->m_pkthdr.len;
+   uma_zfree(ngp_zone, ngp_h);
+   m_freem(m);
+   continue;
+   }
}
 
/* Discard frame if outbound queue size limit exceeded */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215743 - in stable/8/sys: libkern netgraph vm

2010-11-23 Thread Marko Zec
Author: zec
Date: Tue Nov 23 13:25:27 2010
New Revision: 215743
URL: http://svn.freebsd.org/changeset/base/215743

Log:
  MFC 206360:
 Start copyright notice with /*-

Modified:
  stable/8/sys/libkern/iconv_xlat.c
  stable/8/sys/libkern/strcasecmp.c
  stable/8/sys/netgraph/ng_pipe.c
  stable/8/sys/netgraph/ng_pipe.h
  stable/8/sys/vm/memguard.c
  stable/8/sys/vm/memguard.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/libkern/iconv_xlat.c
==
--- stable/8/sys/libkern/iconv_xlat.c   Tue Nov 23 12:51:08 2010
(r215742)
+++ stable/8/sys/libkern/iconv_xlat.c   Tue Nov 23 13:25:27 2010
(r215743)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2000-2001, Boris Popov
  * All rights reserved.
  *

Modified: stable/8/sys/libkern/strcasecmp.c
==
--- stable/8/sys/libkern/strcasecmp.c   Tue Nov 23 12:51:08 2010
(r215742)
+++ stable/8/sys/libkern/strcasecmp.c   Tue Nov 23 13:25:27 2010
(r215743)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 1987, 1993
  * The Regents of the University of California.  All rights reserved.
  *

Modified: stable/8/sys/netgraph/ng_pipe.c
==
--- stable/8/sys/netgraph/ng_pipe.c Tue Nov 23 12:51:08 2010
(r215742)
+++ stable/8/sys/netgraph/ng_pipe.c Tue Nov 23 13:25:27 2010
(r215743)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2004-2008 University of Zagreb
  * Copyright (c) 2007-2008 FreeBSD Foundation
  *

Modified: stable/8/sys/netgraph/ng_pipe.h
==
--- stable/8/sys/netgraph/ng_pipe.h Tue Nov 23 12:51:08 2010
(r215742)
+++ stable/8/sys/netgraph/ng_pipe.h Tue Nov 23 13:25:27 2010
(r215743)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2004-2008 University of Zagreb
  * Copyright (c) 2007-2008 FreeBSD Foundation
  *

Modified: stable/8/sys/vm/memguard.c
==
--- stable/8/sys/vm/memguard.c  Tue Nov 23 12:51:08 2010(r215742)
+++ stable/8/sys/vm/memguard.c  Tue Nov 23 13:25:27 2010(r215743)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2005, Bosko Milekic .
  * Copyright (c) 2010 Isilon Systems, Inc. (http://www.isilon.com/)
  * All rights reserved.

Modified: stable/8/sys/vm/memguard.h
==
--- stable/8/sys/vm/memguard.h  Tue Nov 23 12:51:08 2010(r215742)
+++ stable/8/sys/vm/memguard.h  Tue Nov 23 13:25:27 2010(r215743)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2005,
  * Bosko Milekic .  All rights reserved.
  *
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215726 - head/sys/net

2010-11-22 Thread Marko Zec
Author: zec
Date: Mon Nov 22 23:35:29 2010
New Revision: 215726
URL: http://svn.freebsd.org/changeset/base/215726

Log:
  Allow for vlan(4) ifnets to have overlapping unit numbers if they are
  created in separated vnets.  As a side-effect of having a separated
  if_cloner instance for each vnet, all vlan ifnets created in a vnet
  will be automatically destroyed when vnet teardown is initiated.
  
  Disallow SIOCSETVLAN and SIOCGETVLAN ioctls on vlan ifnets which are
  associated with physical ifnets residing in parent vnets.
  
  This is an interim vlan-specific solution which will be superseded by a
  more generic if_cloner V_irtualization change from p4.  For nooptions
  VIMAGE builds, this should be a no-op change.
  
  Discussed with:   bz
  MFC after:3 days

Modified:
  head/sys/net/if_vlan.c

Modified: head/sys/net/if_vlan.c
==
--- head/sys/net/if_vlan.c  Mon Nov 22 23:04:25 2010(r215725)
+++ head/sys/net/if_vlan.c  Mon Nov 22 23:35:29 2010(r215726)
@@ -206,6 +206,11 @@ static  void vlan_iflladdr(void *arg, st
 static struct if_clone vlan_cloner = IFC_CLONE_INITIALIZER(VLANNAME, NULL,
 IF_MAXUNIT, NULL, vlan_clone_match, vlan_clone_create, vlan_clone_destroy);
 
+#ifdef VIMAGE
+static VNET_DEFINE(struct if_clone, vlan_cloner);
+#defineV_vlan_cloner   VNET(vlan_cloner)
+#endif
+
 #ifndef VLAN_ARRAY
 #define HASH(n, m) n) >> 8) ^ ((n) >> 4) ^ (n)) & (m))
 
@@ -588,7 +593,9 @@ vlan_modevent(module_t mod, int type, vo
vlan_input_p = vlan_input;
vlan_link_state_p = vlan_link_state;
vlan_trunk_cap_p = vlan_trunk_capabilities;
+#ifndef VIMAGE
if_clone_attach(&vlan_cloner);
+#endif
if (bootverbose)
printf("vlan: initialized, using "
 #ifdef VLAN_ARRAY
@@ -600,7 +607,9 @@ vlan_modevent(module_t mod, int type, vo
   "\n");
break;
case MOD_UNLOAD:
+#ifndef VIMAGE
if_clone_detach(&vlan_cloner);
+#endif
EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag);
EVENTHANDLER_DEREGISTER(iflladdr_event, iflladdr_tag);
vlan_input_p = NULL;
@@ -625,6 +634,27 @@ static moduledata_t vlan_mod = {
 DECLARE_MODULE(if_vlan, vlan_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 MODULE_VERSION(if_vlan, 3);
 
+#ifdef VIMAGE
+static void
+vnet_vlan_init(const void *unused __unused)
+{
+
+   V_vlan_cloner = vlan_cloner;
+   if_clone_attach(&V_vlan_cloner);
+}
+VNET_SYSINIT(vnet_vlan_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
+vnet_vlan_init, NULL);
+
+static void
+vnet_vlan_uninit(const void *unused __unused)
+{
+
+   if_clone_detach(&V_vlan_cloner);
+}
+VNET_SYSUNINIT(vnet_vlan_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST,
+vnet_vlan_uninit, NULL);
+#endif
+
 static struct ifnet *
 vlan_clone_match_ethertag(struct if_clone *ifc, const char *name, int *tag)
 {
@@ -1432,6 +1462,12 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
break;
 
case SIOCSETVLAN:
+#ifdef VIMAGE
+   if (ifp->if_vnet != ifp->if_home_vnet) {
+   error = EPERM;
+   break;
+   }
+#endif
error = copyin(ifr->ifr_data, &vlr, sizeof(vlr));
if (error)
break;
@@ -1461,6 +1497,12 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
break;
 
case SIOCGETVLAN:
+#ifdef VIMAGE
+   if (ifp->if_vnet != ifp->if_home_vnet) {
+   error = EPERM;
+   break;
+   }
+#endif
bzero(&vlr, sizeof(vlr));
VLAN_LOCK();
if (TRUNK(ifv) != NULL) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215677 - head/sys/netinet

2010-11-22 Thread Marko Zec
Author: zec
Date: Mon Nov 22 14:16:23 2010
New Revision: 215677
URL: http://svn.freebsd.org/changeset/base/215677

Log:
  Remove an apparently redundant CURVNET_SET() / CURVNET_RESTORE() pair.
  
  MFC after:3 days

Modified:
  head/sys/netinet/if_ether.c

Modified: head/sys/netinet/if_ether.c
==
--- head/sys/netinet/if_ether.c Mon Nov 22 14:16:22 2010(r215676)
+++ head/sys/netinet/if_ether.c Mon Nov 22 14:16:23 2010(r215677)
@@ -154,12 +154,10 @@ arp_ifscrub(struct ifnet *ifp, uint32_t 
addr4.sin_len= sizeof(addr4);
addr4.sin_family = AF_INET;
addr4.sin_addr.s_addr = addr;
-   CURVNET_SET(ifp->if_vnet);
IF_AFDATA_LOCK(ifp);
lla_lookup(LLTABLE(ifp), (LLE_DELETE | LLE_IFADDR),
(struct sockaddr *)&addr4);
IF_AFDATA_UNLOCK(ifp);
-   CURVNET_RESTORE();
 }
 #endif
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215673 - head/sys/netgraph

2010-11-22 Thread Marko Zec
Author: zec
Date: Mon Nov 22 12:32:19 2010
New Revision: 215673
URL: http://svn.freebsd.org/changeset/base/215673

Log:
  Allow for MTU sizes of up to ETHER_MAX_LEN_JUMBO (i.e. 9018) bytes to be
  configured on ng_eiface ifnets.  The default MTU remains unchanged at
  1500 bytes.
  
  Mark ng_eiface ifnets as IFCAP_VLAN_MTU capable, so that the associated
  vlan(4) ifnets may use full-sized Ethernet MTUs (1500 bytes).
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_eiface.c
  head/sys/netgraph/ng_eiface.h

Modified: head/sys/netgraph/ng_eiface.c
==
--- head/sys/netgraph/ng_eiface.c   Mon Nov 22 11:24:11 2010
(r215672)
+++ head/sys/netgraph/ng_eiface.c   Mon Nov 22 12:32:19 2010
(r215673)
@@ -371,6 +371,8 @@ ng_eiface_constructor(node_p node)
ifp->if_ioctl = ng_eiface_ioctl;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_flags = (IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST);
+   ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
+   ifp->if_capenable = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
 
/* Give this node the same name as the interface (if possible) */
if (ng_name_node(node, ifp->if_xname) != 0)

Modified: head/sys/netgraph/ng_eiface.h
==
--- head/sys/netgraph/ng_eiface.h   Mon Nov 22 11:24:11 2010
(r215672)
+++ head/sys/netgraph/ng_eiface.h   Mon Nov 22 12:32:19 2010
(r215673)
@@ -46,7 +46,7 @@
 
 /* MTU bounds */
 #define NG_EIFACE_MTU_MIN  72
-#define NG_EIFACE_MTU_MAX  2312
+#define NG_EIFACE_MTU_MAX  ETHER_MAX_LEN_JUMBO
 #define NG_EIFACE_MTU_DEFAULT  1500
 
 /* Netgraph commands */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r215318 - in head/sys: net sys

2010-11-15 Thread Marko Zec
On Monday 15 November 2010 15:58:15 Bjoern A. Zeeb wrote:
> On Sun, 14 Nov 2010, Dimitry Andric wrote:
> > Author: dim
> > Date: Sun Nov 14 20:40:55 2010
> > New Revision: 215318
> > URL: http://svn.freebsd.org/changeset/base/215318
> >
> > Log:
> >  Instead of unconditionally emitting .globl's for the __start_set_xxx and
> >  __stop_set_xxx symbols, only emit them when the set_vnet or set_pcpu
> >  sections are actually defined.
>
> Unless you have a very good reason that is NOT cosmetic for this I
> want to know it. None of you commit messages is giving this.
>
> This breaks the classic C semantics that we had gained with the former
> type of macros, which is a shame.
>
> Kind of annoying neither of the changes had a Reviewed by: and despite
> being about 2 weeks behind of most email I hadn't spotted this on arch@
> before nor seen it on virtualization@ that it obviously touches.  I
> would have loved to hear about them before foing to have a hard time
> integrating this white space into half a year of development work.
>
> Looking forward to the technical explanation.

Another fundamental problem is that the commit note doesn't include a MFC 
plan, so if we just leave it as is, starting from now on an extremely large 
portion MFCs of networking code will need to be hand-adjusted.

Marko


> > Modified:
> >  head/sys/net/vnet.h
> >  head/sys/sys/cdefs.h
> >  head/sys/sys/linker_set.h
> >  head/sys/sys/pcpu.h


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r212726 - head/sbin/sysctl

2010-09-16 Thread Marko Zec
Author: zec
Date: Thu Sep 16 10:53:01 2010
New Revision: 212726
URL: http://svn.freebsd.org/changeset/base/212726

Log:
  Make the format of "Real Memory" and "Virtual Memory" lines more
  consistent with the rest of sysctl vm.vmtotal output.
  
  MFC after:3 days

Modified:
  head/sbin/sysctl/sysctl.c

Modified: head/sbin/sysctl/sysctl.c
==
--- head/sbin/sysctl/sysctl.c   Thu Sep 16 09:29:48 2010(r212725)
+++ head/sbin/sysctl/sysctl.c   Thu Sep 16 10:53:01 2010(r212726)
@@ -406,9 +406,9 @@ S_vmtotal(int l2, void *p)
"%hd Sleep: %hd)\n",
v->t_rq, v->t_dw, v->t_pw, v->t_sl);
printf(
-   "Virtual Memory:\t\t(Total: %dK, Active %dK)\n",
+   "Virtual Memory:\t\t(Total: %dK Active: %dK)\n",
v->t_vm * pageKilo, v->t_avm * pageKilo);
-   printf("Real Memory:\t\t(Total: %dK Active %dK)\n",
+   printf("Real Memory:\t\t(Total: %dK Active: %dK)\n",
v->t_rm * pageKilo, v->t_arm * pageKilo);
printf("Shared Virtual Memory:\t(Total: %dK Active: %dK)\n",
v->t_vmshr * pageKilo, v->t_avmshr * pageKilo);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r212320 - stable/8/sys/net

2010-09-08 Thread Marko Zec
Author: zec
Date: Wed Sep  8 14:22:35 2010
New Revision: 212320
URL: http://svn.freebsd.org/changeset/base/212320

Log:
  MFC r211283:
  
When moving an ethernet ifnet from one vnet to another, destroy the
associated ng_ether netgraph node in the current vnet, and create a
new one in the target vnet.
  
Reviewed by:  julian

Modified:
  stable/8/sys/net/if.c
  stable/8/sys/net/if_ethersubr.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/net/if.c
==
--- stable/8/sys/net/if.c   Wed Sep  8 14:21:12 2010(r212319)
+++ stable/8/sys/net/if.c   Wed Sep  8 14:22:35 2010(r212320)
@@ -974,12 +974,21 @@ if_vmove(struct ifnet *ifp, struct vnet 
 */
IFNET_WLOCK();
ifindex_free_locked(ifp->if_index);
+   IFNET_WUNLOCK();
+
+   /*
+* Perform interface-specific reassignment tasks, if provided by
+* the driver.
+*/
+   if (ifp->if_reassign != NULL)
+   ifp->if_reassign(ifp, new_vnet, NULL);
 
/*
 * Switch to the context of the target vnet.
 */
CURVNET_SET_QUIET(new_vnet);
 
+   IFNET_WLOCK();
if (ifindex_alloc_locked(&idx) != 0) {
IFNET_WUNLOCK();
panic("if_index overflow");

Modified: stable/8/sys/net/if_ethersubr.c
==
--- stable/8/sys/net/if_ethersubr.c Wed Sep  8 14:21:12 2010
(r212319)
+++ stable/8/sys/net/if_ethersubr.c Wed Sep  8 14:22:35 2010
(r212320)
@@ -135,6 +135,9 @@ static const u_char etherbroadcastaddr[E
 
 static int ether_resolvemulti(struct ifnet *, struct sockaddr **,
struct sockaddr *);
+#ifdef VIMAGE
+static void ether_reassign(struct ifnet *, struct vnet *, char *);
+#endif
 
 /* XXX: should be in an arp support file, not here */
 MALLOC_DEFINE(M_ARPCOM, "arpcom", "802.* interface internals");
@@ -954,6 +957,9 @@ ether_ifattach(struct ifnet *ifp, const 
ifp->if_output = ether_output;
ifp->if_input = ether_input;
ifp->if_resolvemulti = ether_resolvemulti;
+#ifdef VIMAGE
+   ifp->if_reassign = ether_reassign;
+#endif
if (ifp->if_baudrate == 0)
ifp->if_baudrate = IF_Mbps(10); /* just a default */
ifp->if_broadcastaddr = etherbroadcastaddr;
@@ -993,6 +999,25 @@ ether_ifdetach(struct ifnet *ifp)
if_detach(ifp);
 }
 
+#ifdef VIMAGE
+void
+ether_reassign(struct ifnet *ifp, struct vnet *new_vnet, char *unused __unused)
+{
+
+   if (IFP2AC(ifp)->ac_netgraph != NULL) {
+   KASSERT(ng_ether_detach_p != NULL,
+   ("ng_ether_detach_p is NULL"));
+   (*ng_ether_detach_p)(ifp);
+   }
+
+   if (ng_ether_attach_p != NULL) {
+   CURVNET_SET_QUIET(new_vnet);
+   (*ng_ether_attach_p)(ifp);
+   CURVNET_RESTORE();
+   }
+}
+#endif
+
 SYSCTL_DECL(_net_link);
 SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet");
 #if defined(INET) || defined(INET6)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r212319 - stable/8/sys/netinet

2010-09-08 Thread Marko Zec
Author: zec
Date: Wed Sep  8 14:21:12 2010
New Revision: 212319
URL: http://svn.freebsd.org/changeset/base/212319

Log:
  MFC r208744:
  
Virtualize the IPv4 multicast routing code.
  
Submitted by: iprebeg
Reviewed by:  bms, bz, Pavlin Radoslavov

Modified:
  stable/8/sys/netinet/ip_mroute.c
  stable/8/sys/netinet/ip_mroute.h
  stable/8/sys/netinet/pim_var.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/netinet/ip_mroute.c
==
--- stable/8/sys/netinet/ip_mroute.cWed Sep  8 14:19:33 2010
(r212318)
+++ stable/8/sys/netinet/ip_mroute.cWed Sep  8 14:21:12 2010
(r212319)
@@ -123,6 +123,9 @@ __FBSDID("$FreeBSD$");
 #defineVIFI_INVALID((vifi_t) -1)
 #defineM_HASCL(m)  ((m)->m_flags & M_EXT)
 
+static VNET_DEFINE(uint32_t, last_tv_sec); /* last time we processed this */
+#defineV_last_tv_sec   VNET(last_tv_sec)
+
 static MALLOC_DEFINE(M_MRTABLE, "mroutetbl", "multicast forwarding cache");
 
 /*
@@ -141,21 +144,28 @@ static struct mtx mrouter_mtx;
mtx_init(&mrouter_mtx, "IPv4 multicast forwarding", NULL, MTX_DEF)
 #defineMROUTER_LOCK_DESTROY()  mtx_destroy(&mrouter_mtx)
 
-static struct mrtstat  mrtstat;
-SYSCTL_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW,
-&mrtstat, mrtstat,
+static int ip_mrouter_cnt; /* # of vnets with active mrouters */
+static int ip_mrouter_unloading; /* Allow no more V_ip_mrouter sockets */
+
+static VNET_DEFINE(struct mrtstat, mrtstat);
+#defineV_mrtstat   VNET(mrtstat)
+SYSCTL_VNET_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW,
+&VNET_NAME(mrtstat), mrtstat,
 "IPv4 Multicast Forwarding Statistics (struct mrtstat, "
 "netinet/ip_mroute.h)");
 
-static u_long   mfchash;
-#define MFCHASH(a, g)  \
+static VNET_DEFINE(u_long, mfchash);
+#defineV_mfchash   VNET(mfchash)
+#defineMFCHASH(a, g)   
\
a).s_addr >> 20) ^ ((a).s_addr >> 10) ^ (a).s_addr ^ \
- ((g).s_addr >> 20) ^ ((g).s_addr >> 10) ^ (g).s_addr) & mfchash)
-#define MFCHASHSIZE256
+ ((g).s_addr >> 20) ^ ((g).s_addr >> 10) ^ (g).s_addr) & V_mfchash)
+#defineMFCHASHSIZE 256
 
-static u_char  *nexpire;   /* 0..mfchashsize-1 */
-static u_long   mfchashsize;   /* Hash size */
-LIST_HEAD(mfchashhdr, mfc) *mfchashtbl;
+static u_long mfchashsize; /* Hash size */
+static VNET_DEFINE(u_char *, nexpire); /* 0..mfchashsize-1 */
+#defineV_nexpire   VNET(nexpire)
+static VNET_DEFINE(LIST_HEAD(mfchashhdr, mfc)*, mfchashtbl);
+#defineV_mfchashtblVNET(mfchashtbl)
 
 static struct mtx mfc_mtx;
 #defineMFC_LOCK()  mtx_lock(&mfc_mtx)
@@ -165,10 +175,12 @@ static struct mtx mfc_mtx;
mtx_init(&mfc_mtx, "IPv4 multicast forwarding cache", NULL, MTX_DEF)
 #defineMFC_LOCK_DESTROY()  mtx_destroy(&mfc_mtx)
 
-static vifi_t  numvifs;
-static struct vif  viftable[MAXVIFS];
-SYSCTL_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_RD,
-&viftable, sizeof(viftable), "S,vif[MAXVIFS]",
+static VNET_DEFINE(vifi_t, numvifs);
+#defineV_numvifs   VNET(numvifs)
+static VNET_DEFINE(struct vif, viftable[MAXVIFS]);
+#defineV_viftable  VNET(viftable)
+SYSCTL_VNET_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_RD,
+&VNET_NAME(viftable), sizeof(V_viftable), "S,vif[MAXVIFS]",
 "IPv4 Multicast Interfaces (struct vif[MAXVIFS], netinet/ip_mroute.h)");
 
 static struct mtx vif_mtx;
@@ -181,7 +193,9 @@ static struct mtx vif_mtx;
 
 static eventhandler_tag if_detach_event_tag = NULL;
 
-static struct callout expire_upcalls_ch;
+static VNET_DEFINE(struct callout, expire_upcalls_ch);
+#defineV_expire_upcalls_ch VNET(expire_upcalls_ch)
+
 #defineEXPIRE_TIMEOUT  (hz / 4)/* 4x / second  
*/
 #defineUPCALL_EXPIRE   6   /* number of timeouts   
*/
 
@@ -193,25 +207,32 @@ static MALLOC_DEFINE(M_BWMETER, "bwmeter
  * Pending timeouts are stored in a hash table, the key being the
  * expiration time. Periodically, the entries are analysed and processed.
  */
-#define BW_METER_BUCKETS   1024
-static struct bw_meter *bw_meter_timers[BW_METER_BUCKETS];
-static struct callout bw_meter_ch;
-#define BW_METER_PERIOD (hz)   /* periodical handling of bw meters */
+#defineBW_METER_BUCKETS1024
+static VNET_DEFIN

svn commit: r212318 - stable/8/sys/net

2010-09-08 Thread Marko Zec
Author: zec
Date: Wed Sep  8 14:19:33 2010
New Revision: 212318
URL: http://svn.freebsd.org/changeset/base/212318

Log:
  MFC r208743:
  
Provide a macro for registering a virtualized sysctl handler for
VNET opaque data.

Modified:
  stable/8/sys/net/vnet.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/net/vnet.h
==
--- stable/8/sys/net/vnet.h Wed Sep  8 13:26:19 2010(r212317)
+++ stable/8/sys/net/vnet.h Wed Sep  8 14:19:33 2010(r212318)
@@ -236,6 +236,11 @@ intvnet_sysctl_handle_uint(SYSCTL_HANDL
fmt, descr) \
SYSCTL_OID(parent, nbr, name, CTLFLAG_VNET|(access), ptr, arg,  \
handler, fmt, descr)
+#defineSYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt,
\
+   descr)  \
+   SYSCTL_OID(parent, nbr, name,   \
+   CTLTYPE_OPAQUE|CTLFLAG_VNET|(access), ptr, len, \
+   vnet_sysctl_handle_opaque, fmt, descr)
 #defineSYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr)  
\
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_STRING|CTLFLAG_VNET|(access),   \
@@ -389,6 +394,9 @@ do {
\
fmt, descr) \
SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt,  \
descr)
+#defineSYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt,
\
+   descr)  \
+   SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr)
 #defineSYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr)  
\
SYSCTL_STRING(parent, nbr, name, access, arg, len, descr)
 #defineSYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr) 
\
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211283 - head/sys/net

2010-08-13 Thread Marko Zec
Author: zec
Date: Fri Aug 13 18:17:32 2010
New Revision: 211283
URL: http://svn.freebsd.org/changeset/base/211283

Log:
  When moving an ethernet ifnet from one vnet to another, destroy the
  associated ng_ether netgraph node in the current vnet, and create a
  new one in the target vnet.
  
  Reviewed by:  julian
  MFC after:3 days

Modified:
  head/sys/net/if.c
  head/sys/net/if_ethersubr.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Fri Aug 13 15:17:19 2010(r211282)
+++ head/sys/net/if.c   Fri Aug 13 18:17:32 2010(r211283)
@@ -956,12 +956,21 @@ if_vmove(struct ifnet *ifp, struct vnet 
 */
IFNET_WLOCK();
ifindex_free_locked(ifp->if_index);
+   IFNET_WUNLOCK();
+
+   /*
+* Perform interface-specific reassignment tasks, if provided by
+* the driver.
+*/
+   if (ifp->if_reassign != NULL)
+   ifp->if_reassign(ifp, new_vnet, NULL);
 
/*
 * Switch to the context of the target vnet.
 */
CURVNET_SET_QUIET(new_vnet);
 
+   IFNET_WLOCK();
if (ifindex_alloc_locked(&idx) != 0) {
IFNET_WUNLOCK();
panic("if_index overflow");

Modified: head/sys/net/if_ethersubr.c
==
--- head/sys/net/if_ethersubr.c Fri Aug 13 15:17:19 2010(r211282)
+++ head/sys/net/if_ethersubr.c Fri Aug 13 18:17:32 2010(r211283)
@@ -129,6 +129,9 @@ static const u_char etherbroadcastaddr[E
 
 static int ether_resolvemulti(struct ifnet *, struct sockaddr **,
struct sockaddr *);
+#ifdef VIMAGE
+static void ether_reassign(struct ifnet *, struct vnet *, char *);
+#endif
 
 /* XXX: should be in an arp support file, not here */
 MALLOC_DEFINE(M_ARPCOM, "arpcom", "802.* interface internals");
@@ -944,6 +947,9 @@ ether_ifattach(struct ifnet *ifp, const 
ifp->if_output = ether_output;
ifp->if_input = ether_input;
ifp->if_resolvemulti = ether_resolvemulti;
+#ifdef VIMAGE
+   ifp->if_reassign = ether_reassign;
+#endif
if (ifp->if_baudrate == 0)
ifp->if_baudrate = IF_Mbps(10); /* just a default */
ifp->if_broadcastaddr = etherbroadcastaddr;
@@ -983,6 +989,25 @@ ether_ifdetach(struct ifnet *ifp)
if_detach(ifp);
 }
 
+#ifdef VIMAGE
+void
+ether_reassign(struct ifnet *ifp, struct vnet *new_vnet, char *unused __unused)
+{
+
+   if (IFP2AC(ifp)->ac_netgraph != NULL) {
+   KASSERT(ng_ether_detach_p != NULL,
+   ("ng_ether_detach_p is NULL"));
+   (*ng_ether_detach_p)(ifp);
+   }
+
+   if (ng_ether_attach_p != NULL) {
+   CURVNET_SET_QUIET(new_vnet);
+   (*ng_ether_attach_p)(ifp);
+   CURVNET_RESTORE();
+   }
+}
+#endif
+
 SYSCTL_DECL(_net_link);
 SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet");
 #if defined(INET) || defined(INET6)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r209723 - head/sys/netgraph

2010-07-06 Thread Marko Zec
Author: zec
Date: Tue Jul  6 12:13:15 2010
New Revision: 209723
URL: http://svn.freebsd.org/changeset/base/209723

Log:
  Fix a double-free bug which can occur if both bit error rate and packet
  duplication probability are configured on a ng_pipe node.
  
  Submitted by: Jeffrey Ahrenholtz
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_pipe.c

Modified: head/sys/netgraph/ng_pipe.c
==
--- head/sys/netgraph/ng_pipe.c Tue Jul  6 10:45:38 2010(r209722)
+++ head/sys/netgraph/ng_pipe.c Tue Jul  6 12:13:15 2010(r209723)
@@ -779,8 +779,9 @@ pipe_dequeue(struct hookinfo *hinfo, str
random() % 100 <= hinfo->cfg.duplicate) {
ngp_h = uma_zalloc(ngp_zone, M_NOWAIT);
KASSERT(ngp_h != NULL, ("ngp_h zalloc failed (3)"));
-   ngp_h->m = m_dup(m, M_NOWAIT);
-   KASSERT(ngp_h->m != NULL, ("m_dup failed"));
+   m = m_dup(m, M_NOWAIT);
+   KASSERT(m != NULL, ("m_dup failed"));
+   ngp_h->m = m;
} else {
TAILQ_REMOVE(&ngp_f->packet_head, ngp_h, ngp_link);
hinfo->run.qin_frames--;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r208744 - head/sys/netinet

2010-06-02 Thread Marko Zec
Author: zec
Date: Wed Jun  2 15:44:43 2010
New Revision: 208744
URL: http://svn.freebsd.org/changeset/base/208744

Log:
  Virtualize the IPv4 multicast routing code.
  
  Submitted by: iprebeg
  Reviewed by:  bms, bz, Pavlin Radoslavov
  MFC after:30 days

Modified:
  head/sys/netinet/ip_mroute.c
  head/sys/netinet/ip_mroute.h
  head/sys/netinet/pim_var.h

Modified: head/sys/netinet/ip_mroute.c
==
--- head/sys/netinet/ip_mroute.cWed Jun  2 15:29:21 2010
(r208743)
+++ head/sys/netinet/ip_mroute.cWed Jun  2 15:44:43 2010
(r208744)
@@ -121,6 +121,9 @@ __FBSDID("$FreeBSD$");
 #defineVIFI_INVALID((vifi_t) -1)
 #defineM_HASCL(m)  ((m)->m_flags & M_EXT)
 
+static VNET_DEFINE(uint32_t, last_tv_sec); /* last time we processed this */
+#defineV_last_tv_sec   VNET(last_tv_sec)
+
 static MALLOC_DEFINE(M_MRTABLE, "mroutetbl", "multicast forwarding cache");
 
 /*
@@ -139,21 +142,28 @@ static struct mtx mrouter_mtx;
mtx_init(&mrouter_mtx, "IPv4 multicast forwarding", NULL, MTX_DEF)
 #defineMROUTER_LOCK_DESTROY()  mtx_destroy(&mrouter_mtx)
 
-static struct mrtstat  mrtstat;
-SYSCTL_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW,
-&mrtstat, mrtstat,
+static int ip_mrouter_cnt; /* # of vnets with active mrouters */
+static int ip_mrouter_unloading; /* Allow no more V_ip_mrouter sockets */
+
+static VNET_DEFINE(struct mrtstat, mrtstat);
+#defineV_mrtstat   VNET(mrtstat)
+SYSCTL_VNET_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW,
+&VNET_NAME(mrtstat), mrtstat,
 "IPv4 Multicast Forwarding Statistics (struct mrtstat, "
 "netinet/ip_mroute.h)");
 
-static u_long   mfchash;
-#define MFCHASH(a, g)  \
+static VNET_DEFINE(u_long, mfchash);
+#defineV_mfchash   VNET(mfchash)
+#defineMFCHASH(a, g)   
\
a).s_addr >> 20) ^ ((a).s_addr >> 10) ^ (a).s_addr ^ \
- ((g).s_addr >> 20) ^ ((g).s_addr >> 10) ^ (g).s_addr) & mfchash)
-#define MFCHASHSIZE256
+ ((g).s_addr >> 20) ^ ((g).s_addr >> 10) ^ (g).s_addr) & V_mfchash)
+#defineMFCHASHSIZE 256
 
-static u_char  *nexpire;   /* 0..mfchashsize-1 */
-static u_long   mfchashsize;   /* Hash size */
-LIST_HEAD(mfchashhdr, mfc) *mfchashtbl;
+static u_long mfchashsize; /* Hash size */
+static VNET_DEFINE(u_char *, nexpire); /* 0..mfchashsize-1 */
+#defineV_nexpire   VNET(nexpire)
+static VNET_DEFINE(LIST_HEAD(mfchashhdr, mfc)*, mfchashtbl);
+#defineV_mfchashtblVNET(mfchashtbl)
 
 static struct mtx mfc_mtx;
 #defineMFC_LOCK()  mtx_lock(&mfc_mtx)
@@ -163,10 +173,12 @@ static struct mtx mfc_mtx;
mtx_init(&mfc_mtx, "IPv4 multicast forwarding cache", NULL, MTX_DEF)
 #defineMFC_LOCK_DESTROY()  mtx_destroy(&mfc_mtx)
 
-static vifi_t  numvifs;
-static struct vif  viftable[MAXVIFS];
-SYSCTL_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_RD,
-&viftable, sizeof(viftable), "S,vif[MAXVIFS]",
+static VNET_DEFINE(vifi_t, numvifs);
+#defineV_numvifs   VNET(numvifs)
+static VNET_DEFINE(struct vif, viftable[MAXVIFS]);
+#defineV_viftable  VNET(viftable)
+SYSCTL_VNET_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_RD,
+&VNET_NAME(viftable), sizeof(V_viftable), "S,vif[MAXVIFS]",
 "IPv4 Multicast Interfaces (struct vif[MAXVIFS], netinet/ip_mroute.h)");
 
 static struct mtx vif_mtx;
@@ -179,7 +191,9 @@ static struct mtx vif_mtx;
 
 static eventhandler_tag if_detach_event_tag = NULL;
 
-static struct callout expire_upcalls_ch;
+static VNET_DEFINE(struct callout, expire_upcalls_ch);
+#defineV_expire_upcalls_ch VNET(expire_upcalls_ch)
+
 #defineEXPIRE_TIMEOUT  (hz / 4)/* 4x / second  
*/
 #defineUPCALL_EXPIRE   6   /* number of timeouts   
*/
 
@@ -191,25 +205,32 @@ static MALLOC_DEFINE(M_BWMETER, "bwmeter
  * Pending timeouts are stored in a hash table, the key being the
  * expiration time. Periodically, the entries are analysed and processed.
  */
-#define BW_METER_BUCKETS   1024
-static struct bw_meter *bw_meter_timers[BW_METER_BUCKETS];
-static struct callout bw_meter_ch;
-#define BW_METER_PERIOD (hz)   /* periodical handling of bw meters */
+#defineBW_METER_BUCKETS1024
+static VNET_DEFINE(struct bw_meter*, bw_meter_timers[BW_METER_BUCKETS]);
+#defineV_bw_meter_timers   VNET(bw_meter_timers)
+static VNET_DEFINE(struct callout, bw_meter_ch);
+#defineV_bw_meter_ch   VNET(bw_meter_ch)
+#defineBW_METER_PERIOD (hz)/* periodical handling of bw 
meters */
 
 /*
  * Pendin

svn commit: r208743 - head/sys/net

2010-06-02 Thread Marko Zec
Author: zec
Date: Wed Jun  2 15:29:21 2010
New Revision: 208743
URL: http://svn.freebsd.org/changeset/base/208743

Log:
  Provide a macro for registering a virtualized sysctl handler for
  VNET opaque data.
  
  MFC after:30 days

Modified:
  head/sys/net/vnet.h

Modified: head/sys/net/vnet.h
==
--- head/sys/net/vnet.h Wed Jun  2 15:09:36 2010(r208742)
+++ head/sys/net/vnet.h Wed Jun  2 15:29:21 2010(r208743)
@@ -245,6 +245,11 @@ intvnet_sysctl_handle_uint(SYSCTL_HANDL
fmt, descr) \
SYSCTL_OID(parent, nbr, name, CTLFLAG_VNET|(access), ptr, arg,  \
handler, fmt, descr)
+#defineSYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt,
\
+   descr)  \
+   SYSCTL_OID(parent, nbr, name,   \
+   CTLTYPE_OPAQUE|CTLFLAG_VNET|(access), ptr, len, \
+   vnet_sysctl_handle_opaque, fmt, descr)
 #defineSYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr)  
\
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_STRING|CTLFLAG_VNET|(access),   \
@@ -398,6 +403,9 @@ do {
\
fmt, descr) \
SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt,  \
descr)
+#defineSYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt,
\
+   descr)  \
+   SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr)
 #defineSYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr)  
\
SYSCTL_STRING(parent, nbr, name, access, arg, len, descr)
 #defineSYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr) 
\
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r208146 - stable/8/sys/netgraph

2010-05-16 Thread Marko Zec
Author: zec
Date: Sun May 16 14:53:43 2010
New Revision: 208146
URL: http://svn.freebsd.org/changeset/base/208146

Log:
  MFC r208036:
  
Increase the target buffer for performing NGM_ASCII2BINARY conversion
from 2000 bytes to 20 Kbytes, which now matches the buffer size used for
NGM_BINARY2ASCII conversions.
  
The aim of this change is to allow for bigger binary structures to be
managed via netgraph ASCII messages, until we come up with an API
improvement which would get rid of such arbitrary hardcoded limits.

Modified:
  stable/8/sys/netgraph/ng_base.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/netgraph/ng_base.c
==
--- stable/8/sys/netgraph/ng_base.c Sun May 16 14:51:36 2010
(r208145)
+++ stable/8/sys/netgraph/ng_base.c Sun May 16 14:53:43 2010
(r208146)
@@ -2763,7 +2763,7 @@ ng_generic_msg(node_p here, item_p item,
 
case NGM_ASCII2BINARY:
{
-   int bufSize = 2000; /* XXX hard coded constant */
+   int bufSize = 20 * 1024;/* XXX hard coded constant */
const struct ng_cmdlist *c;
const struct ng_parse_type *argstype;
struct ng_mesg *ascii, *binary;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r208145 - in stable/8: share/man/man4 sys/netgraph

2010-05-16 Thread Marko Zec
Author: zec
Date: Sun May 16 14:51:36 2010
New Revision: 208145
URL: http://svn.freebsd.org/changeset/base/208145

Log:
  MFC r207680:
  
Add an optional "persistent" flag to ng_hub and ng_bridge, which if set,
disables automatic node shutdown when the last hook gets disconnected.
  
Reviewed by:  julian

Modified:
  stable/8/share/man/man4/ng_bridge.4
  stable/8/share/man/man4/ng_hub.4
  stable/8/sys/netgraph/ng_bridge.c
  stable/8/sys/netgraph/ng_bridge.h
  stable/8/sys/netgraph/ng_hub.c
  stable/8/sys/netgraph/ng_hub.h
Directory Properties:
  stable/8/share/man/man4/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/share/man/man4/ng_bridge.4
==
--- stable/8/share/man/man4/ng_bridge.4 Sun May 16 14:31:53 2010
(r208144)
+++ stable/8/share/man/man4/ng_bridge.4 Sun May 16 14:51:36 2010
(r208145)
@@ -34,7 +34,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 31, 2000
+.Dd May 5, 2010
 .Dt NG_BRIDGE 4
 .Os
 .Sh NAME
@@ -181,11 +181,17 @@ but also atomically clears the statistic
 .It Dv NGM_BRIDGE_GET_TABLE
 Returns the current host mapping table used to direct packets, in a
 .Dv "struct ng_bridge_host_ary" .
+.It Dv NGM_BRIDGE_SET_PERSISTENT
+This command sets the persistent flag on the node, and takes no arguments.
 .El
 .Sh SHUTDOWN
 This node shuts down upon receipt of a
 .Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
+control message, or when all hooks have been disconnected.  Setting the
+persistent flag via a
+.Dv NGM_BRIDGE_SET_PERSISTENT
+control message disables automatic node shutdown when the last hook gets
+disconnected.
 .Sh FILES
 .Bl -tag -width  -compact
 .It Pa /usr/share/examples/netgraph/ether.bridge

Modified: stable/8/share/man/man4/ng_hub.4
==
--- stable/8/share/man/man4/ng_hub.4Sun May 16 14:31:53 2010
(r208144)
+++ stable/8/share/man/man4/ng_hub.4Sun May 16 14:51:36 2010
(r208145)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 17, 2004
+.Dd May 5, 2010
 .Dt NG_HUB 4
 .Os
 .Sh NAME
@@ -45,11 +45,20 @@ A
 node accepts any request to connect, regardless of the hook name,
 as long as the name is unique.
 .Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
+This node type supports the generic control messages, plus the
+following:
+.Bl -tag -width foo
+.It Dv NGM_HUB_SET_PERSISTENT
+This command sets the persistent flag on the node, and takes no arguments.
+.El
 .Sh SHUTDOWN
 This node shuts down upon receipt of a
 .Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
+control message, or when all hooks have been disconnected.  Setting the
+persistent flag via a
+.Dv NGM_HUB_SET_PERSISTENT
+control message disables automatic node shutdown when the last hook gets
+disconnected.
 .Sh SEE ALSO
 .Xr netgraph 4 ,
 .Xr ng_bridge 4 ,

Modified: stable/8/sys/netgraph/ng_bridge.c
==
--- stable/8/sys/netgraph/ng_bridge.c   Sun May 16 14:31:53 2010
(r208144)
+++ stable/8/sys/netgraph/ng_bridge.c   Sun May 16 14:51:36 2010
(r208145)
@@ -83,7 +83,7 @@
 #include 
 
 #ifdef NG_SEPARATE_MALLOC
-MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", "netgraph bridge node ");
+MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", "netgraph bridge node");
 #else
 #define M_NETGRAPH_BRIDGE M_NETGRAPH
 #endif
@@ -105,6 +105,7 @@ struct ng_bridge_private {
u_int   numBuckets; /* num buckets in table */
u_int   hashMask;   /* numBuckets - 1 */
int numLinks;   /* num connected links */
+   int persistent; /* can exist w/o hooks */
struct callout  timer;  /* one second periodic timer */
 };
 typedef struct ng_bridge_private *priv_p;
@@ -270,6 +271,13 @@ static const struct ng_cmdlist ng_bridge
  NULL,
  &ng_bridge_host_ary_type
},
+   {
+ NGM_BRIDGE_COOKIE,
+ NGM_BRIDGE_SET_PERSISTENT,
+ "setpersistent",
+ NULL,
+ NULL
+   },
{ 0 }
 };
 
@@ -494,6 +502,11 @@ ng_bridge_rcvmsg(node_p node, item_p ite
}
break;
}
+   case NGM_BRIDGE_SET_PERSISTENT:
+   {
+   priv->persistent = 1;
+   break;
+   }
default:
error = EINVAL;
 

svn commit: r208036 - head/sys/netgraph

2010-05-13 Thread Marko Zec
Author: zec
Date: Thu May 13 16:48:28 2010
New Revision: 208036
URL: http://svn.freebsd.org/changeset/base/208036

Log:
  Increase the target buffer for performing NGM_ASCII2BINARY conversion
  from 2000 bytes to 20 Kbytes, which now matches the buffer size used for
  NGM_BINARY2ASCII conversions.
  
  The aim of this change is to allow for bigger binary structures to be
  managed via netgraph ASCII messages, until we come up with an API
  improvement which would get rid of such arbitrary hardcoded limits.
  
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_base.c

Modified: head/sys/netgraph/ng_base.c
==
--- head/sys/netgraph/ng_base.c Thu May 13 16:46:23 2010(r208035)
+++ head/sys/netgraph/ng_base.c Thu May 13 16:48:28 2010(r208036)
@@ -2763,7 +2763,7 @@ ng_generic_msg(node_p here, item_p item,
 
case NGM_ASCII2BINARY:
{
-   int bufSize = 2000; /* XXX hard coded constant */
+   int bufSize = 20 * 1024;/* XXX hard coded constant */
const struct ng_cmdlist *c;
const struct ng_parse_type *argstype;
struct ng_mesg *ascii, *binary;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r207698 - stable/8/sys/netgraph

2010-05-06 Thread Marko Zec
Author: zec
Date: Thu May  6 09:54:01 2010
New Revision: 207698
URL: http://svn.freebsd.org/changeset/base/207698

Log:
  MFC r207572:
When destroying a vnet, shut down all netgraph nodes tied to that vnet
before proceeding with dismantling other protocol domains.
  
This change only affects options VIMAGE builds.
  
Reviewed by:  julian, bz

Modified:
  stable/8/sys/netgraph/ng_base.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/netgraph/ng_base.c
==
--- stable/8/sys/netgraph/ng_base.c Thu May  6 09:52:32 2010
(r207697)
+++ stable/8/sys/netgraph/ng_base.c Thu May  6 09:54:01 2010
(r207698)
@@ -3067,28 +3067,42 @@ ng_mod_event(module_t mod, int event, vo
 static void
 vnet_netgraph_uninit(const void *unused __unused)
 {
-#if 0
-   node_p node, last_killed = NULL;
+   node_p node = NULL, last_killed = NULL;
+   int i;
+
+   do {
+   /* Find a node to kill */
+   mtx_lock(&ng_namehash_mtx);
+   for (i = 0; i < NG_NAME_HASH_SIZE; i++) {
+   LIST_FOREACH(node, &V_ng_name_hash[i], nd_nodes) {
+   if (node != &ng_deadnode) {
+   NG_NODE_REF(node);
+   break;
+   }
+   }
+   if (node != NULL)
+   break;
+   }
+   mtx_unlock(&ng_namehash_mtx);
 
-   /* XXXRW: utterly bogus. */
-   while ((node = LIST_FIRST(&V_ng_allnodes)) != NULL) {
-   if (node == last_killed) {
-   /* This should never happen */
-   node->nd_flags |= NGF_REALLY_DIE;
-   printf("netgraph node %s needs NGF_REALLY_DIE\n",
-   node->nd_name);
+   /* Attempt to kill it only if it is a regular node */
+   if (node != NULL) {
+   if (node == last_killed) {
+   /* This should never happen */
+   printf("ng node %s needs"
+   "NGF_REALLY_DIE\n", node->nd_name);
+   if (node->nd_flags & NGF_REALLY_DIE)
+   panic("ng node %s won't die",
+   node->nd_name);
+   node->nd_flags |= NGF_REALLY_DIE;
+   }
ng_rmnode(node, NULL, NULL, 0);
-   /* This must never happen */
-   if (node == LIST_FIRST(&V_ng_allnodes))
-   panic("netgraph node %s won't die",
-   node->nd_name);
+   NG_NODE_UNREF(node);
+   last_killed = node;
}
-   ng_rmnode(node, NULL, NULL, 0);
-   last_killed = node;
-   }
-#endif
+   } while (node != NULL);
 }
-VNET_SYSUNINIT(vnet_netgraph_uninit, SI_SUB_NETGRAPH, SI_ORDER_ANY,
+VNET_SYSUNINIT(vnet_netgraph_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
 vnet_netgraph_uninit, NULL);
 #endif /* VIMAGE */
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r207697 - stable/8/sys/kern

2010-05-06 Thread Marko Zec
Author: zec
Date: Thu May  6 09:52:32 2010
New Revision: 207697
URL: http://svn.freebsd.org/changeset/base/207697

Log:
  MFC r207475:
Remove a redundant variable assignment.
  
Reviewed by:  bz, rwatson

Modified:
  stable/8/sys/kern/uipc_mbuf.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/kern/uipc_mbuf.c
==
--- stable/8/sys/kern/uipc_mbuf.c   Thu May  6 06:44:26 2010
(r207696)
+++ stable/8/sys/kern/uipc_mbuf.c   Thu May  6 09:52:32 2010
(r207697)
@@ -948,9 +948,8 @@ m_adj(struct mbuf *mp, int req_len)
len = 0;
}
}
-   m = mp;
if (mp->m_flags & M_PKTHDR)
-   m->m_pkthdr.len -= (req_len - len);
+   mp->m_pkthdr.len -= (req_len - len);
} else {
/*
 * Trim from tail.  Scan the mbuf chain,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r207680 - in head: share/man/man4 sys/netgraph

2010-05-05 Thread Marko Zec
Author: zec
Date: Wed May  5 22:06:05 2010
New Revision: 207680
URL: http://svn.freebsd.org/changeset/base/207680

Log:
  Add an optional "persistent" flag to ng_hub and ng_bridge, which if set,
  disables automatic node shutdown when the last hook gets disconnected.
  
  Reviewed by:  julian

Modified:
  head/share/man/man4/ng_bridge.4
  head/share/man/man4/ng_hub.4
  head/sys/netgraph/ng_bridge.c
  head/sys/netgraph/ng_bridge.h
  head/sys/netgraph/ng_hub.c
  head/sys/netgraph/ng_hub.h

Modified: head/share/man/man4/ng_bridge.4
==
--- head/share/man/man4/ng_bridge.4 Wed May  5 22:00:57 2010
(r207679)
+++ head/share/man/man4/ng_bridge.4 Wed May  5 22:06:05 2010
(r207680)
@@ -34,7 +34,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 31, 2000
+.Dd May 5, 2010
 .Dt NG_BRIDGE 4
 .Os
 .Sh NAME
@@ -181,11 +181,17 @@ but also atomically clears the statistic
 .It Dv NGM_BRIDGE_GET_TABLE
 Returns the current host mapping table used to direct packets, in a
 .Dv "struct ng_bridge_host_ary" .
+.It Dv NGM_BRIDGE_SET_PERSISTENT
+This command sets the persistent flag on the node, and takes no arguments.
 .El
 .Sh SHUTDOWN
 This node shuts down upon receipt of a
 .Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
+control message, or when all hooks have been disconnected.  Setting the
+persistent flag via a
+.Dv NGM_BRIDGE_SET_PERSISTENT
+control message disables automatic node shutdown when the last hook gets
+disconnected.
 .Sh FILES
 .Bl -tag -width  -compact
 .It Pa /usr/share/examples/netgraph/ether.bridge

Modified: head/share/man/man4/ng_hub.4
==
--- head/share/man/man4/ng_hub.4Wed May  5 22:00:57 2010
(r207679)
+++ head/share/man/man4/ng_hub.4Wed May  5 22:06:05 2010
(r207680)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 17, 2004
+.Dd May 5, 2010
 .Dt NG_HUB 4
 .Os
 .Sh NAME
@@ -45,11 +45,20 @@ A
 node accepts any request to connect, regardless of the hook name,
 as long as the name is unique.
 .Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
+This node type supports the generic control messages, plus the
+following:
+.Bl -tag -width foo
+.It Dv NGM_HUB_SET_PERSISTENT
+This command sets the persistent flag on the node, and takes no arguments.
+.El
 .Sh SHUTDOWN
 This node shuts down upon receipt of a
 .Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
+control message, or when all hooks have been disconnected.  Setting the
+persistent flag via a
+.Dv NGM_HUB_SET_PERSISTENT
+control message disables automatic node shutdown when the last hook gets
+disconnected.
 .Sh SEE ALSO
 .Xr netgraph 4 ,
 .Xr ng_bridge 4 ,

Modified: head/sys/netgraph/ng_bridge.c
==
--- head/sys/netgraph/ng_bridge.c   Wed May  5 22:00:57 2010
(r207679)
+++ head/sys/netgraph/ng_bridge.c   Wed May  5 22:06:05 2010
(r207680)
@@ -84,7 +84,7 @@
 #include 
 
 #ifdef NG_SEPARATE_MALLOC
-MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", "netgraph bridge node ");
+MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", "netgraph bridge node");
 #else
 #define M_NETGRAPH_BRIDGE M_NETGRAPH
 #endif
@@ -106,6 +106,7 @@ struct ng_bridge_private {
u_int   numBuckets; /* num buckets in table */
u_int   hashMask;   /* numBuckets - 1 */
int numLinks;   /* num connected links */
+   int persistent; /* can exist w/o hooks */
struct callout  timer;  /* one second periodic timer */
 };
 typedef struct ng_bridge_private *priv_p;
@@ -271,6 +272,13 @@ static const struct ng_cmdlist ng_bridge
  NULL,
  &ng_bridge_host_ary_type
},
+   {
+ NGM_BRIDGE_COOKIE,
+ NGM_BRIDGE_SET_PERSISTENT,
+ "setpersistent",
+ NULL,
+ NULL
+   },
{ 0 }
 };
 
@@ -495,6 +503,11 @@ ng_bridge_rcvmsg(node_p node, item_p ite
}
break;
}
+   case NGM_BRIDGE_SET_PERSISTENT:
+   {
+   priv->persistent = 1;
+   break;
+   }
default:
error = EINVAL;
break;
@@ -800,7 +813,8 @@ ng_bridge_disconnect(hook_p hook)
 
/* If no more hooks, go away */
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
-   && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook {
+   && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))
+   && !priv->persistent) {
ng_rmnode_self(NG_HOOK_NODE(hook));
}
return (0);

Modified: head/sys/netgraph/ng_bridge.h

svn commit: r207572 - head/sys/netgraph

2010-05-03 Thread Marko Zec
Author: zec
Date: Mon May  3 16:08:24 2010
New Revision: 207572
URL: http://svn.freebsd.org/changeset/base/207572

Log:
  When destroying a vnet, shut down all netgraph nodes tied to that vnet
  before proceeding with dismantling other protocol domains.
  
  This change only affects options VIMAGE builds.
  
  Reviewed by:  julian, bz
  MFC after:3 days

Modified:
  head/sys/netgraph/ng_base.c

Modified: head/sys/netgraph/ng_base.c
==
--- head/sys/netgraph/ng_base.c Mon May  3 15:51:59 2010(r207571)
+++ head/sys/netgraph/ng_base.c Mon May  3 16:08:24 2010(r207572)
@@ -3067,28 +3067,42 @@ ng_mod_event(module_t mod, int event, vo
 static void
 vnet_netgraph_uninit(const void *unused __unused)
 {
-#if 0
-   node_p node, last_killed = NULL;
+   node_p node = NULL, last_killed = NULL;
+   int i;
+
+   do {
+   /* Find a node to kill */
+   mtx_lock(&ng_namehash_mtx);
+   for (i = 0; i < NG_NAME_HASH_SIZE; i++) {
+   LIST_FOREACH(node, &V_ng_name_hash[i], nd_nodes) {
+   if (node != &ng_deadnode) {
+   NG_NODE_REF(node);
+   break;
+   }
+   }
+   if (node != NULL)
+   break;
+   }
+   mtx_unlock(&ng_namehash_mtx);
 
-   /* XXXRW: utterly bogus. */
-   while ((node = LIST_FIRST(&V_ng_allnodes)) != NULL) {
-   if (node == last_killed) {
-   /* This should never happen */
-   node->nd_flags |= NGF_REALLY_DIE;
-   printf("netgraph node %s needs NGF_REALLY_DIE\n",
-   node->nd_name);
+   /* Attempt to kill it only if it is a regular node */
+   if (node != NULL) {
+   if (node == last_killed) {
+   /* This should never happen */
+   printf("ng node %s needs"
+   "NGF_REALLY_DIE\n", node->nd_name);
+   if (node->nd_flags & NGF_REALLY_DIE)
+   panic("ng node %s won't die",
+   node->nd_name);
+   node->nd_flags |= NGF_REALLY_DIE;
+   }
ng_rmnode(node, NULL, NULL, 0);
-   /* This must never happen */
-   if (node == LIST_FIRST(&V_ng_allnodes))
-   panic("netgraph node %s won't die",
-   node->nd_name);
+   NG_NODE_UNREF(node);
+   last_killed = node;
}
-   ng_rmnode(node, NULL, NULL, 0);
-   last_killed = node;
-   }
-#endif
+   } while (node != NULL);
 }
-VNET_SYSUNINIT(vnet_netgraph_uninit, SI_SUB_NETGRAPH, SI_ORDER_ANY,
+VNET_SYSUNINIT(vnet_netgraph_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
 vnet_netgraph_uninit, NULL);
 #endif /* VIMAGE */
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r207475 - head/sys/kern

2010-05-01 Thread Marko Zec
Author: zec
Date: Sat May  1 18:34:50 2010
New Revision: 207475
URL: http://svn.freebsd.org/changeset/base/207475

Log:
  Remove a redundant variable assignment.
  
  Reviewed by:  bz, rwatson
  MFC after:3 days

Modified:
  head/sys/kern/uipc_mbuf.c

Modified: head/sys/kern/uipc_mbuf.c
==
--- head/sys/kern/uipc_mbuf.c   Sat May  1 16:39:46 2010(r207474)
+++ head/sys/kern/uipc_mbuf.c   Sat May  1 18:34:50 2010(r207475)
@@ -948,9 +948,8 @@ m_adj(struct mbuf *mp, int req_len)
len = 0;
}
}
-   m = mp;
if (mp->m_flags & M_PKTHDR)
-   m->m_pkthdr.len -= (req_len - len);
+   mp->m_pkthdr.len -= (req_len - len);
} else {
/*
 * Trim from tail.  Scan the mbuf chain,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r203748 - stable/8/sys/net

2010-02-10 Thread Marko Zec
Author: zec
Date: Wed Feb 10 08:50:06 2010
New Revision: 203748
URL: http://svn.freebsd.org/changeset/base/203748

Log:
  MFC r203483:
Instead of spamming the console on each curvnet recursion event, print
out each such call graph only once, along with a stack backtrace.  This
should make kernels built with VNET_DEBUG reasonably usable again in
busy / production environments.
  
Introduce a new DDB command "show vnetrcrs" which dumps the whole log
of distinctive curvnet recursion events.  This might be useful when
recursion reports get burried / lost too deep in the message buffer.
In the later case stack backtraces are not available.
  
Reviewed by:  bz

Modified:
  stable/8/sys/net/vnet.c
  stable/8/sys/net/vnet.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/netinet/   (props changed)

Modified: stable/8/sys/net/vnet.c
==
--- stable/8/sys/net/vnet.c Wed Feb 10 07:15:21 2010(r203747)
+++ stable/8/sys/net/vnet.c Wed Feb 10 08:50:06 2010(r203748)
@@ -37,8 +37,10 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_ddb.h"
+#include "opt_kdb.h"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -616,6 +618,65 @@ vnet_sysuninit(void)
VNET_SYSINIT_RUNLOCK();
 }
 
+#ifdef VNET_DEBUG
+struct vnet_recursion {
+   SLIST_ENTRY(vnet_recursion)  vnr_le;
+   const char  *prev_fn;
+   const char  *where_fn;
+   int  where_line;
+   struct vnet *old_vnet;
+   struct vnet *new_vnet;
+};
+
+static SLIST_HEAD(, vnet_recursion) vnet_recursions =
+SLIST_HEAD_INITIALIZER(vnet_recursions);
+
+static void
+vnet_print_recursion(struct vnet_recursion *vnr, int brief)
+{
+
+   if (!brief)
+   printf("CURVNET_SET() recursion in ");
+   printf("%s() line %d, prev in %s()", vnr->where_fn, vnr->where_line,
+   vnr->prev_fn);
+   if (brief)
+   printf(", ");
+   else
+   printf("\n");
+   printf("%p -> %p\n", vnr->old_vnet, vnr->new_vnet);
+}
+
+void
+vnet_log_recursion(struct vnet *old_vnet, const char *old_fn, int line)
+{
+   struct vnet_recursion *vnr;
+
+   /* Skip already logged recursion events. */
+   SLIST_FOREACH(vnr, &vnet_recursions, vnr_le)
+   if (vnr->prev_fn == old_fn &&
+   vnr->where_fn == curthread->td_vnet_lpush &&
+   vnr->where_line == line &&
+   (vnr->old_vnet == vnr->new_vnet) == (curvnet == old_vnet))
+   return;
+
+   vnr = malloc(sizeof(*vnr), M_VNET, M_NOWAIT | M_ZERO);
+   if (vnr == NULL)
+   panic("%s: malloc failed", __func__);
+   vnr->prev_fn = old_fn;
+   vnr->where_fn = curthread->td_vnet_lpush;
+   vnr->where_line = line;
+   vnr->old_vnet = old_vnet;
+   vnr->new_vnet = curvnet;
+
+   SLIST_INSERT_HEAD(&vnet_recursions, vnr, vnr_le);
+
+   vnet_print_recursion(vnr, 0);
+#ifdef KDB
+   kdb_backtrace();
+#endif
+}
+#endif /* VNET_DEBUG */
+
 #ifdef DDB
 DB_SHOW_COMMAND(vnets, db_show_vnets)
 {
@@ -637,4 +698,14 @@ DB_SHOW_COMMAND(vnets, db_show_vnets)
break;
}
 }
+
+#ifdef VNET_DEBUG
+DB_SHOW_COMMAND(vnetrcrs, db_show_vnetrcrs)
+{
+   struct vnet_recursion *vnr;
+
+   SLIST_FOREACH(vnr, &vnet_recursions, vnr_le)
+   vnet_print_recursion(vnr, 1);
+}
 #endif
+#endif /* DDB */

Modified: stable/8/sys/net/vnet.h
==
--- stable/8/sys/net/vnet.h Wed Feb 10 07:15:21 2010(r203747)
+++ stable/8/sys/net/vnet.h Wed Feb 10 08:50:06 2010(r203748)
@@ -108,6 +108,8 @@ voidvnet_destroy(struct vnet *vnet);
  * assertions.
  */
 #ifdef VNET_DEBUG
+void vnet_log_recursion(struct vnet *, const char *, int);
+
 #defineVNET_ASSERT(condition)  
\
if (!(condition)) { \
printf("VNET_ASSERT @ %s:%d %s():\n",   \
@@ -125,9 +127,7 @@ voidvnet_destroy(struct vnet *vnet);
 #defineCURVNET_SET_VERBOSE(arg)
\
CURVNET_SET_QUIET(arg)  \
if (saved_vnet) \
-   printf("CURVNET_SET(%p) in %s() on cpu %d, prev %p in %s()\n", \
-  curvnet, curthread->td_vnet_lpush, curcpu,   \
-

svn commit: r203483 - head/sys/net

2010-02-03 Thread Marko Zec
Author: zec
Date: Thu Feb  4 07:55:42 2010
New Revision: 203483
URL: http://svn.freebsd.org/changeset/base/203483

Log:
  Instead of spamming the console on each curvnet recursion event, print
  out each such call graph only once, along with a stack backtrace.  This
  should make kernels built with VNET_DEBUG reasonably usable again in
  busy / production environments.
  
  Introduce a new DDB command "show vnetrcrs" which dumps the whole log
  of distinctive curvnet recursion events.  This might be useful when
  recursion reports get burried / lost too deep in the message buffer.
  In the later case stack backtraces are not available.
  
  Reviewed by:  bz
  MFC after:3 days

Modified:
  head/sys/net/vnet.c
  head/sys/net/vnet.h

Modified: head/sys/net/vnet.c
==
--- head/sys/net/vnet.c Thu Feb  4 07:26:26 2010(r203482)
+++ head/sys/net/vnet.c Thu Feb  4 07:55:42 2010(r203483)
@@ -37,8 +37,10 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_ddb.h"
+#include "opt_kdb.h"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -616,6 +618,65 @@ vnet_sysuninit(void)
VNET_SYSINIT_RUNLOCK();
 }
 
+#ifdef VNET_DEBUG
+struct vnet_recursion {
+   SLIST_ENTRY(vnet_recursion)  vnr_le;
+   const char  *prev_fn;
+   const char  *where_fn;
+   int  where_line;
+   struct vnet *old_vnet;
+   struct vnet *new_vnet;
+};
+
+static SLIST_HEAD(, vnet_recursion) vnet_recursions =
+SLIST_HEAD_INITIALIZER(vnet_recursions);
+
+static void
+vnet_print_recursion(struct vnet_recursion *vnr, int brief)
+{
+
+   if (!brief)
+   printf("CURVNET_SET() recursion in ");
+   printf("%s() line %d, prev in %s()", vnr->where_fn, vnr->where_line,
+   vnr->prev_fn);
+   if (brief)
+   printf(", ");
+   else
+   printf("\n");
+   printf("%p -> %p\n", vnr->old_vnet, vnr->new_vnet);
+}
+
+void
+vnet_log_recursion(struct vnet *old_vnet, const char *old_fn, int line)
+{
+   struct vnet_recursion *vnr;
+
+   /* Skip already logged recursion events. */
+   SLIST_FOREACH(vnr, &vnet_recursions, vnr_le)
+   if (vnr->prev_fn == old_fn &&
+   vnr->where_fn == curthread->td_vnet_lpush &&
+   vnr->where_line == line &&
+   (vnr->old_vnet == vnr->new_vnet) == (curvnet == old_vnet))
+   return;
+
+   vnr = malloc(sizeof(*vnr), M_VNET, M_NOWAIT | M_ZERO);
+   if (vnr == NULL)
+   panic("%s: malloc failed", __func__);
+   vnr->prev_fn = old_fn;
+   vnr->where_fn = curthread->td_vnet_lpush;
+   vnr->where_line = line;
+   vnr->old_vnet = old_vnet;
+   vnr->new_vnet = curvnet;
+
+   SLIST_INSERT_HEAD(&vnet_recursions, vnr, vnr_le);
+
+   vnet_print_recursion(vnr, 0);
+#ifdef KDB
+   kdb_backtrace();
+#endif
+}
+#endif /* VNET_DEBUG */
+
 #ifdef DDB
 DB_SHOW_COMMAND(vnets, db_show_vnets)
 {
@@ -637,4 +698,14 @@ DB_SHOW_COMMAND(vnets, db_show_vnets)
break;
}
 }
+
+#ifdef VNET_DEBUG
+DB_SHOW_COMMAND(vnetrcrs, db_show_vnetrcrs)
+{
+   struct vnet_recursion *vnr;
+
+   SLIST_FOREACH(vnr, &vnet_recursions, vnr_le)
+   vnet_print_recursion(vnr, 1);
+}
 #endif
+#endif /* DDB */

Modified: head/sys/net/vnet.h
==
--- head/sys/net/vnet.h Thu Feb  4 07:26:26 2010(r203482)
+++ head/sys/net/vnet.h Thu Feb  4 07:55:42 2010(r203483)
@@ -108,6 +108,8 @@ voidvnet_destroy(struct vnet *vnet);
  * assertions.
  */
 #ifdef VNET_DEBUG
+void vnet_log_recursion(struct vnet *, const char *, int);
+
 #defineVNET_ASSERT(condition)  
\
if (!(condition)) { \
printf("VNET_ASSERT @ %s:%d %s():\n",   \
@@ -125,9 +127,7 @@ voidvnet_destroy(struct vnet *vnet);
 #defineCURVNET_SET_VERBOSE(arg)
\
CURVNET_SET_QUIET(arg)  \
if (saved_vnet) \
-   printf("CURVNET_SET(%p) in %s() on cpu %d, prev %p in %s()\n", \
-  curvnet, curthread->td_vnet_lpush, curcpu,   \
-  saved_vnet, saved_vnet_lpush);
+   vnet_log_recursion(saved_vnet, saved_vnet_lpush, __LINE__);
 
 #defineCURVNET_SET(arg)CURVNET_SET_VERBOSE(arg)
  
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r202968 - stable/8/sys/nfsclient

2010-01-25 Thread Marko Zec
Author: zec
Date: Mon Jan 25 14:17:13 2010
New Revision: 202968
URL: http://svn.freebsd.org/changeset/base/202968

Log:
  MFC r201895:
Reduce recursions on curvnet and thus spamming the console with warning
messages for kernels built with options VIMAGE and VNET_DEBUG enabled.
  
Reviewed by:  bz

Modified:
  stable/8/sys/nfsclient/nfs_vfsops.c
  stable/8/sys/nfsclient/nfs_vnops.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/nfsclient/nfs_vfsops.c
==
--- stable/8/sys/nfsclient/nfs_vfsops.c Mon Jan 25 12:23:51 2010
(r202967)
+++ stable/8/sys/nfsclient/nfs_vfsops.c Mon Jan 25 14:17:13 2010
(r202968)
@@ -423,14 +423,18 @@ nfs_mountroot(struct mount *mp)
char buf[128];
char *cp;
 
+   CURVNET_SET(TD_TO_VNET(td));
+
 #if defined(BOOTP_NFSROOT) && defined(BOOTP)
bootpc_init();  /* use bootp to get nfs_diskless filled in */
 #elif defined(NFS_ROOT)
nfs_setup_diskless();
 #endif
 
-   if (nfs_diskless_valid == 0)
+   if (nfs_diskless_valid == 0) {
+   CURVNET_RESTORE();
return (-1);
+   }
if (nfs_diskless_valid == 1)
nfs_convert_diskless();
 
@@ -516,6 +520,7 @@ nfs_mountroot(struct mount *mp)
nd->root_args.hostname = buf;
if ((error = nfs_mountdiskless(buf,
&nd->root_saddr, &nd->root_args, td, &vp, mp)) != 0) {
+   CURVNET_RESTORE();
return (error);
}
 
@@ -529,6 +534,7 @@ nfs_mountroot(struct mount *mp)
sizeof (prison0.pr_hostname));
mtx_unlock(&prison0.pr_mtx);
inittodr(ntohl(nd->root_time));
+   CURVNET_RESTORE();
return (0);
 }
 
@@ -827,8 +833,6 @@ nfs_mount(struct mount *mp)
has_fh_opt = 0;
has_hostname_opt = 0;
 
-   CURVNET_SET(CRED_TO_VNET(curthread->td_ucred));
-
if (vfs_filteropt(mp->mnt_optnew, nfs_opts)) {
error = EINVAL;
goto out;
@@ -1128,7 +1132,6 @@ out:
mp->mnt_kern_flag |= (MNTK_MPSAFE|MNTK_LOOKUP_SHARED);
MNT_IUNLOCK(mp);
}
-   CURVNET_RESTORE();
return (error);
 }
 

Modified: stable/8/sys/nfsclient/nfs_vnops.c
==
--- stable/8/sys/nfsclient/nfs_vnops.c  Mon Jan 25 12:23:51 2010
(r202967)
+++ stable/8/sys/nfsclient/nfs_vnops.c  Mon Jan 25 14:17:13 2010
(r202968)
@@ -1555,19 +1555,15 @@ nfs_create(struct vop_create_args *ap)
struct vattr vattr;
int v3 = NFS_ISV3(dvp);
 
-   CURVNET_SET(CRED_TO_VNET(curthread->td_ucred));
-
/*
 * Oops, not for me..
 */
if (vap->va_type == VSOCK) {
error = nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap);
-   CURVNET_RESTORE();
return (error);
}
 
if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0) {
-   CURVNET_RESTORE();
return (error);
}
if (vap->va_vaflags & VA_EXCLUSIVE)
@@ -1665,7 +1661,6 @@ nfsmout:
KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp);
}
mtx_unlock(&(VTONFS(dvp))->n_mtx);
-   CURVNET_RESTORE();
return (error);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   >