net: Replace NF_CT_ASSERT() with WARN_ON().
Subsystems (5)
PATCH 1/1 net: Replace NF_CT_ASSERT() with WARN_ON().
This patch removes NF_CT_ASSERT() and instead uses WARN_ON().
Signed-off-by Varsha Rao <[email protected]>
--- include/net/netfilter/nf_conntrack.h | 2 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 2 +- net/ipv4/netfilter/nf_nat_l3proto_ipv4.c | 6 +++--- net/ipv4/netfilter/nf_nat_masquerade_ipv4.c | 8 ++++---- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 2 +- net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 6 +++--- net/ipv6/netfilter/nf_nat_masquerade_ipv6.c | 4 ++-- net/netfilter/nf_conntrack_core.c | 11 +++++------ net/netfilter/nf_conntrack_expect.c | 4 ++-- net/netfilter/nf_conntrack_extend.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 6 +++--- net/netfilter/nf_nat_core.c | 4 ++-- net/netfilter/nf_nat_redirect.c | 6 +++--- net/netfilter/xt_NETMAP.c | 8 ++++---- net/netfilter/xt_nat.c | 20 ++++++++++---------- 15 files changed, 45 insertions(+), 46 deletions(-)
include/net/netfilter/nf_conntrack.h +1 -1
@@ -159,7 +159,7 @@ nf_ct_get(const struct sk_buff *skb, enum ip_conntrack_info *ctinfo)/* decrement reference count on a conntrack */ static inline void nf_ct_put (struct nf_conn *ct) { -NF_CT_ASSERT (ct); +WARN_ON (!ct);nf_conntrack_put (&ct->ct_general); }
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -127,7 +127,7 @@ icmp_error_message(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,enum ip_conntrack_info ctinfo;struct nf_conntrack_zone tmp; -NF_CT_ASSERT (!skb_nfct (skb)); +WARN_ON (skb_nfct (skb)); zone =nf_ct_zone_tmpl (tmpl, skb, &tmp);/* Are they talking about one of our connections? */
net/ipv4/netfilter/nf_nat_l3proto_ipv4.c +3 -3
@@ -190,7 +190,7 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb,struct nf_conntrack_tuple target;unsigned long statusbit; -NF_CT_ASSERT (ctinfo ==IP_CT_RELATED || ctinfo ==IP_CT_RELATED_REPLY ); +WARN_ON (ctinfo !=IP_CT_RELATED && ctinfo !=IP_CT_RELATED_REPLY );if (!skb_make_writable (skb, hdrlen +sizeof (*inside)))return 0 ;
@@ -306,8 +306,8 @@ nf_nat_ipv4_fn(void *priv, struct sk_buff *skb,default :/* ESTABLISHED */ -NF_CT_ASSERT (ctinfo ==IP_CT_ESTABLISHED || - ctinfo ==IP_CT_ESTABLISHED_REPLY ); +WARN_ON (ctinfo !=IP_CT_ESTABLISHED && + ctinfo !=IP_CT_ESTABLISHED_REPLY );if (nf_nat_oif_changed (state->hook, ctinfo, nat, state->out)) goto oif_changed; }
net/ipv4/netfilter/nf_nat_masquerade_ipv4.c +4 -4
@@ -34,12 +34,12 @@ nf_nat_masquerade_ipv4(struct sk_buff *skb, unsigned int hooknum,const struct rtable *rt;__be32 newsrc, nh; -NF_CT_ASSERT (hooknum ==NF_INET_POST_ROUTING ); +WARN_ON (hooknum !=NF_INET_POST_ROUTING ); ct =nf_ct_get (skb, &ctinfo); -NF_CT_ASSERT (ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || - ctinfo ==IP_CT_RELATED_REPLY )); +WARN_ON (!(ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || + ctinfo ==IP_CT_RELATED_REPLY )));/* Source address is 0.0.0.0 - locally generated packet that is * probably not supposed to be masqueraded.
@@ -96,7 +96,7 @@ static int masq_device_event(struct notifier_block *this,* conntracks which were associated with that device, * and forget them. */ -NF_CT_ASSERT (dev->ifindex !=0 ); +WARN_ON (dev->ifindex ==0 );nf_ct_iterate_cleanup_net (net, device_cmp, (void *)(long )dev->ifindex,0 ,0 );
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -138,7 +138,7 @@ icmpv6_error_message(struct net *net, struct nf_conn *tmpl,enum ip_conntrack_info ctinfo;struct nf_conntrack_zone tmp; -NF_CT_ASSERT (!skb_nfct (skb)); +WARN_ON (skb_nfct (skb));/* Are they talking about one of our connections? */ if (!nf_ct_get_tuplepr(skb,
net/ipv6/netfilter/nf_nat_l3proto_ipv6.c +3 -3
@@ -196,7 +196,7 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,struct nf_conntrack_tuple target;unsigned long statusbit; -NF_CT_ASSERT (ctinfo ==IP_CT_RELATED || ctinfo ==IP_CT_RELATED_REPLY ); +WARN_ON (ctinfo !=IP_CT_RELATED && ctinfo !=IP_CT_RELATED_REPLY );if (!skb_make_writable (skb, hdrlen +sizeof (*inside)))return 0 ;
@@ -319,8 +319,8 @@ nf_nat_ipv6_fn(void *priv, struct sk_buff *skb,default :/* ESTABLISHED */ -NF_CT_ASSERT (ctinfo ==IP_CT_ESTABLISHED || - ctinfo ==IP_CT_ESTABLISHED_REPLY ); +WARN_ON (ctinfo !=IP_CT_ESTABLISHED && + ctinfo !=IP_CT_ESTABLISHED_REPLY );if (nf_nat_oif_changed (state->hook, ctinfo, nat, state->out)) goto oif_changed; }
net/ipv6/netfilter/nf_nat_masquerade_ipv6.c +2 -2
@@ -36,8 +36,8 @@ nf_nat_masquerade_ipv6(struct sk_buff *skb, const struct nf_nat_range *range,struct nf_nat_range newrange; ct =nf_ct_get (skb, &ctinfo); -NF_CT_ASSERT (ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || - ctinfo ==IP_CT_RELATED_REPLY )); +WARN_ON (!(ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || + ctinfo ==IP_CT_RELATED_REPLY )));if (ipv6_dev_get_saddr (nf_ct_net (ct), out, &ipv6_hdr (skb)->daddr,0 , &src) <0 )
net/netfilter/nf_conntrack_core.c +5 -6
@@ -403,7 +403,7 @@ destroy_conntrack(struct nf_conntrack *nfct)const struct nf_conntrack_l4proto *l4proto;pr_debug ("destroy_conntrack(%p)\n" , ct); -NF_CT_ASSERT (atomic_read (&nfct->use) ==0 ); +WARN_ON (atomic_read (&nfct->use) !=0 );if (unlikely (nf_ct_is_template (ct))) {nf_ct_tmpl_free (ct);
@@ -756,12 +756,11 @@ __nf_conntrack_confirm(struct sk_buff *skb)* connections for unconfirmed conns. But packet copies and * REJECT will give spurious warnings here. */ -/* NF_CT_ASSERT(atomic_read(&ct->ct_general.use) == 1); */ /* No external references means no one else could have * confirmed us. */ -NF_CT_ASSERT (!nf_ct_is_confirmed (ct)); +WARN_ON (nf_ct_is_confirmed (ct));pr_debug ("Confirming conntrack %p\n" , ct);/* We have to check the DYING flag after unlink to prevent * a race against nf_ct_get_next_corpse() possibly called from
@@ -1160,7 +1159,7 @@ void nf_conntrack_free(struct nf_conn *ct)/* A freed object has refcnt == 0, that's * the golden rule for SLAB_TYPESAFE_BY_RCU */ -NF_CT_ASSERT (atomic_read (&ct->ct_general.use) ==0 ); +WARN_ON (atomic_read (&ct->ct_general.use) !=0 );nf_ct_ext_destroy (ct);nf_ct_ext_free (ct);
@@ -1468,7 +1467,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,struct nf_conn_help *help =nfct_help (ct);/* Should be unconfirmed, so not in hash table yet */ -NF_CT_ASSERT (!nf_ct_is_confirmed (ct)); +WARN_ON (nf_ct_is_confirmed (ct));pr_debug ("Altering reply tuple of %p to " , ct);nf_ct_dump_tuple (newreply);
@@ -1490,7 +1489,7 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, unsigned long extra_jiffies, int do_acct) { -NF_CT_ASSERT (skb ); +WARN_ON (!skb);/* Only update if this is not a fixed timeout */ if (test_bit (IPS_FIXED_TIMEOUT_BIT , &ct->status))
net/netfilter/nf_conntrack_expect.c +2 -2
@@ -51,8 +51,8 @@ void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,struct nf_conn_help *master_help =nfct_help (exp->master);struct net *net =nf_ct_exp_net (exp); -NF_CT_ASSERT (master_help); -NF_CT_ASSERT (!timer_pending (&exp->timeout)); +WARN_ON (!master_help); +WARN_ON (timer_pending (&exp->timeout));hlist_del_rcu (&exp->hnode); net->ct.expect_count--;
net/netfilter/nf_conntrack_extend.c +1 -1
@@ -47,7 +47,7 @@ void *nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)struct nf_ct_ext_type *t;/* Conntrack must not be confirmed to avoid races on reallocation. */ -NF_CT_ASSERT (!nf_ct_is_confirmed (ct)); +WARN_ON (nf_ct_is_confirmed (ct)); old = ct->ext;
net/netfilter/nf_conntrack_standalone.c +3 -3
@@ -287,7 +287,7 @@ static int ct_seq_show(struct seq_file *s, void *v)struct net *net =seq_file_net (s);int ret =0 ; -NF_CT_ASSERT (ct); +WARN_ON (!ct);if (unlikely (!atomic_inc_not_zero (&ct->ct_general.use)))return 0 ;
@@ -304,9 +304,9 @@ static int ct_seq_show(struct seq_file *s, void *v) goto release; l3proto =__nf_ct_l3proto_find (nf_ct_l3num (ct)); -NF_CT_ASSERT (l3proto); +WARN_ON (!l3proto); l4proto =__nf_ct_l4proto_find (nf_ct_l3num (ct),nf_ct_protonum (ct)); -NF_CT_ASSERT (l4proto); +WARN_ON (!l4proto); ret = -ENOSPC ; seq_printf(s, "%-8s %u %-8s %u %ld ",
net/netfilter/nf_nat_core.c +2 -2
@@ -414,8 +414,8 @@ nf_nat_setup_info(struct nf_conn *ct,if (nf_ct_is_confirmed (ct))return NF_ACCEPT ; -NF_CT_ASSERT (maniptype ==NF_NAT_MANIP_SRC || - maniptype ==NF_NAT_MANIP_DST ); +WARN_ON (maniptype !=NF_NAT_MANIP_SRC && + maniptype !=NF_NAT_MANIP_DST );BUG_ON (nf_nat_initialized (ct, maniptype));/* What we've got will look like inverse of reply. Normally
net/netfilter/nf_nat_redirect.c +3 -3
@@ -38,11 +38,11 @@ nf_nat_redirect_ipv4(struct sk_buff *skb,__be32 newdst;struct nf_nat_range newrange; -NF_CT_ASSERT (hooknum ==NF_INET_PRE_ROUTING || - hooknum ==NF_INET_LOCAL_OUT ); +WARN_ON (hooknum !=NF_INET_PRE_ROUTING && + hooknum !=NF_INET_LOCAL_OUT ); ct =nf_ct_get (skb, &ctinfo); -NF_CT_ASSERT (ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED )); +WARN_ON (!(ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED )));/* Local packets: make them go to loopback */ if (hooknum ==NF_INET_LOCAL_OUT ) {
net/netfilter/xt_NETMAP.c +4 -4
@@ -77,10 +77,10 @@ netmap_tg4(struct sk_buff *skb, const struct xt_action_param *par)const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo;struct nf_nat_range newrange; -NF_CT_ASSERT (xt_hooknum (par) ==NF_INET_PRE_ROUTING || -xt_hooknum (par) ==NF_INET_POST_ROUTING || -xt_hooknum (par) ==NF_INET_LOCAL_OUT || -xt_hooknum (par) ==NF_INET_LOCAL_IN ); +WARN_ON (xt_hooknum (par) !=NF_INET_PRE_ROUTING && +xt_hooknum (par) !=NF_INET_POST_ROUTING && +xt_hooknum (par) !=NF_INET_LOCAL_OUT && +xt_hooknum (par) !=NF_INET_LOCAL_IN ); ct =nf_ct_get (skb, &ctinfo); netmask = ~(mr->range[0 ].min_ip ^ mr->range[0 ].max_ip);
net/netfilter/xt_nat.c +10 -10
@@ -58,9 +58,9 @@ xt_snat_target_v0(struct sk_buff *skb, const struct xt_action_param *par)struct nf_conn *ct; ct =nf_ct_get (skb, &ctinfo); -NF_CT_ASSERT (ct !=NULL && - (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || - ctinfo ==IP_CT_RELATED_REPLY )); +WARN_ON (!(ct !=NULL && + (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || + ctinfo ==IP_CT_RELATED_REPLY )));xt_nat_convert_range (&range, &mr->range[0 ]);return nf_nat_setup_info (ct, &range,NF_NAT_MANIP_SRC );
@@ -75,8 +75,8 @@ xt_dnat_target_v0(struct sk_buff *skb, const struct xt_action_param *par)struct nf_conn *ct; ct =nf_ct_get (skb, &ctinfo); -NF_CT_ASSERT (ct !=NULL && - (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED )); +WARN_ON (!(ct !=NULL && + (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED )));xt_nat_convert_range (&range, &mr->range[0 ]);return nf_nat_setup_info (ct, &range,NF_NAT_MANIP_DST );
@@ -90,9 +90,9 @@ xt_snat_target_v1(struct sk_buff *skb, const struct xt_action_param *par)struct nf_conn *ct; ct =nf_ct_get (skb, &ctinfo); -NF_CT_ASSERT (ct !=NULL && - (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || - ctinfo ==IP_CT_RELATED_REPLY )); +WARN_ON (!(ct !=NULL && + (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || + ctinfo ==IP_CT_RELATED_REPLY )));return nf_nat_setup_info (ct, range,NF_NAT_MANIP_SRC ); }
@@ -105,8 +105,8 @@ xt_dnat_target_v1(struct sk_buff *skb, const struct xt_action_param *par)struct nf_conn *ct; ct =nf_ct_get (skb, &ctinfo); -NF_CT_ASSERT (ct !=NULL && - (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED )); +WARN_ON (!(ct !=NULL && + (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED )));return nf_nat_setup_info (ct, range,NF_NAT_MANIP_DST ); }
Signature · 1 line
2.13.5
PATCH 1/1 net: Remove CONFIG_NETFILTER_DEBUG and _ASSERT() macros.
This patch removes CONFIG_NETFILTER_DEBUG and _ASSERT() macros as they are no longer required. Replace _ASSERT() macros with WARN_ON().
Signed-off-by Varsha Rao <[email protected]>
--- arch/parisc/configs/c3000_defconfig | 1 - arch/sh/configs/se7751_defconfig | 1 - include/net/netfilter/nf_conntrack.h | 6 ------ net/Kconfig | 7 ------- net/bridge/netfilter/ebtables.c | 20 ++++++++------------ net/ipv4/netfilter/ip_tables.c | 12 +++--------- net/ipv6/netfilter/ip6_tables.c | 12 +++--------- 7 files changed, 14 insertions(+), 45 deletions(-)
arch/parisc/configs/c3000_defconfig +0 -1
@@ -36,7 +36,6 @@ CONFIG_IP_PNP_BOOTP=y CONFIG_INET6_IPCOMP=m CONFIG_IPV6_TUNNEL=m CONFIG_NETFILTER=y -CONFIG_NETFILTER_DEBUG=y CONFIG_IP_NF_QUEUE=m CONFIG_NET_PKTGEN=m CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
arch/sh/configs/se7751_defconfig +0 -1
@@ -28,7 +28,6 @@ CONFIG_IP_PNP_RARP=y # CONFIG_INET_LRO is not set # CONFIG_IPV6 is not set CONFIG_NETFILTER=y -CONFIG_NETFILTER_DEBUG=y CONFIG_IP_NF_QUEUE=y CONFIG_MTD=y CONFIG_MTD_PARTITIONS=y
include/net/netfilter/nf_conntrack.h +0 -6
@@ -44,12 +44,6 @@ union nf_conntrack_expect_proto {#include <linux/types.h> #include <linux/skbuff.h> -#ifdef CONFIG_NETFILTER_DEBUG -#define NF_CT_ASSERT (x) WARN_ON(!(x)) -#else -#define NF_CT_ASSERT (x) -#endif -#include <net/netfilter/ipv4/nf_conntrack_ipv4.h> #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
net/Kconfig +0 -7
@@ -166,13 +166,6 @@ menuconfig NETFILTER if NETFILTER -config NETFILTER_DEBUG - bool "Network packet filtering debugging" - depends on NETFILTER - help - You can say Y here if you want to get additional messages useful in - debugging the netfilter code. - config NETFILTER_ADVANCED bool "Advanced netfilter configuration" depends on NETFILTER
net/bridge/netfilter/ebtables.c +8 -12
@@ -252,13 +252,11 @@ unsigned int ebt_do_table(struct sk_buff *skb, }if (verdict ==EBT_RETURN ) { letsreturn: -#ifdef CONFIG_NETFILTER_DEBUG -if (sp ==0 ) { -BUGPRINT ("RETURN on base chain" ); +if (WARN (sp ==0 ,"RETURN on base chain" )) {/* act like this is EBT_CONTINUE */ goto letscontinue; } -#endif + sp--;/* put all the local variables right */ i = cs[sp].n;
@@ -271,26 +269,24 @@ unsigned int ebt_do_table(struct sk_buff *skb, }if (verdict ==EBT_CONTINUE ) goto letscontinue; -#ifdef CONFIG_NETFILTER_DEBUG -if (verdict <0 ) { -BUGPRINT ("bogus standard verdict\n" ); + +if (WARN (verdict <0 ,"bogus standard verdict\n" )) {read_unlock_bh (&table->lock);return NF_DROP ; } -#endif +/* jump to a udc */ cs[sp].n = i +1 ; cs[sp].chaininfo = chaininfo; cs[sp].e =ebt_next_entry (point); i =0 ; chaininfo = (struct ebt_entries *) (base + verdict); -#ifdef CONFIG_NETFILTER_DEBUG -if (chaininfo->distinguisher) { -BUGPRINT ("jump to non-chain\n" ); + +if (WARN (chaininfo->distinguisher,"jump to non-chain\n" )) {read_unlock_bh (&table->lock);return NF_DROP ; } -#endif + nentries = chaininfo->nentries; point = (struct ebt_entry *)chaininfo->data; counter_base = cb_base + chaininfo->counter_offset;
net/ipv4/netfilter/ip_tables.c +3 -9
@@ -35,12 +35,6 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Netfilter Core Team <[email protected]>" );MODULE_DESCRIPTION ("IPv4 packet filter" ); -#ifdef CONFIG_NETFILTER_DEBUG -#define IP_NF_ASSERT (x) WARN_ON(!(x)) -#else -#define IP_NF_ASSERT (x) -#endif -void *ipt_alloc_initial_table (const struct xt_table *info) {return xt_alloc_initial_table (ipt,IPT );
@@ -263,7 +257,7 @@ ipt_do_table(struct sk_buff *skb, acpar.hotdrop = false; acpar.state = state; -IP_NF_ASSERT (table->valid_hooks & (1 << hook)); +WARN_ON (!(table->valid_hooks & (1 << hook)));local_bh_disable (); addend =xt_write_recseq_begin (); private = table->private;
@@ -293,7 +287,7 @@ ipt_do_table(struct sk_buff *skb,const struct xt_entry_match *ematch;struct xt_counters *counter; -IP_NF_ASSERT (e); +WARN_ON (!e);if (!ip_packet_match (ip, indev, outdev, &e->ip, acpar.fragoff)) { no_match:
@@ -312,7 +306,7 @@ ipt_do_table(struct sk_buff *skb,ADD_COUNTER (*counter, skb->len,1 ); t =ipt_get_target (e); -IP_NF_ASSERT (t->u.kernel.target); +WARN_ON (!t->u.kernel.target);#if IS_ENABLED (CONFIG_NETFILTER_XT_TARGET_TRACE )/* The packet is traced: log it */
net/ipv6/netfilter/ip6_tables.c +3 -9
@@ -39,12 +39,6 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Netfilter Core Team <[email protected]>" );MODULE_DESCRIPTION ("IPv6 packet filter" ); -#ifdef CONFIG_NETFILTER_DEBUG -#define IP_NF_ASSERT (x) WARN_ON(!(x)) -#else -#define IP_NF_ASSERT (x) -#endif -void *ip6t_alloc_initial_table (const struct xt_table *info) {return xt_alloc_initial_table (ip6t,IP6T );
@@ -284,7 +278,7 @@ ip6t_do_table(struct sk_buff *skb, acpar.hotdrop = false; acpar.state = state; -IP_NF_ASSERT (table->valid_hooks & (1 << hook)); +WARN_ON (!(table->valid_hooks & (1 << hook)));local_bh_disable (); addend =xt_write_recseq_begin ();
@@ -315,7 +309,7 @@ ip6t_do_table(struct sk_buff *skb,const struct xt_entry_match *ematch;struct xt_counters *counter; -IP_NF_ASSERT (e); +WARN_ON (!e); acpar.thoff =0 ;if (!ip6_packet_match (skb, indev, outdev, &e->ipv6, &acpar.thoff, &acpar.fragoff, &acpar.hotdrop)) {
@@ -335,7 +329,7 @@ ip6t_do_table(struct sk_buff *skb,ADD_COUNTER (*counter, skb->len,1 ); t =ip6t_get_target_c (e); -IP_NF_ASSERT (t->u.kernel.target); +WARN_ON (!t->u.kernel.target);#if IS_ENABLED (CONFIG_NETFILTER_XT_TARGET_TRACE )/* The packet is traced: log it */
Signature · 1 line
2.13.5