Lines Matching refs:db

145 #define SOFLOW_DB_FREE(db) \  argument
146 if (db && (os_ref_release(&db->soflow_db_ref_count) == 0)) { \
147 soflow_db_free(db); \
394 struct soflow_db *db = NULL; in soflow_db_init() local
397 db = kalloc_type(struct soflow_db, Z_WAITOK | Z_ZERO | Z_NOFAIL); in soflow_db_init()
398 db->soflow_db_so = so; in soflow_db_init()
399 db->soflow_db_hashbase = hashinit(SOFLOW_HASH_SIZE, M_CFIL, &db->soflow_db_hashmask); in soflow_db_init()
400 if (db->soflow_db_hashbase == NULL) { in soflow_db_init()
401 kfree_type(struct soflow_db, db); in soflow_db_init()
405 db->soflow_db_debug = SOFLOW_ENABLE_DEBUG(so, hash_entry); in soflow_db_init()
406 os_ref_init(&db->soflow_db_ref_count, &soflow_refgrp); in soflow_db_init()
407 so->so_flow_db = db; in soflow_db_init()
426 soflow_db_remove_entry(struct soflow_db *db, struct soflow_hash_entry *hash_entry) in soflow_db_remove_entry() argument
431 if (db == NULL || db->soflow_db_count == 0) { in soflow_db_remove_entry()
437 …SOFLOW_LOG(LOG_INFO, db->soflow_db_so, hash_entry->soflow_debug, "<Close nstat> - context %lX", (u… in soflow_db_remove_entry()
444 db->soflow_db_count--; in soflow_db_remove_entry()
445 if (db->soflow_db_only_entry == hash_entry) { in soflow_db_remove_entry()
446 db->soflow_db_only_entry = NULL; in soflow_db_remove_entry()
452 soflow_feat_detach_entry_func_ptr(db->soflow_db_so, hash_entry); in soflow_db_remove_entry()
470 soflow_db_free(struct soflow_db *db) in soflow_db_free() argument
476 if (db == NULL) { in soflow_db_free()
480 …SOFLOW_LOG(LOG_INFO, db->soflow_db_so, db->soflow_db_debug, "<db %p> freeing db (count == %d)", db in soflow_db_free()
483 flowhash = &db->soflow_db_hashbase[i]; in soflow_db_free()
485 SOFLOW_ENTRY_LOG(LOG_INFO, db->soflow_db_so, entry, entry->soflow_debug, "Remove entry"); in soflow_db_free()
486 soflow_db_remove_entry(db, entry); in soflow_db_free()
491 soflow_feat_detach_db_func_ptr(db->soflow_db_so, db); in soflow_db_free()
495 VERIFY(db->soflow_db_count == 0); in soflow_db_free()
496 hashdestroy(db->soflow_db_hashbase, M_CFIL, db->soflow_db_hashmask); in soflow_db_free()
497 kfree_type(struct soflow_db, db); in soflow_db_free()
545 soflow_db_lookup_entry_internal(struct soflow_db *db, struct sockaddr *local, struct sockaddr *remo… in soflow_db_lookup_entry_internal() argument
549 struct inpcb *inp = sotoinpcb(db->soflow_db_so); in soflow_db_lookup_entry_internal()
555 if (inp == NULL || db == NULL) { in soflow_db_lookup_entry_internal()
569 matchentry.soflow_debug = SOFLOW_ENABLE_DEBUG(db->soflow_db_so, (&matchentry)); in soflow_db_lookup_entry_internal()
570 SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, &matchentry, true, "Looking for entry"); in soflow_db_lookup_entry_internal()
584 inp_hash_element &= db->soflow_db_hashmask; in soflow_db_lookup_entry_internal()
585 flowhash = &db->soflow_db_hashbase[inp_hash_element]; in soflow_db_lookup_entry_internal()
590 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Found entry v6"… in soflow_db_lookup_entry_internal()
595 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Found entry v4"… in soflow_db_lookup_entry_internal()
602 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, &matchentry, matchentry.soflow_debug, "Entry not fou… in soflow_db_lookup_entry_internal()
608 soflow_db_lookup_entry(struct soflow_db *db, struct sockaddr *local, struct sockaddr *remote, boole… in soflow_db_lookup_entry() argument
610 …struct soflow_hash_entry *entry = soflow_db_lookup_entry_internal(db, local, remote, remoteOnly, f… in soflow_db_lookup_entry()
612 entry = soflow_db_lookup_entry_internal(db, local, remote, remoteOnly, true); in soflow_db_lookup_entry()
618 soflow_db_lookup_by_feature_context_id(struct soflow_db *db, u_int64_t feature_context_id) in soflow_db_lookup_by_feature_context_id() argument
624 inp_hash_element &= db->soflow_db_hashmask; in soflow_db_lookup_by_feature_context_id()
625 flowhash = &db->soflow_db_hashbase[inp_hash_element]; in soflow_db_lookup_by_feature_context_id()
628 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Looking at entr… in soflow_db_lookup_by_feature_context_id()
631 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Found entry by … in soflow_db_lookup_by_feature_context_id()
637 …SOFLOW_LOG(LOG_DEBUG, db->soflow_db_so, db->soflow_db_debug, "No entry found for featureID %llu <c… in soflow_db_lookup_by_feature_context_id()
638 …feature_context_id, db->soflow_db_count, inp_hash_element, (u_int32_t)(feature_context_id & 0x0fff… in soflow_db_lookup_by_feature_context_id()
644 soflow_db_get_feature_context(struct soflow_db *db, u_int64_t feature_context_id) in soflow_db_get_feature_context() argument
649 if (db == NULL || db->soflow_db_so == NULL || feature_context_id == 0) { in soflow_db_get_feature_context()
653 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_get_feature_context()
657 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_get_feature_context()
662 if (db->soflow_db_count == 1) { in soflow_db_get_feature_context()
663 if (db->soflow_db_only_entry != NULL && in soflow_db_get_feature_context()
664db->soflow_db_only_entry->soflow_feat_ctxt != NULL && db->soflow_db_only_entry->soflow_feat_ctxt_i… in soflow_db_get_feature_context()
665 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, db->soflow_db_only_entry, db->soflow_db_only_entry->… in soflow_db_get_feature_context()
666 context = db->soflow_db_only_entry->soflow_feat_ctxt; in soflow_db_get_feature_context()
668 …SOFLOW_LOG(LOG_DEBUG, db->soflow_db_so, db->soflow_db_debug, "MISMATCHED only entry for featureID … in soflow_db_get_feature_context()
670 db->soflow_db_only_entry, in soflow_db_get_feature_context()
671 db->soflow_db_only_entry ? db->soflow_db_only_entry->soflow_feat_ctxt : NULL, in soflow_db_get_feature_context()
672 db->soflow_db_only_entry ? db->soflow_db_only_entry->soflow_feat_ctxt_id : 0); in soflow_db_get_feature_context()
675 hash_entry = soflow_db_lookup_by_feature_context_id(db, feature_context_id); in soflow_db_get_feature_context()
679 SOFLOW_DB_FREE(db); in soflow_db_get_feature_context()
684 soflow_db_get_feature_context_id(struct soflow_db *db, struct sockaddr *local, struct sockaddr *rem… in soflow_db_get_feature_context_id() argument
689 if (db == NULL || db->soflow_db_so == NULL) { in soflow_db_get_feature_context_id()
693 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_get_feature_context_id()
697 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_get_feature_context_id()
701 hash_entry = soflow_db_lookup_entry(db, local, remote, false); in soflow_db_get_feature_context_id()
704 hash_entry = soflow_db_lookup_entry(db, local, remote, true); in soflow_db_get_feature_context_id()
710 SOFLOW_DB_FREE(db); in soflow_db_get_feature_context_id()
716 soflow_db_add_entry(struct soflow_db *db, struct sockaddr *local, struct sockaddr *remote) in soflow_db_add_entry() argument
719 struct inpcb *inp = db ? sotoinpcb(db->soflow_db_so) : NULL; in soflow_db_add_entry()
724 if (db == NULL || inp == NULL) { in soflow_db_add_entry()
742 entry->soflow_db = db; in soflow_db_add_entry()
743 entry->soflow_debug = SOFLOW_ENABLE_DEBUG(db->soflow_db_so, entry); in soflow_db_add_entry()
754 inp_hash_element = entry->soflow_flowhash & db->soflow_db_hashmask; in soflow_db_add_entry()
756 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_add_entry()
760 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_add_entry()
764 flowhash = &db->soflow_db_hashbase[inp_hash_element]; in soflow_db_add_entry()
767 db->soflow_db_count++; in soflow_db_add_entry()
768 db->soflow_db_only_entry = entry; in soflow_db_add_entry()
769 SOFLOW_LOG(LOG_INFO, db->soflow_db_so, db->soflow_db_debug, "total count %d", db->soflow_db_count); in soflow_db_add_entry()
771 SOFLOW_DB_FREE(db); in soflow_db_add_entry()
846 soflow_entry_update_local(struct soflow_db *db, struct soflow_hash_entry *entry, struct sockaddr *l… in soflow_entry_update_local() argument
848 struct inpcb *inp = sotoinpcb(db->soflow_db_so); in soflow_entry_update_local()
857 SOFLOW_ENTRY_LOG(LOG_INFO, db->soflow_db_so, entry, entry->soflow_debug, "Updated outifp"); in soflow_entry_update_local()
898 SOFLOW_ENTRY_LOG(LOG_INFO, db->soflow_db_so, entry, entry->soflow_debug, "Updated address"); in soflow_entry_update_local()
902 if (soflow_entry_local_port_needs_update(db->soflow_db_so, entry)) { in soflow_entry_update_local()
905 SOFLOW_ENTRY_LOG(LOG_INFO, db->soflow_db_so, entry, entry->soflow_debug, "Updated port"); in soflow_entry_update_local()
1380 struct soflow_db *db = NULL; in soflow_gc_cleanup() local
1386 db = so->so_flow_db; in soflow_gc_cleanup()
1392 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_gc_cleanup()
1397 flowhash = &db->soflow_db_hashbase[i]; in soflow_gc_cleanup()
1410 soflow_db_remove_entry(db, entry); in soflow_gc_cleanup()
1417 SOFLOW_DB_FREE(db); in soflow_gc_cleanup()
1512 soflow_db_apply(struct soflow_db *db, soflow_entry_apply_func entry_apply_fn, void *context) in soflow_db_apply() argument
1518 if (db == NULL || db->soflow_db_so == NULL || entry_apply_fn == NULL) { in soflow_db_apply()
1522 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_apply()
1526 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_apply()
1531 flowhash = &db->soflow_db_hashbase[i]; in soflow_db_apply()
1533 if (entry_apply_fn(db->soflow_db_so, entry, context) == false) { in soflow_db_apply()
1540 SOFLOW_DB_FREE(db); in soflow_db_apply()