[NETFILTER]: nf_sockopts list head cleanup
Code is using knowledge that nf_sockopt_ops::list list_head is first field in structure by using casts. Switch to list_for_each_entry() itetators while I am at it. Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d1332e0ab8
commit
55d84acd36
@@ -23,14 +23,13 @@ static inline int overlap(int min1, int max1, int min2, int max2)
|
|||||||
/* Functions to register sockopt ranges (exclusive). */
|
/* Functions to register sockopt ranges (exclusive). */
|
||||||
int nf_register_sockopt(struct nf_sockopt_ops *reg)
|
int nf_register_sockopt(struct nf_sockopt_ops *reg)
|
||||||
{
|
{
|
||||||
struct list_head *i;
|
struct nf_sockopt_ops *ops;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
|
if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
|
|
||||||
list_for_each(i, &nf_sockopts) {
|
list_for_each_entry(ops, &nf_sockopts, list) {
|
||||||
struct nf_sockopt_ops *ops = (struct nf_sockopt_ops *)i;
|
|
||||||
if (ops->pf == reg->pf
|
if (ops->pf == reg->pf
|
||||||
&& (overlap(ops->set_optmin, ops->set_optmax,
|
&& (overlap(ops->set_optmin, ops->set_optmax,
|
||||||
reg->set_optmin, reg->set_optmax)
|
reg->set_optmin, reg->set_optmax)
|
||||||
@@ -65,7 +64,6 @@ EXPORT_SYMBOL(nf_unregister_sockopt);
|
|||||||
static int nf_sockopt(struct sock *sk, int pf, int val,
|
static int nf_sockopt(struct sock *sk, int pf, int val,
|
||||||
char __user *opt, int *len, int get)
|
char __user *opt, int *len, int get)
|
||||||
{
|
{
|
||||||
struct list_head *i;
|
|
||||||
struct nf_sockopt_ops *ops;
|
struct nf_sockopt_ops *ops;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -75,8 +73,7 @@ static int nf_sockopt(struct sock *sk, int pf, int val,
|
|||||||
if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
|
if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
|
|
||||||
list_for_each(i, &nf_sockopts) {
|
list_for_each_entry(ops, &nf_sockopts, list) {
|
||||||
ops = (struct nf_sockopt_ops *)i;
|
|
||||||
if (ops->pf == pf) {
|
if (ops->pf == pf) {
|
||||||
if (!try_module_get(ops->owner))
|
if (!try_module_get(ops->owner))
|
||||||
goto out_nosup;
|
goto out_nosup;
|
||||||
@@ -124,7 +121,6 @@ EXPORT_SYMBOL(nf_getsockopt);
|
|||||||
static int compat_nf_sockopt(struct sock *sk, int pf, int val,
|
static int compat_nf_sockopt(struct sock *sk, int pf, int val,
|
||||||
char __user *opt, int *len, int get)
|
char __user *opt, int *len, int get)
|
||||||
{
|
{
|
||||||
struct list_head *i;
|
|
||||||
struct nf_sockopt_ops *ops;
|
struct nf_sockopt_ops *ops;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -135,8 +131,7 @@ static int compat_nf_sockopt(struct sock *sk, int pf, int val,
|
|||||||
if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
|
if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
|
|
||||||
list_for_each(i, &nf_sockopts) {
|
list_for_each_entry(ops, &nf_sockopts, list) {
|
||||||
ops = (struct nf_sockopt_ops *)i;
|
|
||||||
if (ops->pf == pf) {
|
if (ops->pf == pf) {
|
||||||
if (!try_module_get(ops->owner))
|
if (!try_module_get(ops->owner))
|
||||||
goto out_nosup;
|
goto out_nosup;
|
||||||
|
Reference in New Issue
Block a user