networkd: Introduce l2tp tunnel
This works allows networkd to configure l2tp tunnel. See http://man7.org/linux/man-pages/man8/ip-l2tp.8.html
This commit is contained in:
committed by
Yu Watanabe
parent
7033af49df
commit
3a56e697c8
@@ -10,9 +10,10 @@ typedef struct {
|
||||
} genl_family;
|
||||
|
||||
static const genl_family genl_families[] = {
|
||||
[SD_GENL_ID_CTRL] = { .name = "", .version = 1 },
|
||||
[SD_GENL_ID_CTRL] = { .name = "", .version = 1 },
|
||||
[SD_GENL_WIREGUARD] = { .name = "wireguard", .version = 1 },
|
||||
[SD_GENL_FOU] = { .name = "fou", .version = 1 },
|
||||
[SD_GENL_L2TP] = { .name = "l2tp", .version = 1},
|
||||
};
|
||||
|
||||
int sd_genl_socket_open(sd_netlink **ret) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/if_bridge.h>
|
||||
#include <linux/if_link.h>
|
||||
#include <linux/if_tunnel.h>
|
||||
#include <linux/l2tp.h>
|
||||
#include <linux/veth.h>
|
||||
|
||||
#if HAVE_LINUX_FOU_H
|
||||
@@ -797,10 +798,62 @@ static const NLTypeSystem genl_fou_cmds_type_system = {
|
||||
.types = genl_fou_cmds,
|
||||
};
|
||||
|
||||
static const NLType genl_l2tp_types[] = {
|
||||
[L2TP_ATTR_PW_TYPE] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_OFFSET] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_DATA_SEQ] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_L2SPEC_TYPE] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_L2SPEC_LEN] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_PROTO_VERSION] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_IFNAME] = { .type = NETLINK_TYPE_STRING },
|
||||
[L2TP_ATTR_CONN_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_PEER_CONN_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_SESSION_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_PEER_SESSION_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_UDP_CSUM] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_VLAN_ID] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_RECV_SEQ] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_SEND_SEQ] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_LNS_MODE] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_USING_IPSEC] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_FD] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_IP_SADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_IP_DADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_UDP_SPORT] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_UDP_DPORT] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_IP6_SADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_IP6_DADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_FLAG },
|
||||
[L2TP_ATTR_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_FLAG },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_l2tp_type_system = {
|
||||
.count = ELEMENTSOF(genl_l2tp_types),
|
||||
.types = genl_l2tp_types,
|
||||
};
|
||||
|
||||
static const NLType genl_l2tp[] = {
|
||||
[L2TP_CMD_TUNNEL_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_TUNNEL_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_TUNNEL_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_TUNNEL_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_l2tp_tunnel_session_type_system = {
|
||||
.count = ELEMENTSOF(genl_l2tp),
|
||||
.types = genl_l2tp,
|
||||
};
|
||||
|
||||
static const NLType genl_families[] = {
|
||||
[SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_id_ctrl_type_system },
|
||||
[SD_GENL_WIREGUARD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_type_system },
|
||||
[SD_GENL_FOU] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_cmds_type_system},
|
||||
[SD_GENL_L2TP] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_tunnel_session_type_system },
|
||||
};
|
||||
|
||||
const NLTypeSystem genl_family_type_system_root = {
|
||||
|
||||
Reference in New Issue
Block a user