#include "network-internal.h"
#include "util.h"
#include "missing.h"
+#include "conf-parser.h"
static int netdev_fill_ipip_rtnl_message(Link *link, sd_rtnl_message *m) {
netdev = link->network->tunnel;
+ assert(netdev->family == AF_INET);
+
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
if (r < 0) {
log_error_netdev(netdev,
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->local);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->local.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->remote);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->remote.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
netdev = link->network->tunnel;
+ assert(netdev->family == AF_INET);
+
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
if (r < 0) {
log_error_netdev(netdev,
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->local);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->local.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->remote);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->remote.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
netdev = link->network->tunnel;
+ assert(netdev->family == AF_INET);
+
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
if (r < 0) {
log_error_netdev(netdev,
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_LOCAL, &netdev->local);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_LOCAL, &netdev->local.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_GRE_LOCAL attribute: %s",
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_REMOTE, &netdev->remote);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_REMOTE, &netdev->remote.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_GRE_REMOTE attribute: %s",
netdev = link->network->tunnel;
+ assert(netdev->family == AF_INET);
+
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
if (r < 0) {
log_error_netdev(netdev,
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_LOCAL, &netdev->local);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_LOCAL, &netdev->local.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
return r;
}
- r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_REMOTE, &netdev->remote);
+ r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_REMOTE, &netdev->remote.in);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
return r;
}
+ link_ref(link);
+
log_debug_netdev(netdev, "Creating tunnel netdev: %s",
netdev_kind_to_string(netdev->kind));
return 0;
}
+
+int config_parse_tunnel_address(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) {
+ NetDev *n = userdata;
+ union in_addr_union *addr = data;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ r = net_parse_inaddr(rvalue, &n->family, addr);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Tunnel address is invalid, ignoring assignment: %s", rvalue);
+ return 0;
+ }
+
+ return 0;
+}