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

Function pfr_set_addrs

freebsd/netpfil/pf/pf_table.c:400–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398}
399
400int
401pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
402 int *size2, int *nadd, int *ndel, int *nchange, int flags,
403 u_int32_t ignore_pfrt_flags)
404{
405 struct pfr_ktable *kt, *tmpkt;
406 struct pfr_kentryworkq addq, delq, changeq;
407 struct pfr_kentry *p, *q;
408 struct pfr_addr ad;
409 int i, rv, xadd = 0, xdel = 0, xchange = 0;
410 long tzero = time_second;
411
412 PF_RULES_WASSERT();
413
414 ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY | PFR_FLAG_FEEDBACK);
415 if (pfr_validate_table(tbl, ignore_pfrt_flags, flags &
416 PFR_FLAG_USERIOCTL))
417 return (EINVAL);
418 kt = pfr_lookup_table(tbl);
419 if (kt == NULL || !(kt->pfrkt_flags & PFR_TFLAG_ACTIVE))
420 return (ESRCH);
421 if (kt->pfrkt_flags & PFR_TFLAG_CONST)
422 return (EPERM);
423 tmpkt = pfr_create_ktable(&V_pfr_nulltable, 0, 0);
424 if (tmpkt == NULL)
425 return (ENOMEM);
426 pfr_mark_addrs(kt);
427 SLIST_INIT(&addq);
428 SLIST_INIT(&delq);
429 SLIST_INIT(&changeq);
430 for (i = 0; i < size; i++) {
431 /*
432 * XXXGL: undertand pf_if usage of this function
433 * and make ad a moving pointer
434 */
435 bcopy(addr + i, &ad, sizeof(ad));
436 if (pfr_validate_addr(&ad))
437 senderr(EINVAL);
438 ad.pfra_fback = PFR_FB_NONE;
439 p = pfr_lookup_addr(kt, &ad, 1);
440 if (p != NULL) {
441 if (p->pfrke_mark) {
442 ad.pfra_fback = PFR_FB_DUPLICATE;
443 goto _skip;
444 }
445 p->pfrke_mark = 1;
446 if (p->pfrke_not != ad.pfra_not) {
447 SLIST_INSERT_HEAD(&changeq, p, pfrke_workq);
448 ad.pfra_fback = PFR_FB_CHANGED;
449 xchange++;
450 }
451 } else {
452 q = pfr_lookup_addr(tmpkt, &ad, 1);
453 if (q != NULL) {
454 ad.pfra_fback = PFR_FB_DUPLICATE;
455 goto _skip;
456 }
457 p = pfr_create_kentry(&ad,

Callers 2

pfi_table_updateFunction · 0.85
pfioctlFunction · 0.85

Calls 15

pfr_validate_tableFunction · 0.85
pfr_lookup_tableFunction · 0.85
pfr_create_ktableFunction · 0.85
pfr_mark_addrsFunction · 0.85
pfr_validate_addrFunction · 0.85
pfr_lookup_addrFunction · 0.85
pfr_create_kentryFunction · 0.85
pfr_route_kentryFunction · 0.85
pfr_destroy_kentryFunction · 0.85
pfr_enqueue_addrsFunction · 0.85
pfr_copyout_addrFunction · 0.85
pfr_clean_node_maskFunction · 0.85

Tested by

no test coverage detected