]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/netdev/geneve.c
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / network / netdev / geneve.c
index bb9807b556085b90d4ffd0d74e339a858a9f4884..f64547c76452e5217dfca4d3aee64470d4827368 100644 (file)
@@ -1,20 +1,6 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-    This file is part of systemd.
-
-    Copyright 2017 Susant Sahani
-
-    systemd is free software; you can redistribute it and/or modify it
-    under the terms of the GNU Lesser General Public License as published by
-    the Free Software Foundation; either version 2.1 of the License, or
-    (at your option) any later version.
-
-    systemd is distributed in the hope that it will be useful, but
-    WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public License
-    along with systemd; If not, see <http://www.gnu.org/licenses/>.
+  Copyright 2017 Susant Sahani
 ***/
 
 #include <net/if.h>
@@ -35,7 +21,7 @@
 
 /* callback for geneve netdev's created without a backing Link */
 static int geneve_netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
-        _cleanup_netdev_unref_ NetDev *netdev = userdata;
+        _cleanup_(netdev_unrefp) NetDev *netdev = userdata;
         int r;
 
         assert(netdev->state != _NETDEV_STATE_INVALID);
@@ -78,7 +64,7 @@ static int netdev_geneve_create(NetDev *netdev) {
                         return log_netdev_error_errno(netdev, r, "Could not append IFLA_ADDRESS attribute: %m");
         }
 
-        if (netdev->mtu) {
+        if (netdev->mtu != 0) {
                 r = sd_netlink_message_append_u32(m, IFLA_MTU, netdev->mtu);
                 if (r < 0)
                         return log_netdev_error_errno(netdev, r, "Could not append IFLA_MTU attribute: %m");
@@ -162,7 +148,6 @@ static int netdev_geneve_create(NetDev *netdev) {
 
         log_netdev_debug(netdev, "Creating");
 
-
         return r;
 }
 
@@ -201,71 +186,6 @@ int config_parse_geneve_vni(const char *unit,
         return 0;
 }
 
-int config_parse_geneve_tos(const char *unit,
-                                   const char *filename,
-                                   unsigned line,
-                                   const char *section,
-                                   unsigned section_line,
-                                   const char *lvalue,
-                                   int ltype,
-                                   const char *rvalue,
-                                   void *data,
-                                   void *userdata) {
-        Geneve *v = userdata;
-        uint8_t f;
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        r = safe_atou8(rvalue, &f);
-        if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve TOS '%s'.", rvalue);
-                return 0;
-        }
-
-        v->tos = f;
-
-        return 0;
-}
-
-int config_parse_geneve_ttl(const char *unit,
-                            const char *filename,
-                            unsigned line,
-                            const char *section,
-                            unsigned section_line,
-                            const char *lvalue,
-                            int ltype,
-                            const char *rvalue,
-                            void *data,
-                            void *userdata) {
-        Geneve *v = userdata;
-        uint8_t f;
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        r = safe_atou8(rvalue, &f);
-        if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve TTL '%s'.", rvalue);
-                return 0;
-        }
-
-        if (f == 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r, "Invalid Geneve TTL '%s'.", rvalue);
-                return 0;
-        }
-
-        v->ttl = f;
-
-        return 0;
-}
-
 int config_parse_geneve_address(const char *unit,
                                 const char *filename,
                                 unsigned line,
@@ -303,36 +223,6 @@ int config_parse_geneve_address(const char *unit,
         return 0;
 }
 
-int config_parse_geneve_destination_port(const char *unit,
-                                         const char *filename,
-                                         unsigned line,
-                                         const char *section,
-                                         unsigned section_line,
-                                         const char *lvalue,
-                                         int ltype,
-                                         const char *rvalue,
-                                         void *data,
-                                         void *userdata) {
-        Geneve *v = userdata;
-        uint16_t port;
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        r = parse_ip_port(rvalue, &port);
-        if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve destination port '%s'.", rvalue);
-                return 0;
-        }
-
-        v->dest_port = port;
-
-        return 0;
-}
-
 int config_parse_geneve_flow_label(const char *unit,
                                    const char *filename,
                                    unsigned line,
@@ -369,6 +259,21 @@ int config_parse_geneve_flow_label(const char *unit,
         return 0;
 }
 
+static int netdev_geneve_verify(NetDev *netdev, const char *filename) {
+        Geneve *v = GENEVE(netdev);
+
+        assert(netdev);
+        assert(v);
+        assert(filename);
+
+        if (v->ttl == 0) {
+                log_warning("Invalid Geneve TTL value '0' configured in '%s'. Ignoring", filename);
+                return -EINVAL;
+        }
+
+        return 0;
+}
+
 static void geneve_init(NetDev *netdev) {
         Geneve *v;
 
@@ -391,4 +296,5 @@ const NetDevVTable geneve_vtable = {
         .sections = "Match\0NetDev\0GENEVE\0",
         .create = netdev_geneve_create,
         .create_type = NETDEV_CREATE_INDEPENDENT,
+        .config_verify = netdev_geneve_verify,
 };