($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski at intel.com>
To: ell at lists.01.org
Subject: [PATCH 03/15] examples: Update netconfig method calls
Date: Fri, 20 May 2022 17:43:26 +0200	[thread overview]
Message-ID: <20220520154338.2056273-3-andrew.zaborowski@intel.com> (raw)
In-Reply-To: 20220520154338.2056273-1-andrew.zaborowski@intel.com

[-- Attachment #1: Type: text/plain, Size: 2472 bytes --]

---
 examples/netconfig-test.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/examples/netconfig-test.c b/examples/netconfig-test.c
index d75e4ad..aba63f9 100644
--- a/examples/netconfig-test.c
+++ b/examples/netconfig-test.c
@@ -61,16 +61,14 @@ static void signal_handler(uint32_t signo, void *user_data)
 }
 
 static void log_addresses(const char *af_str, const char *action,
-				struct l_queue *list)
+				const struct l_queue_entry *entry)
 {
-	const struct l_queue_entry *entry;
-
-	if (l_queue_isempty(list))
+	if (!entry)
 		return;
 
 	l_info("[netconfig%s] Addresses %s:", af_str, action);
 
-	for (entry = l_queue_get_entries(list); entry; entry = entry->next) {
+	for (; entry; entry = entry->next) {
 		struct l_rtnl_address *addr = entry->data;
 		char ip_str[INET6_ADDRSTRLEN];
 
@@ -83,25 +81,26 @@ static void log_addresses(const char *af_str, const char *action,
 }
 
 static void log_routes(const char *af_str, const char *action,
-			struct l_queue *list)
+			const struct l_queue_entry *entry)
 {
-	const struct l_queue_entry *entry;
-
-	if (l_queue_isempty(list))
+	if (!entry)
 		return;
 
 	l_info("[netconfig%s] Routes %s:", af_str, action);
 
-	for (entry = l_queue_get_entries(list); entry; entry = entry->next) {
+	for (; entry; entry = entry->next) {
 		struct l_rtnl_route *rt = entry->data;
-		char subnet_str[INET6_ADDRSTRLEN];
+		char subnet_str[INET6_ADDRSTRLEN] = "unknown";
 		char gateway_str[INET6_ADDRSTRLEN];
 		uint8_t prefix_len;
+		bool onlink;
 
 		l_rtnl_route_get_dst(rt, subnet_str, &prefix_len);
-		l_rtnl_route_get_gateway(rt, gateway_str);
-		l_info("[netconfig%s] \t%s/%i, gateway %s, orig lifetime %i s",
-			af_str, subnet_str, prefix_len, gateway_str,
+		onlink = !l_rtnl_route_get_gateway(rt, gateway_str);
+		l_info("[netconfig%s] \t%s/%i, %s%s, orig lifetime %i s",
+			af_str, subnet_str, prefix_len,
+			onlink ? "onlink" : "next-hop ",
+			onlink ? "" : gateway_str,
 			l_rtnl_route_get_lifetime(rt));
 	}
 }
@@ -110,7 +109,7 @@ static void event_handler(struct l_netconfig *netconfig, uint8_t family,
 				enum l_netconfig_event event, void *user_data)
 {
 	const char *af_str = family == AF_INET ? "v4" : "v6";
-	struct l_queue *added, *updated, *removed;
+	const struct l_queue_entry *added, *updated, *removed;
 
 	switch (event) {
 	case L_NETCONFIG_EVENT_CONFIGURE:
-- 
2.32.0

                 reply	other threads:[~2022-05-20 15:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220520154338.2056273-3-andrew.zaborowski@intel.com \
    --to=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).