Commit Graph

617 Commits

Author SHA1 Message Date
Gleb Smirnoff
35fd572dcb - Gather statistics about failed mbuf+cluster+ng_item allocations.
- Adjust comments and variables names in nfinfo.
2005-05-12 13:52:49 +00:00
Gleb Smirnoff
494e177ada A new version of NetFlow node.
The most significant changes are:
- Use UMA zone instead of own chunk of memory.
- Lock each hash entry separately.
- Expire items "actively" - interrupt method can expire flows
  from hash slot, when it searches through it.
- Remove global tailqueue. Make callout thread search through
  every hash slot.
- Export datagram is detached from private data and filled. If
  it is incomplete, it is attached back. Another thread will
  continue working with it.

Lesser, but also important speedups:
- Flows in hash slot are stored in tailqueue. Whenever a flow is
  hit, it is moved to the begging, so it can be located quicker.
- When callout thread works with hash slot it bails out if
  slot mutex is contested.
2005-05-11 11:26:24 +00:00
Gleb Smirnoff
cc8c6970fd Move assertion below initializer.
Submitted by:	Noritoshi Demizu
Pointy hat to: 	glebius
2005-05-11 08:28:09 +00:00
Maksim Yevmenkin
c18a1440f0 Mark AVM USB Bluetooth-Adapter BlueFritz! as "broken". This device is not
supported by ng_ubt(4) driver and needs its own driver.

PR:		kern/76205
Submitted by:	Tim Hemel < bsd AT timit DOT nl >
MFC after:	1 week
2005-05-10 16:25:58 +00:00
Gleb Smirnoff
2046fd5f68 - Assert that mbuf length equals packet length.
- Tell libalias, that we have MCLBYTES to play with.
- Obtain length of data in mbuf from updated IP header.
2005-05-10 14:19:10 +00:00
Gleb Smirnoff
c4c9b52b87 ng_nat - a netgraph(4) node, which does NAT 2005-05-05 23:41:21 +00:00
Maksim Yevmenkin
75ae257016 Change m_uiotombuf so it will accept offset at which data should be copied
to the mbuf. Offset cannot exceed MHLEN bytes. This is currently used to
fix Ethernet header alignment problem on alpha and sparc64. Also change all
users of m_uiotombuf to pass proper offset.

Reviewed by:	jmg, sam
Tested by:	Sten Spans "sten AT blinkenlights DOT nl"
MFC after:	1 week
2005-05-04 18:55:03 +00:00
Gleb Smirnoff
15749e57aa - Initialize interface as UP when hook is connected.
- Call if_link_state_change() when netgraph flow control
  messages are received.

Sponsored by:	Rambler
2005-04-20 14:22:13 +00:00
Gleb Smirnoff
3b1c41c548 When netgraph flow control message comes from downstream, broadcast
it to all vlans.

Sponsored by:	Rambler
2005-04-20 14:19:20 +00:00
Gleb Smirnoff
6c949d5f92 Remove extra ifnet pointer from private data. It can be accessed via arpcom. 2005-04-20 12:22:33 +00:00
Gleb Smirnoff
644168eedb Add macro NG_COPYMESSAGE(), which allocates memory and creates a
copy of given control message.
2005-04-20 12:18:22 +00:00
Gleb Smirnoff
bc90ff47ff Fix panics with misconfigured routing:
- Backout previous revision, the check is useless.
- Turn node to queue mode, since it is edge node.

Reported by:	sem
2005-04-18 11:32:17 +00:00
Gleb Smirnoff
dfc17a329e - Return error, if there was one.
- No need to initialize error here.

PR:		kern/79884
Submitted by:	Wojciech A. Koszek
2005-04-15 10:14:00 +00:00
Gleb Smirnoff
20064a62a9 NG_MKRESPONSE() macro includes sizeof struct ng_mesg when doing allocation.
PR:		kern/79806
Submitted by:	Wojciech A. Koszek
2005-04-13 14:03:28 +00:00
Gleb Smirnoff
d6bd5ec90c Remove goto. 2005-04-11 10:16:17 +00:00
Peter Wemm
e76ce25370 Change the embedded module name from "bluetooth" to "ng_bluetooth" to match
the rest of the names assigned to this object.
2005-04-08 05:13:53 +00:00
Maksim Yevmenkin
dc612cfc34 Correct typo that could cause FIFO overflow.
PR:		kern/78431
MFC after:	3 days
2005-04-06 22:09:32 +00:00
Maksim Yevmenkin
aa9e985aed Remove PR_ATOMIC flag in ng_btsocket_protosw[] for BLUETOOTH_PROTO_RFCOMM
protocol. RFCOMM is a SOCK_STREAM protocol not SOCK_SEQPACKET. This was a
serious bug caused by cut-and-paste. I'm surprised it did not bite me before.
Dunce hat goes to me.

MFC after:	3 days
2005-04-06 20:54:05 +00:00
Maksim Yevmenkin
f93b258c94 In ng_btsocket_rfcomm_receive_frame() correctly set length variable when
EA bit is set in hdr->length (16-bit length). This currently has no effect
on the rest of the code. It just fixes the debug message.

MFC After:	3 weeks
2005-04-06 18:55:58 +00:00
Gleb Smirnoff
d8f5d037f8 Major overhaul and cleanup of ng_source node.
Functional changes:
- Cut struct source_hookinfo. Just use hook_p pointer.
- Remove "start_now" command. "start" command now requires number of
  packets to send as argument. "start" command actually starts sending.
  Move the code that actually starts sending from ng_source_rcvmsg()
  to ng_source_start().
- Remove check for NG_SOURCE_ACTIVE in ng_source_stop(). We can be called
  with flag cleared (see begin of ng_source_intr()).
- If NG_SEND_DATA_ONLY() use log(LOG_DEBUG) instead of printf(). Otherwise
  we will *flood* console.
- Add ng_connect_t method, which sends NGM_ETHER_GET_IFNAME command
  to "output" hook. Cut ng_source_request_output_ifp(). Refactor
  ng_source_store_output_ifp() to use ifunit() and don't muck through
  interface list.
- Add "setiface" command, which gives ability to configure interface
  in case when ng_source_connect() failed. This happens, when we are not
  connected directly to ng_ether(4) node.
- Remove KASSERTs, which can never fire.
- Don't check for M_PKTHDR in rcvdata method. netgraph(4) does this
  for us.

Style:
- Assign sc_p = NG_NODE_PRIVATE(node) in declaration, to be
  consistent with style of other nodes.
- Sort variables.
- u_intXX -> uintXX.
- Dots at ends of comments.

Sponsored by:   Rambler
2005-04-05 17:22:05 +00:00
Brooks Davis
6d9a161274 Don't init ifp->if_addrhead, if_attach() does it for us. 2005-04-03 05:21:29 +00:00
Gleb Smirnoff
9818b82ff3 Add a possibility to bypass unmodified accounted data to special
hook(s). Data received on these hook(s) is sent back to ifaceX hook(s).
2005-03-22 15:49:22 +00:00
Gleb Smirnoff
2b38b68736 Refactor node so that it does not modify mbuf contents. Next step would
be pass-thru mode, when traffic is not copied by ng_tee, but passed thru
ng_netflow.

Changes made:

- In ng_netflow_rcvdata() do all necessary pulluping: Ethernet header,
  IP header, and TCP/UDP header.
- Pass only pointer to struct ip to ng_netflow_flow_add(). Any TCP/UDP
  headers are guaranteed to by after it.
- Merge make_flow_rec() function into ng_netflow_flow_add().
2005-03-21 15:40:25 +00:00
Gleb Smirnoff
1d03bd1684 Refactor node so that it does not modify mbuf contents. Next step would
be pass-thru mode, when traffic is not copied by ng_tee, but passed thru
ng_netflow.

Changes made:

- In ng_netflow_rcvdata() do all necessary pulluping: Ethernet header,
  IP header, and TCP/UDP header.
- Pass only pointer to struct ip to ng_netflow_flow_add(). Any TCP/UDP
  headers are guaranteed to by after it.
- Merge make_flow_rec() function into ng_netflow_flow_add().
2005-03-21 15:34:03 +00:00
Gleb Smirnoff
0e406d0f63 Plug item leak, which occured when m_pullup() failed. 2005-03-21 11:48:54 +00:00
Gleb Smirnoff
c1249c6338 - Don't lose TCP flags of the first packet in a flow.
- Don't account length of the first packet in a flow twice.
2005-03-20 21:03:43 +00:00
Gleb Smirnoff
30afbe338b Remove ng_connect_t where it is unused. Probably it remained from ng_source.c. 2005-03-14 20:49:48 +00:00
Gleb Smirnoff
8633e59c17 Use subr_unit allocator instead of own functions. 2005-03-14 20:11:29 +00:00
Gleb Smirnoff
933fedbacc Use subr_unit allocator instead of own functions. 2005-03-14 19:25:24 +00:00
Gleb Smirnoff
5cdd064d8a o Use subr_unit allocator. This simplifies code much:
- Remove get_free_unit().
  - Remove SLIST of nodes.
  - Remove global mutex.

o Increase NGD_MAX to 999.
o Move ngd_mod_event() up to netgraph methods.
2005-03-14 16:02:53 +00:00
Gleb Smirnoff
43eca7506e Fix getting stats from many links with index > 0.
Submitted by:	Richard Kojedzinszky
MFC after:	3 days
2005-03-11 10:29:38 +00:00
Bosko Milekic
2b0ffc0216 Make some basic grammar and style fixes to ng_source.c and ng_source.h.
The latter was particularly violated by someone's editor in the past, due
to an effect I like to call "premature linewrapping."
2005-03-10 21:50:50 +00:00
Gleb Smirnoff
1436fff881 Plug item leak in macro NG_RESPOND_MSG. Item was leaked when destination
node couldn't be addressed.

Submitted by:	Roselyn Lee
2005-03-10 19:34:20 +00:00
Gleb Smirnoff
8bb55179ad Plug item leak in case when NGI_FN is applied to invalid node.
Submitted by:	Roselyn Lee
MFC after:	3 days
2005-03-10 19:27:08 +00:00
Gleb Smirnoff
5fac4ee9ab Cisco uses milliseconds for uptime. This is stupid. Nobody cares of such
precision when IP packet may travel through internet for several seconds.
Also uptime measured in milliseconds overflows every 48+ days.
But we have to do same to keep compatibility with Cisco and flow-tools.

Make a macro MILLIUPTIME, which does overflowable multiplication to 1000.

Requested by:	Sergey Ryabin, Oleg Bulyzhin
MFC after:	1 week
2005-03-03 11:01:05 +00:00
Ruslan Ermilov
a9a03de54d Pull up to ETHER_HDR_LEN before passing an mbuf to ether_input().
The bug was found by running ng_dummy(4) node configured with a
delay, in front of the ng_eiface(4) node.
2005-03-01 19:39:57 +00:00
Gleb Smirnoff
f627a37920 Replace NG_PARSE_APPEND() macro with ng_parse_append() function. Check
its return value and free resources if function returns error. Plug
several memory leaks with this change.

Submitted by:	archie
Found by:	Coverity Prevent analysis tool
2005-03-01 11:31:06 +00:00
Sam Leffler
81c95c5292 move ptr use down to after null check
Noticed by:	Coverity Prevent analysis tool
Reviewed by:	emax
2005-02-26 02:31:34 +00:00
Robert Watson
0daccb9c94 In the current world order, solisten() implements the state transition of
a socket from a regular socket to a listening socket able to accept new
connections.  As part of this state transition, solisten() calls into the
protocol to update protocol-layer state.  There were several bugs in this
implementation that could result in a race wherein a TCP SYN received
in the interval between the protocol state transition and the shortly
following socket layer transition would result in a panic in the TCP code,
as the socket would be in the TCPS_LISTEN state, but the socket would not
have the SO_ACCEPTCONN flag set.

This change does the following:

- Pushes the socket state transition from the socket layer solisten() to
  to socket "library" routines called from the protocol.  This permits
  the socket routines to be called while holding the protocol mutexes,
  preventing a race exposing the incomplete socket state transition to TCP
  after the TCP state transition has completed.  The check for a socket
  layer state transition is performed by solisten_proto_check(), and the
  actual transition is performed by solisten_proto().

- Holds the socket lock for the duration of the socket state test and set,
  and over the protocol layer state transition, which is now possible as
  the socket lock is acquired by the protocol layer, rather than vice
  versa.  This prevents additional state related races in the socket
  layer.

This permits the dual transition of socket layer and protocol layer state
to occur while holding locks for both layers, making the two changes
atomic with respect to one another.  Similar changes are likely require
elsewhere in the socket/protocol code.

Reported by:		Peter Holm <peter@holm.cc>
Review and fixes from:	emax, Antoine Brodin <antoine.brodin@laposte.net>
Philosophical head nod:	gnn
2005-02-21 21:58:17 +00:00
Gleb Smirnoff
f1c6a420b1 Reimplement recursion protection, checking whether current thread holds
sockbuf mutex.

Reviewed by:	rwatson
2005-02-19 14:41:49 +00:00
Gleb Smirnoff
848a25c773 Remove a recursion protection, which we inherited from splnet() netgraph times.
Now several threads may write data to ng_ksocket. Locking of socket is done in
sosend().

Reviewed by:	archie, julian, rwatson
MFC after:	2 weeks
2005-02-16 16:00:35 +00:00
Gleb Smirnoff
843cfd5ae0 Make WITNESS happier:
- refactor ngd_constructor, so that make_dev() is called without
  any locks held, since it mallocs memory with M_WAITOK flag.
- rename global mtx, to have name different to per-node mtx

MFC after:	2 weeks
2005-02-14 13:47:06 +00:00
Gleb Smirnoff
cefddd662e Add new netgraph control message NGM_ETHER_DETACH, which actually
removes netgraph node and unwraps Ethernet interface.

This gives us ability to unload ng_ether.ko, when all interfaces
are detached, making ng_ether(4) developers happy.

Reviewed by:	ru
2005-02-14 12:01:09 +00:00
Archie Cobbs
cd22454e8b Bump cookie value to reflect change in NGM_IFACE_GET_IFNAME semantics. 2005-02-13 16:36:41 +00:00
Ruslan Ermilov
48f4d9918c Drop mythical module dependency on ng_ether. 2005-02-13 00:50:18 +00:00
Gleb Smirnoff
b5fe181661 Restore previous cookie. Old programs will work with new node OK,
new programs with old node wil receive EINVAL trying to access new
messages.

Submitted by:	ru
2005-02-12 19:23:20 +00:00
Gleb Smirnoff
ba20540e3d - bzero sockaddr_dl
- use constant instead of number

Suggested by:	ru
2005-02-12 19:19:29 +00:00
Ruslan Ermilov
3667c04da9 Fix typo in a comment. 2005-02-12 18:10:26 +00:00
Ruslan Ermilov
0572dfac4b Fallout from the ALTQ import. 2005-02-12 17:03:01 +00:00
Gleb Smirnoff
d96bd8d144 Allocate enough space for new tag.
Pointy hat to:	glebius
2005-02-12 16:26:36 +00:00