MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pfr_set_tflags

Function pfr_set_tflags

freebsd/netpfil/pf/pf_table.c:1381–1427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1379}
1380
1381int
1382pfr_set_tflags(struct pfr_table *tbl, int size, int setflag, int clrflag,
1383 int *nchange, int *ndel, int flags)
1384{
1385 struct pfr_ktableworkq workq;
1386 struct pfr_ktable *p, *q, key;
1387 int i, xchange = 0, xdel = 0;
1388
1389 ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY);
1390 if ((setflag & ~PFR_TFLAG_USRMASK) ||
1391 (clrflag & ~PFR_TFLAG_USRMASK) ||
1392 (setflag & clrflag))
1393 return (EINVAL);
1394 SLIST_INIT(&workq);
1395 for (i = 0; i < size; i++) {
1396 bcopy(tbl + i, &key.pfrkt_t, sizeof(key.pfrkt_t));
1397 if (pfr_validate_table(&key.pfrkt_t, 0,
1398 flags & PFR_FLAG_USERIOCTL))
1399 return (EINVAL);
1400 p = RB_FIND(pfr_ktablehead, &V_pfr_ktables, &key);
1401 if (p != NULL && (p->pfrkt_flags & PFR_TFLAG_ACTIVE)) {
1402 p->pfrkt_nflags = (p->pfrkt_flags | setflag) &
1403 ~clrflag;
1404 if (p->pfrkt_nflags == p->pfrkt_flags)
1405 goto _skip;
1406 SLIST_FOREACH(q, &workq, pfrkt_workq)
1407 if (!pfr_ktable_compare(p, q))
1408 goto _skip;
1409 SLIST_INSERT_HEAD(&workq, p, pfrkt_workq);
1410 if ((p->pfrkt_flags & PFR_TFLAG_PERSIST) &&
1411 (clrflag & PFR_TFLAG_PERSIST) &&
1412 !(p->pfrkt_flags & PFR_TFLAG_REFERENCED))
1413 xdel++;
1414 else
1415 xchange++;
1416 }
1417_skip:
1418 ;
1419 }
1420 if (!(flags & PFR_FLAG_DUMMY))
1421 pfr_setflags_ktables(&workq);
1422 if (nchange != NULL)
1423 *nchange = xchange;
1424 if (ndel != NULL)
1425 *ndel = xdel;
1426 return (0);
1427}
1428
1429int
1430pfr_ina_begin(struct pfr_table *trs, u_int32_t *ticket, int *ndel, int flags)

Callers 1

pfioctlFunction · 0.85

Calls 3

pfr_validate_tableFunction · 0.85
pfr_ktable_compareFunction · 0.85
pfr_setflags_ktablesFunction · 0.85

Tested by

no test coverage detected