Skip to content

Commit 1c2fc02

Browse files
JordanYateskartben
authored andcommitted
net: ip: net_if: consistent interface id logging
Update logging to consistently refer to interfaces by their ID, instead of a mix of IDs and pointers. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 3772c71 commit 1c2fc02

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

subsys/net/ip/net_if.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static bool net_if_tx(struct net_if *iface, struct net_pkt *pkt)
302302

303303
} else {
304304
/* Drop packet if interface is not up */
305-
NET_WARN("iface %p is down", iface);
305+
NET_WARN("iface %d is down", net_if_get_by_iface(iface));
306306
status = -ENETDOWN;
307307
}
308308

@@ -438,7 +438,7 @@ static inline void init_iface(struct net_if *iface)
438438

439439
net_virtual_init(iface);
440440

441-
NET_DBG("On iface %p", iface);
441+
NET_DBG("On iface %d", net_if_get_by_iface(iface));
442442

443443
#ifdef CONFIG_USERSPACE
444444
k_object_init(iface);
@@ -465,7 +465,7 @@ enum net_verdict net_if_try_send_data(struct net_if *iface, struct net_pkt *pkt,
465465
if (!net_if_flag_is_set(iface, NET_IF_LOWER_UP) ||
466466
net_if_flag_is_set(iface, NET_IF_SUSPENDED)) {
467467
/* Drop packet if interface is not up */
468-
NET_WARN("iface %p is down", iface);
468+
NET_WARN("iface %d is down", net_if_get_by_iface(iface));
469469
verdict = NET_DROP;
470470
status = -ENETDOWN;
471471
goto done;
@@ -478,14 +478,15 @@ enum net_verdict net_if_try_send_data(struct net_if *iface, struct net_pkt *pkt,
478478
l2 = net_if_l2(iface);
479479
if (l2 == NULL) {
480480
/* Offloaded ifaces may choose not to use an L2 at all. */
481-
NET_WARN("no l2 for iface %p, discard pkt", iface);
481+
NET_WARN("no l2 for iface %d, discard pkt", net_if_get_by_iface(iface));
482482
verdict = NET_DROP;
483483
goto done;
484484
} else if (l2->send == NULL) {
485485
/* Or, their chosen L2 (for example, OFFLOADED_NETDEV_L2)
486486
* might simply not implement send.
487487
*/
488-
NET_WARN("l2 for iface %p cannot send, discard pkt", iface);
488+
NET_WARN("l2 for iface %d cannot send, discard pkt",
489+
net_if_get_by_iface(iface));
489490
verdict = NET_DROP;
490491
goto done;
491492
}
@@ -1339,7 +1340,7 @@ void net_if_start_dad(struct net_if *iface)
13391340

13401341
net_if_lock(iface);
13411342

1342-
NET_DBG("Starting DAD for iface %p", iface);
1343+
NET_DBG("Starting DAD for iface %d", net_if_get_by_iface(iface));
13431344

13441345
ret = net_if_config_ipv6_get(iface, &ipv6);
13451346
if (ret < 0) {
@@ -1532,8 +1533,8 @@ static void rs_timeout(struct k_work *work)
15321533
}
15331534

15341535
if (iface) {
1535-
NET_DBG("RS no respond iface %p count %d",
1536-
iface, ipv6->rs_count);
1536+
NET_DBG("RS no respond iface %d count %d",
1537+
net_if_get_by_iface(iface), ipv6->rs_count);
15371538
if (ipv6->rs_count < RS_COUNT) {
15381539
net_if_start_rs(iface);
15391540
}
@@ -1560,7 +1561,7 @@ void net_if_start_rs(struct net_if *iface)
15601561

15611562
net_if_unlock(iface);
15621563

1563-
NET_DBG("Starting ND/RS for iface %p", iface);
1564+
NET_DBG("Starting ND/RS for iface %d", net_if_get_by_iface(iface));
15641565

15651566
if (!net_ipv6_start_rs(iface)) {
15661567
ipv6->rs_start = k_uptime_get_32();
@@ -1591,7 +1592,7 @@ void net_if_stop_rs(struct net_if *iface)
15911592
goto out;
15921593
}
15931594

1594-
NET_DBG("Stopping ND/RS for iface %p", iface);
1595+
NET_DBG("Stopping ND/RS for iface %d", net_if_get_by_iface(iface));
15951596

15961597
k_mutex_lock(&lock, K_FOREVER);
15971598
sys_slist_find_and_remove(&active_rs_timers, &ipv6->rs_node);
@@ -4357,9 +4358,9 @@ void net_if_ipv4_start_acd(struct net_if *iface, struct net_if_addr *ifaddr)
43574358
net_sprint_ipv4_addr(&ifaddr->address.in_addr));
43584359

43594360
if (net_ipv4_acd_start(iface, ifaddr) != 0) {
4360-
NET_DBG("Failed to start ACD for %s on iface %p.",
4361+
NET_DBG("Failed to start ACD for %s on iface %d.",
43614362
net_sprint_ipv4_addr(&ifaddr->address.in_addr),
4362-
iface);
4363+
net_if_get_by_iface(iface));
43634364

43644365
/* Just act as if no conflict was detected. */
43654366
net_if_ipv4_acd_succeeded(iface, ifaddr);
@@ -4379,7 +4380,7 @@ void net_if_start_acd(struct net_if *iface)
43794380

43804381
net_if_lock(iface);
43814382

4382-
NET_DBG("Starting ACD for iface %p", iface);
4383+
NET_DBG("Starting ACD for iface %d", net_if_get_by_iface(iface));
43834384

43844385
ret = net_if_config_ipv4_get(iface, &ipv4);
43854386
if (ret < 0) {
@@ -5835,7 +5836,7 @@ int net_if_down(struct net_if *iface)
58355836
{
58365837
int status = 0;
58375838

5838-
NET_DBG("iface %p", iface);
5839+
NET_DBG("iface %d", net_if_get_by_iface(iface));
58395840

58405841
net_if_lock(iface);
58415842

0 commit comments

Comments
 (0)