networkd-netdev-tunnel.c revision 9011ce771f149ba45e8ffdb2ae4f0950cdbc6b8b
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Susant Sahani
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/>.
***/
#include <linux/if_tunnel.h>
#include <linux/ip6_tunnel.h>
#include "sd-rtnl.h"
#include "networkd-netdev-tunnel.h"
#include "networkd-link.h"
#include "util.h"
#include "missing.h"
#include "conf-parser.h"
#define DEFAULT_TNL_HOP_LIMIT 64
static const char* const ip6tnl_mode_table[_NETDEV_IP6_TNL_MODE_MAX] = {
[NETDEV_IP6_TNL_MODE_IP6IP6] = "ip6ip6",
[NETDEV_IP6_TNL_MODE_IPIP6] = "ipip6",
[NETDEV_IP6_TNL_MODE_ANYIP6] = "any",
};
DEFINE_CONFIG_PARSE_ENUM(config_parse_ip6tnl_mode, ip6tnl_mode, Ip6TnlMode, "Failed to parse ip6 tunnel Mode");
int r;
assert(m);
assert(t);
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
return r;
}
int r;
assert(m);
assert(t);
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
return r;
}
Tunnel *t;
int r;
else
assert(t);
assert(m);
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
return r;
}
Tunnel *t;
int r;
else
assert(t);
assert(m);
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
return r;
}
int r;
assert(m);
assert(t);
if (r < 0)
if (r < 0)
if (r < 0)
return r;
}
int r;
assert(m);
assert(t);
if (r < 0)
if (r < 0)
if (r < 0)
return r;
}
int r;
assert(m);
assert(t);
if (r < 0)
if (r < 0)
if (r < 0)
if (r < 0)
switch (t->ip6tnl_mode) {
break;
break;
default:
proto = 0;
break;
}
if (r < 0)
return r;
}
case NETDEV_KIND_IPIP:
break;
case NETDEV_KIND_SIT:
break;
case NETDEV_KIND_GRE:
break;
case NETDEV_KIND_GRETAP:
break;
case NETDEV_KIND_IP6GRE:
break;
case NETDEV_KIND_IP6GRETAP:
break;
case NETDEV_KIND_VTI:
break;
case NETDEV_KIND_VTI6:
break;
case NETDEV_KIND_IP6TNL:
break;
default:
assert_not_reached("Invalid tunnel kind");
}
assert(t);
return -EINVAL;
}
return -EINVAL;
}
if (t->ip6tnl_mode == _NETDEV_IP6_TNL_MODE_INVALID) {
return -EINVAL;
}
}
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) {
int r, f;
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Tunnel address is invalid, ignoring assignment: %s", rvalue);
return 0;
}
log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Tunnel addresses incompatible, ignoring assignment: %s", rvalue);
return 0;
}
t->family = f;
return 0;
}
assert(n);
assert(t);
t->pmtudisc = true;
}
assert(n);
assert(t);
t->pmtudisc = true;
}
assert(n);
if (n->kind == NETDEV_KIND_VTI)
t = VTI(n);
else
t = VTI6(n);
assert(t);
t->pmtudisc = true;
}
Tunnel *t;
assert(n);
if (n->kind == NETDEV_KIND_GRE)
t = GRE(n);
else
t = GRETAP(n);
assert(t);
t->pmtudisc = true;
}
static void ip6gre_init(NetDev *n) {
Tunnel *t;
assert(n);
if (n->kind == NETDEV_KIND_IP6GRE)
t = IP6GRE(n);
else
t = IP6GRETAP(n);
assert(t);
t->ttl = DEFAULT_TNL_HOP_LIMIT;
}
static void ip6tnl_init(NetDev *n) {
assert(n);
assert(t);
t->ttl = DEFAULT_TNL_HOP_LIMIT;
}
const NetDevVTable ipip_vtable = {
.object_size = sizeof(Tunnel),
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable sit_vtable = {
.object_size = sizeof(Tunnel),
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable vti_vtable = {
.object_size = sizeof(Tunnel),
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable vti6_vtable = {
.object_size = sizeof(Tunnel),
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable gre_vtable = {
.object_size = sizeof(Tunnel),
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable gretap_vtable = {
.object_size = sizeof(Tunnel),
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable ip6gre_vtable = {
.object_size = sizeof(Tunnel),
.init = ip6gre_init,
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable ip6gretap_vtable = {
.object_size = sizeof(Tunnel),
.init = ip6gre_init,
.sections = "Match\0NetDev\0Tunnel\0",
};
const NetDevVTable ip6tnl_vtable = {
.object_size = sizeof(Tunnel),
.init = ip6tnl_init,
.sections = "Match\0NetDev\0Tunnel\0",
};