+/* 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>
/* 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);
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");
log_netdev_debug(netdev, "Creating");
-
return r;
}
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,
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,
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;
.sections = "Match\0NetDev\0GENEVE\0",
.create = netdev_geneve_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
+ .config_verify = netdev_geneve_verify,
};