Skip to content

Commit

Permalink
Merge git://1984.lsi.us.es/nf-next
Browse files Browse the repository at this point in the history
Pablo Neira Ayuso says:

====================
This is the first batch of Netfilter and IPVS updates for your
net-next tree. Mostly cleanups for the Netfilter side. They are:

* Remove unnecessary RTNL locking now that we have support
  for namespace in nf_conntrack, from Patrick McHardy.

* Cleanup to eliminate unnecessary goto in the initialization
  path of several Netfilter tables, from Jean Sacren.

* Another cleanup from Wu Fengguang, this time to PTR_RET instead
  of if IS_ERR then return PTR_ERR.

* Use list_for_each_entry_continue_rcu in nf_iterate, from
  Michael Wang.

* Add pmtu_disc sysctl option to disable PMTU in their tunneling
  transmitter, from Julian Anastasov.

* Generalize application protocol registration in IPVS and modify
  IPVS FTP helper to use it, from Julian Anastasov.

* update Kconfig. The IPVS FTP helper depends on the Netfilter FTP
  helper for NAT support, from Julian Anastasov.

* Add logic to update PMTU for IPIP packets in IPVS, again
  from Julian Anastasov.

* A couple of sparse warning fixes for IPVS and Netfilter from
  Claudiu Ghioc and Patrick McHardy respectively.

Patrick's IPv6 NAT changes will follow after this batch, I need
to flush this batch first before refreshing my tree.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Aug 23, 2012
2 parents bba6ec7 + 90efbed commit bf277b0
Show file tree
Hide file tree
Showing 23 changed files with 232 additions and 132 deletions.
16 changes: 13 additions & 3 deletions include/net/ip_vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,6 @@ struct netns_ipvs {
struct list_head rs_table[IP_VS_RTAB_SIZE];
/* ip_vs_app */
struct list_head app_list;
/* ip_vs_ftp */
struct ip_vs_app *ftp_app;
/* ip_vs_proto */
#define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
Expand Down Expand Up @@ -890,6 +888,7 @@ struct netns_ipvs {
unsigned int sysctl_sync_refresh_period;
int sysctl_sync_retries;
int sysctl_nat_icmp_send;
int sysctl_pmtu_disc;

/* ip_vs_lblc */
int sysctl_lblc_expiration;
Expand Down Expand Up @@ -976,6 +975,11 @@ static inline int sysctl_sync_sock_size(struct netns_ipvs *ipvs)
return ipvs->sysctl_sync_sock_size;
}

static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
{
return ipvs->sysctl_pmtu_disc;
}

#else

static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
Expand Down Expand Up @@ -1018,6 +1022,11 @@ static inline int sysctl_sync_sock_size(struct netns_ipvs *ipvs)
return 0;
}

static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
{
return 1;
}

#endif

/*
Expand Down Expand Up @@ -1179,7 +1188,8 @@ extern void ip_vs_service_net_cleanup(struct net *net);
* (from ip_vs_app.c)
*/
#define IP_VS_APP_MAX_PORTS 8
extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app);
extern struct ip_vs_app *register_ip_vs_app(struct net *net,
struct ip_vs_app *app);
extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app);
extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
extern void ip_vs_unbind_app(struct ip_vs_conn *cp);
Expand Down
4 changes: 1 addition & 3 deletions net/bridge/netfilter/ebtable_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
static int __net_init frame_filter_net_init(struct net *net)
{
net->xt.frame_filter = ebt_register_table(net, &frame_filter);
if (IS_ERR(net->xt.frame_filter))
return PTR_ERR(net->xt.frame_filter);
return 0;
return PTR_RET(net->xt.frame_filter);
}

static void __net_exit frame_filter_net_exit(struct net *net)
Expand Down
4 changes: 1 addition & 3 deletions net/bridge/netfilter/ebtable_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
static int __net_init frame_nat_net_init(struct net *net)
{
net->xt.frame_nat = ebt_register_table(net, &frame_nat);
if (IS_ERR(net->xt.frame_nat))
return PTR_ERR(net->xt.frame_nat);
return 0;
return PTR_RET(net->xt.frame_nat);
}

static void __net_exit frame_nat_net_exit(struct net *net)
Expand Down
10 changes: 2 additions & 8 deletions net/ipv4/netfilter/iptable_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ static int __net_init iptable_filter_net_init(struct net *net)
net->ipv4.iptable_filter =
ipt_register_table(net, &packet_filter, repl);
kfree(repl);
if (IS_ERR(net->ipv4.iptable_filter))
return PTR_ERR(net->ipv4.iptable_filter);
return 0;
return PTR_RET(net->ipv4.iptable_filter);
}

static void __net_exit iptable_filter_net_exit(struct net *net)
Expand All @@ -96,14 +94,10 @@ static int __init iptable_filter_init(void)
filter_ops = xt_hook_link(&packet_filter, iptable_filter_hook);
if (IS_ERR(filter_ops)) {
ret = PTR_ERR(filter_ops);
goto cleanup_table;
unregister_pernet_subsys(&iptable_filter_net_ops);
}

return ret;

cleanup_table:
unregister_pernet_subsys(&iptable_filter_net_ops);
return ret;
}

static void __exit iptable_filter_fini(void)
Expand Down
10 changes: 2 additions & 8 deletions net/ipv4/netfilter/iptable_mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ static int __net_init iptable_mangle_net_init(struct net *net)
net->ipv4.iptable_mangle =
ipt_register_table(net, &packet_mangler, repl);
kfree(repl);
if (IS_ERR(net->ipv4.iptable_mangle))
return PTR_ERR(net->ipv4.iptable_mangle);
return 0;
return PTR_RET(net->ipv4.iptable_mangle);
}

static void __net_exit iptable_mangle_net_exit(struct net *net)
Expand All @@ -131,14 +129,10 @@ static int __init iptable_mangle_init(void)
mangle_ops = xt_hook_link(&packet_mangler, iptable_mangle_hook);
if (IS_ERR(mangle_ops)) {
ret = PTR_ERR(mangle_ops);
goto cleanup_table;
unregister_pernet_subsys(&iptable_mangle_net_ops);
}

return ret;

cleanup_table:
unregister_pernet_subsys(&iptable_mangle_net_ops);
return ret;
}

static void __exit iptable_mangle_fini(void)
Expand Down
10 changes: 2 additions & 8 deletions net/ipv4/netfilter/iptable_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ static int __net_init iptable_raw_net_init(struct net *net)
net->ipv4.iptable_raw =
ipt_register_table(net, &packet_raw, repl);
kfree(repl);
if (IS_ERR(net->ipv4.iptable_raw))
return PTR_ERR(net->ipv4.iptable_raw);
return 0;
return PTR_RET(net->ipv4.iptable_raw);
}

static void __net_exit iptable_raw_net_exit(struct net *net)
Expand All @@ -75,14 +73,10 @@ static int __init iptable_raw_init(void)
rawtable_ops = xt_hook_link(&packet_raw, iptable_raw_hook);
if (IS_ERR(rawtable_ops)) {
ret = PTR_ERR(rawtable_ops);
goto cleanup_table;
unregister_pernet_subsys(&iptable_raw_net_ops);
}

return ret;

cleanup_table:
unregister_pernet_subsys(&iptable_raw_net_ops);
return ret;
}

static void __exit iptable_raw_fini(void)
Expand Down
5 changes: 1 addition & 4 deletions net/ipv4/netfilter/iptable_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ static int __net_init iptable_security_net_init(struct net *net)
net->ipv4.iptable_security =
ipt_register_table(net, &security_table, repl);
kfree(repl);
if (IS_ERR(net->ipv4.iptable_security))
return PTR_ERR(net->ipv4.iptable_security);

return 0;
return PTR_RET(net->ipv4.iptable_security);
}

static void __net_exit iptable_security_net_exit(struct net *net)
Expand Down
4 changes: 1 addition & 3 deletions net/ipv6/netfilter/ip6table_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ static int __net_init ip6table_filter_net_init(struct net *net)
net->ipv6.ip6table_filter =
ip6t_register_table(net, &packet_filter, repl);
kfree(repl);
if (IS_ERR(net->ipv6.ip6table_filter))
return PTR_ERR(net->ipv6.ip6table_filter);
return 0;
return PTR_RET(net->ipv6.ip6table_filter);
}

static void __net_exit ip6table_filter_net_exit(struct net *net)
Expand Down
4 changes: 1 addition & 3 deletions net/ipv6/netfilter/ip6table_mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ static int __net_init ip6table_mangle_net_init(struct net *net)
net->ipv6.ip6table_mangle =
ip6t_register_table(net, &packet_mangler, repl);
kfree(repl);
if (IS_ERR(net->ipv6.ip6table_mangle))
return PTR_ERR(net->ipv6.ip6table_mangle);
return 0;
return PTR_RET(net->ipv6.ip6table_mangle);
}

static void __net_exit ip6table_mangle_net_exit(struct net *net)
Expand Down
4 changes: 1 addition & 3 deletions net/ipv6/netfilter/ip6table_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ static int __net_init ip6table_raw_net_init(struct net *net)
net->ipv6.ip6table_raw =
ip6t_register_table(net, &packet_raw, repl);
kfree(repl);
if (IS_ERR(net->ipv6.ip6table_raw))
return PTR_ERR(net->ipv6.ip6table_raw);
return 0;
return PTR_RET(net->ipv6.ip6table_raw);
}

static void __net_exit ip6table_raw_net_exit(struct net *net)
Expand Down
5 changes: 1 addition & 4 deletions net/ipv6/netfilter/ip6table_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ static int __net_init ip6table_security_net_init(struct net *net)
net->ipv6.ip6table_security =
ip6t_register_table(net, &security_table, repl);
kfree(repl);
if (IS_ERR(net->ipv6.ip6table_security))
return PTR_ERR(net->ipv6.ip6table_security);

return 0;
return PTR_RET(net->ipv6.ip6table_security);
}

static void __net_exit ip6table_security_net_exit(struct net *net)
Expand Down
10 changes: 6 additions & 4 deletions net/netfilter/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,13 @@ unsigned int nf_iterate(struct list_head *head,
int hook_thresh)
{
unsigned int verdict;
struct nf_hook_ops *elem = list_entry_rcu(*i, struct nf_hook_ops, list);

/*
* The caller must not block between calls to this
* function because of risk of continuing from deleted element.
*/
list_for_each_continue_rcu(*i, head) {
struct nf_hook_ops *elem = (struct nf_hook_ops *)*i;

list_for_each_entry_continue_rcu(elem, head, list) {
if (hook_thresh > elem->priority)
continue;

Expand All @@ -155,11 +154,14 @@ unsigned int nf_iterate(struct list_head *head,
continue;
}
#endif
if (verdict != NF_REPEAT)
if (verdict != NF_REPEAT) {
*i = &elem->list;
return verdict;
}
goto repeat;
}
}
*i = &elem->list;
return NF_ACCEPT;
}

Expand Down
3 changes: 2 additions & 1 deletion net/netfilter/ipvs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ comment 'IPVS application helper'

config IP_VS_FTP
tristate "FTP protocol helper"
depends on IP_VS_PROTO_TCP && NF_CONNTRACK && NF_NAT
depends on IP_VS_PROTO_TCP && NF_CONNTRACK && NF_NAT && \
NF_CONNTRACK_FTP
select IP_VS_NFCT
---help---
FTP is a protocol that transfers IP address and/or port number in
Expand Down
58 changes: 42 additions & 16 deletions net/netfilter/ipvs/ip_vs_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,38 @@ register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, __u16 proto,
}


/*
* ip_vs_app registration routine
*/
int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
/* Register application for netns */
struct ip_vs_app *register_ip_vs_app(struct net *net, struct ip_vs_app *app)
{
struct netns_ipvs *ipvs = net_ipvs(net);
/* increase the module use count */
ip_vs_use_count_inc();
struct ip_vs_app *a;
int err = 0;

if (!ipvs)
return ERR_PTR(-ENOENT);

mutex_lock(&__ip_vs_app_mutex);

list_add(&app->a_list, &ipvs->app_list);
list_for_each_entry(a, &ipvs->app_list, a_list) {
if (!strcmp(app->name, a->name)) {
err = -EEXIST;
goto out_unlock;
}
}
a = kmemdup(app, sizeof(*app), GFP_KERNEL);
if (!a) {
err = -ENOMEM;
goto out_unlock;
}
INIT_LIST_HEAD(&a->incs_list);
list_add(&a->a_list, &ipvs->app_list);
/* increase the module use count */
ip_vs_use_count_inc();

out_unlock:
mutex_unlock(&__ip_vs_app_mutex);

return 0;
return err ? ERR_PTR(err) : a;
}


Expand All @@ -205,20 +221,29 @@ int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
*/
void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app)
{
struct ip_vs_app *inc, *nxt;
struct netns_ipvs *ipvs = net_ipvs(net);
struct ip_vs_app *a, *anxt, *inc, *nxt;

if (!ipvs)
return;

mutex_lock(&__ip_vs_app_mutex);

list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) {
ip_vs_app_inc_release(net, inc);
}
list_for_each_entry_safe(a, anxt, &ipvs->app_list, a_list) {
if (app && strcmp(app->name, a->name))
continue;
list_for_each_entry_safe(inc, nxt, &a->incs_list, a_list) {
ip_vs_app_inc_release(net, inc);
}

list_del(&app->a_list);
list_del(&a->a_list);
kfree(a);

mutex_unlock(&__ip_vs_app_mutex);
/* decrease the module use count */
ip_vs_use_count_dec();
}

/* decrease the module use count */
ip_vs_use_count_dec();
mutex_unlock(&__ip_vs_app_mutex);
}


Expand Down Expand Up @@ -586,5 +611,6 @@ int __net_init ip_vs_app_net_init(struct net *net)

void __net_exit ip_vs_app_net_cleanup(struct net *net)
{
unregister_ip_vs_app(net, NULL /* all */);
proc_net_remove(net, "ip_vs_app");
}
Loading

0 comments on commit bf277b0

Please sign in to comment.