From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: Patrick McHardy <kaber@trash.net>, netfilter-devel@vger.kernel.org
Subject: [NETFILTER 06/07]: nf_sockopts list head cleanup
Date: Fri, 2 Nov 2007 12:23:18 +0100 (MET) [thread overview]
Message-ID: <20071102112008.22803.12783.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20071102112000.22803.92699.sendpatchset@localhost.localdomain>
[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>
---
commit 430f032387ee5ed1babaac827c116493d79217d8
tree f75f080c68c90d3c879dbaba73aa3e136e88f4ef
parent 04a6b70568aa679cdce548f4edaac0a668440c60
author Alexey Dobriyan <adobriyan@sw.ru> Fri, 02 Nov 2007 11:58:58 +0100
committer Patrick McHardy <kaber@trash.net> Fri, 02 Nov 2007 11:58:58 +0100
net/netfilter/nf_sockopt.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
index aa28315..2dfac32 100644
--- a/net/netfilter/nf_sockopt.c
+++ b/net/netfilter/nf_sockopt.c
@@ -23,14 +23,13 @@ static inline int overlap(int min1, int max1, int min2, int max2)
/* Functions to register sockopt ranges (exclusive). */
int nf_register_sockopt(struct nf_sockopt_ops *reg)
{
- struct list_head *i;
+ struct nf_sockopt_ops *ops;
int ret = 0;
if (mutex_lock_interruptible(&nf_sockopt_mutex) != 0)
return -EINTR;
- list_for_each(i, &nf_sockopts) {
- struct nf_sockopt_ops *ops = (struct nf_sockopt_ops *)i;
+ list_for_each_entry(ops, &nf_sockopts, list) {
if (ops->pf == reg->pf
&& (overlap(ops->set_optmin, ops->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,
char __user *opt, int *len, int get)
{
- struct list_head *i;
struct nf_sockopt_ops *ops;
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)
return -EINTR;
- list_for_each(i, &nf_sockopts) {
- ops = (struct nf_sockopt_ops *)i;
+ list_for_each_entry(ops, &nf_sockopts, list) {
if (ops->pf == pf) {
if (!try_module_get(ops->owner))
goto out_nosup;
@@ -124,7 +121,6 @@ EXPORT_SYMBOL(nf_getsockopt);
static int compat_nf_sockopt(struct sock *sk, int pf, int val,
char __user *opt, int *len, int get)
{
- struct list_head *i;
struct nf_sockopt_ops *ops;
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)
return -EINTR;
- list_for_each(i, &nf_sockopts) {
- ops = (struct nf_sockopt_ops *)i;
+ list_for_each_entry(ops, &nf_sockopts, list) {
if (ops->pf == pf) {
if (!try_module_get(ops->owner))
goto out_nosup;
next prev parent reply other threads:[~2007-11-02 11:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-02 11:23 [NETFILTER00/07]: Netfilter update+fixes Patrick McHardy
2007-11-02 11:23 ` [NETFILTER 01/07]: ip{,6}_queue: convert to seq_file interface Patrick McHardy
2007-11-06 4:35 ` David Miller
2007-11-02 11:23 ` [NETFILTER 02/07]: Copyright/Email update Patrick McHardy
2007-11-06 4:36 ` David Miller
2007-11-02 11:23 ` [NETFILTER 03/07]: Clean up Makefile Patrick McHardy
2007-11-06 4:43 ` David Miller
2007-11-02 11:23 ` [NETFILTER 04/07]: Sort matches/targets in Kbuild file Patrick McHardy
2007-11-06 4:42 ` David Miller
2007-11-02 11:23 ` [NETFILTER 05/07]: remove unneeded rcu_dereference() calls Patrick McHardy
2007-11-06 4:43 ` David Miller
2007-11-02 11:23 ` Patrick McHardy [this message]
2007-11-06 4:59 ` [NETFILTER 06/07]: nf_sockopts list head cleanup David Miller
2007-11-02 11:23 ` [NETFILTER 07/07]: ebt_arp: fix --arp-gratuitous matching dependence on --arp-ip-{src,dst} Patrick McHardy
2007-11-06 5:00 ` David Miller
2007-11-05 18:20 ` [NETFILTER00/07]: Netfilter update+fixes Kłoczko Tomasz
2007-11-06 0:12 ` Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071102112008.22803.12783.sendpatchset@localhost.localdomain \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).