]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/netdev/l2tp-tunnel.c
tree-wide: define iterator inside of the macro
[thirdparty/systemd.git] / src / network / netdev / l2tp-tunnel.c
index 6ac23052bb3ce94ed37a6ba4852ac62869d63468..949f124ccd66fdeb46a0a73677fb57f97d44605b 100644 (file)
@@ -4,12 +4,9 @@
 #include <linux/l2tp.h>
 #include <linux/genetlink.h>
 
-#include "sd-netlink.h"
-
 #include "conf-parser.h"
 #include "hashmap.h"
 #include "l2tp-tunnel.h"
-#include "missing.h"
 #include "netlink-util.h"
 #include "networkd-address.h"
 #include "networkd-manager.h"
@@ -47,7 +44,7 @@ static void l2tp_session_free(L2tpSession *s) {
                 return;
 
         if (s->tunnel && s->section)
-                ordered_hashmap_remove(s->tunnel->sessions_by_section, s);
+                ordered_hashmap_remove(s->tunnel->sessions_by_section, s->section);
 
         network_config_section_free(s->section);
 
@@ -278,7 +275,6 @@ static int l2tp_acquire_local_address_one(L2tpTunnel *t, Address *a, union in_ad
 
 static int l2tp_acquire_local_address(L2tpTunnel *t, Link *link, union in_addr_union *ret) {
         Address *a;
-        Iterator i;
 
         assert(t);
         assert(link);
@@ -291,11 +287,11 @@ static int l2tp_acquire_local_address(L2tpTunnel *t, Link *link, union in_addr_u
                 return 0;
         }
 
-        SET_FOREACH(a, link->addresses, i)
+        SET_FOREACH(a, link->addresses)
                 if (l2tp_acquire_local_address_one(t, a, ret) >= 0)
                         return 1;
 
-        SET_FOREACH(a, link->addresses_foreign, i)
+        SET_FOREACH(a, link->addresses_foreign)
                 if (l2tp_acquire_local_address_one(t, a, ret) >= 0)
                         return 1;
 
@@ -351,7 +347,6 @@ static int l2tp_create_session(NetDev *netdev, L2tpSession *session) {
 static int l2tp_create_tunnel_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) {
         L2tpSession *session;
         L2tpTunnel *t;
-        Iterator i;
         int r;
 
         assert(netdev);
@@ -373,7 +368,7 @@ static int l2tp_create_tunnel_handler(sd_netlink *rtnl, sd_netlink_message *m, N
 
         log_netdev_debug(netdev, "L2TP tunnel is created");
 
-        ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section, i)
+        ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section)
                 (void) l2tp_create_session(netdev, session);
 
         return 1;
@@ -462,7 +457,7 @@ int config_parse_l2tp_tunnel_address(
         else
                 r = in_addr_from_string(t->family, rvalue, addr);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r,
+                log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Invalid L2TP Tunnel address specified in %s='%s', ignoring assignment: %m", lvalue, rvalue);
                 return 0;
         }
@@ -492,13 +487,13 @@ int config_parse_l2tp_tunnel_id(
 
         r = safe_atou32(rvalue, &k);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r,
+                log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to parse L2TP tunnel id. Ignoring assignment: %s", rvalue);
                 return 0;
         }
 
         if (k == 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r,
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
                            "Invalid L2TP tunnel id. Ignoring assignment: %s", rvalue);
                 return 0;
         }
@@ -533,17 +528,17 @@ int config_parse_l2tp_session_id(
 
         r = l2tp_session_new_static(t, filename, section_line, &session);
         if (r < 0)
-                return r;
+                return log_oom();
 
         r = safe_atou32(rvalue, &k);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r,
+                log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to parse L2TP session id. Ignoring assignment: %s", rvalue);
                 return 0;
         }
 
         if (k == 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r,
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
                            "Invalid L2TP session id. Ignoring assignment: %s", rvalue);
                 return 0;
         }
@@ -582,11 +577,11 @@ int config_parse_l2tp_session_l2spec(
 
         r = l2tp_session_new_static(t, filename, section_line, &session);
         if (r < 0)
-                return r;
+                return log_oom();
 
         spec = l2tp_l2spec_type_from_string(rvalue);
         if (spec < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, 0,
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
                            "Failed to parse layer2 specific header type. Ignoring assignment: %s", rvalue);
                 return 0;
         }
@@ -621,10 +616,10 @@ int config_parse_l2tp_session_name(
 
         r = l2tp_session_new_static(t, filename, section_line, &session);
         if (r < 0)
-                return r;
+                return log_oom();
 
         if (!ifname_valid(rvalue)) {
-                log_syntax(unit, LOG_ERR, filename, line, 0,
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
                            "Failed to parse L2TP tunnel session name. Ignoring assignment: %s", rvalue);
                 return 0;
         }
@@ -680,7 +675,6 @@ static int l2tp_session_verify(L2tpSession *session) {
 static int netdev_l2tp_tunnel_verify(NetDev *netdev, const char *filename) {
         L2tpTunnel *t;
         L2tpSession *session;
-        Iterator i;
 
         assert(netdev);
         assert(filename);
@@ -704,7 +698,7 @@ static int netdev_l2tp_tunnel_verify(NetDev *netdev, const char *filename) {
                                               "%s: L2TP tunnel without tunnel IDs configured. Ignoring",
                                               filename);
 
-        ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section, i)
+        ORDERED_HASHMAP_FOREACH(session, t->sessions_by_section)
                 if (l2tp_session_verify(session) < 0)
                         l2tp_session_free(session);
 
@@ -726,7 +720,7 @@ static void l2tp_tunnel_done(NetDev *netdev) {
 const NetDevVTable l2tptnl_vtable = {
         .object_size = sizeof(L2tpTunnel),
         .init = l2tp_tunnel_init,
-        .sections = "Match\0NetDev\0L2TP\0L2TPSession\0",
+        .sections = NETDEV_COMMON_SECTIONS "L2TP\0L2TPSession\0",
         .create_after_configured = l2tp_create_tunnel,
         .done = l2tp_tunnel_done,
         .create_type = NETDEV_CREATE_AFTER_CONFIGURED,