Commit Graph

634 Commits

Author SHA1 Message Date
Gleb Smirnoff
2dc628b54a Remove local error variable, which leads to hiding error from return
value.

PR:		kern/81371
Submitted by:	Wojciech A. Koszek
MFC after:	1 week
2005-05-23 13:49:49 +00:00
Gleb Smirnoff
a09c9f01cd Return EINVAL for incorrect hook names.
PR:		kern/81349
Submitted by:	Wojciech A. Koszek
2005-05-23 13:39:20 +00:00
Gleb Smirnoff
24ac2f1c5e - Unwind NG_SEND_MSG_PATH() macro and merge it with already unwinded
version under TRACE_MESSAGES.
- Pass NG_WAITOK flag to ng_package_data() in unwinded macro.
2005-05-17 12:18:13 +00:00
Gleb Smirnoff
45b719ae22 Use NG_QUEUE instead of constant. 2005-05-16 19:52:42 +00:00
Gleb Smirnoff
d0784b4740 Refactor places where ng_package_data() failed.
Suggested & reviewed by:	archie
2005-05-16 19:12:57 +00:00
Gleb Smirnoff
ae76957d25 - Fix build with TRACE_MESSAGES on.
- Reformat code under TRACE_MESSAGES to make it more readable.
- Move linker hackery out of #ifdef.
- Break long lines in linker hackery block.
2005-05-16 18:50:26 +00:00
Gleb Smirnoff
94b73ad3a9 Close race between node being shutdown and socket being detached. To
do this, obtain netgraph locking in detach method via ng_send_fn1().

Reviewed by:	julian
MFC after:	2 weeks
2005-05-16 17:25:49 +00:00
Gleb Smirnoff
336b3f1e51 Catch up with new ng_package_data(). 2005-05-16 17:10:08 +00:00
Gleb Smirnoff
3033e8026a Catch up with new ng_package_data(). Use NG_WAITOK on userland
path.
2005-05-16 17:09:35 +00:00
Gleb Smirnoff
74eafa88cf - Catch up with new interface to ng_package_data().
- Handle errors from ng_package_data().
2005-05-16 17:08:53 +00:00
Gleb Smirnoff
f6c9d18d2f Catch up with new ng_send_fn1() interface. 2005-05-16 17:07:39 +00:00
Gleb Smirnoff
42282202ee - Extend interface of ng_getqblk(), so that malloc wait flags are
specified by caller.
- Change ng_send_item() interface - use 'flags' argument instead of
  boolean 'queue'.
- Extend ng_send_fn(), ng_package_data() and ng_package_msg()
  interface - add possibility to pass flags. Rename ng_send_fn() to
  ng_send_fn1(). Create macro for ng_send_fn().
- Update all macros, that use ng_package_data() and ng_package_msg().

Reviewed by:	julian
2005-05-16 17:07:03 +00:00
Gleb Smirnoff
73e872668d Make NETGRAPH_DEBUG a kernel option, so that it can't be turned off
without hacking source.

In collaboration with:	ru, julian
2005-05-16 08:25:55 +00:00
Gleb Smirnoff
8253c060cf Move queue element routines upper, so that all related
declarations are in one place, to improve readability.
No functional changes.
2005-05-14 10:07:17 +00:00
Gleb Smirnoff
1489164f6b Use uma(9) for allocating netgraph items:
- ng_getqblk() simply runs uma_zalloc().
  - ng_free_item() simply frees.
  - ngq_mtx is pushed down under NETGRAPH_DEBUG.
  - NGQF_FREE is removed.

Increase default maxalloc to 512.

Reviewed by:	julian
2005-05-14 09:25:18 +00:00
Gleb Smirnoff
0f4a3524dd When used as divert socket we need to decouple stack when node is entered
from socket side. Use ng_queue_fn() instead of ng_send_fn().
2005-05-13 11:40:08 +00:00
Gleb Smirnoff
aacdb11479 Since there is no way to queue a function call to node, create
ng_queue_fn() - a queue version of ng_send_fn().
2005-05-13 11:35:02 +00:00
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