Skip to contentSkip to conversation

ipv6: ip6_route_output() never returns NULL.

PATCH Applied [email protected] 2 participants 6 messages Feb 22, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ipv6: ip6_route_output() never returns NULL.

From: RongQing.Li <[email protected]>

ip6_route_output() never returns NULL, so it is wrong to check if the return value is NULL.

---
 net/ipv6/ip6mr.c |    4 +++-
 net/ipv6/ndisc.c |    5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
net/ipv6/ip6mr.c +3 -1
index c7e95c8..5aa3981 100644
@@ -1926,8 +1926,10 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
 	};
 
 	dst = ip6_route_output(net, NULL, &fl6);
-	if (!dst)
+	if (dst->error) {
+		dst_release(dst);
 		goto out_free;
+	}
 
 	skb_dst_drop(skb);
 	skb_dst_set(skb, dst);
net/ipv6/ndisc.c +3 -2
index 8d81701..3dcdb81 100644
@@ -1550,9 +1550,10 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 			 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex);
 
 	dst = ip6_route_output(net, NULL, &fl6);
-	if (dst == NULL)
+	if (dst->error) {
+		dst_release(dst);
 		return;
-
+	}
 	dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
 	if (IS_ERR(dst))
 		return;
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/3 ethernet/broadcom: ip6_route_output() never returns NULL.

From: RongQing.Li <[email protected]>

ip6_route_output() never returns NULL, so it is wrong to check if the return value is NULL.

---
 drivers/net/ethernet/broadcom/cnic.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +5 -1
index df42995..7b65716 100644
@@ -3616,7 +3616,11 @@ static int cnic_get_v6_route(struct sockaddr_in6 *dst_addr,
 		fl6.flowi6_oif = dst_addr->sin6_scope_id;
 
 	*dst = ip6_route_output(&init_net, NULL, &fl6);
-	if (*dst)
+	if ((*dst)->error) {
+		dst_release(*dst);
+		*dst = NULL;
+		return -ENETUNREACH;
+	} else
 		return 0;
 #endif
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/3 netfilter: ip6_route_output() never returns NULL.

In reply to [email protected]

From: RongQing.Li <[email protected]>

ip6_route_output() never returns NULL, so it is wrong to check if the return value is NULL.

---
 net/netfilter/xt_TEE.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
net/netfilter/xt_TEE.c +3 -2
index 3aae66f..4d50579 100644
@@ -152,9 +152,10 @@ tee_tg_route6(struct sk_buff *skb, const struct xt_tee_tginfo *info)
 	fl6.flowlabel = ((iph->flow_lbl[0] & 0xF) << 16) |
 			   (iph->flow_lbl[1] << 8) | iph->flow_lbl[2];
 	dst = ip6_route_output(net, NULL, &fl6);
-	if (dst == NULL)
+	if (dst->error) {
+		dst_release(dst);
 		return false;
-
+	}
 	skb_dst_drop(skb);
 	skb_dst_set(skb, dst);
 	skb->dev      = dst->dev;
Signature · 1 line
1.7.1