net: rpl: RPL route entry was fetched too late

The RPL route entry variable "extra" was resolved inside an
if-statement and the code was always returning from it.
This meant the the later code dealing with "extra" was never
executed. Fixed by moving the resolving of "extra" a bit
earlier so that the "extra" variable has always a proper value.

Coverity-CID: 173659
Coverity-CID: 173654

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-08-04 23:07:17 +03:00 committed by Anas Nashif
parent 7182620340
commit b14586c3ca

View file

@ -3272,10 +3272,10 @@ static int forwarding_dao(struct net_rpl_instance *instance,
static enum net_verdict handle_dao(struct net_pkt *pkt)
{
struct in6_addr *dao_sender = &NET_IPV6_HDR(pkt)->src;
struct net_rpl_route_entry *extra = NULL;
struct net_rpl_parent *parent = NULL;
enum net_rpl_route_source learned_from;
struct net_rpl_instance *instance;
struct net_rpl_route_entry *extra;
struct net_route_entry *route;
struct net_rpl_dag *dag;
struct net_buf *frag;
@ -3440,18 +3440,29 @@ static enum net_verdict handle_dao(struct net_pkt *pkt)
}
#endif
route = net_route_lookup(net_pkt_iface(pkt), &addr);
if (!route) {
NET_DBG("No route to %s for iface %p",
net_sprint_ipv6_addr(&addr), net_pkt_iface(pkt));
return NET_DROP;
}
nbr = net_route_get_nbr(route);
if (!nbr) {
return NET_DROP;
}
extra = net_nbr_extra_data(nbr);
if (lifetime == NET_RPL_ZERO_LIFETIME) {
struct in6_addr *nexthop;
NET_DBG("No-Path DAO received");
route = net_route_lookup(net_pkt_iface(pkt), &addr);
nbr = net_route_get_nbr(route);
extra = net_nbr_extra_data(nbr);
nexthop = net_route_get_nexthop(route);
/* No-Path DAO received; invoke the route purging routine. */
if (route && !extra->no_path_received &&
if (route && extra && !extra->no_path_received &&
route->prefix_len == target_len && nexthop &&
net_ipv6_addr_cmp(nexthop, dao_sender)) {
NET_DBG("Setting expiration timer for target %s",