1773 Commits

Author SHA1 Message Date
thompsa
3a707b5728 MFC r1.52, fix inconsistencies with the bridge route table.
Approved by:	re (scottl)
2006-02-03 08:06:11 +00:00
glebius
c625a74834 MFC:
Add some initial locking to gif(4), that covers output path.
2006-01-31 15:56:47 +00:00
bz
42bcb0a389 MFC:
rev. 1.39 sys/net/if_gre.c
  rev. 1.21 sys/netinet/ip_gre.c      rev. 1.4  sys/netinet/ip_gre.h
  rev. 1.12 sys/netipsec/keysock.c    rev. 1.3  sys/netipsec/keysock.h
  rev. 1.32 sys/netkey/keysock.c      rev. 1.9  sys/netkey/keysock.h

  Fix stack corruptions on amd64.

  Vararg functions have a different calling convention than regular
  functions on amd64. Casting a varag function to a regular one to
  match the function pointer declaration will hide the varargs from
  the caller and we will end up with an incorrectly setup stack.

  Entirely remove the varargs from these functions and change the
  functions to match the declaration of the function pointers.
  Remove the now unnecessary casts.

  Lots of explanations and help from:     peter
  PR:                                     amd64/89261
2006-01-27 21:50:11 +00:00
oleg
a8c9b6ffde MFC 1.211:
1) remove useless check of loop_copy
2) convert loop_copy to "non-negative" flag
2006-01-26 23:18:11 +00:00
glebius
06cfdf6652 MFC 1.85 - 1.87: Some diagnostic nitpicking and cleanup.
MFC 1.88:
  Improve handling flags that must be propagated
  to the parent interface, such as IFF_PROMISC and
  IFF_ALLMULTI.  In addition, vlan(4) gains ability
  to migrate from one parent to another w/o losing
  its own flags.

  PR:             kern/81978
2006-01-26 22:21:37 +00:00
harti
f67a055541 MFC: IFDATA_DRIVERNAME support.
if_mib.h: 1.8
	if_mib.c: 1.18
2006-01-26 07:46:28 +00:00
cperciva
5648502507 Make sure buffers in if_bridge are fully initialized before copying
them to userland. [1]

MFC rev. 1.16 of sys/contrib/pf/net/pf_norm.c: Correct an error in pf
handling of IP packet fragments which could result in a kernel panic.
[2]

Security:	FreeBSD-SA-06:06.kmem [1]
Security:	FreeBSD-SA-06:07.pf [2]
2006-01-25 10:00:59 +00:00
brooks
28e24b4843 Backout ill considered MFC of 1.20. It doesn't compile.
Pointy hat:	brooks
2006-01-24 06:30:51 +00:00
brooks
d13e981617 MFC revs:
1.17: convert from network byte order to host byte order not to reverse.
  1.19: Get rid of the bogus IFP2FC() macro and use IFP2FWC().
  1.20: Fix ip_fastforward() return handling.

PR:		kern/91307 (1.19)
Found by:	Coverity Prevent(tm) (1.20)
2006-01-24 06:28:22 +00:00
thompsa
07a0a1ec64 MFC: if_bridge.c, r1.50; if_bridgevar.h, r1.10
Clear IFCAP_TXCSUM from member interfaces while bridging.
2006-01-18 20:49:21 +00:00
glebius
03bc08061d - Restore VLAN_INPUT_TAG() macro to preserve API compatibility for
third party drivers.
- Fix bugs destribed in previous revision using macro with
  another name.
2006-01-13 19:21:45 +00:00
glebius
ed67dec936 MFC:
- Use VLAN_TAG_VALUE() not only to read a dot1q tag
    value from an m_tag, but also to set it.  This reduces
    complex code duplication and improves its readability.
  - Fix VLAN_INPUT_TAG() macro, so that it doesn't touch mtag in
    case if memory allocation failed.
  - Remove fourth argument from VLAN_INPUT_TAG(), that was used
    incorrectly in almost all drivers. Indicate failure with
    mbuf value of NULL.
2006-01-13 11:51:11 +00:00
glebius
102e170e76 Merge rev. 1.130 that I though was merged long time ago. Thanks to emaste
for noticing this.

  Drop current rtentry lock before calling rt_getifa(). This fixes a LOR
  and a possible recursive use of rtentry mutex.
2006-01-12 00:22:12 +00:00
thompsa
6c8496e9b7 MFC: sync code to HEAD
- whitespace
 - add net.link.bridge.pfil_onlyip
 - use time_uptime
2006-01-03 21:47:34 +00:00
thompsa
d2572297a0 MFC: EtherIP support, adding gif interfaces to bridges. 2006-01-03 08:15:33 +00:00
thompsa
d5df7ef24c MFC r1.39-40, whitespace and M_ZERO fixes 2005-12-28 06:27:52 +00:00
thompsa
a48e8794fd MFC: Add support for creating span ports
sbin/ifconfig/ifbridge.c	r1.3
 sbin/ifconfig/ifconfig.8	r1.109
 sys/net/if_bridge.c		r1.36, 1.38
 sys/net/if_bridgevar.h		r1.7, 1.8
 sys/net/if_ethersubr.c		r1.210
2005-12-28 04:12:58 +00:00
thompsa
911c4e7496 MFC r1.41, do not BPF_MTAP the packet twice 2005-12-24 01:13:17 +00:00
thompsa
9bc985ef4d MFC r1.37: use m_dup rather than m_copypacket 2005-12-21 22:52:48 +00:00
glebius
25cfadb32a MFC 1.93:
Take if_baudrate from the parent. This fixes problem with SNMP
  daemons reporting zero speed for vlan(4) interfaces.
2005-12-12 11:18:15 +00:00
thompsa
b7b016a19f MFC r1.35, set IFF_BROADCAST on the interface 2005-12-07 03:10:42 +00:00
glebius
b7866a6d78 MFC 1.51:
Force this interface to be RUNNING.
2005-11-25 14:41:31 +00:00
glebius
5baa2f368f MFC 1.89:
- Do not raise IFF_DRV_OACTIVE flag in vlan_start, because this
    can lead to stalled interface
  - Explain this fact in a comment.

  Reviewed by:    rwatson, thompsa, yar
2005-11-25 14:34:05 +00:00
ru
539591f019 MFC: Use sparse initializers for "struct domain" and "struct protosw". 2005-11-16 10:31:23 +00:00
thompsa
f012cfe982 MFC: Sync bridge code up with HEAD
- plug mbuf and refcnt leak
 - make funtions static
2005-11-16 10:17:15 +00:00
ru
c474afb088 MFC: 1.203: Remove a stale comment. 2005-11-16 08:49:22 +00:00
csjp
516e77bfa8 MFC Log:
Before we export network interface data through the ifmibdata structure,
  OR the flags bits with the driver managed status flags.
2005-11-08 16:38:21 +00:00
ume
d87e40fcf5 MFC: scope cleanup. with this change
- most of the kernel code will not care about the actual encoding of
  scope zone IDs and won't touch "s6_addr16[1]" directly.
- similarly, most of the kernel code will not care about link-local
  scoped addresses as a special case.
- scope boundary check will be stricter.  For example, the current
  *BSD code allows a packet with src=::1 and dst=(some global IPv6
  address) to be sent outside of the node, if the application do:
    s = socket(AF_INET6);
    bind(s, "::1");
    sendto(s, some_global_IPv6_addr);
  This is clearly wrong, since ::1 is only meaningful within a single
  node, but the current implementation of the *BSD kernel cannot
  reject this attempt.

	sys/net/if_gif.c:		1.53
	sys/net/if_spppsubr.c:		1.120
	sys/netinet/icmp6.h:		1.19
	sys/netinet/ip_carp.c:		1.28,1.29
	sys/netinet/ip_fw2.c:		1.107
	sys/netinet/tcp_subr.c:		1.230,1.231,1.235
	sys/netinet/tcp_usrreq.c:	1.125
	sys/netinet6/ah_core.c:		1.26
	sys/netinet6/icmp6.c:		1.63,1.64
	sys/netinet6/in6.c:		1.52
	sys/netinet6/in6.h:		1.38
	sys/netinet6/in6_cksum.c:	1.11
	sys/netinet6/in6_ifattach.c:	1.27
	sys/netinet6/in6_pcb.c:		1.63
	sys/netinet6/in6_proto.c:	1.33
	sys/netinet6/in6_src.c:		1.31,1.32
	sys/netinet6/in6_var.h:		1.22
	sys/netinet6/ip6_forward.c:	1.29
	sys/netinet6/ip6_input.c:	1.83
	sys/netinet6/ip6_mroute.c:	1.30
	sys/netinet6/ip6_output.c:	1.95
	sys/netinet6/ip6_var.h:		1.33
	sys/netinet6/ipsec.c:		1.43
	sys/netinet6/mld6.c:		1.21
	sys/netinet6/nd6.c:		1.50
	sys/netinet6/nd6_nbr.c:		1.30
	sys/netinet6/nd6_rtr.c:		1.27
	sys/netinet6/raw_ip6.c:		1.54
	sys/netinet6/route6.c:		1.12
	sys/netinet6/scope6.c:		1.13,1.14,1.15
	sys/netinet6/scope6_var.h:	1.5
	sys/netinet6/udp6_output.c:	1.23
	sys/netinet6/udp6_usrreq.c:	1.55
	sys/netkey/key.c:		1.72,1.73
2005-11-04 20:26:16 +00:00
avatar
07ad715e98 MFC: (1.16) Fixing a name collision in module declaration by renaming
"firewire" to "if_firewire."  According to the PR originator and Cai's
test, this bug prevents a RELENG_6 GENERIC kernel from loading if_fwip.ko
and will panic the kernel if users compile "device fwip" into their
GENERIC kernel.

Approved by:	re (scottl)
2005-10-28 22:45:52 +00:00
thompsa
5fa108d1d5 MFC if_bridge r1.30
> If we have been called from ether_ifdetach() then do not try and clear the
> promisc flag from the member interface, this is a no-op anyway since the
> interface is disappearing. The driver may have already released
> its resources such as miibus and this is likely to panic the kernel.

Approved by:	re (scottl)
2005-10-27 19:41:43 +00:00
thompsa
35a7273cfa MFC ng_ether support for if_bridge and cleanup of bridge hooks.
bridgestp.c; r1.8
 if_bridge.c; r1.25, 1.27
 if_bridgevar.h; r1.5
 if_ethersubr.c; r1.201, 1.202, 1.206
 ng_ether.c; r1.52 - 1.54

Approved by:	re (scottl)
2005-10-23 02:36:58 +00:00
thompsa
73007defbe MFC: if_bridge.c r1.26, if_ethersubr.c r1.205
>   Use bridge_ifdetach() to notify the bridge that a member has been detached.
>   The bridge can then remove it from its interface list and not try to send
>   out via a dead pointer.

Approved by:	re (scottl)
2005-10-19 20:46:16 +00:00
glebius
97d261903e Big overall MFC of polling(4) cleanup:
o First attempt on removing Giant from polling. Details:
  http://lists.freebsd.org/pipermail/cvs-src/2005-September/051848.html
o Second attempt, and big polling cleanup including:
  - Functinal approach to turning polling on/off
  - Deprecating of poll_in_trap
  - Removal of ifnet knowledge from kern_poll.c
  Details:
  http://lists.freebsd.org/pipermail/cvs-src/2005-October/053267.html
o Improved checking of user configurable sysctls. Details:
  http://lists.freebsd.org/pipermail/cvs-src/2005-October/053351.html
o Moving DEVICE_POLLING from opt_global.h to opt_device_polling.h:
  http://lists.freebsd.org/pipermail/cvs-src/2005-October/053479.html

o All related documentation fixes.

Approved by:	re (kensmith)
Thanks to:	everyone, who helped with testing
2005-10-07 14:00:06 +00:00
thompsa
28e5001029 MFC: if_bridge.c r1.23
> Do not packet filter in the bridge_start() routine, locally generated packets
> are already filtered by the higher layers.

Approved by:	re (kensmith)
2005-10-06 20:43:24 +00:00
rwatson
9e61878b2e Merge netisr.c:1.16 from HEAD to RELENG_6:
Rename net.isr.enable to net.isr.direct.

  No compatibility code is provided, as this will be the production name
  as of 6.0.  Previously this has been an experimental and unsupported
  feature.

  Requested by:	scottl

Approved by:	re (kensmith)
2005-10-05 12:32:23 +00:00
csjp
0fcc9c347d MFC bpf.c v1.159
Make stats a bit more accurate by refreshing the PID after each
descriptor operation.

Approved by:	re (scottl)
2005-10-01 18:43:16 +00:00
csjp
a49552acda MFC privilege separation enhancements for bpf(4)
Introduce BIOCLOCK and BIOCSETWF

Revision(s)
    1.158     +81 -23    src/sys/net/bpf.c
    1.40      +2 -0      src/sys/net/bpf.h
    1.31      +4 -1      src/sys/net/bpfdesc.h

Approved by:	re (scottl)
2005-09-29 23:48:04 +00:00
rwatson
a15c06842e Merge if.c:1.247, in.c:1.88, in.h:1.92 from HEAD to RELENG_6:
Take a first cut at cleaning up ifnet removal and multicast socket
  panics, which occur when stale ifnet pointers are left in struct
  moptions hung off of inpcbs:

  - Add in_ifdetach(), which matches in6_ifdetach(), and allows the
    protocol to perform early tear-down on the interface early in
    if_detach().

  - Annotate that if_detach() needs careful consideration.

  - Remove calls to in_pcbpurgeif0() in the handling of SIOCDIFADDR --
    this is not the place to detect interface removal!  This also
    removes what is basically a nasty (and now unnecessary) hack.

  - Invoke in_pcbpurgeif0() from in_ifdetach(), in both raw and UDP
    IPv4 sockets.

  It is now possible to run the msocket_ifnet_remove regression test
  using HEAD without panicking.

  Reported by:	Gavin Atkinson <gavin dot atkinson at ury dot york dot ac dot uk>

Approved by:	re (scottl)
2005-09-29 20:57:07 +00:00
glebius
eea24f1858 MFC 1.113:
Several fixes to rt_setgate(), that fix problems with route changing:

  - Rearrange code so that in a case of failure the affected
    route is not changed. Otherwise, a bogus rtentry will be
    left and later rt_check() can recurse on its lock. [1]
  - Remove comment about protocol cloning.
  - Fix two places where rtentry mutex was recursed on, because
    accessed via two different pointers, that were actually pointing
    to the same rtentry in some cases. [1]
  - Return EADDRINUSE instead of bogus EDQUOT, in case when gateway
    uses the same route. [2]

  Reported & tested by:	ps, Andrej Zverev <az inec.ru> [1]
  PR:			kern/64090 [2]

Approved by:	re (scottl)
2005-09-26 14:59:12 +00:00
andre
3fe532433d MFC 1.160: Undo optimization which broke BIOCGSEESENT handling.
Approved by:	re (scottl)
2005-09-26 12:06:18 +00:00
thompsa
1d1e4f1a56 MFC: if_bridge.c, r1.22
> Fix an alignment panic my preserving the 2byte padding (ETHER_ALIGN) on our
> copied mbuf, which keeps the IP header 32-bit aligned. This copied mbuf is
> reinjected back into ether_input and off to the IP routines.
>
> Reported and tested by: Peter van Dijk

Approved by:	re (scottl), mlaier (mentor)
2005-09-25 20:36:02 +00:00
glebius
ea4e44a4c6 MFC 1.84 by yar:
Test the new M_VLANTAG packet flag before calling
  m_tag_locate().  This adds little overhead of a simple
  bitwise operation in case hardware VLAN acceleration
  is on, yet saves the more expensive function call if
  the acceleration is off.

  Reviewed by:	ru, glebius

Approved by:	re (kensmith)
2005-09-20 13:44:36 +00:00
csjp
79bee3e493 MFC v1.129 src/sys/net/rtsock.c
Make sysctl_rtsock MP safe.

Approved by:	re (scottl)
2005-09-20 01:59:54 +00:00
rwatson
6f1fd55954 Merge if.c:1.246 from HEAD to RELENG_6:
In netkqfilter(), return EINVAL instead of 1 (EPERM) when a filter type
  is requested on a network interface file descriptor that is
  non-applicable.

Approved by:	re (kensmith)
2005-09-15 20:53:22 +00:00
thompsa
12b6d396b7 MFC: if_bridge.c, r1.21; if_ethersubr.c, r1.198; in6_ifattach.c, r1.28;
nd6.c, r1.55; nd6_nbr.c, r1.33

> Add support for multicast to the bridge and allow inet6 addresses to be
> assigned to the interface.
>
> IPv6 auto-configuration is disabled. An IPv6 link-local address has a
> link-local scope within one link, the spec is unclear for the bridge case and
> it may cause scope violation.
>
> An address can be assigned in the usual way;
>   ifconfig bridge0 inet6 xxxx:...
>
> Tested by:      bmah
> Reviewed by:    ume (netinet6)
> Approved by:    mlaier (mentor)

Approved by:	re (kensmith), mlaier (mentor)
2005-09-13 18:02:39 +00:00
sam
fd987c5315 MFC 1.245: reclaim sbuf and clear lock on error in ifconf
Approved by:	re (scottl)
2005-09-08 22:43:10 +00:00
glebius
9015847fb5 Merge 1.82:
Fix fallout from revision 1.77, mark outgoing packets with M_VLANTAG flag.

  PR:		kern/80646
  Reviewed by:	yar

Approved by:	re (scottl)
2005-09-02 14:06:26 +00:00
thompsa
b24c9f9f85 MFC: if_bridge, r1.20
> Fix a panic in softclock() if the interface is destroyed with a bpf consumer
> attached.
>
> This is caused by bpf_detachd clearing IFF_PROMISC on the interface which does
> a SIOCSIFFLAGS ioctl. The problem here is that while the interface has been
> stopped, IFF_UP has not been cleared so IFF_UP != IFF_DRV_RUNNING, this causes
> the ioctl function to init() the interface which resets the callouts.
>
> The destroy then completes and frees the softc but softclock will panic on a
> dead callout pointer.
>
> Ensure ifp->if_flags matches reality by clearing IFF_UP when we destroy.

Approved by:	re (kensmith), mlaier (mentor)
2005-08-30 20:30:44 +00:00
thompsa
707f7071f3 MFC: bridgestp.c, r1.6; if_bridge.c, r1.18
> Mark the callouts as MPSAFE as if_bridge has been giant-free since day 1.
>
> Use the SMP friendly callout_init_mtx() while we are here.
>

Approved by:	re (kensmith), mlaier (mentor)
2005-08-30 20:26:53 +00:00
mlaier
9ffdae0a26 MFC: if_ethersubr.c, 1.197:
Don't loop back packets that have been routed by pf.  This fixes an
  endless loop where the same packet is sent over and over again.

  Obtained from:  OpenBSD
  Reported by:    Sergey Lapin
  Tested by:      Sergey Lapin

Approved by:	re (scottl)
2005-08-30 16:43:24 +00:00