net: ipv6: nbr: Refactor because of timeout overhaul
Convert minimal parts to support k_timeout_t values. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
63a7b92fd8
commit
005ee2f768
3 changed files with 15 additions and 15 deletions
|
@ -77,8 +77,8 @@ static void ipv6_nd_restart_reachable_timer(struct net_nbr *nbr, s64_t time);
|
||||||
/* Protocol constants from RFC 4861 Chapter 10 */
|
/* Protocol constants from RFC 4861 Chapter 10 */
|
||||||
#define MAX_MULTICAST_SOLICIT 3
|
#define MAX_MULTICAST_SOLICIT 3
|
||||||
#define MAX_UNICAST_SOLICIT 3
|
#define MAX_UNICAST_SOLICIT 3
|
||||||
#define DELAY_FIRST_PROBE_TIME K_SECONDS(5)
|
#define DELAY_FIRST_PROBE_TIME (5 * MSEC_PER_SEC)
|
||||||
#define RETRANS_TIMER K_MSEC(1000)
|
#define RETRANS_TIMER 1000 /* ms */
|
||||||
|
|
||||||
extern void net_neighbor_data_remove(struct net_nbr *nbr);
|
extern void net_neighbor_data_remove(struct net_nbr *nbr);
|
||||||
extern void net_neighbor_table_clear(struct net_nbr_table *table);
|
extern void net_neighbor_table_clear(struct net_nbr_table *table);
|
||||||
|
@ -333,7 +333,7 @@ bool net_ipv6_nbr_rm(struct net_if *iface, struct in6_addr *addr)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NS_REPLY_TIMEOUT K_SECONDS(1)
|
#define NS_REPLY_TIMEOUT (1 * MSEC_PER_SEC)
|
||||||
|
|
||||||
static void ipv6_ns_reply_timeout(struct k_work *work)
|
static void ipv6_ns_reply_timeout(struct k_work *work)
|
||||||
{
|
{
|
||||||
|
@ -367,7 +367,7 @@ static void ipv6_ns_reply_timeout(struct k_work *work)
|
||||||
if (!k_delayed_work_remaining_get(
|
if (!k_delayed_work_remaining_get(
|
||||||
&ipv6_ns_reply_timer)) {
|
&ipv6_ns_reply_timer)) {
|
||||||
k_delayed_work_submit(&ipv6_ns_reply_timer,
|
k_delayed_work_submit(&ipv6_ns_reply_timer,
|
||||||
remaining);
|
K_MSEC(remaining));
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -1395,7 +1395,7 @@ static void ipv6_nd_restart_reachable_timer(struct net_nbr *nbr, s64_t time)
|
||||||
|
|
||||||
remaining = k_delayed_work_remaining_get(&ipv6_nd_reachable_timer);
|
remaining = k_delayed_work_remaining_get(&ipv6_nd_reachable_timer);
|
||||||
if (!remaining || remaining > time) {
|
if (!remaining || remaining > time) {
|
||||||
k_delayed_work_submit(&ipv6_nd_reachable_timer, time);
|
k_delayed_work_submit(&ipv6_nd_reachable_timer, K_MSEC(time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1913,7 +1913,7 @@ int net_ipv6_send_ns(struct net_if *iface,
|
||||||
/* Let's start the timer if necessary */
|
/* Let's start the timer if necessary */
|
||||||
if (!k_delayed_work_remaining_get(&ipv6_ns_reply_timer)) {
|
if (!k_delayed_work_remaining_get(&ipv6_ns_reply_timer)) {
|
||||||
k_delayed_work_submit(&ipv6_ns_reply_timer,
|
k_delayed_work_submit(&ipv6_ns_reply_timer,
|
||||||
NS_REPLY_TIMEOUT);
|
K_MSEC(NS_REPLY_TIMEOUT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2131,7 +2131,7 @@ static inline u32_t remaining_lifetime(struct net_if_addr *ifaddr)
|
||||||
(u64_t)time_diff(k_uptime_get_32(),
|
(u64_t)time_diff(k_uptime_get_32(),
|
||||||
ifaddr->lifetime.timer_start);
|
ifaddr->lifetime.timer_start);
|
||||||
|
|
||||||
return (u32_t)(remaining / K_MSEC(1000));
|
return (u32_t)(remaining / MSEC_PER_SEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void handle_prefix_autonomous(struct net_pkt *pkt,
|
static inline void handle_prefix_autonomous(struct net_pkt *pkt,
|
||||||
|
|
|
@ -179,7 +179,7 @@ static void prepare_ra_message(struct net_pkt *pkt)
|
||||||
pkt->buffer = NULL;
|
pkt->buffer = NULL;
|
||||||
|
|
||||||
net_pkt_alloc_buffer(pkt, sizeof(struct net_eth_hdr) +
|
net_pkt_alloc_buffer(pkt, sizeof(struct net_eth_hdr) +
|
||||||
sizeof(icmpv6_ra), AF_UNSPEC, 0);
|
sizeof(icmpv6_ra), AF_UNSPEC, K_NO_WAIT);
|
||||||
net_pkt_cursor_init(pkt);
|
net_pkt_cursor_init(pkt);
|
||||||
|
|
||||||
hdr.type = htons(NET_ETH_PTYPE_IPV6);
|
hdr.type = htons(NET_ETH_PTYPE_IPV6);
|
||||||
|
@ -565,7 +565,7 @@ static void test_prefix_timeout_long(void)
|
||||||
zassert_equal(ifprefix->lifetime.wrap_counter, 2000,
|
zassert_equal(ifprefix->lifetime.wrap_counter, 2000,
|
||||||
"Wrap counter wrong (%d)",
|
"Wrap counter wrong (%d)",
|
||||||
ifprefix->lifetime.wrap_counter);
|
ifprefix->lifetime.wrap_counter);
|
||||||
remaining = K_SECONDS((u64_t)lifetime) -
|
remaining = MSEC_PER_SEC * (u64_t)lifetime -
|
||||||
NET_TIMEOUT_MAX_VALUE * (u64_t)ifprefix->lifetime.wrap_counter;
|
NET_TIMEOUT_MAX_VALUE * (u64_t)ifprefix->lifetime.wrap_counter;
|
||||||
|
|
||||||
zassert_equal(remaining, ifprefix->lifetime.timer_timeout,
|
zassert_equal(remaining, ifprefix->lifetime.timer_timeout,
|
||||||
|
@ -925,7 +925,7 @@ static void test_address_lifetime(void)
|
||||||
0, 0, 0, 0, 0, 0, 0x20, 0x1 } } };
|
0, 0, 0, 0, 0, 0, 0x20, 0x1 } } };
|
||||||
struct net_if *iface = net_if_get_default();
|
struct net_if *iface = net_if_get_default();
|
||||||
u32_t vlifetime = 0xffff;
|
u32_t vlifetime = 0xffff;
|
||||||
u64_t timeout = K_SECONDS((u64_t)vlifetime);
|
u64_t timeout = (u64_t)vlifetime * MSEC_PER_SEC;
|
||||||
struct net_if_addr *ifaddr;
|
struct net_if_addr *ifaddr;
|
||||||
u64_t remaining;
|
u64_t remaining;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
@ -953,7 +953,7 @@ static void test_address_lifetime(void)
|
||||||
|
|
||||||
zassert_equal(ifaddr->lifetime.wrap_counter, 2,
|
zassert_equal(ifaddr->lifetime.wrap_counter, 2,
|
||||||
"Wrap counter wrong (%d)", ifaddr->lifetime.wrap_counter);
|
"Wrap counter wrong (%d)", ifaddr->lifetime.wrap_counter);
|
||||||
remaining = K_SECONDS((u64_t)vlifetime) -
|
remaining = MSEC_PER_SEC * (u64_t)vlifetime -
|
||||||
NET_TIMEOUT_MAX_VALUE * (u64_t)ifaddr->lifetime.wrap_counter;
|
NET_TIMEOUT_MAX_VALUE * (u64_t)ifaddr->lifetime.wrap_counter;
|
||||||
|
|
||||||
zassert_equal(remaining, ifaddr->lifetime.timer_timeout,
|
zassert_equal(remaining, ifaddr->lifetime.timer_timeout,
|
||||||
|
@ -966,8 +966,8 @@ static void test_address_lifetime(void)
|
||||||
zassert_equal(ifaddr->lifetime.wrap_counter, 2,
|
zassert_equal(ifaddr->lifetime.wrap_counter, 2,
|
||||||
"Wrap counter wrong (%d)", ifaddr->lifetime.wrap_counter);
|
"Wrap counter wrong (%d)", ifaddr->lifetime.wrap_counter);
|
||||||
|
|
||||||
ifaddr->lifetime.timer_timeout = K_MSEC(10);
|
ifaddr->lifetime.timer_timeout = 10;
|
||||||
ifaddr->lifetime.timer_start = k_uptime_get_32() - K_MSEC(10);
|
ifaddr->lifetime.timer_start = k_uptime_get_32() - 10;
|
||||||
ifaddr->lifetime.wrap_counter = 0;
|
ifaddr->lifetime.wrap_counter = 0;
|
||||||
|
|
||||||
net_address_lifetime_timeout();
|
net_address_lifetime_timeout();
|
||||||
|
@ -1258,7 +1258,7 @@ static void net_ctx_recv(struct net_context *ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = net_context_recv(ctx, recv_cb, 0, NULL);
|
ret = net_context_recv(ctx, recv_cb, K_NO_WAIT, NULL);
|
||||||
zassert_equal(ret, 0, "Context recv IPv6 UDP failed");
|
zassert_equal(ret, 0, "Context recv IPv6 UDP failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -908,7 +908,7 @@ static u16_t pkt_recv_data_len;
|
||||||
|
|
||||||
#define WAIT_TIME K_SECONDS(1)
|
#define WAIT_TIME K_SECONDS(1)
|
||||||
|
|
||||||
#define ALLOC_TIMEOUT 500
|
#define ALLOC_TIMEOUT K_MSEC(500)
|
||||||
|
|
||||||
struct net_if_test {
|
struct net_if_test {
|
||||||
u8_t idx;
|
u8_t idx;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue