net: rpl: DAO message was discarded too early

The commit b14586c3ca ("net: rpl: RPL route entry was fetched
too late") dropped the DAO packet too early which prevents the
RPL root node functionality. Rework the earlier commit so that
Coverity issues are fixed but the RPL DAO message is also properly
handled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-08-08 11:03:21 +03:00
parent 53928aae76
commit a5b4cca94a
2 changed files with 11 additions and 16 deletions

View file

@ -554,7 +554,9 @@ struct in6_addr *net_route_get_nexthop(struct net_route_entry *route)
struct net_route_nexthop *nexthop_route;
struct net_ipv6_nbr_data *ipv6_nbr_data;
NET_ASSERT(route);
if (!route) {
return NULL;
}
SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route, node) {
struct in6_addr *addr;

View file

@ -3290,10 +3290,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;
@ -3458,25 +3458,17 @@ 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);
if (nbr) {
extra = net_nbr_extra_data(nbr);
}
nexthop = net_route_get_nexthop(route);
/* No-Path DAO received; invoke the route purging routine. */
@ -3551,6 +3543,7 @@ static enum net_verdict handle_dao(struct net_pkt *pkt)
return NET_DROP;
}
extra = net_nbr_extra_data(nbr);
if (extra) {
extra->lifetime = net_rpl_lifetime(instance, lifetime);
extra->route_source = learned_from;