git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
netfiltr: ipt_CLUSTERIP: simplify seq_file codeA
[safe/jmp/linux-2.6]
/
net
/
ipv4
/
netfilter
/
ipt_CLUSTERIP.c
diff --git
a/net/ipv4/netfilter/ipt_CLUSTERIP.c
b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index
fafe8eb
..
0886f96
100644
(file)
--- a/
net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/
net/ipv4/netfilter/ipt_CLUSTERIP.c
@@
-168,7
+168,7
@@
clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
char buffer[16];
/* create proc dir entry */
char buffer[16];
/* create proc dir entry */
- sprintf(buffer, "%
u.%u.%u.%u", NIPQUAD(ip)
);
+ sprintf(buffer, "%
pI4", &ip
);
c->pde = proc_create_data(buffer, S_IWUSR|S_IRUSR,
clusterip_procdir,
&clusterip_proc_fops, c);
c->pde = proc_create_data(buffer, S_IWUSR|S_IRUSR,
clusterip_procdir,
&clusterip_proc_fops, c);
@@
-281,11
+281,9
@@
clusterip_responsible(const struct clusterip_config *config, u_int32_t hash)
***********************************************************************/
static unsigned int
***********************************************************************/
static unsigned int
-clusterip_tg(struct sk_buff *skb, const struct net_device *in,
- const struct net_device *out, unsigned int hooknum,
- const struct xt_target *target, const void *targinfo)
+clusterip_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
{
- const struct ipt_clusterip_tgt_info *cipinfo = targinfo;
+ const struct ipt_clusterip_tgt_info *cipinfo =
par->
targinfo;
struct nf_conn *ct;
enum ip_conntrack_info ctinfo;
u_int32_t hash;
struct nf_conn *ct;
enum ip_conntrack_info ctinfo;
u_int32_t hash;
@@
-305,9
+303,9
@@
clusterip_tg(struct sk_buff *skb, const struct net_device *in,
/* special case: ICMP error handling. conntrack distinguishes between
* error messages (RELATED) and information requests (see below) */
/* special case: ICMP error handling. conntrack distinguishes between
* error messages (RELATED) and information requests (see below) */
- if (ip_hdr(skb)->protocol == IPPROTO_ICMP
- && (ctinfo == IP_CT_RELATED
-
|| ctinfo == IP_CT_RELATED+
IP_CT_IS_REPLY))
+ if (ip_hdr(skb)->protocol == IPPROTO_ICMP
&&
+ (ctinfo == IP_CT_RELATED ||
+
ctinfo == IP_CT_RELATED +
IP_CT_IS_REPLY))
return XT_CONTINUE;
/* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO,
return XT_CONTINUE;
/* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO,
@@
-349,13
+347,10
@@
clusterip_tg(struct sk_buff *skb, const struct net_device *in,
return XT_CONTINUE;
}
return XT_CONTINUE;
}
-static bool
-clusterip_tg_check(const char *tablename, const void *e_void,
- const struct xt_target *target, void *targinfo,
- unsigned int hook_mask)
+static bool clusterip_tg_check(const struct xt_tgchk_param *par)
{
{
- struct ipt_clusterip_tgt_info *cipinfo = targinfo;
- const struct ipt_entry *e =
e_void
;
+ struct ipt_clusterip_tgt_info *cipinfo =
par->
targinfo;
+ const struct ipt_entry *e =
par->entryinfo
;
struct clusterip_config *config;
struct clusterip_config *config;
@@
-367,8
+362,8
@@
clusterip_tg_check(const char *tablename, const void *e_void,
return false;
}
return false;
}
- if (e->ip.dmsk.s_addr != htonl(0xffffffff)
-
||
e->ip.dst.s_addr == 0) {
+ if (e->ip.dmsk.s_addr != htonl(0xffffffff)
||
+ e->ip.dst.s_addr == 0) {
printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n");
return false;
}
printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n");
return false;
}
@@
-378,7
+373,7
@@
clusterip_tg_check(const char *tablename, const void *e_void,
config = clusterip_config_find_get(e->ip.dst.s_addr, 1);
if (!config) {
if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {
config = clusterip_config_find_get(e->ip.dst.s_addr, 1);
if (!config) {
if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {
- printk(KERN_WARNING "CLUSTERIP: no config found for %
u.%u.%u.%u, need 'new'\n", NIPQUAD(e->ip.dst.s_addr)
);
+ printk(KERN_WARNING "CLUSTERIP: no config found for %
pI4, need 'new'\n", &e->ip.dst.s_addr
);
return false;
} else {
struct net_device *dev;
return false;
} else {
struct net_device *dev;
@@
-406,9
+401,9
@@
clusterip_tg_check(const char *tablename, const void *e_void,
}
cipinfo->config = config;
}
cipinfo->config = config;
- if (nf_ct_l3proto_try_module_get(target->family) < 0) {
+ if (nf_ct_l3proto_try_module_get(
par->
target->family) < 0) {
printk(KERN_WARNING "can't load conntrack support for "
printk(KERN_WARNING "can't load conntrack support for "
- "proto=%u\n", target->family);
+ "proto=%u\n",
par->
target->family);
return false;
}
return false;
}
@@
-416,9
+411,9
@@
clusterip_tg_check(const char *tablename, const void *e_void,
}
/* drop reference count of cluster config when rule is deleted */
}
/* drop reference count of cluster config when rule is deleted */
-static void clusterip_tg_destroy(const struct xt_t
arget *target, void *targinfo
)
+static void clusterip_tg_destroy(const struct xt_t
gdtor_param *par
)
{
{
- const struct ipt_clusterip_tgt_info *cipinfo = targinfo;
+ const struct ipt_clusterip_tgt_info *cipinfo =
par->
targinfo;
/* if no more entries are referencing the config, remove it
* from the list and destroy the proc entry */
/* if no more entries are referencing the config, remove it
* from the list and destroy the proc entry */
@@
-426,7
+421,7
@@
static void clusterip_tg_destroy(const struct xt_target *target, void *targinfo)
clusterip_config_put(cipinfo->config);
clusterip_config_put(cipinfo->config);
- nf_ct_l3proto_module_put(target->family);
+ nf_ct_l3proto_module_put(
par->
target->family);
}
#ifdef CONFIG_COMPAT
}
#ifdef CONFIG_COMPAT
@@
-445,7
+440,7
@@
struct compat_ipt_clusterip_tgt_info
static struct xt_target clusterip_tg_reg __read_mostly = {
.name = "CLUSTERIP",
static struct xt_target clusterip_tg_reg __read_mostly = {
.name = "CLUSTERIP",
- .family =
AF_INET
,
+ .family =
NFPROTO_IPV4
,
.target = clusterip_tg,
.checkentry = clusterip_tg_check,
.destroy = clusterip_tg_destroy,
.target = clusterip_tg,
.checkentry = clusterip_tg_check,
.destroy = clusterip_tg_destroy,
@@
-483,9
+478,8
@@
static void arp_print(struct arp_payload *payload)
}
hbuffer[--k]='\0';
}
hbuffer[--k]='\0';
- printk("src %u.%u.%u.%u@%s, dst %u.%u.%u.%u\n",
- NIPQUAD(payload->src_ip), hbuffer,
- NIPQUAD(payload->dst_ip));
+ printk("src %pI4@%s, dst %pI4\n",
+ &payload->src_ip, hbuffer, &payload->dst_ip);
}
#endif
}
#endif
@@
-501,14
+495,14
@@
arp_mangle(unsigned int hook,
struct clusterip_config *c;
/* we don't care about non-ethernet and non-ipv4 ARP */
struct clusterip_config *c;
/* we don't care about non-ethernet and non-ipv4 ARP */
- if (arp->ar_hrd != htons(ARPHRD_ETHER)
- || arp->ar_pro != htons(ETH_P_IP)
-
||
arp->ar_pln != 4 || arp->ar_hln != ETH_ALEN)
+ if (arp->ar_hrd != htons(ARPHRD_ETHER)
||
+ arp->ar_pro != htons(ETH_P_IP) ||
+ arp->ar_pln != 4 || arp->ar_hln != ETH_ALEN)
return NF_ACCEPT;
/* we only want to mangle arp requests and replies */
return NF_ACCEPT;
/* we only want to mangle arp requests and replies */
- if (arp->ar_op != htons(ARPOP_REPLY)
-
&&
arp->ar_op != htons(ARPOP_REQUEST))
+ if (arp->ar_op != htons(ARPOP_REPLY)
&&
+ arp->ar_op != htons(ARPOP_REQUEST))
return NF_ACCEPT;
payload = (void *)(arp+1);
return NF_ACCEPT;
payload = (void *)(arp+1);
@@
-546,7
+540,7
@@
arp_mangle(unsigned int hook,
static struct nf_hook_ops cip_arp_ops __read_mostly = {
.hook = arp_mangle,
static struct nf_hook_ops cip_arp_ops __read_mostly = {
.hook = arp_mangle,
- .pf = NF_ARP,
+ .pf = NF
PROTO
_ARP,
.hooknum = NF_ARP_OUT,
.priority = -1
};
.hooknum = NF_ARP_OUT,
.priority = -1
};
@@
-566,8
+560,7
@@
struct clusterip_seq_position {
static void *clusterip_seq_start(struct seq_file *s, loff_t *pos)
{
static void *clusterip_seq_start(struct seq_file *s, loff_t *pos)
{
- const struct proc_dir_entry *pde = s->private;
- struct clusterip_config *c = pde->data;
+ struct clusterip_config *c = s->private;
unsigned int weight;
u_int32_t local_nodes;
struct clusterip_seq_position *idx;
unsigned int weight;
u_int32_t local_nodes;
struct clusterip_seq_position *idx;
@@
-638,10
+631,9
@@
static int clusterip_proc_open(struct inode *inode, struct file *file)
if (!ret) {
struct seq_file *sf = file->private_data;
if (!ret) {
struct seq_file *sf = file->private_data;
- struct proc_dir_entry *pde = PDE(inode);
- struct clusterip_config *c = pde->data;
+ struct clusterip_config *c = PDE(inode)->data;
- sf->private =
pde
;
+ sf->private =
c
;
clusterip_config_get(c);
}
clusterip_config_get(c);
}
@@
-651,8
+643,7
@@
static int clusterip_proc_open(struct inode *inode, struct file *file)
static int clusterip_proc_release(struct inode *inode, struct file *file)
{
static int clusterip_proc_release(struct inode *inode, struct file *file)
{
- struct proc_dir_entry *pde = PDE(inode);
- struct clusterip_config *c = pde->data;
+ struct clusterip_config *c = PDE(inode)->data;
int ret;
ret = seq_release(inode, file);
int ret;
ret = seq_release(inode, file);
@@
-666,10
+657,9
@@
static int clusterip_proc_release(struct inode *inode, struct file *file)
static ssize_t clusterip_proc_write(struct file *file, const char __user *input,
size_t size, loff_t *ofs)
{
static ssize_t clusterip_proc_write(struct file *file, const char __user *input,
size_t size, loff_t *ofs)
{
+ struct clusterip_config *c = PDE(file->f_path.dentry->d_inode)->data;
#define PROC_WRITELEN 10
char buffer[PROC_WRITELEN+1];
#define PROC_WRITELEN 10
char buffer[PROC_WRITELEN+1];
- const struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
- struct clusterip_config *c = pde->data;
unsigned long nodenum;
if (copy_from_user(buffer, input, PROC_WRITELEN))
unsigned long nodenum;
if (copy_from_user(buffer, input, PROC_WRITELEN))