* [PATCH net-next 2/6] ipv6: netfilter: whitespace in line layouts
2015-04-25 9:26 [PATCH net-next 0/6] ipv6: netfilter - coding style improvements Ian Morris
2015-04-25 9:26 ` [PATCH net-next 1/6] ipv6: netfilter: Tidy up indenting Ian Morris
@ 2015-04-25 9:26 ` Ian Morris
2015-04-25 15:57 ` Joe Perches
2015-04-25 9:26 ` [PATCH net-next 3/6] ipv6: netfilter: remove unnecessary braces Ian Morris
` (4 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Ian Morris @ 2015-04-25 9:26 UTC (permalink / raw)
To: netdev; +Cc: Ian Morris
Try to improve coding readability by adding spaces in line layouts. No
changes to functionality. No changes according to objdiff.
Signed-off-by: Ian Morris <ipm@chirality.org.uk>
---
net/ipv6/netfilter/ip6_tables.c | 12 ++++++------
net/ipv6/netfilter/ip6t_rpfilter.c | 2 +-
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 4 ++--
net/ipv6/netfilter/nf_conntrack_reasm.c | 4 ++--
net/ipv6/netfilter/nf_reject_ipv6.c | 4 ++--
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index c6c9de7..82d53d5 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -44,13 +44,13 @@ MODULE_DESCRIPTION("IPv6 packet filter");
/*#define DEBUG_IP_FIREWALL_USER*/
#ifdef DEBUG_IP_FIREWALL
-#define dprintf(format, args...) pr_info(format , ## args)
+#define dprintf(format, args...) pr_info(format, ## args)
#else
#define dprintf(format, args...)
#endif
#ifdef DEBUG_IP_FIREWALL_USER
-#define duprintf(format, args...) pr_info(format , ## args)
+#define duprintf(format, args...) pr_info(format, ## args)
#else
#define duprintf(format, args...)
#endif
@@ -117,7 +117,7 @@ ip6_packet_match(const struct sk_buff *skb,
if (FWINV(ret != 0, IP6T_INV_VIA_IN)) {
dprintf("VIA in mismatch (%s vs %s).%s\n",
indev, ip6info->iniface,
- ip6info->invflags&IP6T_INV_VIA_IN ?" (INV)":"");
+ ip6info->invflags & IP6T_INV_VIA_IN ? " (INV)" : "");
return false;
}
@@ -126,14 +126,14 @@ ip6_packet_match(const struct sk_buff *skb,
if (FWINV(ret != 0, IP6T_INV_VIA_OUT)) {
dprintf("VIA out mismatch (%s vs %s).%s\n",
outdev, ip6info->outiface,
- ip6info->invflags&IP6T_INV_VIA_OUT ?" (INV)":"");
+ ip6info->invflags & IP6T_INV_VIA_OUT ? " (INV)" : "");
return false;
}
/* ... might want to do something with class and flowlabel here ... */
/* look for the desired protocol header */
- if((ip6info->flags & IP6T_F_PROTO)) {
+ if ((ip6info->flags & IP6T_F_PROTO)) {
int protohdr;
unsigned short _frag_off;
@@ -151,7 +151,7 @@ ip6_packet_match(const struct sk_buff *skb,
ip6info->proto);
if (ip6info->proto == protohdr) {
- if(ip6info->invflags & IP6T_INV_PROTO) {
+ if (ip6info->invflags & IP6T_INV_PROTO) {
return false;
}
return true;
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index 790e0c6..1924177 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -34,7 +34,7 @@ static bool rpfilter_lookup_reverse6(const struct sk_buff *skb,
bool ret = false;
struct flowi6 fl6 = {
.flowi6_iif = LOOPBACK_IFINDEX,
- .flowlabel = (* (__be32 *) iph) & IPV6_FLOWINFO_MASK,
+ .flowlabel = (*(__be32 *)iph) & IPV6_FLOWINFO_MASK,
.flowi6_proto = iph->nexthdr,
.daddr = iph->saddr,
};
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 90388d6..1f5b350 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -56,12 +56,12 @@ static const u_int8_t invmap[] = {
[ICMPV6_ECHO_REQUEST - 128] = ICMPV6_ECHO_REPLY + 1,
[ICMPV6_ECHO_REPLY - 128] = ICMPV6_ECHO_REQUEST + 1,
[ICMPV6_NI_QUERY - 128] = ICMPV6_NI_REPLY + 1,
- [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_QUERY +1
+ [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_QUERY + 1
};
static const u_int8_t noct_valid_new[] = {
[ICMPV6_MGM_QUERY - 130] = 1,
- [ICMPV6_MGM_REPORT -130] = 1,
+ [ICMPV6_MGM_REPORT - 130] = 1,
[ICMPV6_MGM_REDUCTION - 130] = 1,
[NDISC_ROUTER_SOLICITATION - 130] = 1,
[NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 6f187c8..07d8534 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -59,7 +59,7 @@ struct nf_ct_frag6_skb_cb
struct sk_buff *orig;
};
-#define NFCT_FRAG6_CB(skb) ((struct nf_ct_frag6_skb_cb*)((skb)->cb))
+#define NFCT_FRAG6_CB(skb) ((struct nf_ct_frag6_skb_cb *)((skb)->cb))
static struct inet_frags nf_frags;
@@ -445,7 +445,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
skb_reset_transport_header(head);
skb_push(head, head->data - skb_network_header(head));
- for (fp=head->next; fp; fp = fp->next) {
+ for (fp = head->next; fp; fp = fp->next) {
head->data_len += fp->len;
head->len += fp->len;
if (head->ip_summed != fp->ip_summed)
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 94b4c6d..5629db8 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -26,7 +26,7 @@ const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
int tcphoff;
proto = oip6h->nexthdr;
- tcphoff = ipv6_skip_exthdr(oldskb, ((u8*)(oip6h+1) - oldskb->data),
+ tcphoff = ipv6_skip_exthdr(oldskb, ((u8 *)(oip6h + 1) - oldskb->data),
&proto, &frag_off);
if ((tcphoff < 0) || (tcphoff > oldskb->len)) {
@@ -224,7 +224,7 @@ static bool reject6_csum_ok(struct sk_buff *skb, int hook)
return true;
proto = ip6h->nexthdr;
- thoff = ipv6_skip_exthdr(skb, ((u8*)(ip6h+1) - skb->data), &proto, &fo);
+ thoff = ipv6_skip_exthdr(skb, ((u8 *)(ip6h + 1) - skb->data), &proto, &fo);
if (thoff < 0 || thoff >= skb->len || (fo & htons(~0x7)) != 0)
return false;
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 4/6] ipv6: netfilter: comparison for equality with NULL
2015-04-25 9:26 [PATCH net-next 0/6] ipv6: netfilter - coding style improvements Ian Morris
` (2 preceding siblings ...)
2015-04-25 9:26 ` [PATCH net-next 3/6] ipv6: netfilter: remove unnecessary braces Ian Morris
@ 2015-04-25 9:26 ` Ian Morris
2015-04-25 9:26 ` [PATCH net-next 5/6] ipv6: netfilter: comparison for inequality " Ian Morris
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Ian Morris @ 2015-04-25 9:26 UTC (permalink / raw)
To: netdev; +Cc: Ian Morris
The code uses a mixture of coding styles. In some instances check for NULL
pointer is done as x == NULL and sometimes as !x. !x is preferred
according to checkpatch and this patch makes the code consistent by
adopting the latter form.
No changes detected by objdiff.
Signed-off-by: Ian Morris <ipm@chirality.org.uk>
---
net/ipv6/netfilter/ip6_tables.c | 4 ++--
net/ipv6/netfilter/ip6t_SYNPROXY.c | 18 +++++++++---------
net/ipv6/netfilter/ip6t_ah.c | 2 +-
net/ipv6/netfilter/ip6t_frag.c | 2 +-
net/ipv6/netfilter/ip6t_hbh.c | 6 +++---
| 2 +-
net/ipv6/netfilter/ip6t_mh.c | 2 +-
net/ipv6/netfilter/ip6t_rt.c | 6 +++---
net/ipv6/netfilter/ip6table_filter.c | 2 +-
net/ipv6/netfilter/ip6table_mangle.c | 2 +-
net/ipv6/netfilter/ip6table_nat.c | 2 +-
net/ipv6/netfilter/ip6table_raw.c | 2 +-
net/ipv6/netfilter/ip6table_security.c | 2 +-
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 2 +-
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 6 +++---
net/ipv6/netfilter/nf_conntrack_reasm.c | 16 ++++++++--------
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 2 +-
net/ipv6/netfilter/nf_log_ipv6.c | 12 ++++++------
net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 2 +-
net/ipv6/netfilter/nf_reject_ipv6.c | 6 +++---
net/ipv6/netfilter/nf_tables_ipv6.c | 2 +-
21 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 1f8a503..ce8c529 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -927,7 +927,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table)
countersize = sizeof(struct xt_counters) * private->number;
counters = vzalloc(countersize);
- if (counters == NULL)
+ if (!counters)
return ERR_PTR(-ENOMEM);
get_counters(private, counters);
@@ -2150,7 +2150,7 @@ icmp6_match(const struct sk_buff *skb, struct xt_action_param *par)
return false;
ic = skb_header_pointer(skb, par->thoff, sizeof(_icmph), &_icmph);
- if (ic == NULL) {
+ if (!ic) {
/* We've been asked to examine this packet, and we
* can't. Hence, no choice but to drop.
*/
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
index 6edb7b1..0dd7123 100644
--- a/net/ipv6/netfilter/ip6t_SYNPROXY.c
+++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c
@@ -59,7 +59,7 @@ synproxy_send_tcp(const struct sk_buff *skb, struct sk_buff *nskb,
fl6.fl6_dport = nth->dest;
security_skb_classify_flow((struct sk_buff *)skb, flowi6_to_flowi(&fl6));
dst = ip6_route_output(net, NULL, &fl6);
- if (dst == NULL || dst->error) {
+ if (!dst || dst->error) {
dst_release(dst);
goto free_nskb;
}
@@ -97,7 +97,7 @@ synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th,
tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
GFP_ATOMIC);
- if (nskb == NULL)
+ if (!nskb)
return;
skb_reserve(nskb, MAX_TCP_HEADER);
@@ -138,7 +138,7 @@ synproxy_send_server_syn(const struct synproxy_net *snet,
tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
GFP_ATOMIC);
- if (nskb == NULL)
+ if (!nskb)
return;
skb_reserve(nskb, MAX_TCP_HEADER);
@@ -183,7 +183,7 @@ synproxy_send_server_ack(const struct synproxy_net *snet,
tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
GFP_ATOMIC);
- if (nskb == NULL)
+ if (!nskb)
return;
skb_reserve(nskb, MAX_TCP_HEADER);
@@ -221,7 +221,7 @@ synproxy_send_client_ack(const struct synproxy_net *snet,
tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
GFP_ATOMIC);
- if (nskb == NULL)
+ if (!nskb)
return;
skb_reserve(nskb, MAX_TCP_HEADER);
@@ -280,7 +280,7 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
return NF_DROP;
th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
- if (th == NULL)
+ if (!th)
return NF_DROP;
if (!synproxy_parse_options(skb, par->thoff, th, &opts))
@@ -329,11 +329,11 @@ static unsigned int ipv6_synproxy_hook(const struct nf_hook_ops *ops,
int thoff;
ct = nf_ct_get(skb, &ctinfo);
- if (ct == NULL)
+ if (!ct)
return NF_ACCEPT;
synproxy = nfct_synproxy(ct);
- if (synproxy == NULL)
+ if (!synproxy)
return NF_ACCEPT;
if (nf_is_loopback_packet(skb))
@@ -346,7 +346,7 @@ static unsigned int ipv6_synproxy_hook(const struct nf_hook_ops *ops,
return NF_ACCEPT;
th = skb_header_pointer(skb, thoff, sizeof(_th), &_th);
- if (th == NULL)
+ if (!th)
return NF_DROP;
state = &ct->proto.tcp;
diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index 04099ab..e504376 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -53,7 +53,7 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
}
ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah);
- if (ah == NULL) {
+ if (!ah) {
par->hotdrop = true;
return false;
}
diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c
index 3b5735e..0e14438 100644
--- a/net/ipv6/netfilter/ip6t_frag.c
+++ b/net/ipv6/netfilter/ip6t_frag.c
@@ -51,7 +51,7 @@ frag_mt6(const struct sk_buff *skb, struct xt_action_param *par)
}
fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag);
- if (fh == NULL) {
+ if (!fh) {
par->hotdrop = true;
return false;
}
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
index 01df142..fc6af64 100644
--- a/net/ipv6/netfilter/ip6t_hbh.c
+++ b/net/ipv6/netfilter/ip6t_hbh.c
@@ -70,7 +70,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
}
oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
- if (oh == NULL) {
+ if (!oh) {
par->hotdrop = true;
return false;
}
@@ -107,7 +107,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
break;
tp = skb_header_pointer(skb, ptr, sizeof(_opttype),
&_opttype);
- if (tp == NULL)
+ if (!tp)
break;
/* Type check */
@@ -128,7 +128,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
lp = skb_header_pointer(skb, ptr + 1,
sizeof(_optlen),
&_optlen);
- if (lp == NULL)
+ if (!lp)
break;
spec_len = optinfo->opts[temp] & 0x00FF;
--git a/net/ipv6/netfilter/ip6t_ipv6header.c b/net/ipv6/netfilter/ip6t_ipv6header.c
index 8b14744..c53ce69 100644
--- a/net/ipv6/netfilter/ip6t_ipv6header.c
+++ b/net/ipv6/netfilter/ip6t_ipv6header.c
@@ -65,7 +65,7 @@ ipv6header_mt6(const struct sk_buff *skb, struct xt_action_param *par)
}
hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
- BUG_ON(hp == NULL);
+ BUG_ON(!hp);
/* Calculate the header length */
if (nexthdr == NEXTHDR_FRAGMENT)
diff --git a/net/ipv6/netfilter/ip6t_mh.c b/net/ipv6/netfilter/ip6t_mh.c
index 0c90c66..e3b4eb6 100644
--- a/net/ipv6/netfilter/ip6t_mh.c
+++ b/net/ipv6/netfilter/ip6t_mh.c
@@ -43,7 +43,7 @@ static bool mh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
return false;
mh = skb_header_pointer(skb, par->thoff, sizeof(_mh), &_mh);
- if (mh == NULL) {
+ if (!mh) {
/* We've been asked to examine this packet, and we
can't. Hence, no choice but to drop. */
pr_debug("Dropping evil MH tinygram.\n");
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
index 2c99b94..bdab49e 100644
--- a/net/ipv6/netfilter/ip6t_rt.c
+++ b/net/ipv6/netfilter/ip6t_rt.c
@@ -57,7 +57,7 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
}
rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route);
- if (rh == NULL) {
+ if (!rh) {
par->hotdrop = true;
return false;
}
@@ -137,7 +137,7 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
sizeof(_addr),
&_addr);
- BUG_ON(ap == NULL);
+ BUG_ON(!ap);
if (ipv6_addr_equal(ap, &rtinfo->addrs[i])) {
pr_debug("i=%d temp=%d;\n", i, temp);
@@ -166,7 +166,7 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
+ temp * sizeof(_addr),
sizeof(_addr),
&_addr);
- BUG_ON(ap == NULL);
+ BUG_ON(!ap);
if (!ipv6_addr_equal(ap, &rtinfo->addrs[temp]))
break;
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index 5c33d8a..139b247 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -51,7 +51,7 @@ static int __net_init ip6table_filter_net_init(struct net *net)
struct ip6t_replace *repl;
repl = ip6t_alloc_initial_table(&packet_filter);
- if (repl == NULL)
+ if (!repl)
return -ENOMEM;
/* Entry 1 is the FORWARD hook */
((struct ip6t_standard *)repl->entries)[1].target.verdict =
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index b551f5b..ff2ad69 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -95,7 +95,7 @@ static int __net_init ip6table_mangle_net_init(struct net *net)
struct ip6t_replace *repl;
repl = ip6t_alloc_initial_table(&packet_mangler);
- if (repl == NULL)
+ if (!repl)
return -ENOMEM;
net->ipv6.ip6table_mangle =
ip6t_register_table(net, &packet_mangler, repl);
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c
index c3a7f7a..87d6d3e 100644
--- a/net/ipv6/netfilter/ip6table_nat.c
+++ b/net/ipv6/netfilter/ip6table_nat.c
@@ -108,7 +108,7 @@ static int __net_init ip6table_nat_net_init(struct net *net)
struct ip6t_replace *repl;
repl = ip6t_alloc_initial_table(&nf_nat_ipv6_table);
- if (repl == NULL)
+ if (!repl)
return -ENOMEM;
net->ipv6.ip6table_nat = ip6t_register_table(net, &nf_nat_ipv6_table, repl);
kfree(repl);
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index 0b33caa..761ae0c 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -34,7 +34,7 @@ static int __net_init ip6table_raw_net_init(struct net *net)
struct ip6t_replace *repl;
repl = ip6t_alloc_initial_table(&packet_raw);
- if (repl == NULL)
+ if (!repl)
return -ENOMEM;
net->ipv6.ip6table_raw =
ip6t_register_table(net, &packet_raw, repl);
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c
index fcef83c..544e15b 100644
--- a/net/ipv6/netfilter/ip6table_security.c
+++ b/net/ipv6/netfilter/ip6table_security.c
@@ -52,7 +52,7 @@ static int __net_init ip6table_security_net_init(struct net *net)
struct ip6t_replace *repl;
repl = ip6t_alloc_initial_table(&security_table);
- if (repl == NULL)
+ if (!repl)
return -ENOMEM;
net->ipv6.ip6table_security =
ip6t_register_table(net, &security_table, repl);
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 4ba0c34..59c29a2 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -42,7 +42,7 @@ static bool ipv6_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff,
ap = skb_header_pointer(skb, nhoff + offsetof(struct ipv6hdr, saddr),
sizeof(_addrs), _addrs);
- if (ap == NULL)
+ if (!ap)
return false;
memcpy(tuple->src.u3.ip6, ap, sizeof(tuple->src.u3.ip6));
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 1f5b350..b6cd77b 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -42,7 +42,7 @@ static bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,
struct icmp6hdr _hdr;
hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
- if (hp == NULL)
+ if (!hp)
return false;
tuple->dst.u.icmp.type = hp->icmp6_type;
tuple->src.u.icmp.id = hp->icmp6_identifier;
@@ -152,7 +152,7 @@ icmpv6_error_message(struct net *net, struct nf_conn *tmpl,
const struct nf_conntrack_l4proto *inproto;
u16 zone = tmpl ? nf_ct_zone(tmpl) : NF_CT_DEFAULT_ZONE;
- NF_CT_ASSERT(skb->nfct == NULL);
+ NF_CT_ASSERT(!skb->nfct);
/* Are they talking about one of our connections? */
if (!nf_ct_get_tuplepr(skb,
@@ -202,7 +202,7 @@ icmpv6_error(struct net *net, struct nf_conn *tmpl,
int type;
icmp6h = skb_header_pointer(skb, dataoff, sizeof(_ih), &_ih);
- if (icmp6h == NULL) {
+ if (!icmp6h) {
if (LOG_INVALID(net, IPPROTO_ICMPV6))
nf_log_packet(net, PF_INET6, 0, skb, NULL, NULL, NULL,
"nf_ct_icmpv6: short packet ");
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index a7f6977..51478de 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -103,7 +103,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
if (!net_eq(net, &init_net)) {
table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
GFP_KERNEL);
- if (table == NULL)
+ if (!table)
goto err_alloc;
table[0].data = &net->nf_frag.frags.timeout;
@@ -115,7 +115,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
}
hdr = register_net_sysctl(net, "net/netfilter", table);
- if (hdr == NULL)
+ if (!hdr)
goto err_reg;
net->nf_frag.sysctl.frags_hdr = hdr;
@@ -384,7 +384,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
inet_frag_kill(&fq->q, &nf_frags);
- WARN_ON(head == NULL);
+ WARN_ON(!head);
WARN_ON(NFCT_FRAG6_CB(head)->offset != 0);
ecn = ip_frag_ecn_table[fq->ecn];
@@ -414,7 +414,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
int i, plen = 0;
clone = alloc_skb(0, GFP_ATOMIC);
- if (clone == NULL)
+ if (!clone)
goto out_oom;
clone->next = head->next;
@@ -475,7 +475,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
/* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */
fp = skb_shinfo(head)->frag_list;
- if (fp && NFCT_FRAG6_CB(fp)->orig == NULL)
+ if (fp && !NFCT_FRAG6_CB(fp)->orig)
/* at above code, head skb is divided into two skbs. */
fp = fp->next;
@@ -586,7 +586,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user)
return skb;
clone = skb_clone(skb, GFP_ATOMIC);
- if (clone == NULL) {
+ if (!clone) {
pr_debug("Can't clone skb\n");
return skb;
}
@@ -604,7 +604,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user)
fq = fq_find(net, fhdr->identification, user, &hdr->saddr, &hdr->daddr,
ip6_frag_ecn(hdr));
- if (fq == NULL) {
+ if (!fq) {
pr_debug("Can't find and can't create new queue\n");
goto ret_orig;
}
@@ -621,7 +621,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user)
if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
fq->q.meat == fq->q.len) {
ret_skb = nf_ct_frag6_reasm(fq, dev);
- if (ret_skb == NULL)
+ if (!ret_skb)
pr_debug("Can't reassemble fragmented packets\n");
}
spin_unlock_bh(&fq->q.lock);
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index a45db0b..16dd024 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -66,7 +66,7 @@ static unsigned int ipv6_defrag(const struct nf_hook_ops *ops,
reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(ops->hooknum, skb));
/* queued */
- if (reasm == NULL)
+ if (!reasm)
return NF_STOLEN;
/* error occurred or not fragmented */
diff --git a/net/ipv6/netfilter/nf_log_ipv6.c b/net/ipv6/netfilter/nf_log_ipv6.c
index 8dd8696..35166a2 100644
--- a/net/ipv6/netfilter/nf_log_ipv6.c
+++ b/net/ipv6/netfilter/nf_log_ipv6.c
@@ -55,7 +55,7 @@ static void dump_ipv6_packet(struct nf_log_buf *m,
logflags = NF_LOG_MASK;
ih = skb_header_pointer(skb, ip6hoff, sizeof(_ip6h), &_ip6h);
- if (ih == NULL) {
+ if (!ih) {
nf_log_buf_add(m, "TRUNCATED");
return;
}
@@ -78,7 +78,7 @@ static void dump_ipv6_packet(struct nf_log_buf *m,
const struct ipv6_opt_hdr *hp;
hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
- if (hp == NULL) {
+ if (!hp) {
nf_log_buf_add(m, "TRUNCATED");
return;
}
@@ -95,7 +95,7 @@ static void dump_ipv6_packet(struct nf_log_buf *m,
nf_log_buf_add(m, "FRAG:");
fh = skb_header_pointer(skb, ptr, sizeof(_fhdr),
&_fhdr);
- if (fh == NULL) {
+ if (!fh) {
nf_log_buf_add(m, "TRUNCATED ");
return;
}
@@ -143,7 +143,7 @@ static void dump_ipv6_packet(struct nf_log_buf *m,
ah = skb_header_pointer(skb, ptr, sizeof(_ahdr),
&_ahdr);
- if (ah == NULL) {
+ if (!ah) {
/*
* Max length: 26 "INCOMPLETE [65535
* bytes] )"
@@ -178,7 +178,7 @@ static void dump_ipv6_packet(struct nf_log_buf *m,
*/
eh = skb_header_pointer(skb, ptr, sizeof(_esph),
&_esph);
- if (eh == NULL) {
+ if (!eh) {
nf_log_buf_add(m, "INCOMPLETE [%u bytes] )",
skb->len - ptr);
return;
@@ -224,7 +224,7 @@ static void dump_ipv6_packet(struct nf_log_buf *m,
/* Max length: 25 "INCOMPLETE [65535 bytes] " */
ic = skb_header_pointer(skb, ptr, sizeof(_icmp6h), &_icmp6h);
- if (ic == NULL) {
+ if (!ic) {
nf_log_buf_add(m, "INCOMPLETE [%u bytes] ",
skb->len - ptr);
return;
diff --git a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
index e76900e..4f78aab 100644
--- a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
@@ -291,7 +291,7 @@ nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
return NF_ACCEPT;
nat = nf_ct_nat_ext_add(ct);
- if (nat == NULL)
+ if (!nat)
return NF_ACCEPT;
switch (ctinfo) {
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 5629db8..6603ae6 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -45,7 +45,7 @@ const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
otcph = skb_header_pointer(oldskb, tcphoff, sizeof(struct tcphdr),
otcph);
- if (otcph == NULL)
+ if (!otcph)
return NULL;
/* No RST for RST. */
@@ -159,7 +159,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
fl6.fl6_dport = otcph->source;
security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
dst = ip6_route_output(net, NULL, &fl6);
- if (dst == NULL || dst->error) {
+ if (!dst || dst->error) {
dst_release(dst);
return;
}
@@ -238,7 +238,7 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,
if (!reject6_csum_ok(skb_in, hooknum))
return;
- if (hooknum == NF_INET_LOCAL_OUT && skb_in->dev == NULL)
+ if (hooknum == NF_INET_LOCAL_OUT && !skb_in->dev)
skb_in->dev = net->loopback_dev;
icmpv6_send(skb_in, ICMPV6_DEST_UNREACH, code, 0);
diff --git a/net/ipv6/netfilter/nf_tables_ipv6.c b/net/ipv6/netfilter/nf_tables_ipv6.c
index c8148ba..f484f97 100644
--- a/net/ipv6/netfilter/nf_tables_ipv6.c
+++ b/net/ipv6/netfilter/nf_tables_ipv6.c
@@ -61,7 +61,7 @@ EXPORT_SYMBOL_GPL(nft_af_ipv6);
static int nf_tables_ipv6_init_net(struct net *net)
{
net->nft.ipv6 = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
- if (net->nft.ipv6 == NULL)
+ if (!net->nft.ipv6)
return -ENOMEM;
memcpy(net->nft.ipv6, &nft_af_ipv6, sizeof(nft_af_ipv6));
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 5/6] ipv6: netfilter: comparison for inequality with NULL
2015-04-25 9:26 [PATCH net-next 0/6] ipv6: netfilter - coding style improvements Ian Morris
` (3 preceding siblings ...)
2015-04-25 9:26 ` [PATCH net-next 4/6] ipv6: netfilter: comparison for equality with NULL Ian Morris
@ 2015-04-25 9:26 ` Ian Morris
2015-04-25 9:27 ` [PATCH net-next 6/6] ipv6: netfilter: simply if-else statements Ian Morris
2015-04-27 2:43 ` [PATCH net-next 0/6] ipv6: netfilter - coding style improvements Pablo Neira Ayuso
6 siblings, 0 replies; 13+ messages in thread
From: Ian Morris @ 2015-04-25 9:26 UTC (permalink / raw)
To: netdev; +Cc: Ian Morris
The code uses a mixture of coding styles. In some instances check for NULL
pointer is done as x != NULL and sometimes as x. x is preferred
according to checkpatch and this patch makes the code consistent by
adopting the latter form.
No changes detected by objdiff.
Signed-off-by: Ian Morris <ipm@chirality.org.uk>
---
net/ipv6/netfilter/ip6_tables.c | 4 ++--
net/ipv6/netfilter/ip6t_REJECT.c | 2 +-
net/ipv6/netfilter/ip6t_ah.c | 16 ++++++++--------
net/ipv6/netfilter/ip6t_frag.c | 24 ++++++++++++------------
net/ipv6/netfilter/ip6t_hbh.c | 7 +++----
net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +-
net/ipv6/netfilter/nf_log_ipv6.c | 4 ++--
net/ipv6/netfilter/nft_reject_ipv6.c | 2 +-
8 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index ce8c529..ed3612d 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -570,7 +570,7 @@ static void cleanup_match(struct xt_entry_match *m, struct net *net)
par.match = m->u.kernel.match;
par.matchinfo = m->data;
par.family = NFPROTO_IPV6;
- if (par.match->destroy != NULL)
+ if (par.match->destroy)
par.match->destroy(&par);
module_put(par.match->me);
}
@@ -793,7 +793,7 @@ static void cleanup_entry(struct ip6t_entry *e, struct net *net)
par.target = t->u.kernel.target;
par.targinfo = t->data;
par.family = NFPROTO_IPV6;
- if (par.target->destroy != NULL)
+ if (par.target->destroy)
par.target->destroy(&par);
module_put(par.target->me);
}
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c
index 12331ef..9003a99 100644
--- a/net/ipv6/netfilter/ip6t_REJECT.c
+++ b/net/ipv6/netfilter/ip6t_REJECT.c
@@ -40,7 +40,7 @@ static unsigned int
reject_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct ip6t_reject_info *reject = par->targinfo;
- struct net *net = dev_net((par->in != NULL) ? par->in : par->out);
+ struct net *net = dev_net(par->in ? par->in : par->out);
pr_debug("%s: medium point\n", __func__);
switch (reject->with) {
diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index e504376..490a4b1 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -77,14 +77,14 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
ahinfo->hdrres, ah->reserved,
!(ahinfo->hdrres && ah->reserved));
- return (ah != NULL) &&
- spi_match(ahinfo->spis[0], ahinfo->spis[1],
- ntohl(ah->spi),
- !!(ahinfo->invflags & IP6T_AH_INV_SPI)) &&
- (!ahinfo->hdrlen ||
- (ahinfo->hdrlen == hdrlen) ^
- !!(ahinfo->invflags & IP6T_AH_INV_LEN)) &&
- !(ahinfo->hdrres && ah->reserved);
+ return ah &&
+ spi_match(ahinfo->spis[0], ahinfo->spis[1],
+ ntohl(ah->spi),
+ !!(ahinfo->invflags & IP6T_AH_INV_SPI)) &&
+ (!ahinfo->hdrlen ||
+ (ahinfo->hdrlen == hdrlen) ^
+ !!(ahinfo->invflags & IP6T_AH_INV_LEN)) &&
+ !(ahinfo->hdrres && ah->reserved);
}
static int ah_mt6_check(const struct xt_mtchk_param *par)
diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c
index 0e14438..a67c2c2 100644
--- a/net/ipv6/netfilter/ip6t_frag.c
+++ b/net/ipv6/netfilter/ip6t_frag.c
@@ -88,18 +88,18 @@ frag_mt6(const struct sk_buff *skb, struct xt_action_param *par)
!((fraginfo->flags & IP6T_FRAG_NMF) &&
(ntohs(fh->frag_off) & IP6_MF)));
- return (fh != NULL) &&
- id_match(fraginfo->ids[0], fraginfo->ids[1],
- ntohl(fh->identification),
- !!(fraginfo->invflags & IP6T_FRAG_INV_IDS)) &&
- !((fraginfo->flags & IP6T_FRAG_RES) &&
- (fh->reserved || (ntohs(fh->frag_off) & 0x6))) &&
- !((fraginfo->flags & IP6T_FRAG_FST) &&
- (ntohs(fh->frag_off) & ~0x7)) &&
- !((fraginfo->flags & IP6T_FRAG_MF) &&
- !(ntohs(fh->frag_off) & IP6_MF)) &&
- !((fraginfo->flags & IP6T_FRAG_NMF) &&
- (ntohs(fh->frag_off) & IP6_MF));
+ return fh &&
+ id_match(fraginfo->ids[0], fraginfo->ids[1],
+ ntohl(fh->identification),
+ !!(fraginfo->invflags & IP6T_FRAG_INV_IDS)) &&
+ !((fraginfo->flags & IP6T_FRAG_RES) &&
+ (fh->reserved || (ntohs(fh->frag_off) & 0x6))) &&
+ !((fraginfo->flags & IP6T_FRAG_FST) &&
+ (ntohs(fh->frag_off) & ~0x7)) &&
+ !((fraginfo->flags & IP6T_FRAG_MF) &&
+ !(ntohs(fh->frag_off) & IP6_MF)) &&
+ !((fraginfo->flags & IP6T_FRAG_NMF) &&
+ (ntohs(fh->frag_off) & IP6_MF));
}
static int frag_mt6_check(const struct xt_mtchk_param *par)
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
index fc6af64..a99313f 100644
--- a/net/ipv6/netfilter/ip6t_hbh.c
+++ b/net/ipv6/netfilter/ip6t_hbh.c
@@ -89,10 +89,9 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
((optinfo->hdrlen == hdrlen) ^
!!(optinfo->invflags & IP6T_OPTS_INV_LEN))));
- ret = (oh != NULL) &&
- (!(optinfo->flags & IP6T_OPTS_LEN) ||
- ((optinfo->hdrlen == hdrlen) ^
- !!(optinfo->invflags & IP6T_OPTS_INV_LEN)));
+ ret = oh && (!(optinfo->flags & IP6T_OPTS_LEN) ||
+ ((optinfo->hdrlen == hdrlen) ^
+ !!(optinfo->invflags & IP6T_OPTS_INV_LEN)));
ptr += 2;
hdrlen -= 2;
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 51478de..0c6faf1 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -304,7 +304,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
goto found;
}
prev = NULL;
- for (next = fq->q.fragments; next != NULL; next = next->next) {
+ for (next = fq->q.fragments; next; next = next->next) {
if (NFCT_FRAG6_CB(next)->offset >= offset)
break; /* bingo! */
prev = next;
diff --git a/net/ipv6/netfilter/nf_log_ipv6.c b/net/ipv6/netfilter/nf_log_ipv6.c
index 35166a2..de3eaf5 100644
--- a/net/ipv6/netfilter/nf_log_ipv6.c
+++ b/net/ipv6/netfilter/nf_log_ipv6.c
@@ -323,7 +323,7 @@ fallback:
p = NULL;
}
- if (p != NULL) {
+ if (p) {
nf_log_buf_add(m, "%02x", *p++);
for (i = 1; i < len; i++)
nf_log_buf_add(m, ":%02x", *p++);
@@ -362,7 +362,7 @@ static void nf_log_ip6_packet(struct net *net, u_int8_t pf,
nf_log_dump_packet_common(m, pf, hooknum, skb, in, out,
loginfo, prefix);
- if (in != NULL)
+ if (in)
dump_ipv6_mac_header(m, loginfo, skb);
dump_ipv6_packet(m, loginfo, skb, skb_network_offset(skb), 1);
diff --git a/net/ipv6/netfilter/nft_reject_ipv6.c b/net/ipv6/netfilter/nft_reject_ipv6.c
index d0d1540..d282995 100644
--- a/net/ipv6/netfilter/nft_reject_ipv6.c
+++ b/net/ipv6/netfilter/nft_reject_ipv6.c
@@ -24,7 +24,7 @@ static void nft_reject_ipv6_eval(const struct nft_expr *expr,
const struct nft_pktinfo *pkt)
{
struct nft_reject *priv = nft_expr_priv(expr);
- struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out);
+ struct net *net = dev_net(pkt->in ? pkt->in : pkt->out);
switch (priv->type) {
case NFT_REJECT_ICMP_UNREACH:
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 6/6] ipv6: netfilter: simply if-else statements
2015-04-25 9:26 [PATCH net-next 0/6] ipv6: netfilter - coding style improvements Ian Morris
` (4 preceding siblings ...)
2015-04-25 9:26 ` [PATCH net-next 5/6] ipv6: netfilter: comparison for inequality " Ian Morris
@ 2015-04-25 9:27 ` Ian Morris
2015-04-25 16:17 ` Joe Perches
2015-04-27 2:43 ` [PATCH net-next 0/6] ipv6: netfilter - coding style improvements Pablo Neira Ayuso
6 siblings, 1 reply; 13+ messages in thread
From: Ian Morris @ 2015-04-25 9:27 UTC (permalink / raw)
To: netdev; +Cc: Ian Morris
Remove "else" branch of "if" statements where a return is always done
when the condition is true.
No changes detected by objdiff.
Signed-off-by: Ian Morris <ipm@chirality.org.uk>
---
net/ipv6/netfilter/ip6_tables.c | 7 +-
net/ipv6/netfilter/ip6t_hbh.c | 105 ++++++++++++-------------
net/ipv6/netfilter/ip6t_rt.c | 100 +++++++++++------------
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 5 +-
4 files changed, 105 insertions(+), 112 deletions(-)
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index ed3612d..ad02f10 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -268,8 +268,8 @@ get_chainname_rulenum(const struct ip6t_entry *s, const struct ip6t_entry *e,
: comments[NF_IP6_TRACE_COMMENT_RETURN];
}
return 1;
- } else
- (*rulenum)++;
+ }
+ (*rulenum)++;
return 0;
}
@@ -446,7 +446,8 @@ ip6t_do_table(struct sk_buff *skb,
#else
if (acpar.hotdrop)
return NF_DROP;
- else return verdict;
+
+ return verdict;
#endif
}
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
index a99313f..98304ba 100644
--- a/net/ipv6/netfilter/ip6t_hbh.c
+++ b/net/ipv6/netfilter/ip6t_hbh.c
@@ -95,70 +95,67 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
ptr += 2;
hdrlen -= 2;
- if (!(optinfo->flags & IP6T_OPTS_OPTS)) {
+ if (!(optinfo->flags & IP6T_OPTS_OPTS))
return ret;
- } else {
- pr_debug("Strict ");
- pr_debug("#%d ", optinfo->optsnr);
- for (temp = 0; temp < optinfo->optsnr; temp++) {
- /* type field exists ? */
- if (hdrlen < 1)
+
+ pr_debug("Strict ");
+ pr_debug("#%d ", optinfo->optsnr);
+ for (temp = 0; temp < optinfo->optsnr; temp++) {
+ /* type field exists ? */
+ if (hdrlen < 1)
+ break;
+ tp = skb_header_pointer(skb, ptr, sizeof(_opttype),
+ &_opttype);
+ if (!tp)
+ break;
+
+ /* Type check */
+ if (*tp != (optinfo->opts[temp] & 0xFF00) >> 8) {
+ pr_debug("Tbad %02X %02X\n", *tp,
+ (optinfo->opts[temp] & 0xFF00) >> 8);
+ return false;
+ }
+ pr_debug("Tok ");
+
+ /* Length check */
+ if (*tp) {
+ u16 spec_len;
+
+ /* length field exists ? */
+ if (hdrlen < 2)
break;
- tp = skb_header_pointer(skb, ptr, sizeof(_opttype),
- &_opttype);
- if (!tp)
+ lp = skb_header_pointer(skb, ptr + 1,
+ sizeof(_optlen),
+ &_optlen);
+ if (!lp)
break;
+ spec_len = optinfo->opts[temp] & 0x00FF;
- /* Type check */
- if (*tp != (optinfo->opts[temp] & 0xFF00) >> 8) {
- pr_debug("Tbad %02X %02X\n", *tp,
- (optinfo->opts[temp] & 0xFF00) >> 8);
+ if (spec_len != 0x00FF && spec_len != *lp) {
+ pr_debug("Lbad %02X %04X\n", *lp,
+ spec_len);
return false;
- } else {
- pr_debug("Tok ");
- }
- /* Length check */
- if (*tp) {
- u16 spec_len;
-
- /* length field exists ? */
- if (hdrlen < 2)
- break;
- lp = skb_header_pointer(skb, ptr + 1,
- sizeof(_optlen),
- &_optlen);
- if (!lp)
- break;
- spec_len = optinfo->opts[temp] & 0x00FF;
-
- if (spec_len != 0x00FF && spec_len != *lp) {
- pr_debug("Lbad %02X %04X\n", *lp,
- spec_len);
- return false;
- }
- pr_debug("Lok ");
- optlen = *lp + 2;
- } else {
- pr_debug("Pad1\n");
- optlen = 1;
}
+ pr_debug("Lok ");
+ optlen = *lp + 2;
+ } else {
+ pr_debug("Pad1\n");
+ optlen = 1;
+ }
- /* Step to the next */
- pr_debug("len%04X\n", optlen);
+ /* Step to the next */
+ pr_debug("len%04X\n", optlen);
- if ((ptr > skb->len - optlen || hdrlen < optlen) &&
- temp < optinfo->optsnr - 1) {
- pr_debug("new pointer is too large!\n");
- break;
- }
- ptr += optlen;
- hdrlen -= optlen;
+ if ((ptr > skb->len - optlen || hdrlen < optlen) &&
+ temp < optinfo->optsnr - 1) {
+ pr_debug("new pointer is too large!\n");
+ break;
}
- if (temp == optinfo->optsnr)
- return ret;
- else
- return false;
+ ptr += optlen;
+ hdrlen -= optlen;
}
+ if (temp == optinfo->optsnr)
+ return ret;
return false;
}
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
index bdab49e..f2668e2 100644
--- a/net/ipv6/netfilter/ip6t_rt.c
+++ b/net/ipv6/netfilter/ip6t_rt.c
@@ -119,66 +119,62 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
if (!(rtinfo->flags & IP6T_RT_FST)) {
return ret;
} else if (rtinfo->flags & IP6T_RT_FST_NSTRICT) {
+ unsigned int i = 0;
+
pr_debug("Not strict ");
if (rtinfo->addrnr > (unsigned int)((hdrlen - 8) / 16)) {
pr_debug("There isn't enough space\n");
return false;
- } else {
- unsigned int i = 0;
-
- pr_debug("#%d ", rtinfo->addrnr);
- for (temp = 0;
- temp < (unsigned int)((hdrlen - 8) / 16);
- temp++) {
- ap = skb_header_pointer(skb,
- ptr
- + sizeof(struct rt0_hdr)
- + temp * sizeof(_addr),
- sizeof(_addr),
- &_addr);
-
- BUG_ON(!ap);
-
- if (ipv6_addr_equal(ap, &rtinfo->addrs[i])) {
- pr_debug("i=%d temp=%d;\n", i, temp);
- i++;
- }
- if (i == rtinfo->addrnr)
- break;
- }
- pr_debug("i=%d #%d\n", i, rtinfo->addrnr);
- if (i == rtinfo->addrnr)
- return ret;
- else
- return false;
}
- } else {
- pr_debug("Strict ");
- if (rtinfo->addrnr > (unsigned int)((hdrlen - 8) / 16)) {
- pr_debug("There isn't enough space\n");
- return false;
- } else {
- pr_debug("#%d ", rtinfo->addrnr);
- for (temp = 0; temp < rtinfo->addrnr; temp++) {
- ap = skb_header_pointer(skb,
- ptr
- + sizeof(struct rt0_hdr)
- + temp * sizeof(_addr),
- sizeof(_addr),
- &_addr);
- BUG_ON(!ap);
-
- if (!ipv6_addr_equal(ap, &rtinfo->addrs[temp]))
- break;
+
+ pr_debug("#%d ", rtinfo->addrnr);
+ for (temp = 0;
+ temp < (unsigned int)((hdrlen - 8) / 16);
+ temp++) {
+ ap = skb_header_pointer(skb,
+ ptr
+ + sizeof(struct rt0_hdr)
+ + temp * sizeof(_addr),
+ sizeof(_addr),
+ &_addr);
+
+ BUG_ON(!ap);
+
+ if (ipv6_addr_equal(ap, &rtinfo->addrs[i])) {
+ pr_debug("i=%d temp=%d;\n", i, temp);
+ i++;
}
- pr_debug("temp=%d #%d\n", temp, rtinfo->addrnr);
- if (temp == rtinfo->addrnr &&
- temp == (unsigned int)((hdrlen - 8) / 16))
- return ret;
- else
- return false;
+ if (i == rtinfo->addrnr)
+ break;
}
+ pr_debug("i=%d #%d\n", i, rtinfo->addrnr);
+ if (i == rtinfo->addrnr)
+ return ret;
+
+ return false;
+ }
+ pr_debug("Strict ");
+ if (rtinfo->addrnr > (unsigned int)((hdrlen - 8) / 16)) {
+ pr_debug("There isn't enough space\n");
+ return false;
}
+ pr_debug("#%d ", rtinfo->addrnr);
+ for (temp = 0; temp < rtinfo->addrnr; temp++) {
+ ap = skb_header_pointer(skb,
+ ptr
+ + sizeof(struct rt0_hdr)
+ + temp * sizeof(_addr),
+ sizeof(_addr),
+ &_addr);
+ BUG_ON(!ap);
+
+ if (!ipv6_addr_equal(ap, &rtinfo->addrs[temp]))
+ break;
+ }
+ pr_debug("temp=%d #%d\n", temp, rtinfo->addrnr);
+ if (temp == rtinfo->addrnr &&
+ temp == (unsigned int)((hdrlen - 8) / 16))
+ return ret;
return false;
}
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index b6cd77b..10030ad 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -181,10 +181,9 @@ icmpv6_error_message(struct net *net, struct nf_conn *tmpl,
if (!h) {
pr_debug("icmpv6_error: no match\n");
return -NF_ACCEPT;
- } else {
- if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY)
- *ctinfo += IP_CT_IS_REPLY;
}
+ if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY)
+ *ctinfo += IP_CT_IS_REPLY;
/* Update skb to refer to this connection */
skb->nfct = &nf_ct_tuplehash_to_ctrack(h)->ct_general;
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread