Lines Matching refs:db
149 #define SOFLOW_DB_FREE(db) \ argument
150 if (db && (os_ref_release(&db->soflow_db_ref_count) == 0)) { \
151 soflow_db_free(db); \
396 struct soflow_db * __single db = NULL; in soflow_db_init() local
399 db = kalloc_type(struct soflow_db, Z_WAITOK | Z_ZERO | Z_NOFAIL); in soflow_db_init()
400 db->soflow_db_so = so; in soflow_db_init()
401 void * __single hash = hashinit(SOFLOW_HASH_SIZE, M_CFIL, &db->soflow_db_hashmask); in soflow_db_init()
402 …db->soflow_db_hashbase = __unsafe_forge_bidi_indexable(struct soflow_hash_head *, hash, SOFLOW_HAS… in soflow_db_init()
403 if (db->soflow_db_hashbase == NULL) { in soflow_db_init()
404 kfree_type(struct soflow_db, db); in soflow_db_init()
408 db->soflow_db_debug = SOFLOW_ENABLE_DEBUG(so, hash_entry); in soflow_db_init()
409 os_ref_init(&db->soflow_db_ref_count, &soflow_refgrp); in soflow_db_init()
410 so->so_flow_db = db; in soflow_db_init()
429 soflow_db_remove_entry(struct soflow_db *db, struct soflow_hash_entry *hash_entry) in soflow_db_remove_entry() argument
434 if (db == NULL || db->soflow_db_count == 0) { in soflow_db_remove_entry()
440 …SOFLOW_LOG(LOG_INFO, db->soflow_db_so, hash_entry->soflow_debug, "<Close nstat> - context %lX", (u… in soflow_db_remove_entry()
447 db->soflow_db_count--; in soflow_db_remove_entry()
448 if (db->soflow_db_only_entry == hash_entry) { in soflow_db_remove_entry()
449 db->soflow_db_only_entry = NULL; in soflow_db_remove_entry()
455 soflow_feat_detach_entry_func_ptr(db->soflow_db_so, hash_entry); in soflow_db_remove_entry()
473 soflow_db_free(struct soflow_db *db) in soflow_db_free() argument
479 if (db == NULL) { in soflow_db_free()
483 …SOFLOW_LOG(LOG_INFO, db->soflow_db_so, db->soflow_db_debug, "<db %p> freeing db (count == %d)", db… in soflow_db_free()
486 flowhash = &db->soflow_db_hashbase[i]; in soflow_db_free()
488 SOFLOW_ENTRY_LOG(LOG_INFO, db->soflow_db_so, entry, entry->soflow_debug, "Remove entry"); in soflow_db_free()
489 soflow_db_remove_entry(db, entry); in soflow_db_free()
494 soflow_feat_detach_db_func_ptr(db->soflow_db_so, db); in soflow_db_free()
498 VERIFY(db->soflow_db_count == 0); in soflow_db_free()
499 hashdestroy(db->soflow_db_hashbase, M_CFIL, db->soflow_db_hashmask); in soflow_db_free()
500 kfree_type(struct soflow_db, db); in soflow_db_free()
548 soflow_db_lookup_entry_internal(struct soflow_db *db, struct sockaddr *local, struct sockaddr *remo… in soflow_db_lookup_entry_internal() argument
552 struct inpcb *inp = sotoinpcb(db->soflow_db_so); in soflow_db_lookup_entry_internal()
558 if (inp == NULL || db == NULL) { in soflow_db_lookup_entry_internal()
572 matchentry.soflow_debug = SOFLOW_ENABLE_DEBUG(db->soflow_db_so, (&matchentry)); in soflow_db_lookup_entry_internal()
573 SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, &matchentry, true, "Looking for entry"); in soflow_db_lookup_entry_internal()
587 inp_hash_element &= db->soflow_db_hashmask; in soflow_db_lookup_entry_internal()
588 flowhash = &db->soflow_db_hashbase[inp_hash_element]; in soflow_db_lookup_entry_internal()
593 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Found entry v6"… in soflow_db_lookup_entry_internal()
598 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Found entry v4"… in soflow_db_lookup_entry_internal()
605 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, &matchentry, matchentry.soflow_debug, "Entry not fou… in soflow_db_lookup_entry_internal()
611 soflow_db_lookup_entry(struct soflow_db *db, struct sockaddr *local, struct sockaddr *remote, boole… in soflow_db_lookup_entry() argument
613 …struct soflow_hash_entry *entry = soflow_db_lookup_entry_internal(db, local, remote, remoteOnly, f… in soflow_db_lookup_entry()
615 entry = soflow_db_lookup_entry_internal(db, local, remote, remoteOnly, true); in soflow_db_lookup_entry()
621 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
627 inp_hash_element &= db->soflow_db_hashmask; in soflow_db_lookup_by_feature_context_id()
628 flowhash = &db->soflow_db_hashbase[inp_hash_element]; in soflow_db_lookup_by_feature_context_id()
631 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Looking at entr… in soflow_db_lookup_by_feature_context_id()
634 …SOFLOW_ENTRY_LOG(LOG_DEBUG, db->soflow_db_so, nextentry, nextentry->soflow_debug, "Found entry by … in soflow_db_lookup_by_feature_context_id()
640 …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()
641 …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()
647 soflow_db_get_feature_context(struct soflow_db *db, u_int64_t feature_context_id) in soflow_db_get_feature_context() argument
652 if (db == NULL || db->soflow_db_so == NULL || feature_context_id == 0) { in soflow_db_get_feature_context()
656 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_get_feature_context()
660 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_get_feature_context()
665 if (db->soflow_db_count == 1) { in soflow_db_get_feature_context()
666 if (db->soflow_db_only_entry != NULL && in soflow_db_get_feature_context()
667 …db->soflow_db_only_entry->soflow_feat_ctxt != NULL && db->soflow_db_only_entry->soflow_feat_ctxt_i… in soflow_db_get_feature_context()
668 …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()
669 context = db->soflow_db_only_entry->soflow_feat_ctxt; in soflow_db_get_feature_context()
671 …SOFLOW_LOG(LOG_DEBUG, db->soflow_db_so, db->soflow_db_debug, "MISMATCHED only entry for featureID … in soflow_db_get_feature_context()
673 db->soflow_db_only_entry, in soflow_db_get_feature_context()
674 db->soflow_db_only_entry ? db->soflow_db_only_entry->soflow_feat_ctxt : NULL, in soflow_db_get_feature_context()
675 db->soflow_db_only_entry ? db->soflow_db_only_entry->soflow_feat_ctxt_id : 0); in soflow_db_get_feature_context()
678 hash_entry = soflow_db_lookup_by_feature_context_id(db, feature_context_id); in soflow_db_get_feature_context()
682 SOFLOW_DB_FREE(db); in soflow_db_get_feature_context()
687 soflow_db_get_feature_context_id(struct soflow_db *db, struct sockaddr *local, struct sockaddr *rem… in soflow_db_get_feature_context_id() argument
692 if (db == NULL || db->soflow_db_so == NULL) { in soflow_db_get_feature_context_id()
696 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_get_feature_context_id()
700 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_get_feature_context_id()
704 hash_entry = soflow_db_lookup_entry(db, local, remote, false); in soflow_db_get_feature_context_id()
707 hash_entry = soflow_db_lookup_entry(db, local, remote, true); in soflow_db_get_feature_context_id()
713 SOFLOW_DB_FREE(db); in soflow_db_get_feature_context_id()
719 soflow_db_add_entry(struct soflow_db *db, struct sockaddr *local, struct sockaddr *remote) in soflow_db_add_entry() argument
722 struct inpcb *inp = db ? sotoinpcb(db->soflow_db_so) : NULL; in soflow_db_add_entry()
727 if (db == NULL || inp == NULL) { in soflow_db_add_entry()
745 entry->soflow_db = db; in soflow_db_add_entry()
746 entry->soflow_debug = SOFLOW_ENABLE_DEBUG(db->soflow_db_so, entry); in soflow_db_add_entry()
758 inp_hash_element = entry->soflow_flowhash & db->soflow_db_hashmask; in soflow_db_add_entry()
760 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_add_entry()
764 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_add_entry()
768 flowhash = &db->soflow_db_hashbase[inp_hash_element]; in soflow_db_add_entry()
771 db->soflow_db_count++; in soflow_db_add_entry()
772 db->soflow_db_only_entry = entry; in soflow_db_add_entry()
773 SOFLOW_LOG(LOG_INFO, db->soflow_db_so, db->soflow_db_debug, "total count %d", db->soflow_db_count); in soflow_db_add_entry()
775 SOFLOW_DB_FREE(db); in soflow_db_add_entry()
852 soflow_entry_update_local(struct soflow_db *db, struct soflow_hash_entry *entry, struct sockaddr *l… in soflow_entry_update_local() argument
854 struct inpcb *inp = sotoinpcb(db->soflow_db_so); in soflow_entry_update_local()
863 SOFLOW_ENTRY_LOG(LOG_INFO, db->soflow_db_so, entry, entry->soflow_debug, "Updated outifp"); in soflow_entry_update_local()
905 SOFLOW_ENTRY_LOG(LOG_INFO, db->soflow_db_so, entry, entry->soflow_debug, "Updated address"); in soflow_entry_update_local()
909 if (soflow_entry_local_port_needs_update(db->soflow_db_so, entry)) { in soflow_entry_update_local()
912 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()
1389 if (db->soflow_db_count == 1 && db->soflow_db_only_entry != NULL) { in soflow_gc_cleanup()
1397 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_gc_cleanup()
1402 flowhash = &db->soflow_db_hashbase[i]; in soflow_gc_cleanup()
1415 soflow_db_remove_entry(db, entry); in soflow_gc_cleanup()
1422 SOFLOW_DB_FREE(db); in soflow_gc_cleanup()
1517 soflow_db_apply(struct soflow_db *db, soflow_entry_apply_func entry_apply_fn, void *context) in soflow_db_apply() argument
1523 if (db == NULL || db->soflow_db_so == NULL || entry_apply_fn == NULL) { in soflow_db_apply()
1527 socket_lock_assert_owned(db->soflow_db_so); in soflow_db_apply()
1531 if (os_ref_retain_try(&db->soflow_db_ref_count) == false) { in soflow_db_apply()
1536 flowhash = &db->soflow_db_hashbase[i]; in soflow_db_apply()
1538 if (entry_apply_fn(db->soflow_db_so, entry, context) == false) { in soflow_db_apply()
1545 SOFLOW_DB_FREE(db); in soflow_db_apply()