rmind / npf

NPF: packet filter with stateful inspection, NAT, IP sets, etc.
Other
237 stars 42 forks source link

Drop table lock around copyout. #126

Open riastradh opened 1 year ago

riastradh commented 1 year ago

It is forbidden to hold a spin lock around copyout, and t_lock is a spin lock.

We need t_lock in order to iterate over the list of entries. However, during copyout itself, we only need to ensure that the object we're copying out isn't freed by npf_table_remove or npf_table_gc.

Fortunately, the only caller of npf_table_list, npf_table_remove, and npf_table_gc is npfctl_table, and it serializes all of them by the npf config lock. So we can safely drop t_lock across copyout.

https://gnats.NetBSD.org/57136 https://gnats.NetBSD.org/57181