]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/l2tp: downgrade log level of several messages
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 9 Sep 2024 18:05:18 +0000 (03:05 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 10 Sep 2024 10:30:17 +0000 (19:30 +0900)
Also, use log_section_warning_errno() where applicable.

src/network/netdev/l2tp-tunnel.c

index 3194f3f785c856096d4bce6bf656af92f04cc7cd..9f8287cb91107aabe00b6f4ea3b73601ceff6bd8 100644 (file)
@@ -752,28 +752,28 @@ static void l2tp_tunnel_init(NetDev *netdev) {
         t->udp6_csum_tx = true;
 }
 
-static int l2tp_session_verify(L2tpSession *session) {
-        NetDev *netdev;
+#define log_session(session, fmt, ...)                                  \
+        ({                                                              \
+                const L2tpSession *_session = (session);                \
+                log_section_warning_errno(                              \
+                                _session ? _session->section : NULL,    \
+                                SYNTHETIC_ERRNO(EINVAL),                \
+                                fmt " Ignoring [L2TPSession] section.", \
+                                ##__VA_ARGS__);                         \
+        })
 
+static int l2tp_session_verify(L2tpSession *session) {
         assert(session);
         assert(session->tunnel);
 
-        netdev = NETDEV(session->tunnel);
-
         if (section_is_invalid(session->section))
                 return -EINVAL;
 
         if (!session->name)
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "%s: L2TP session without name configured. "
-                                              "Ignoring [L2TPSession] section from line %u",
-                                              session->section->filename, session->section->line);
+                return log_session(session, "L2TP session without name configured.");
 
         if (session->session_id == 0 || session->peer_session_id == 0)
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "%s: L2TP session without session IDs configured. "
-                                              "Ignoring [L2TPSession] section from line %u",
-                                              session->section->filename, session->section->line);
+                return log_session(session, "L2TP session without session IDs configured.");
 
         return 0;
 }
@@ -785,19 +785,19 @@ static int netdev_l2tp_tunnel_verify(NetDev *netdev, const char *filename) {
         L2tpSession *session;
 
         if (!IN_SET(t->family, AF_INET, AF_INET6))
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "%s: L2TP tunnel with invalid address family configured. Ignoring",
-                                              filename);
+                return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
+                                                "%s: L2TP tunnel with invalid address family configured. Ignoring",
+                                                filename);
 
         if (!in_addr_is_set(t->family, &t->remote))
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "%s: L2TP tunnel without a remote address configured. Ignoring",
-                                              filename);
+                return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
+                                                "%s: L2TP tunnel without a remote address configured. Ignoring",
+                                                filename);
 
         if (t->tunnel_id == 0 || t->peer_tunnel_id == 0)
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "%s: L2TP tunnel without tunnel IDs configured. Ignoring",
-                                              filename);
+                return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
+                                                "%s: L2TP tunnel without tunnel IDs configured. Ignoring",
+                                                filename);
 
         ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section)
                 if (l2tp_session_verify(session) < 0)