netfilter updates for net-next (batch 1)
Subsystems (6)
[email protected]
maintainercover netfilter updates for net-next (batch 1)
From: Pablo Neira Ayuso <[email protected]>
Hi David,
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.
You can pull these changes from:
git://1984.lsi.us.es/nf-next
Thanks!
Claudiu Ghioc (1):
ipvs: fixed sparse warning
Jean Sacren (1):
netfilter: remove unnecessary goto statement for error recovery
Julian Anastasov (4):
ipvs: ip_vs_ftp depends on nf_conntrack_ftp helper
ipvs: generalize app registration in netns
ipvs: implement passive PMTUD for IPIP packets
ipvs: add pmtu_disc option to disable IP DF for TUN packets
Michael Wang (1):
netfilter: replace list_for_each_continue_rcu with new interface
Patrick McHardy (2):
netfilter: sparse endian fixes
netfilter: nf_conntrack: remove unnecessary RTNL locking
Wu Fengguang (1):
netfilter: PTR_RET can be used
include/net/ip_vs.h | 16 ++++-- net/bridge/netfilter/ebtable_filter.c | 4 +- net/bridge/netfilter/ebtable_nat.c | 4 +- net/ipv4/netfilter/iptable_filter.c | 10 +--- net/ipv4/netfilter/iptable_mangle.c | 10 +--- net/ipv4/netfilter/iptable_raw.c | 10 +--- net/ipv4/netfilter/iptable_security.c | 5 +- net/ipv6/netfilter/ip6table_filter.c | 4 +- net/ipv6/netfilter/ip6table_mangle.c | 4 +- net/ipv6/netfilter/ip6table_raw.c | 4 +- net/ipv6/netfilter/ip6table_security.c | 5 +- net/netfilter/core.c | 10 ++-- net/netfilter/ipvs/Kconfig | 3 +- net/netfilter/ipvs/ip_vs_app.c | 58 ++++++++++++++++------ net/netfilter/ipvs/ip_vs_core.c | 76 +++++++++++++++++++++++++++-- net/netfilter/ipvs/ip_vs_ctl.c | 16 ++++-- net/netfilter/ipvs/ip_vs_ftp.c | 21 ++------ net/netfilter/ipvs/ip_vs_xmit.c | 83 ++++++++++++++++++++++---------- net/netfilter/nf_conntrack_proto.c | 5 -- net/netfilter/nfnetlink_acct.c | 4 +- net/netfilter/nfnetlink_cthelper.c | 2 +- net/netfilter/xt_NFQUEUE.c | 8 +-- net/netfilter/xt_osf.c | 2 +- 23 files changed, 232 insertions(+), 132 deletions(-)
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 1/10 ipvs: ip_vs_ftp depends on nf_conntrack_ftp helper
From: Julian Anastasov <[email protected]>
The FTP application indirectly depends on thenf_conntrack_ftp helper for proper NAT support. If the module is not loaded, IPVS can resize the packets for the command connection, eg. PASV response but the SEQ adjustment logic in ipv4_confirm is not called without helper.
--- net/netfilter/ipvs/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/ipvs/Kconfig +2 -1
@@ -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
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 2/10 ipvs: generalize app registration in netns
In reply to [email protected]From: Julian Anastasov <[email protected]>
Get rid of the ftp_app pointer and allow applications
to be registered without adding fields in the netns_ipvs structure.
v2: fix coding style as suggested by Pablo Neira Ayuso <[email protected]>
--- include/net/ip_vs.h | 5 ++-- net/netfilter/ipvs/ip_vs_app.c | 58 +++++++++++++++++++++++++++++----------- net/netfilter/ipvs/ip_vs_ftp.c | 21 ++++----------- 3 files changed, 49 insertions(+), 35 deletions(-)
include/net/ip_vs.h +2 -3
@@ -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 ];
@@ -1179,7 +1177,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);
net/netfilter/ipvs/ip_vs_app.c +42 -16
89 lines not on this page · raw message
net/netfilter/ipvs/ip_vs_ftp.c +5 -16
@@ -441,16 +441,10 @@ static int __net_init __ip_vs_ftp_init(struct net *net)if (!ipvs)return -ENOENT ; - app =kmemdup (&ip_vs_ftp,sizeof (struct ip_vs_app ),GFP_KERNEL ); -if (!app) -return -ENOMEM ; -INIT_LIST_HEAD (&app->a_list); -INIT_LIST_HEAD (&app->incs_list); - ipvs->ftp_app = app; - ret =register_ip_vs_app (net, app); -if (ret) - goto err_exit; + app =register_ip_vs_app (net, &ip_vs_ftp); +if (IS_ERR (app)) +return PTR_ERR (app);for (i =0 ; i < ports_count; i++) {if (!ports[i])
@@ -464,9 +458,7 @@ static int __net_init __ip_vs_ftp_init(struct net *net)return 0 ; err_unreg: -unregister_ip_vs_app (net, app); -err_exit: -kfree (ipvs->ftp_app); +unregister_ip_vs_app (net, &ip_vs_ftp);return ret; }/*
@@ -474,10 +466,7 @@ err_exit:*/ static void __ip_vs_ftp_exit (struct net *net) { -struct netns_ipvs *ipvs =net_ipvs (net); - -unregister_ip_vs_app (net, ipvs->ftp_app); -kfree (ipvs->ftp_app); +unregister_ip_vs_app (net, &ip_vs_ftp); }static struct pernet_operations ip_vs_ftp_ops = {
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 3/10 ipvs: fixed sparse warning
In reply to [email protected]From: Claudiu Ghioc <[email protected]>
Removed the following sparse warnings, wether CONFIG_SYSCTL is defined or not:
* warning: symbol 'ip_vs_control_net_init_sysctl' was not
declared. Should it be static?
* warning: symbol 'ip_vs_control_net_cleanup_sysctl' was
not declared. Should it be static?
--- net/netfilter/ipvs/ip_vs_ctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +4 -4
@@ -3675,7 +3675,7 @@ static void ip_vs_genl_unregister(void)* per netns intit/exit func. */ #ifdef CONFIG_SYSCTL -int __net_init ip_vs_control_net_init_sysctl (struct net *net) +static int __net_init ip_vs_control_net_init_sysctl (struct net *net) {int idx;struct netns_ipvs *ipvs =net_ipvs (net);
@@ -3743,7 +3743,7 @@ int __net_init ip_vs_control_net_init_sysctl(struct net *net)return 0 ; } -void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) +static void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) {struct netns_ipvs *ipvs =net_ipvs (net);
@@ -3754,8 +3754,8 @@ void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net)#else -int __net_init ip_vs_control_net_init_sysctl (struct net *net) {return 0 ; } -void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { } +static int __net_init ip_vs_control_net_init_sysctl (struct net *net) {return 0 ; } +static void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { }#endif
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 4/10 ipvs: implement passive PMTUD for IPIP packets
In reply to [email protected]From: Julian Anastasov <[email protected]>
IPVS is missing the logic to update PMTU in routing
for its IPIP packets. We monitor the dst_mtu and can return FRAG_NEEDED messages but if the tunneled packets get ICMP error we can not rely on other traffic to save the lowest MTU.
The following patch adds ICMP handling for IPIP
packets in incoming direction, from some remote host to our local IP used as saddr in the outer header. By this way we can forward any related ICMP traffic if it is for IPVS TUN connection. For the special case of PMTUD we update the routing and if client requested DF we can forward the error.
To properly update the routing we have to bind
the cached route (dest->dst_cache) to the selected saddr because ipv4_update_pmtu uses saddr for dst lookup. Add IP_VS_RT_MODE_CONNECT flag to force such binding with second route.
Update ip_vs_tunnel_xmit to provide IP_VS_RT_MODE_CONNECT
and change the code to copy DF. For now we prefer not to force PMTU discovery (outer DF=1) because we don't have configuration option to enable or disable PMTUD. As we do not keep any packets to resend, we prefer not to play games with packets without DF bit because the sender is not informed when they are rejected.
Also, change ops->update_pmtu to be called only
for local clients because there is no point to update MTU for input routes, in our case skb->dst->dev is lo. It seems the code is copied from ipip.c where the skb dst points to tunnel device.
--- net/netfilter/ipvs/ip_vs_core.c | 76 +++++++++++++++++++++++++++++++++++-- net/netfilter/ipvs/ip_vs_xmit.c | 79 +++++++++++++++++++++++++++------------ 2 files changed, 128 insertions(+), 27 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +73 -3
@@ -1303,7 +1303,8 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)struct ip_vs_conn *cp;struct ip_vs_protocol *pp;struct ip_vs_proto_data *pd; -unsigned int offset, ihl, verdict; +unsigned int offset, offset2, ihl, verdict; +bool ipip; *related =1 ;
@@ -1345,6 +1346,21 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum) net =skb_net (skb); +/* Special case for errors for IPIP packets */ + ipip = false; +if (cih->protocol ==IPPROTO_IPIP ) { +if (unlikely (cih->frag_off &htons (IP_OFFSET ))) +return NF_ACCEPT ; +/* Error for our IPIP must arrive at LOCAL_IN */ +if (!(skb_rtable (skb)->rt_flags &RTCF_LOCAL )) +return NF_ACCEPT ; + offset += cih->ihl *4 ; + cih =skb_header_pointer (skb, offset,sizeof (_ciph), &_ciph); +if (cih ==NULL ) +return NF_ACCEPT ;/* The packet looks wrong, ignore */ + ipip = true; + } + pd =ip_vs_proto_data_get (net, cih->protocol);if (!pd)return NF_ACCEPT ;
@@ -1358,11 +1374,14 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)IP_VS_DBG_PKT (11 ,AF_INET , pp, skb, offset,"Checking incoming ICMP for" ); + offset2 = offset; offset += cih->ihl *4 ;ip_vs_fill_iphdr (AF_INET , cih, &ciph); -/* The embedded headers contain source and dest in reverse order */ - cp = pp->conn_in_get (AF_INET , skb, &ciph, offset,1 ); +/* The embedded headers contain source and dest in reverse order. +* For IPIP this is error for request, not for reply. +*/ + cp = pp->conn_in_get (AF_INET , skb, &ciph, offset, ipip ?0 :1 );if (!cp)return NF_ACCEPT ;
@@ -1376,6 +1395,57 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum) goto out; } +if (ipip) { +__be32 info = ic->un.gateway; + +/* Update the MTU */ +if (ic->type ==ICMP_DEST_UNREACH && + ic->code ==ICMP_FRAG_NEEDED ) { +struct ip_vs_dest *dest = cp->dest; +u32 mtu =ntohs (ic->un.frag.mtu); + +/* Strip outer IP and ICMP, go to IPIP header */ +__skb_pull (skb, ihl +sizeof (_icmph)); + offset2 -= ihl +sizeof (_icmph); +skb_reset_network_header (skb); +IP_VS_DBG (12 ,"ICMP for IPIP %pI4->%pI4: mtu=%u\n" , + &ip_hdr (skb)->saddr, &ip_hdr (skb)->daddr, mtu); +rcu_read_lock (); +ipv4_update_pmtu (skb,dev_net (skb->dev), + mtu,0 ,0 ,0 ,0 ); +rcu_read_unlock (); +/* Client uses PMTUD? */ +if (!(cih->frag_off &htons (IP_DF ))) + goto ignore_ipip; +/* Prefer the resulting PMTU */ +if (dest) { +spin_lock (&dest->dst_lock); +if (dest->dst_cache) + mtu =dst_mtu (dest->dst_cache); +spin_unlock (&dest->dst_lock); + } +if (mtu >68 +sizeof (struct iphdr )) + mtu -=sizeof (struct iphdr ); + info =htonl (mtu); + } +/* Strip outer IP, ICMP and IPIP, go to IP header of +* original request. +*/ +__skb_pull (skb, offset2); +skb_reset_network_header (skb); +IP_VS_DBG (12 ,"Sending ICMP for %pI4->%pI4: t=%u, c=%u, i=%u\n" , + &ip_hdr (skb)->saddr, &ip_hdr (skb)->daddr, + ic->type, ic->code,ntohl (info)); +icmp_send (skb, ic->type, ic->code, info); +/* ICMP can be shorter but anyways, account it */ +ip_vs_out_stats (cp, skb); + +ignore_ipip: +consume_skb (skb); + verdict =NF_STOLEN ; + goto out; + } +/* do the statistics and put it back */ ip_vs_in_stats (cp, skb);if (IPPROTO_TCP == cih->protocol ||IPPROTO_UDP == cih->protocol)
net/netfilter/ipvs/ip_vs_xmit.c +55 -24
136 lines not on this page · raw message
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 5/10 ipvs: add pmtu_disc option to disable IP DF for TUN packets
In reply to [email protected]From: Julian Anastasov <[email protected]>
Disabling PMTU discovery can increase the output packet
rate but some users have enough resources and prefer to fragment than to drop traffic. By default, we copy the DF bit but if pmtu_disc is disabled we do not send FRAG_NEEDED messages anymore.
--- include/net/ip_vs.h | 11 +++++++++++ net/netfilter/ipvs/ip_vs_ctl.c | 8 ++++++++ net/netfilter/ipvs/ip_vs_xmit.c | 6 +++--- 3 files changed, 22 insertions(+), 3 deletions(-)
include/net/ip_vs.h +11 -0
@@ -888,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;
@@ -974,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)
@@ -1016,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 /*
net/netfilter/ipvs/ip_vs_ctl.c +8 -0
@@ -1801,6 +1801,12 @@ static struct ctl_table vs_vars[] = { .mode = 0644, .proc_handler = proc_dointvec, }, + { + .procname = "pmtu_disc", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, #ifdef CONFIG_IP_VS_DEBUG { .procname = "debug_level",
@@ -3726,6 +3732,8 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net) ipvs->sysctl_sync_retries =clamp_t (int,DEFAULT_SYNC_RETRIES ,0 ,3 ); tbl[idx++].data = &ipvs->sysctl_sync_retries; tbl[idx++].data = &ipvs->sysctl_nat_icmp_send; + ipvs->sysctl_pmtu_disc =1 ; + tbl[idx++].data = &ipvs->sysctl_pmtu_disc; ipvs->sysctl_hdr =register_net_sysctl (net,"net/ipv4/vs" , tbl);
net/netfilter/ipvs/ip_vs_xmit.c +3 -3
@@ -795,6 +795,7 @@ int ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp) { + struct netns_ipvs *ipvs = net_ipvs(skb_net(skb));struct rtable *rt;/* Route to the other host */ __be32 saddr;/* Source for tunnel */ struct net_device *tdev;/* Device to other host */
@@ -830,10 +831,9 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,skb_dst (skb)->ops->update_pmtu (skb_dst (skb),NULL , skb, mtu);/* Copy DF, reset fragment offset and MF */ - df = old_iph->frag_off &htons (IP_DF ); + df =sysctl_pmtu_disc (ipvs) ? old_iph->frag_off &htons (IP_DF ) :0 ; -if ((old_iph->frag_off &htons (IP_DF ) && - mtu <ntohs (old_iph->tot_len) && !skb_is_gso (skb))) { +if (df && mtu <ntohs (old_iph->tot_len) && !skb_is_gso (skb)) {icmp_send (skb,ICMP_DEST_UNREACH ,ICMP_FRAG_NEEDED ,htonl (mtu));IP_VS_DBG_RL ("%s(): frag needed\n" , __func__); goto tx_error_put;
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 6/10 netfilter: PTR_RET can be used
In reply to [email protected]From: Wu Fengguang <[email protected]>
This quiets the coccinelle warnings:
net/bridge/netfilter/ebtable_filter.c:107:1-3: WARNING: PTR_RET can be used net/bridge/netfilter/ebtable_nat.c:107:1-3: WARNING: PTR_RET can be used net/ipv6/netfilter/ip6table_filter.c:65:1-3: WARNING: PTR_RET can be used net/ipv6/netfilter/ip6table_mangle.c:100:1-3: WARNING: PTR_RET can be used net/ipv6/netfilter/ip6table_raw.c:44:1-3: WARNING: PTR_RET can be used net/ipv6/netfilter/ip6table_security.c:62:1-3: WARNING: PTR_RET can be used net/ipv4/netfilter/iptable_filter.c:72:1-3: WARNING: PTR_RET can be used net/ipv4/netfilter/iptable_mangle.c:107:1-3: WARNING: PTR_RET can be used net/ipv4/netfilter/iptable_raw.c:51:1-3: WARNING: PTR_RET can be used net/ipv4/netfilter/iptable_security.c:70:1-3: WARNING: PTR_RET can be used
--- net/bridge/netfilter/ebtable_filter.c | 4 +--- net/bridge/netfilter/ebtable_nat.c | 4 +--- net/ipv4/netfilter/iptable_filter.c | 4 +--- net/ipv4/netfilter/iptable_mangle.c | 4 +--- net/ipv4/netfilter/iptable_raw.c | 4 +--- net/ipv4/netfilter/iptable_security.c | 5 +---- net/ipv6/netfilter/ip6table_filter.c | 4 +--- net/ipv6/netfilter/ip6table_mangle.c | 4 +--- net/ipv6/netfilter/ip6table_raw.c | 4 +--- net/ipv6/netfilter/ip6table_security.c | 5 +---- 10 files changed, 10 insertions(+), 32 deletions(-)
net/bridge/netfilter/ebtable_filter.c +1 -3
@@ -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)
net/bridge/netfilter/ebtable_nat.c +1 -3
@@ -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)
net/ipv4/netfilter/iptable_filter.c +1 -3
@@ -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)
net/ipv4/netfilter/iptable_mangle.c +1 -3
@@ -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)
net/ipv4/netfilter/iptable_raw.c +1 -3
@@ -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)
net/ipv4/netfilter/iptable_security.c +1 -4
@@ -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)
net/ipv6/netfilter/ip6table_filter.c +1 -3
@@ -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)
net/ipv6/netfilter/ip6table_mangle.c +1 -3
@@ -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)
net/ipv6/netfilter/ip6table_raw.c +1 -3
@@ -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)
net/ipv6/netfilter/ip6table_security.c +1 -4
@@ -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)
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 7/10 netfilter: sparse endian fixes
In reply to [email protected]From: Patrick McHardy <[email protected]>
Fix a couple of endian annotation in net/netfilter:
net/netfilter/nfnetlink_acct.c:82:30: warning: cast to restricted __be64 net/netfilter/nfnetlink_acct.c:86:30: warning: cast to restricted __be64 net/netfilter/nfnetlink_cthelper.c:77:28: warning: cast to restricted __be16 net/netfilter/xt_NFQUEUE.c:46:16: warning: restricted __be32 degrades to integer net/netfilter/xt_NFQUEUE.c:60:34: warning: restricted __be32 degrades to integer net/netfilter/xt_NFQUEUE.c:68:34: warning: restricted __be32 degrades to integer net/netfilter/xt_osf.c:272:55: warning: cast to restricted __be16
--- net/netfilter/nfnetlink_acct.c | 4 ++-- net/netfilter/nfnetlink_cthelper.c | 2 +- net/netfilter/xt_NFQUEUE.c | 8 +++++--- net/netfilter/xt_osf.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-)
net/netfilter/nfnetlink_acct.c +2 -2
@@ -79,11 +79,11 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,if (tb[NFACCT_BYTES ]) {atomic64_set (&nfacct->bytes, -be64_to_cpu (nla_get_u64 (tb[NFACCT_BYTES ]))); +be64_to_cpu (nla_get_be64 (tb[NFACCT_BYTES ]))); }if (tb[NFACCT_PKTS ]) {atomic64_set (&nfacct->pkts, -be64_to_cpu (nla_get_u64 (tb[NFACCT_PKTS ]))); +be64_to_cpu (nla_get_be64 (tb[NFACCT_PKTS ]))); }atomic_set (&nfacct->refcnt,1 );list_add_tail_rcu (&nfacct->head, &nfnl_acct_list);
net/netfilter/nfnetlink_cthelper.c +1 -1
@@ -74,7 +74,7 @@ nfnl_cthelper_parse_tuple(struct nf_conntrack_tuple *tuple,if (!tb[NFCTH_TUPLE_L3PROTONUM ] || !tb[NFCTH_TUPLE_L4PROTONUM ])return -EINVAL ; - tuple->src.l3num =ntohs (nla_get_u16 (tb[NFCTH_TUPLE_L3PROTONUM ])); + tuple->src.l3num =ntohs (nla_get_be16 (tb[NFCTH_TUPLE_L3PROTONUM ])); tuple->dst.protonum =nla_get_u8 (tb[NFCTH_TUPLE_L4PROTONUM ]);return 0 ;
net/netfilter/xt_NFQUEUE.c +5 -3
@@ -43,7 +43,7 @@ static u32 hash_v4(const struct sk_buff *skb)const struct iphdr *iph =ip_hdr (skb);/* packets in either direction go into same queue */ -if (iph->saddr < iph->daddr) +if ((__force u32 )iph->saddr < (__force u32 )iph->daddr)return jhash_3words ((__force u32 )iph->saddr, (__force u32 )iph->daddr, iph->protocol, jhash_initval);
@@ -57,7 +57,8 @@ static u32 hash_v6(const struct sk_buff *skb)const struct ipv6hdr *ip6h =ipv6_hdr (skb);u32 a, b, c; -if (ip6h->saddr.s6_addr32[3 ] < ip6h->daddr.s6_addr32[3 ]) { +if ((__force u32 )ip6h->saddr.s6_addr32[3 ] < + (__force u32 )ip6h->daddr.s6_addr32[3 ]) { a = (__force u32 ) ip6h->saddr.s6_addr32[3 ]; b = (__force u32 ) ip6h->daddr.s6_addr32[3 ]; }else {
@@ -65,7 +66,8 @@ static u32 hash_v6(const struct sk_buff *skb) a = (__force u32 ) ip6h->daddr.s6_addr32[3 ]; } -if (ip6h->saddr.s6_addr32[1 ] < ip6h->daddr.s6_addr32[1 ]) +if ((__force u32 )ip6h->saddr.s6_addr32[1 ] < + (__force u32 )ip6h->daddr.s6_addr32[1 ]) c = (__force u32 ) ip6h->saddr.s6_addr32[1 ];else c = (__force u32 ) ip6h->daddr.s6_addr32[1 ];
net/netfilter/xt_osf.c +1 -1
@@ -269,7 +269,7 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p) mss <<=8 ; mss |= optp[2 ]; - mss =ntohs (mss); + mss =ntohs ((__force __be16 )mss);break ;case OSFOPT_TS : loop_cont =1 ;
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 8/10 netfilter: nf_conntrack: remove unnecessary RTNL locking
In reply to [email protected]From: Patrick McHardy <[email protected]>
Locking the rtnl was added to nf_conntrack_l{3,4}_proto_unregister() for walking the network namespace list. This is not done anymore since we have proper namespace support in the protocols now, so we don't need to take the RTNL anymore.
--- net/netfilter/nf_conntrack_proto.c | 5 ----- 1 file changed, 5 deletions(-)
net/netfilter/nf_conntrack_proto.c +0 -5
@@ -21,7 +21,6 @@#include <linux/notifier.h> #include <linux/kernel.h> #include <linux/netdevice.h> -#include <linux/rtnetlink.h> #include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack_l3proto.h>
@@ -294,9 +293,7 @@ void nf_conntrack_l3proto_unregister(struct net *net,nf_ct_l3proto_unregister_sysctl (net, proto);/* Remove all contrack entries for this protocol */ -rtnl_lock ();nf_ct_iterate_cleanup (net, kill_l3proto, proto); -rtnl_unlock (); }EXPORT_SYMBOL_GPL (nf_conntrack_l3proto_unregister);
@@ -502,9 +499,7 @@ void nf_conntrack_l4proto_unregister(struct net *net,nf_ct_l4proto_unregister_sysctl (net, pn, l4proto);/* Remove all contrack entries for this protocol */ -rtnl_lock ();nf_ct_iterate_cleanup (net, kill_l4proto, l4proto); -rtnl_unlock (); }EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_unregister);
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 9/10 netfilter: replace list_for_each_continue_rcu with new interface
In reply to [email protected]From: Michael Wang <[email protected]>
This patch replaces list_for_each_continue_rcu() with list_for_each_entry_continue_rcu() to allow removing list_for_each_continue_rcu().
--- net/netfilter/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/netfilter/core.c +6 -4
@@ -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 ;
@@ -155,11 +154,14 @@ repeat: continue; }#endif -if (verdict !=NF_REPEAT ) +if (verdict !=NF_REPEAT ) { + *i = &elem->list;return verdict; + } goto repeat; } } + *i = &elem->list;return NF_ACCEPT ; }
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 10/10 netfilter: remove unnecessary goto statement for error recovery
In reply to [email protected]From: Jean Sacren <[email protected]>
Usually it's a good practice to use goto statement for error recovery when initializing the module. This approach could be an overkill if:
1) there is only one fail case;
2) success and failure use the same return statement.
For a cleaner approach, remove the unnecessary goto statement and directly implement error recovery.
--- net/ipv4/netfilter/iptable_filter.c | 6 +----- net/ipv4/netfilter/iptable_mangle.c | 6 +----- net/ipv4/netfilter/iptable_raw.c | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-)
net/ipv4/netfilter/iptable_filter.c +1 -5
@@ -94,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)
net/ipv4/netfilter/iptable_mangle.c +1 -5
@@ -129,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)
net/ipv4/netfilter/iptable_raw.c +1 -5
@@ -73,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)
Signature · 1 line
1.7.10.4
David Miller
maintainerFrom: [email protected]
Date: Thu, 23 Aug 2012 01:38:36 +0200
Quoted 2 lines
This is the first batch of Netfilter and IPVS updates for your net-next tree. Mostly cleanups for the Netfilter side. They are:
Pulled, thanks a lot Pablo.