Skip to content

Commit

Permalink
ip: route: disable LL address check when using dummy L2
Browse files Browse the repository at this point in the history
The dummy L2 does not setup the link layer address. Do not check the
source and destination link layer addresses when routing packets
otherwise packet routing will not work when using a dummy L2.

Signed-off-by: Florian Vaussard <[email protected]>
Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
vaussard authored and jukkar committed Aug 2, 2018
1 parent 334ce69 commit 1f23d26
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions subsys/net/ip/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,18 +780,29 @@ int net_route_packet(struct net_pkt *pkt, struct in6_addr *nexthop)
return -ESRCH;
}

if (!net_pkt_ll_src(pkt)->addr) {
NET_DBG("Link layer source address not set");
return -EINVAL;
}

/* Sanitycheck: If src and dst ll addresses are going to be same,
* then something went wrong in route lookup.
#if defined(CONFIG_NET_L2_DUMMY)
/* No need to do this check for dummy L2 as it does not have any
* link layer. This is done at runtime because we can have multiple
* network technologies enabled.
*/
if (!memcmp(net_pkt_ll_src(pkt)->addr, lladdr->addr, lladdr->len)) {
NET_ERR("Src ll and Dst ll are same");
return -EINVAL;
if (net_if_l2(net_pkt_iface(pkt)) != &NET_L2_GET_NAME(DUMMY)) {
#endif
if (!net_pkt_ll_src(pkt)->addr) {
NET_DBG("Link layer source address not set");
return -EINVAL;
}

/* Sanitycheck: If src and dst ll addresses are going to be
* same, then something went wrong in route lookup.
*/
if (!memcmp(net_pkt_ll_src(pkt)->addr, lladdr->addr,
lladdr->len)) {
NET_ERR("Src ll and Dst ll are same");
return -EINVAL;
}
#if defined(CONFIG_NET_L2_DUMMY)
}
#endif

net_pkt_set_forwarding(pkt, true);

Expand Down

0 comments on commit 1f23d26

Please sign in to comment.