net: if: Add ASSERT in net_if_ipv4/6_select_src_addr

Add an assert for the destination address provided to find the best
source address.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2023-09-26 08:57:09 +02:00 committed by Carles Cufí
commit cb4fb765f0

View file

@ -2864,6 +2864,8 @@ const struct in6_addr *net_if_ipv6_select_src_addr(struct net_if *dst_iface,
const struct in6_addr *src = NULL;
uint8_t best_match = 0U;
NET_ASSERT(dst);
if (!net_ipv6_is_ll_addr(dst) && !net_ipv6_is_addr_mcast_link(dst)) {
/* If caller has supplied interface, then use that */
if (dst_iface) {
@ -3405,6 +3407,8 @@ const struct in_addr *net_if_ipv4_select_src_addr(struct net_if *dst_iface,
const struct in_addr *src = NULL;
uint8_t best_match = 0U;
NET_ASSERT(dst);
if (!net_ipv4_is_ll_addr(dst)) {
/* If caller has supplied interface, then use that */