692 Commits

Author SHA1 Message Date
glebius
a0d17dcfa1 MFC 1.8:
Mark appropriate commands with NGM_READONLY and NGM_HASREPLY and
  bump type cookie.

  This fixes flowctl(8) exiting without any output under high load on SMP.
2006-01-21 10:06:15 +00:00
glebius
098f73d3f4 Partial MFC of NGM_HASREPLY flag. The flag is introduced, but message
codes and netgraph cookie are not altered, to preserve ABI compatibility.
2006-01-21 10:04:40 +00:00
glebius
443e91f57b MFC 1.65:
Provide additional macros for sending netgraph items, which allow
  to use non-default flags for netgraph functions. Implement current
  macros via new ones.
2006-01-21 10:00:51 +00:00
glebius
94513f129b Sync with HEAD:
- Some whitespace and style(9) cleanup.
  - Add ktr(4) debugging.
2006-01-21 09:59:43 +00:00
glebius
65952b1976 MFC 1.11:
In ng_netflow_disconnect() check whether we are working with "iface"
  or with "out" hook, and clear the right pointer.

  Reported by:    Vitaliy Ovsyannikov <V.Ovsyannikov kr.ru>
2006-01-10 10:22:22 +00:00
glebius
801f2fea18 MFC:
Implement an upper limit for packets per second sent by node.
2006-01-10 10:11:48 +00:00
ru
9dbd13db82 MFC: Fix memory leak. 2005-12-09 07:13:06 +00:00
glebius
a95ec831a0 MFC 1.17:
- Update the flow sequence before converting count to
    network byte order.
  - Update the flow sequence in one atomic op instead of two.

  Reported by:    Denis Shaposhnikov <dsh vlink.ru>
  Reported by:    Daniil Kharoun <kdl chelcom.ru>
  PR:             kern/89417
2005-12-06 09:51:10 +00:00
glebius
d60eb7f43e MFC 1.70:
Fix several races between socket closure and node/hook
  destruction:
    - Backout 1.62, since it doesn't fix all possible
    problems.
    - Upon node creation, put an additional reference on node.
    - Add a mutex and refcounter to struct ngsock. Netgraph node,
      control socket and data socket all count as references.
    - Introduce ng_socket_free_priv() which removes one reference
      from ngsock, and frees it when all references has gone.
    - No direct pointers between pcbs and node, all pointing
      is done via struct ngsock and protected with mutex.
2005-11-25 14:26:40 +00:00
glebius
f85409be55 Sync with HEAD, merging the following:
revision 1.117
date: 2005/11/02 15:23:47;  author: glebius;  state: Exp;  lines: +47 -8
Fix two races which happen when netgraph is restructuring:
  - Introduce ng_topo_mtx, a mutex to protect topology changes.
  - In ng_destroy_node() protect with ng_topo_mtx the process
    of checking and pointing at ng_deadnode. [1]
  - In ng_con_part2() check that our peer is not a ng_deadnode,
    and protect the check with ng_topo_mtx.
  - Add KASSERTs to ng_acquire_read/write, to make more
    understandible synopsis in case if called on ng_deadnode.

Reported by:    Roselyn Lee [1]
----------------------------
revision 1.116
date: 2005/11/02 14:27:24;  author: glebius;  state: Exp;  lines: +106 -121
Rework the ng_item queueing on nodes:
  - Introduce a new flags NGQF_QREADER and NGQF_QWRITER,
    which tell how the item should be actually applied,
    overriding NGQF_READER/NGQF_WRITER flags.
  - Do not differ between pending reader or writer. Use only
    one flag that is raised, when there are pending items.
  - Schedule netgraph ISR in ng_queue_rw(), so that callers
    do not need to do this job.
  - Fix several comments.

Submitted by:   julian

As well as some lesser changes: ng_base.c 1.114, 1.113, 1.107, 1.118.
2005-11-25 14:23:27 +00:00
ru
b8108a4f96 MFC: 1.56: Make IFP2NG() usable as lvalue. 2005-11-16 10:33:53 +00:00
ru
539591f019 MFC: Use sparse initializers for "struct domain" and "struct protosw". 2005-11-16 10:31:23 +00:00
ru
693f92adc9 MFC: 1.34: Simplify setting the link-level address. 2005-11-16 10:14:25 +00:00
ru
f8684a4759 MFC: All recent fixes. 2005-11-16 10:13:34 +00:00
ru
f130d9a1f5 MFC: 1.55: Restore part of the code mistakenly dropped in rev. 1.25. 2005-11-16 10:09:51 +00:00
ru
af77f484ad MFC: Use variable-sized arrays where appropriate. 2005-11-16 10:08:02 +00:00
ru
40f4fd56fd MFC: 1.5: Make the cookie constant name canonical. 2005-11-16 10:01:27 +00:00
ru
4bcf743b75 MFC: 1.58: Fix up comment. 2005-11-16 07:36:51 +00:00
glebius
88bf054121 MFC ALTQ support for ng_iface(4). 2005-11-09 11:36:07 +00:00
glebius
9cf9c62adb MFC 1.115:
- When flushing node input queue, check whether item has a callback. If
    it does, then call it suppling ENOENT as error value.
  - Add assert, that helped to catch the above error.
2005-11-04 18:20:32 +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
tanimura
e04edc1b3f MFC 1.35: do not derefer NULL sc in ngt_input().
Approved by:	re (scottl)
2005-10-09 00:19:28 +00:00
glebius
be4f3d3a0f MFC typo fix from 1.75:
Dej'a vu of revision 1.35

  PR:		kern/86258
  Submitted by:	Hiroshi Oota <ghelp excite.co.jp>

Approved by:	re (kensmith)
2005-09-20 13:46:15 +00:00
glebius
2031716961 MFC 1.69:
When message can't fit into socket receive buffer return ENOBUFS
  to userland program instead of letting it wait until end of days.

  PR:	kern/85907

Approved by:	re (kensmith)
2005-09-20 13:42:20 +00:00
glebius
93d4651ace Merge locking of ng_pptpgre node. See 1.38, 1.39 log for longer
description.

Approved by:	re (kensmith)
2005-09-20 13:40:55 +00:00
glebius
f3983d158a MFC 1.7:
Plug item leak in case when not all hooks are connected.

  Found by:	David Vos <david.vos gmail.com>

Approved by:	re (kensmith)
2005-09-13 12:44:19 +00:00
glebius
3a2f67e4e3 MFC 1.68 by obrien:
Fix missing '=' in structure initialization.

Approved by:	re (kensmith)
2005-09-13 12:43:15 +00:00
glebius
7b7ee804e9 MFC 1.26 by ru:
Fixed parsing of unsigned integers.

Approved by:	re (kensmith)
2005-09-13 12:41:05 +00:00
glebius
a9f4fdf4f8 MFC 1.112:
Fix an item leak, that happens when some node calls ng_callout() two
  times consequently, without checking whether callout has been serviced
  or not. (ng_pptpgre and ng_ppp were catched in this behavior).

    - In ng_callout() save old item before calling callout_reset(). If the
      latter has returned 1, then free this item.
    - In ng_uncallout() clear c->c_arg.

  Problem reported by:    Alexandre Kardanev

Approved by:	re (kensmith)
2005-09-12 14:46:19 +00:00
glebius
1cb55cc44f MFC 1.57 (see original revision for full description):
- in ng_ksocket_incoming2() clear m_nextpkt on all mbufs
    read from socket.
  - restore rev. 1.54 change in ng_ksocket_incoming().

  PR:		kern/84952
  PR:		kern/82413
  In collaboration with:	rwatson

Approved by:	re (scottl)
2005-09-09 06:13:25 +00:00
glebius
0bc972befd MFC 1.109:
Raise one more bit in READER_MASK. I believe that before this change
  it was possible to have 1 reader and 1 writer thread working on
  a node simultaneously.

  Reviewed by:	julian

Approved by:	re (scottl)
2005-09-09 06:08:07 +00:00
glebius
4905127030 MFC 1.108, 1.110, 1.111:
Use non-debug macros inside debugging functions, to prevent
  important information from being rewritten.

  In INVARIANTS case also check that nodes do not pass queues of mbufs
  each other.

Approved by:	re (scottl)
2005-09-09 06:06:51 +00:00
emax
6e96afd69d MFC to RELENG 6
Fix dangling callout problem in the Bluetooth L2CAP code that leads to
panic. The panic happens when outgoing L2CAP connection descriptor is
deleted with the L2CAP command(s) pending in the queue. In this case when
the last L2CAP command is deleted (due to cleanup) and reference counter
for the L2CAP connection goes down to zero the auto disconnect timeout
is incorrectly set. pjd gets credit for tracking this down and committing
bandaid.

Reported by:	Jonatan B <onatan at gmail dot com>
Approved by:	re (scottl)
2005-09-03 03:34:23 +00:00
emax
21c9adb9b0 MFC to RELENG_6
Address minor locking issues. Use taskqueue_swi instead of taskqueue_swi_giant.

Approved by:	re (scottl)
2005-08-29 17:00:54 +00:00
emax
2b0bdd9bb3 MFC to RELENG_6
Make sure ng_fec_init() uses the same calling convention as the rest of
the code, i.e. ng_fec_init() is called with the ifp->if_softc pointer and
NOT with the ifp pointer.

PR:		kern/85239
Reviewed by:	brooks
Approved by:	re (scottl)
2005-08-29 16:23:21 +00:00
glebius
ff71da86ca MFC:
Backout revision 1.54, because it exposes a worse problem, than
  it fixes. I believe the problem lives somewhere outside ng_ksocket,
  but until it is found, let the node be working.

  PR:		kern/84952
  PR:		kern/82413

Approved by:	re (scottl)
2005-08-29 09:01:58 +00:00
emax
9547e540c3 MFC to RELENG_6
Fix multiple typos in the mutex names. This fixes false positive (and pretty
strange looking too) LORs I have seen on my system. Pointy hat to goes to me.

Approved by:	re (scottl)
2005-08-25 16:14:33 +00:00
rwatson
e13b2df854 Merge linux_ioctl.c:1.128 svr4_sockio.c:1.17 altq_cbq.c:1.3 if_oltr.c:1.38
if_pflog.c:1.14 if_pfsync.c:1.21 if_an.c:1.70 if_ar.c:1.72 if_arl.c:1.11
amrr.c:1.10 onoe.c:1.10 if_ath.c:1.101 awi.c:1.41 if_bfe.c:1.27
if_bge.c:1.93 if_cm_isa.c:1.7 smc90cx6.c:1.16 if_cnw.c:1.20 if_cp.c:1.25
if_cs.c:1.42 if_ct.c:1.26 if_cx.c:1.46 if_ed.c:1.256 if_em.c:1.68
if_en_pci.c:1.37 midway.c:1.66 if_ep.c:1.143 if_ex.c:1.58 if_fatm.c:1.20
if_fe.c:1.93 if_fwe.c:1.38 if_fwip.c:1.8 if_fxp.c:1.244 if_gem.c:1.33
if_hatm.c:1.25 if_hatm_intr.c:1.20 if_hatm_ioctl.c:1.13 if_hatm_rx.c:1.10
if_hatm_tx.c:1.14 if_hme.c:1.39 if_ie.c:1.104 if_ndis.c:1.101
if_ic.c:1.24 if_ipw.c:1.10 if_iwi.c:1.10 if_ixgb.c:1.13 if_lge.c:1.41
if_lnc.c:1.113 if_my.c:1.31 if_nge.c:1.77 if_nve.c:1.10 if_owi.c:1.12
if_patm.c:1.9 if_patm_intr.c:1.6 if_patm_ioctl.c:1.10 if_patm_tx.c:1.10
pdq_ifsubr.c:1.28 if_plip.c:1.38 if_ral.c:1.12 if_ral_pci.c:1.2
if_ray.c:1.81 if_rayvar.h:1.22 if_re.c:1.49 if_sbni.c:1.21 if_sbsh.c:1.14
if_sn.c:1.48 dp83932.c:1.21 if_snc_pccard.c:1.9 if_sr.c:1.70 if_tx.c:1.91
if_txp.c:1.33 if_aue.c:1.92 if_axe.c:1.32 if_cdce.c:1.8 if_cue.c:1.59
if_kue.c:1.66 if_rue.c:1.23 if_udav.c:1.16 if_ural.c:1.12 if_vge.c:1.16
if_vx.c:1.58 if_wi.c:1.185 if_wi_pci.c:1.26 if_wl.c:1.68 if_xe.c:1.60
if_xe_pccard.c:1.30 if_el.c:1.68 i4b_ipr.c:1.35 i4b_isppp.c:1.31
kern_poll.c:1.20 bridge.c:1.94 bridgestp.c:1.4 if_arcsubr.c:1.27
if_atm.h:1.24 if_atmsubr.c:1.40 if_bridge.c:1.16 if_ef.c:1.35
if_ethersubr.c:1.196 if_faith.c:1.37 if_fddisubr.c:1.100 if_fwsubr.c:1.14
if_gif.c:1.54 if_gre.c:1.34 if_iso88025subr.c:1.70 if_loop.c:1.107
if_ppp.c:1.106 if_spppsubr.c:1.121 if_tap.c:1.57 if_tun.c:1.154
if_vlan.c:1.80 ppp_tty.c:1.67 ieee80211_ioctl.c:1.32 atm_if.c:1.31
ng_eiface.c:1.33 ng_ether.c:1.50 ng_fec.c:1.19 ng_iface.c:1.44
ng_sppp.c:1.9 ip_carp.c:1.30 ip_fastfwd.c:1.30 in6.c:1.53 nd6_nbr.c:1.31
natm.c:1.40 if_dc.c:1.162 if_de.c:1.168 if_pcn.c:1.72 if_rl.c:1.154
if_sf.c:1.84 if_sis.c:1.135 if_sk.c:1.108 if_ste.c:1.86 if_ti.c:1.109
if_tl.c:1.101 if_vr.c:1.106 if_wb.c:1.81 if_xl.c:1.194 from HEAD to
RELENG_6:

  Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
  IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
  ifnet.if_drv_flags.  Device drivers are now responsible for
  synchronizing access to these flags, as they are in if_drv_flags.  This
  helps prevent races between the network stack and device driver in
  maintaining the interface flags field.

  Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
  some less so.

  Reviewed by:    pjd, bz

Approved by:	re (scottl)
2005-08-25 05:01:24 +00:00
julian
46484dc67f MFC: reduce warnings when compiled under -W.
Obtained from:	Sandvine inc.
Approved by:  re (ken)
2005-08-15 20:04:28 +00:00
glebius
ff5247fe56 MFC 1.10:
Check that we have first fragment before pulling up TCP/UDP header.

Approved by:	re (kensmith)
2005-08-10 15:00:57 +00:00
glebius
7943163abe MFC:
Enhance struct ng_hook - add hk_type field and bump NG_ABI_VERSION.

Approved by:	re (kensmith)
2005-08-10 14:58:18 +00:00
glebius
c3a5dea7f4 MFC 1.103, 1.105:
avoid recursion problems in netgraph(4). See 1.103 log for
more information.

Approved by:	re (kensmith)
2005-08-10 14:54:52 +00:00
emax
01e9f84530 Insta-MFC to RELENG_6
Fix typo and check correct (rsp) pointer against the NULL value.

Submitted by:	Oliver < urnenfel at tiscali dot es >
Approved by:	re (kensmith)
2005-07-29 16:42:42 +00:00
emax
d1df494821 MFC to RELENG_6 ng_ubt.c v1.25
Add support for AVM BlueFRITZ! USB Bluetooth Adapter v2.0. It appears that
there are at least two versions of the adapter. Version 1 (product ID 0x2200)
of the adapter does not work with ng_ubt(4) and require special driver and
firmware. Version 2 (product ID 0x3800) seems to work just fine, except it
does not have bDeviceClass, bDeviceSubClass and bDeviceProtocol set to required
(by specification) values. This change forces ng_ubt(4) to attach to the
version 2 adapter.

Ignore AVM BlueFRITZ! USB Bluetooth Adapter v1.0 (product ID 0x2200).
It does not work with ng_ubt(4) and require special driver and firmware.

Submitted by:	Rainer Goellner < rainer at jabbe dot de >
Approved by:	re (kensmith)
Obtained from:	Marcel Holtmann < marcel at holtmann dot org >
2005-07-25 16:22:38 +00:00
glebius
af3bb40686 Remove obsoleted sysctl interface for switching between standard and 3Com
PPPoE modes. The interface was declared obsoleted before 5.3-RELEASE.

When running as access concentrator ng_pppoe(4) supports both modes
simultanously. When running as client mode can be swicthed in ppp(8)
configuration.

Approved by:	re (scottl)
2005-07-05 17:51:02 +00:00
glebius
fcbdfd0eb4 In the splnet times, netgraph was functional and synchronous. Nowadays,
an item may be queued and processed later. While this is OK for mbufs,
this is a problem for control messages.

In the framework:
- Add optional callback function pointer to an item. When item gets
  applied the callback is executed from ng_apply_item().
- Add new flag NG_PROGRESS. If this flag is supplied, then return
  EINPROGRESS instead of 0 in case if item failed to deliver
  synchronously and was queued.
- Honor NG_PROGRESS in ng_snd_item().

In ng_socket:
- When userland sends control message add callback to the item.
- If ng_snd_item() returns EINPROGRESS, then sleep.

This change fixes possible races in ngctl(8) scripts.

Reviewed by:	julian
Approved by:	re (scottl)
2005-07-05 17:35:20 +00:00
glebius
9c25e36cc6 - After LibAlias processing check for TCP packet with th_x2 field
set. If found, then recalculate its checksum.
- Remove debugging printfs.
- Slightly rearrange code in ng_nat_rcvdata().

Approved by:	re (scottl)
2005-06-27 07:39:13 +00:00
dwmalone
f1f0123e88 Fix some long standing bugs in writing to the BPF device attached to
a DLT_NULL interface. In particular:

        1) Consistently use type u_int32_t for the header of a
           DLT_NULL device - it continues to represent the address
           family as always.
        2) In the DLT_NULL case get bpf_movein to store the u_int32_t
           in a sockaddr rather than in the mbuf, to be consistent
           with all the DLT types.
        3) Consequently fix a bug in bpf_movein/bpfwrite which
           only permitted packets up to 4 bytes less than the MTU
           to be written.
        4) Fix all DLT_NULL devices to have the code required to
           allow writing to their bpf devices.
        5) Move the code to allow writing to if_lo from if_simloop
           to looutput, because it only applies to DLT_NULL devices
           but was being applied to other devices that use if_simloop
           possibly incorrectly.

PR:		82157
Submitted by:	Matthew Luckie <mjl@luckie.org.nz>
Approved by:	re (scottl)
2005-06-26 18:11:11 +00:00
imp
8616206ff9 Eliminate unused argument in PCMCIA_CARD macro.
Provide a backwards compatible way to have the extra macro by defining
PCCARD_API_LEVEL 5 before including pccarddevs for driver writers that
want/need to have the same driver on 5 and 6 with pccard attachments.

Approved by: re (dwhite)
2005-06-24 14:36:54 +00:00
brooks
567ba9b00a Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.

This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.

Other changes of note:
 - Struct arpcom is no longer referenced in normal interface code.
   Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
   To enforce this ac_enaddr has been renamed to _ac_enaddr.
 - The second argument to ether_ifattach is now always the mac address
   from driver private storage rather than sometimes being ac_enaddr.

Reviewed by:	sobomax, sam
2005-06-10 16:49:24 +00:00