Lines Matching refs:flow

47  * of 256 hash buckets. When the action routine is invoked for a flow,
48 * if the flow (identified by the 5-tuple: saddr, daddr, sport, dport, proto)
49 * is already present in the flow table (indexed by the hash function FLOW_HASH)
50 * then a check is made to see if an item for this flow with the same
53 * not exist a new item is added for the flow. If the flow is not present
54 * an entry is made for the flow.
56 * A timer runs thru the table and writes all the flow items that have
59 * flow timeout value can also be configured. While the timeout is in nsec,
60 * the flow timer interval is in usec.
61 * Information for an active flow can be obtained by using kstats.
284 /* Check if the flow (identified by the 5-tuple) exists in the hash table */
290 flow_t *flow;
293 flow = (flow_t *)hdr->objp;
294 if ((flow != NULL) &&
295 (IN6_ARE_ADDR_EQUAL(&flow->saddr, &header->saddr)) &&
296 (IN6_ARE_ADDR_EQUAL(&flow->daddr, &header->daddr)) &&
297 (flow->proto == header->proto) &&
298 (flow->sport == header->sport) &&
299 (flow->dport == header->dport)) {
300 return (flow);
308 * Add an object to the list at insert_point. This could be a flow item or
309 * a flow itself.
356 /* Delete an obj from the list. This could be a flow item or the flow itself */
402 * is already present for the flow.
405 flowacct_item_present(flow_t *flow, uint8_t dsfield, pid_t proj_id, uint_t uid)
410 itemhdr = flow->items.head;
427 * Add the flow to the table, if not already present. If the flow is
428 * present in the table, add the item. Also, update the flow stats.
441 flow_t *flow;
450 flow = flowacct_flow_present(header, index, flowacct_data);
451 if (flow == NULL) {
452 flow = (flow_t *)kmem_zalloc(FLOWACCT_FLOW_SZ, KM_NOSLEEP);
453 if (flow == NULL) {
459 flow->hdr = flowacct_add_obj(fhead, fhead->tail, (void *)flow);
460 if (flow->hdr == NULL) {
462 kmem_free(flow, FLOWACCT_FLOW_SZ);
468 flow->type = FLOWACCT_FLOW;
469 flow->isv4 = header->isv4;
470 bcopy(header->saddr.s6_addr32, flow->saddr.s6_addr32,
472 bcopy(header->daddr.s6_addr32, flow->daddr.s6_addr32,
474 flow->proto = header->proto;
475 flow->sport = header->sport;
476 flow->dport = header->dport;
477 flow->back_ptr = fhead;
481 * We need to make sure that this 'flow' is not deleted
485 flow->inuse = B_TRUE;
488 ihead = &flow->items;
489 item = flowacct_item_present(flow, header->dsfield, header->projid,
495 * the flow table - i.e. the max_limt that a user specifies is
496 * the maximum no. of flow items in the table.
507 * could contain a flow that can be timed
518 flow->inuse = B_FALSE;
519 /* Need to remove the flow, if one was added */
521 flowacct_del_obj(fhead, flow->hdr,
532 flow->inuse = B_FALSE;
533 /* Need to remove the flow, if one was added */
535 flowacct_del_obj(fhead, flow->hdr,
546 flow->inuse = B_FALSE;
547 /* Need to remove the flow, if one was added */
549 flowacct_del_obj(fhead, flow->hdr,
559 /* If a flow was added, add it too */
578 flow->hdr->last_seen = item->hdr->last_seen = now;
588 /* If the flow was added, append it to the tail of the timeout list */
591 thead->head = flow->hdr;
592 thead->tail = flow->hdr;
594 thead->tail->timeout_next = flow->hdr;
595 flow->hdr->timeout_prev = thead->tail;
596 thead->tail = flow->hdr;
599 * Else, move this flow to the tail of the timeout list, if it is not
601 * flow->hdr in the timeout list :-
606 * ignore such flow.
608 } else if ((flow->hdr->timeout_next != NULL) ||
609 (flow->hdr->timeout_prev != NULL)) {
610 if (flow->hdr != thead->tail) {
611 if (flow->hdr == thead->head) {
614 flow->hdr->timeout_next = NULL;
615 thead->tail->timeout_next = flow->hdr;
616 flow->hdr->timeout_prev = thead->tail;
617 thead->tail = flow->hdr;
619 flow->hdr->timeout_prev->timeout_next =
620 flow->hdr->timeout_next;
621 flow->hdr->timeout_next->timeout_prev =
622 flow->hdr->timeout_prev;
623 flow->hdr->timeout_next = NULL;
624 thead->tail->timeout_next = flow->hdr;
625 flow->hdr->timeout_prev = thead->tail;
626 thead->tail = flow->hdr;
632 * flow gets deleted (i.e. after timing out its
633 * flow items) since we are done using it.
635 flow->inuse = B_FALSE;
642 /* Timer for timing out flows/items from the flow table */
653 /* Delete the item from the flow in the flow table */
655 flowacct_timeout_item(flow_t **flow, list_hdr_t **item_hdr)
660 flowacct_del_obj(&(*flow)->items, *item_hdr, FLOWACCT_DEL_OBJ);
664 /* Create a flow record for this timed out item */
666 flowacct_create_record(flow_t *flow, list_hdr_t *ithdr)
688 htonl(flow->saddr.s6_addr32[count]);
690 htonl(flow->daddr.s6_addr32[count]);
697 tmp_frec->fl_use->fu_sport = htons(flow->sport);
698 tmp_frec->fl_use->fu_dport = htons(flow->dport);
699 tmp_frec->fl_use->fu_protocol = flow->proto;
700 tmp_frec->fl_use->fu_isv4 = flow->isv4;
720 * table or as FLOWACCT_JUST_ONE - delete the first timed out flow. Since the
723 * the first flow that has not timed out (which means none of the following
732 flow_t *flow;
750 * For each flow in the table, scan thru all the items and delete
752 * flow have timed out, delete the flow entry as well. Finally,
763 flow = (flow_t *)fl_hdr->objp;
764 head = flow->back_ptr;
781 ithdr = flow->items.head;
785 * Fill in the flow record to be
788 tmp_frec = flowacct_create_record(flow, ithdr);
823 flowacct_timeout_item(&flow, &ithdr);
827 ASSERT(flow->items.nbr_items == 0);
831 * Don't delete this flow if we are making place for
832 * a new item for this flow.
834 if (!flow->inuse) {
872 * Get the IP header contents from the packet, update the flow table with
909 /* Updated the flow table with this entry */