net: if: Add possibility to disable ND per interface
Add new network interface flag, which allows to disable Neighbour Discovery protocol from being used on the interface. This allows to interfaces that do not support ND (like OpenThread) to coexist with other IPv6 interfaces. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
1113c2efd4
commit
c43c408783
|
@ -203,6 +203,9 @@ enum net_if_flag {
|
|||
/** Driver signals dormant. */
|
||||
NET_IF_DORMANT,
|
||||
|
||||
/** IPv6 Neighbor Discovery disabled. */
|
||||
NET_IF_IPV6_NO_ND,
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
/* Total number of flags - must be at the end of the enum */
|
||||
NET_IF_NUM_FLAGS
|
||||
|
|
|
@ -846,8 +846,8 @@ ignore_frag_error:
|
|||
/* Workaround Linux bug, see:
|
||||
* https://github.com/zephyrproject-rtos/zephyr/issues/3111
|
||||
*/
|
||||
net_if_flag_is_set(net_pkt_iface(pkt),
|
||||
NET_IF_POINTOPOINT)) {
|
||||
net_if_flag_is_set(net_pkt_iface(pkt), NET_IF_POINTOPOINT) ||
|
||||
net_if_flag_is_set(net_pkt_iface(pkt), NET_IF_IPV6_NO_ND)) {
|
||||
return NET_OK;
|
||||
}
|
||||
|
||||
|
@ -1162,6 +1162,10 @@ static enum net_verdict handle_ns_input(struct net_pkt *pkt,
|
|||
|
||||
src_lladdr.len = 0;
|
||||
|
||||
if (net_if_flag_is_set(net_pkt_iface(pkt), NET_IF_IPV6_NO_ND)) {
|
||||
goto drop;
|
||||
}
|
||||
|
||||
ns_hdr = (struct net_icmpv6_ns_hdr *)net_pkt_get_data(pkt, &ns_access);
|
||||
if (!ns_hdr) {
|
||||
NET_ERR("DROP: NULL NS header");
|
||||
|
@ -1731,6 +1735,10 @@ static enum net_verdict handle_na_input(struct net_pkt *pkt,
|
|||
struct net_icmpv6_na_hdr *na_hdr;
|
||||
struct net_if_addr *ifaddr;
|
||||
|
||||
if (net_if_flag_is_set(net_pkt_iface(pkt), NET_IF_IPV6_NO_ND)) {
|
||||
goto drop;
|
||||
}
|
||||
|
||||
na_hdr = (struct net_icmpv6_na_hdr *)net_pkt_get_data(pkt, &na_access);
|
||||
if (!na_hdr) {
|
||||
NET_ERR("DROP: NULL NA header");
|
||||
|
@ -2400,6 +2408,10 @@ static enum net_verdict handle_ra_input(struct net_pkt *pkt,
|
|||
uint32_t mtu, reachable_time, retrans_timer;
|
||||
uint16_t router_lifetime;
|
||||
|
||||
if (net_if_flag_is_set(net_pkt_iface(pkt), NET_IF_IPV6_NO_ND)) {
|
||||
goto drop;
|
||||
}
|
||||
|
||||
ra_hdr = (struct net_icmpv6_ra_hdr *)net_pkt_get_data(pkt, &ra_access);
|
||||
if (!ra_hdr) {
|
||||
NET_ERR("DROP: NULL RA header");
|
||||
|
|
|
@ -1407,6 +1407,10 @@ void net_if_start_rs(struct net_if *iface)
|
|||
|
||||
k_mutex_lock(&lock, K_FOREVER);
|
||||
|
||||
if (net_if_flag_is_set(iface, NET_IF_IPV6_NO_ND)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
ipv6 = iface->config.ip.ipv6;
|
||||
if (!ipv6) {
|
||||
goto out;
|
||||
|
@ -1725,7 +1729,8 @@ struct net_if_addr *net_if_ipv6_addr_add(struct net_if *iface,
|
|||
net_addr_type2str(addr_type));
|
||||
|
||||
if (!(l2_flags_get(iface) & NET_L2_POINT_TO_POINT) &&
|
||||
!net_ipv6_is_addr_loopback(addr)) {
|
||||
!net_ipv6_is_addr_loopback(addr) &&
|
||||
!net_if_flag_is_set(iface, NET_IF_IPV6_NO_ND)) {
|
||||
/* RFC 4862 5.4.2
|
||||
* Before sending a Neighbor Solicitation, an interface
|
||||
* MUST join the all-nodes multicast address and the
|
||||
|
@ -2792,7 +2797,8 @@ uint32_t net_if_ipv6_calc_reachable_time(struct net_if_ipv6 *ipv6)
|
|||
|
||||
static void iface_ipv6_start(struct net_if *iface)
|
||||
{
|
||||
if (!net_if_flag_is_set(iface, NET_IF_IPV6)) {
|
||||
if (!net_if_flag_is_set(iface, NET_IF_IPV6) ||
|
||||
net_if_flag_is_set(iface, NET_IF_IPV6_NO_ND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -283,9 +283,10 @@ static void setup_ipv6(struct net_if *iface, uint32_t flags)
|
|||
|
||||
exit:
|
||||
|
||||
#if !defined(CONFIG_NET_IPV6_DAD)
|
||||
services_notify_ready(NET_CONFIG_NEED_IPV6);
|
||||
#endif
|
||||
if (!IS_ENABLED(CONFIG_NET_IPV6_DAD) ||
|
||||
net_if_flag_is_set(iface, NET_IF_IPV6_NO_ND)) {
|
||||
services_notify_ready(NET_CONFIG_NEED_IPV6);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue