netfilter: Remove useless variable timeouts in init_conntrack
Subsystems (2)
PATCH 1/1 netfilter: Remove useless variable timeouts in init_conntrack
From: Gao Feng <[email protected]>
All l4_proto->new callbacks don't use the param timeouts currently, so remove it from param list. Then the variable timeouts isn't used as right value in init_conntrack, so remove it too.
--- include/net/netfilter/nf_conntrack_l4proto.h | 2 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 2 +- net/netfilter/nf_conntrack_core.c | 13 ++----------- net/netfilter/nf_conntrack_proto_dccp.c | 2 +- net/netfilter/nf_conntrack_proto_sctp.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 2 +- net/netfilter/nf_conntrack_proto_udp.c | 2 +- 7 files changed, 8 insertions(+), 17 deletions(-)
include/net/netfilter/nf_conntrack_l4proto.h +1 -1
@@ -49,7 +49,7 @@ struct nf_conntrack_l4proto {/* Called when a new connection for this protocol found; * returns TRUE if it's OK. If so, packet() called next. */ bool (*new)(struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff,unsigned int *timeouts); +unsigned int dataoff);/* Called when a conntrack entry is destroyed */ void (*destroy)(struct nf_conn *ct);
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -105,7 +105,7 @@ static int icmp_packet(struct nf_conn *ct,/* Called when a new connection for this protocol found. */ static bool icmp_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff,unsigned int *timeouts) +unsigned int dataoff) {static const u_int8_t valid_new[] = { [ICMP_ECHO ] =1 ,
net/netfilter/nf_conntrack_core.c +2 -11
@@ -1145,7 +1145,6 @@ void nf_conntrack_free(struct nf_conn *ct)const struct nf_conntrack_zone *zone;struct nf_conn_timeout *timeout_ext;struct nf_conntrack_zone tmp; -unsigned int *timeouts;if (!nf_ct_invert_tuple (&repl_tuple, tuple, l3proto, l4proto)) {pr_debug ("Can't invert tuple.\n" );
@@ -1163,21 +1162,13 @@ void nf_conntrack_free(struct nf_conn *ct)return ERR_PTR (-ENOMEM ); } - timeout_ext = tmpl ?nf_ct_timeout_find (tmpl) :NULL ; -if (timeout_ext) { - timeouts =nf_ct_timeout_data (timeout_ext); -if (unlikely (!timeouts)) - timeouts = l4proto->get_timeouts (net); - }else { - timeouts = l4proto->get_timeouts (net); - } - -if (!l4proto->new (ct, skb, dataoff, timeouts)) { +if (!l4proto->new (ct, skb, dataoff)) {nf_conntrack_free (ct);pr_debug ("can't track with proto module\n" );return NULL ; } + timeout_ext = tmpl ?nf_ct_timeout_find (tmpl) :NULL ;if (timeout_ext)nf_ct_timeout_ext_add (ct,rcu_dereference (timeout_ext->timeout),GFP_ATOMIC );
net/netfilter/nf_conntrack_proto_dccp.c +1 -1
@@ -412,7 +412,7 @@ static bool dccp_invert_tuple(struct nf_conntrack_tuple *inv, }static bool dccp_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff,unsigned int *timeouts) +unsigned int dataoff) {struct net *net =nf_ct_net (ct);struct nf_dccp_net *dn;
net/netfilter/nf_conntrack_proto_sctp.c +1 -1
@@ -432,7 +432,7 @@ static int sctp_packet(struct nf_conn *ct,/* Called when a new connection for this protocol found. */ static bool sctp_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff,unsigned int *timeouts) +unsigned int dataoff) {enum sctp_conntrack new_state;const struct sctphdr *sh;
net/netfilter/nf_conntrack_proto_tcp.c +1 -1
@@ -1098,7 +1098,7 @@ static int tcp_packet(struct nf_conn *ct,/* Called when a new connection for this protocol found. */ static bool tcp_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff,unsigned int *timeouts) +unsigned int dataoff) {enum tcp_conntrack new_state;const struct tcphdr *th;
net/netfilter/nf_conntrack_proto_udp.c +1 -1
@@ -103,7 +103,7 @@ static int udp_packet(struct nf_conn *ct,/* Called when a new connection for this protocol found. */ static bool udp_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff,unsigned int *timeouts) +unsigned int dataoff) {return true; }
Signature · 1 line
1.9.1
Florian Westphal
maintainerQuoted 6 lines · [email protected] <[email protected]> wrote:
From: Gao Feng <[email protected]>
All
l4_proto->newcallbacks don't use the param timeouts currently, so remove it from param list. Then the variable timeouts isn't used as right value ininit_conntrack, so remove it too.Signed-off-by Gao Feng <[email protected]>
Quoted 9 lines
--- include/net/netfilter/nf_conntrack_l4proto.h | 2 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 2 +- net/netfilter/nf_conntrack_core.c | 13 ++----------- net/netfilter/nf_conntrack_proto_dccp.c | 2 +- net/netfilter/nf_conntrack_proto_sctp.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 2 +- net/netfilter/nf_conntrack_proto_udp.c | 2 +- 7 files changed, 8 insertions(+), 17 deletions(-)
What about net/netfilter/nf_conntrack_proto_gre.c ?
Hi Florian,
Quoted 7 lines
-----Original Message-----
From: Florian Westphal [mailto:[email protected]]
Sent: Wednesday, April 5, 2017 9:17 PM
To: [email protected]
Cc: [email protected]; [email protected]; Gao Feng <[email protected]>
Subject: Re: [PATCH nf-next 1/1] netfilter: Remove useless variable
timeouts in
Quoted 19 lines
init_conntrackQuoted 6 lines · [email protected] <[email protected]> wrote:
From: Gao Feng <[email protected]>
All
l4_proto->newcallbacks don't use the param timeouts currently, so remove it from param list. Then the variable timeouts isn't used as right value ininit_conntrack, so remove it too.Signed-off-by Gao Feng <[email protected]>Quoted 9 lines
--- include/net/netfilter/nf_conntrack_l4proto.h | 2 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 2 +- net/netfilter/nf_conntrack_core.c | 13 ++----------- net/netfilter/nf_conntrack_proto_dccp.c | 2 +- net/netfilter/nf_conntrack_proto_sctp.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 2 +- net/netfilter/nf_conntrack_proto_udp.c | 2 +- 7 files changed, 8 insertions(+), 17 deletions(-)
Quoted 1 line
What about
net/netfilter/nf_conntrack_proto_gre.c?
It's my fault.
I only checked the protos in nf_conntrack_ipv4.h.
Best Regards
Feng
kbuild test robot
build botreproduce:
Hi Gao,
[auto build test ERROR on nf-next/master]
url: https://github.com/0day-ci/linux/commits/gfree-wind-foxmail-com/netfilter-Remove-useless-variable-timeouts-in-init_conntrack/20170406-031517 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master config: i386-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
>> net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c:377:11: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.new = icmpv6_new,
^~~~~~~~~~
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c:377:11: note: (near initialization for 'nf_conntrack_l4proto_icmpv6.new')
cc1: some warnings being treated as errors
--
>> net/netfilter/nf_conntrack_proto_generic.c:196:11: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.new = generic_new,
^~~~~~~~~~~
net/netfilter/nf_conntrack_proto_generic.c:196:11: note: (near initialization for 'nf_conntrack_l4proto_generic.new')
cc1: some warnings being treated as errors
--
>> net/netfilter/nf_conntrack_proto_gre.c:374:11: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.new = gre_new,
^~~~~~~
net/netfilter/nf_conntrack_proto_gre.c:374:11: note: (near initialization for 'nf_conntrack_l4proto_gre4.new')
cc1: some warnings being treated as errors
vim +377 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
8fc027816 Gao feng 2012-06-21 361
08911475d Pablo Neira Ayuso 2012-06-29 362 static struct nf_proto_net *icmpv6_get_net_proto(struct net *net)
08911475d Pablo Neira Ayuso 2012-06-29 363 {
08911475d Pablo Neira Ayuso 2012-06-29 364 return &net->ct.nf_ct_proto.icmpv6.pn;
08911475d Pablo Neira Ayuso 2012-06-29 365 }
08911475d Pablo Neira Ayuso 2012-06-29 366
61075af51 Patrick McHardy 2007-07-14 367 struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 __read_mostly =
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 368 {
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 369 .l3proto = PF_INET6,
605dcad6c Martin Josefsson 2006-11-29 370 .l4proto = IPPROTO_ICMPV6,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 371 .name = "icmpv6",
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 372 .pkt_to_tuple = icmpv6_pkt_to_tuple,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 373 .invert_tuple = icmpv6_invert_tuple,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 374 .print_tuple = icmpv6_print_tuple,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 375 .packet = icmpv6_packet,
2c8503f55 Pablo Neira Ayuso 2012-02-28 376 .get_timeouts = icmpv6_get_timeouts,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 @377 .new = icmpv6_new,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 378 .error = icmpv6_error,
07a936260 Amerigo Wang 2012-10-29 379 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
fdf708322 Patrick McHardy 2007-09-28 380 .tuple_to_nlattr = icmpv6_tuple_to_nlattr,
a400c30ed Holger Eitzenberger 2009-03-25 381 .nlattr_tuple_size = icmpv6_nlattr_tuple_size,
fdf708322 Patrick McHardy 2007-09-28 382 .nlattr_to_tuple = icmpv6_nlattr_to_tuple,
f73e924cd Patrick McHardy 2007-09-28 383 .nla_policy = icmpv6_nla_policy,
c1d10adb4 Pablo Neira Ayuso 2006-01-05 384 #endif
509784623 Pablo Neira Ayuso 2012-02-28 385 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT):::::: The code at line 377 was first introduced by commit
:::::: 9fb9cbb1082d6b31fb45aa1a14432449a0df6cf1 [NETFILTER]: Add nf_conntrack subsystem.
:::::: TO: Yasuyuki Kozakai <[email protected]> :::::: CC: David S. Miller <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 5 lines
-----Original Message-----
From: kbuild test robot [mailto:[email protected]]
Sent: Thursday, April 6, 2017 4:01 AM
To: [email protected]
Cc: [email protected]; [email protected];
Quoted 2 lines
Gao Feng <[email protected]>
Subject: Re: [PATCH nf-next 1/1] netfilter: Remove useless variable
timeouts in
Quoted 8 lines
init_conntrackHi Gao,
[auto build test ERROR on nf-next/master]
url:
https://github.com/0day-ci/linux/commits/gfree-wind-foxmail-com/netfilter-R
Quoted 6 lines
emove-useless-variable-timeouts-in-init_conntrack/20170406-031517
base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
master
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
Quoted 6 lines
# save the attached .config to linux build tree make ARCH=i386All errors (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c:377:11: error:
initialization
Quoted 8 lines
from incompatible pointer type [-Werror=incompatible-pointer-types]
.new =icmpv6_new,
^~~~~~~~~~
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c:377:11: note: (near
initialization for 'nf_conntrack_l4proto_icmpv6.new')
cc1: some warnings being treated as errors
--Quoted 1 line
Quoted 1 line
net/netfilter/nf_conntrack_proto_generic.c:196:11: error:
initialization from
Quoted 8 lines
incompatible pointer type [-Werror=incompatible-pointer-types]
.new =generic_new,
^~~~~~~~~~~
net/netfilter/nf_conntrack_proto_generic.c:196:11: note: (near
initialization for 'nf_conntrack_l4proto_generic.new')
cc1: some warnings being treated as errors
--Quoted 1 line
Quoted 1 line
net/netfilter/nf_conntrack_proto_gre.c:374:11: error: initialization
from
Quoted 4 lines
incompatible pointer type [-Werror=incompatible-pointer-types]
.new =gre_new,
^~~~~~~
net/netfilter/nf_conntrack_proto_gre.c:374:11: note: (near
initialization for
Quoted 5 lines
'nf_conntrack_l4proto_gre4.new')
cc1: some warnings being treated as errorsvim +377
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
Quoted 12 lines
8fc027816 Gao feng 2012-06-21 361
08911475d Pablo Neira Ayuso 2012-06-29 362 static struct nf_proto_net
*icmpv6_get_net_proto(struct net *net)
08911475d Pablo Neira Ayuso 2012-06-29 363 {
08911475d Pablo Neira Ayuso 2012-06-29 364 return
&net->ct.nf_ct_proto.icmpv6.pn;
08911475d Pablo Neira Ayuso 2012-06-29 365 }
08911475d Pablo Neira Ayuso 2012-06-29 366
61075af51 Patrick McHardy 2007-07-14 367 struct
nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 __read_mostly =
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 368 {
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 369 .l3proto=
Quoted 2 lines
PF_INET6,605dcad6cMartin Josefsson 2006-11-29 370 .l4proto
=
Quoted 2 lines
IPPROTO_ICMPV6,9fb9cbb10Yasuyuki Kozakai 2005-11-09 371 .name
=
Quoted 2 lines
"icmpv6",
9fb9cbb10Yasuyuki Kozakai 2005-11-09 372 .pkt_to_tuple
=
Quoted 2 lines
icmpv6_pkt_to_tuple,9fb9cbb10Yasuyuki Kozakai 2005-11-09 373 .invert_tuple
=
Quoted 2 lines
icmpv6_invert_tuple,9fb9cbb10Yasuyuki Kozakai 2005-11-09 374 .print_tuple
=
Quoted 2 lines
icmpv6_print_tuple,9fb9cbb10Yasuyuki Kozakai 2005-11-09 375 .packet
=
Quoted 2 lines
icmpv6_packet,2c8503f55Pablo Neira Ayuso 2012-02-28 376 .get_timeouts
=
Quoted 2 lines
icmpv6_get_timeouts,9fb9cbb10Yasuyuki Kozakai 2005-11-09 @377 .new
=
Quoted 2 lines
icmpv6_new,9fb9cbb10Yasuyuki Kozakai 2005-11-09 378 .error
=
Quoted 4 lines
icmpv6_error,07a936260Amerigo Wang 2012-10-29 379 #ifIS_ENABLED(CONFIG_NF_CT_NETLINK)fdf708322Patrick McHardy 2007-09-28 380 .tuple_to_nlattr
=
Quoted 2 lines
icmpv6_tuple_to_nlattr,a400c30edHolger Eitzenberger 2009-03-25 381 .nlattr_tuple_size
=
Quoted 2 lines
icmpv6_nlattr_tuple_size,fdf708322Patrick McHardy 2007-09-28 382 .nlattr_to_tuple
=
Quoted 2 lines
icmpv6_nlattr_to_tuple,f73e924cdPatrick McHardy 2007-09-28 383 .nla_policy
=
Quoted 9 lines
icmpv6_nla_policy,c1d10adb4 Pablo Neira Ayuso 2006-01-05 384 #endif 509784623 Pablo Neira Ayuso 2012-02-28 385 #if
IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT):::::: The code at line 377 was first introduced by commit ::::::
9fb9cbb1082d6b31fb45aa1a14432449a0df6cf1[NETFILTER]: Addnf_conntracksubsystem.
Quoted 8 lines
:::::: TO: Yasuyuki Kozakai <[email protected]> :::::: CC: David S. Miller <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology
Center
https://lists.01.org/pipermail/kbuild-all Intel
Corporation
It is one bad patch.
Please ignore it.
Regards
Feng
kbuild test robot
build botreproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross…
Hi Gao,
[auto build test WARNING on nf-next/master]
url: https://github.com/0day-ci/linux/commits/gfree-wind-foxmail-com/netfilter-Remove-useless-variable-timeouts-in-init_conntrack/20170406-031517 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master config: xtensa-allyesconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
All warnings (new ones prefixed by >>):
>> net/netfilter/nf_conntrack_proto_generic.c:196:2: warning: initialization from incompatible pointer type
.new = generic_new,
^
net/netfilter/nf_conntrack_proto_generic.c:196:2: warning: (near initialization for 'nf_conntrack_l4proto_generic.new')
--
>> net/netfilter/nf_conntrack_proto_gre.c:374:2: warning: initialization from incompatible pointer type
.new = gre_new,
^
net/netfilter/nf_conntrack_proto_gre.c:374:2: warning: (near initialization for 'nf_conntrack_l4proto_gre4.new')
--
>> net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c:377:2: warning: initialization from incompatible pointer type
.new = icmpv6_new,
^
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c:377:2: warning: (near initialization for 'nf_conntrack_l4proto_icmpv6.new')
vim +196 net/netfilter/nf_conntrack_proto_generic.c
22ac03772 Gao feng 2012-06-21 180
08911475d Pablo Neira Ayuso 2012-06-29 181 static struct nf_proto_net *generic_get_net_proto(struct net *net)
08911475d Pablo Neira Ayuso 2012-06-29 182 {
08911475d Pablo Neira Ayuso 2012-06-29 183 return &net->ct.nf_ct_proto.generic.pn;
08911475d Pablo Neira Ayuso 2012-06-29 184 }
08911475d Pablo Neira Ayuso 2012-06-29 185
61075af51 Patrick McHardy 2007-07-14 186 struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly =
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 187 {
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 188 .l3proto = PF_UNSPEC,
fe2a7ce4d Christoph Paasch 2009-02-18 189 .l4proto = 255,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 190 .name = "unknown",
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 191 .pkt_to_tuple = generic_pkt_to_tuple,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 192 .invert_tuple = generic_invert_tuple,
9fb9cbb10 Yasuyuki Kozakai 2005-11-09 193 .print_tuple = generic_print_tuple,
2c8503f55 Pablo Neira Ayuso 2012-02-28 194 .packet = generic_packet,
2c8503f55 Pablo Neira Ayuso 2012-02-28 195 .get_timeouts = generic_get_timeouts,
2c8503f55 Pablo Neira Ayuso 2012-02-28 @196 .new = generic_new,
509784623 Pablo Neira Ayuso 2012-02-28 197 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
509784623 Pablo Neira Ayuso 2012-02-28 198 .ctnl_timeout = {
509784623 Pablo Neira Ayuso 2012-02-28 199 .nlattr_to_obj = generic_timeout_nlattr_to_obj,
509784623 Pablo Neira Ayuso 2012-02-28 200 .obj_to_nlattr = generic_timeout_obj_to_nlattr,
509784623 Pablo Neira Ayuso 2012-02-28 201 .nlattr_max = CTA_TIMEOUT_GENERIC_MAX,
509784623 Pablo Neira Ayuso 2012-02-28 202 .obj_size = sizeof(unsigned int),
509784623 Pablo Neira Ayuso 2012-02-28 203 .nla_policy = generic_timeout_nla_policy,
509784623 Pablo Neira Ayuso 2012-02-28 204 },:::::: The code at line 196 was first introduced by commit
:::::: 2c8503f55fbdfbeff4164f133df804cf4d316290 netfilter: nf_conntrack: pass timeout array to l4->new and l4->packet
:::::: TO: Pablo Neira Ayuso <[email protected]> :::::: CC: Pablo Neira Ayuso <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation