| 1294 | } |
| 1295 | |
| 1296 | int |
| 1297 | pfr_get_tstats(struct pfr_table *filter, struct pfr_tstats *tbl, int *size, |
| 1298 | int flags) |
| 1299 | { |
| 1300 | struct pfr_ktable *p; |
| 1301 | struct pfr_ktableworkq workq; |
| 1302 | int n, nn; |
| 1303 | long tzero = time_second; |
| 1304 | int pfr_dir, pfr_op; |
| 1305 | |
| 1306 | /* XXX PFR_FLAG_CLSTATS disabled */ |
| 1307 | ACCEPT_FLAGS(flags, PFR_FLAG_ALLRSETS); |
| 1308 | if (pfr_fix_anchor(filter->pfrt_anchor)) |
| 1309 | return (EINVAL); |
| 1310 | n = nn = pfr_table_count(filter, flags); |
| 1311 | if (n < 0) |
| 1312 | return (ENOENT); |
| 1313 | if (n > *size) { |
| 1314 | *size = n; |
| 1315 | return (0); |
| 1316 | } |
| 1317 | SLIST_INIT(&workq); |
| 1318 | RB_FOREACH(p, pfr_ktablehead, &V_pfr_ktables) { |
| 1319 | if (pfr_skip_table(filter, p, flags)) |
| 1320 | continue; |
| 1321 | if (n-- <= 0) |
| 1322 | continue; |
| 1323 | bcopy(&p->pfrkt_kts.pfrts_t, &tbl->pfrts_t, |
| 1324 | sizeof(struct pfr_table)); |
| 1325 | for (pfr_dir = 0; pfr_dir < PFR_DIR_MAX; pfr_dir ++) { |
| 1326 | for (pfr_op = 0; pfr_op < PFR_OP_TABLE_MAX; pfr_op ++) { |
| 1327 | tbl->pfrts_packets[pfr_dir][pfr_op] = |
| 1328 | counter_u64_fetch( |
| 1329 | p->pfrkt_packets[pfr_dir][pfr_op]); |
| 1330 | tbl->pfrts_bytes[pfr_dir][pfr_op] = |
| 1331 | counter_u64_fetch( |
| 1332 | p->pfrkt_bytes[pfr_dir][pfr_op]); |
| 1333 | } |
| 1334 | } |
| 1335 | tbl->pfrts_match = counter_u64_fetch(p->pfrkt_match); |
| 1336 | tbl->pfrts_nomatch = counter_u64_fetch(p->pfrkt_nomatch); |
| 1337 | tbl->pfrts_tzero = p->pfrkt_tzero; |
| 1338 | tbl->pfrts_cnt = p->pfrkt_cnt; |
| 1339 | for (pfr_op = 0; pfr_op < PFR_REFCNT_MAX; pfr_op++) |
| 1340 | tbl->pfrts_refcnt[pfr_op] = p->pfrkt_refcnt[pfr_op]; |
| 1341 | tbl++; |
| 1342 | SLIST_INSERT_HEAD(&workq, p, pfrkt_workq); |
| 1343 | } |
| 1344 | if (flags & PFR_FLAG_CLSTATS) |
| 1345 | pfr_clstats_ktables(&workq, tzero, |
| 1346 | flags & PFR_FLAG_ADDRSTOO); |
| 1347 | |
| 1348 | KASSERT(n == 0, ("%s: corruption detected (%d)", __func__, n)); |
| 1349 | |
| 1350 | *size = nn; |
| 1351 | return (0); |
| 1352 | } |
| 1353 |
no test coverage detected