Lines Matching defs:fve
212 static inline struct fve *flowlist_lookup(struct flowvalve *,
214 static inline struct fve *flowlist_reclaim(struct flowvalve *,
216 static inline void flowlist_move_to_head(struct flowvalve *, struct fve *);
221 struct fve **);
223 struct fve *);
354 struct fve *fve = NULL;
357 if (fv_checkflow(rp->red_flowvalve, pktattr, &fve)) {
471 fv_dropbyred(rp->red_flowvalve, pktattr, fve);
1084 #define FV_TTHRESH 3 /* time threshold to delete fve */
1124 static inline struct fve *
1128 struct fve *fve;
1147 TAILQ_FOREACH(fve, &fv->fv_flowlist, fve_lru){
1148 if (fve->fve_lastdrop.tv_sec == 0)
1150 if (fve->fve_lastdrop.tv_sec < tthresh.tv_sec) {
1151 fve->fve_lastdrop.tv_sec = 0;
1154 if (fve->fve_flow.flow_af == AF_INET &&
1155 fve->fve_flow.flow_ip.ip_src.s_addr ==
1157 fve->fve_flow.flow_ip.ip_dst.s_addr ==
1159 return fve;
1166 TAILQ_FOREACH(fve, &fv->fv_flowlist, fve_lru){
1167 if (fve->fve_lastdrop.tv_sec == 0)
1169 if (fve->fve_lastdrop.tv_sec < tthresh.tv_sec) {
1170 fve->fve_lastdrop.tv_sec = 0;
1173 if (fve->fve_flow.flow_af == AF_INET6 &&
1174 IN6_ARE_ADDR_EQUAL(&fve->fve_flow.flow_ip6.ip6_src,
1176 IN6_ARE_ADDR_EQUAL(&fve->fve_flow.flow_ip6.ip6_dst,
1178 return fve;
1188 fv->fv_flows = flows; /* save the number of active fve's */
1192 static inline struct fve *
1195 struct fve *fve;
1204 fve = TAILQ_LAST(&fv->fv_flowlist, fv_flowhead);
1209 fve->fve_flow.flow_af = AF_INET;
1210 fve->fve_flow.flow_ip.ip_src = ip->ip_src;
1211 fve->fve_flow.flow_ip.ip_dst = ip->ip_dst;
1216 fve->fve_flow.flow_af = AF_INET6;
1217 fve->fve_flow.flow_ip6.ip6_src = ip6->ip6_src;
1218 fve->fve_flow.flow_ip6.ip6_dst = ip6->ip6_dst;
1223 fve->fve_state = Green;
1224 fve->fve_p = 0.0;
1225 fve->fve_f = 0.0;
1226 fve->fve_ifseq = fv->fv_ifseq - 1;
1227 fve->fve_count = 0;
1233 return fve;
1237 flowlist_move_to_head(struct flowvalve *fv, struct fve *fve)
1239 if (TAILQ_FIRST(&fv->fv_flowlist) != fve) {
1240 TAILQ_REMOVE(&fv->fv_flowlist, fve, fve_lru);
1241 TAILQ_INSERT_HEAD(&fv->fv_flowlist, fve, fve_lru);
1252 struct fve *fve;
1260 fv->fv_fves = malloc(sizeof(struct fve) * num, M_DEVBUF,
1270 fve = &fv->fv_fves[i];
1271 fve->fve_lastdrop.tv_sec = 0;
1272 TAILQ_INSERT_TAIL(&fv->fv_flowlist, fve, fve_lru);
1329 struct fve **fcache)
1331 struct fve *fve;
1337 if ((fve = flowlist_lookup(fv, pktattr, &now)) == NULL)
1341 *fcache = fve;
1344 if (++fve->fve_count == FV_N) {
1348 fve->fve_f =
1349 (FV_N << FP_SHIFT) / (fv->fv_ifseq - fve->fve_ifseq)
1350 + fve->fve_f - FV_FUNSCALE(fve->fve_f);
1351 fve->fve_ifseq = fv->fv_ifseq;
1352 fve->fve_count = 0;
1358 if (fve->fve_state == Green && fve->fve_p > fv->fv_pthresh) {
1362 fthresh = fv_p2f(fv, fve->fve_p);
1363 if (fve->fve_f > fthresh)
1364 fve->fve_state = Red;
1367 if (fve->fve_state == Red) {
1371 if (now.tv_sec - fve->fve_lastdrop.tv_sec > FV_BACKOFFTHRESH) {
1373 fve->fve_p = 0;
1374 fve->fve_state = Green;
1380 flowlist_move_to_head(fv, fve);
1381 fve->fve_lastdrop = now;
1392 fve->fve_p -= FV_PUNSCALE(fve->fve_p);
1393 if (fve->fve_p < 0)
1394 fve->fve_p = 0;
1407 struct fve *fcache)
1409 struct fve *fve;
1417 /* the fve of this packet is already cached */
1418 fve = fcache;
1419 else if ((fve = flowlist_lookup(fv, pktattr, &now)) == NULL)
1420 fve = flowlist_reclaim(fv, pktattr);
1422 flowlist_move_to_head(fv, fve);
1429 fve->fve_p = (1 << FP_SHIFT) + fve->fve_p;
1431 fve->fve_lastdrop = now;