Skip to content
Permalink
Browse files

ip: route: disable LL address check when using dummy L2

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 <florian.vaussard@gmail.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
vaussard authored and jukkar committed May 17, 2018
1 parent 334ce69 commit 1f23d2681ffff25933cedd386860a5e1760549ee
Showing with 21 additions and 10 deletions.
  1. +21 −10 subsys/net/ip/route.c
@@ -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);

0 comments on commit 1f23d26

Please sign in to comment.
You can’t perform that action at this time.