Merge pull request #12576 from ssahani/fou

networkd: FOU tunnel support Local and Peer tunnel addresses
This commit is contained in:
Yu Watanabe 2019-05-16 05:10:35 +02:00 committed by GitHub
commit db439337f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 152 additions and 13 deletions

View File

@ -1310,6 +1310,18 @@
<varname>Encapsulation=GenericUDPEncapsulation</varname>, this must not be specified.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Peer=</varname></term>
<listitem>
<para>Configures peer IP address.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Local=</varname></term>
<listitem>
<para>Configures local IP address.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>

View File

@ -1,3 +1,6 @@
The files in this directory are copied from kernel-5.0, and the following modifications are applied:
The files in this directory are copied from current kernel master
(b06ed1e7a2fa9b636f368a9e97c3c8877623f8b2) or WireGuard master
(8416093498ac2c754536dad4757c5d86c9ba8809), and the following
modifications are applied:
- btrfs.h: drop '__user' attributes
- if.h: drop '#include <linux/compiler.h>' and '__user' attributes

View File

@ -135,7 +135,7 @@ struct btrfs_scrub_progress {
__u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */
__u64 read_errors; /* # of read errors encountered (EIO) */
__u64 csum_errors; /* # of failed csum checks */
__u64 verify_errors; /* # of occurrences, where the metadata
__u64 verify_errors; /* # of occurences, where the metadata
* of a tree block did not match the
* expected values, like generation or
* logical */
@ -155,7 +155,7 @@ struct btrfs_scrub_progress {
__u64 last_physical; /* last physical address scrubbed. In
* case a scrub was aborted, this can
* be used to restart the scrub */
__u64 unverified_errors; /* # of occurrences where a read for a
__u64 unverified_errors; /* # of occurences where a read for a
* full (64k) bio failed, but the re-
* check succeeded for each 4k piece.
* Intermittent error. */
@ -837,6 +837,8 @@ enum btrfs_err_code {
struct btrfs_ioctl_vol_args)
#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
struct btrfs_ioctl_vol_args)
#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \
struct btrfs_ioctl_vol_args)
/* trans start and trans end are dangerous, and only for
* use by applications that know how to avoid the
* resulting deadlocks

View File

@ -54,7 +54,7 @@
/* for storing balance parameters in the root tree */
#define BTRFS_BALANCE_OBJECTID -4ULL
/* orphan objectid for tracking unlinked/truncated files */
/* orhpan objectid for tracking unlinked/truncated files */
#define BTRFS_ORPHAN_OBJECTID -5ULL
/* does write ahead logging to speed up fsyncs */
@ -270,7 +270,7 @@
#define BTRFS_PERSISTENT_ITEM_KEY 249
/*
* Persistently stores the device replace state in the device tree.
* Persistantly stores the device replace state in the device tree.
* The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0).
*/
#define BTRFS_DEV_REPLACE_KEY 250
@ -307,6 +307,8 @@
*
* Used by:
* struct btrfs_dir_item.type
*
* Values 0..7 must match common file type values in fs_types.h.
*/
#define BTRFS_FT_UNKNOWN 0
#define BTRFS_FT_REG_FILE 1

View File

@ -16,6 +16,12 @@ enum {
FOU_ATTR_IPPROTO, /* u8 */
FOU_ATTR_TYPE, /* u8 */
FOU_ATTR_REMCSUM_NOPARTIAL, /* flag */
FOU_ATTR_LOCAL_V4, /* u32 */
FOU_ATTR_LOCAL_V6, /* in6_addr */
FOU_ATTR_PEER_V4, /* u32 */
FOU_ATTR_PEER_V6, /* in6_addr */
FOU_ATTR_PEER_PORT, /* u16 */
FOU_ATTR_IFINDEX, /* s32 */
__FOU_ATTR_MAX,
};

View File

@ -179,7 +179,7 @@ enum {
};
/*
* Device mapping structure. I'd just gone off and designed a
* Device mapping structure. I'd just gone off and designed a
* beautiful scheme using only loadable modules with arguments
* for driver options and along come the PCMCIA people 8)
*
@ -193,7 +193,7 @@ enum {
struct ifmap {
unsigned long mem_start;
unsigned long mem_end;
unsigned short base_addr;
unsigned short base_addr;
unsigned char irq;
unsigned char dma;
unsigned char port;
@ -233,7 +233,7 @@ struct ifreq {
{
char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
} ifr_ifrn;
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;

View File

@ -117,6 +117,30 @@ struct ad_info {
__u8 partner_system[ETH_ALEN];
};
/* Embedded inside LINK_XSTATS_TYPE_BOND */
enum {
BOND_XSTATS_UNSPEC,
BOND_XSTATS_3AD,
__BOND_XSTATS_MAX
};
#define BOND_XSTATS_MAX (__BOND_XSTATS_MAX - 1)
/* Embedded inside BOND_XSTATS_3AD */
enum {
BOND_3AD_STAT_LACPDU_RX,
BOND_3AD_STAT_LACPDU_TX,
BOND_3AD_STAT_LACPDU_UNKNOWN_RX,
BOND_3AD_STAT_LACPDU_ILLEGAL_RX,
BOND_3AD_STAT_MARKER_RX,
BOND_3AD_STAT_MARKER_TX,
BOND_3AD_STAT_MARKER_RESP_RX,
BOND_3AD_STAT_MARKER_RESP_TX,
BOND_3AD_STAT_MARKER_UNKNOWN_RX,
BOND_3AD_STAT_PAD,
__BOND_3AD_STAT_MAX
};
#define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
#endif /* _LINUX_IF_BONDING_H */
/*

View File

@ -109,6 +109,7 @@
#define ETH_P_QINQ2 0x9200 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_QINQ3 0x9300 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_DSA_8021Q 0xDADB /* Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */
#define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */

View File

@ -925,6 +925,7 @@ enum {
enum {
LINK_XSTATS_TYPE_UNSPEC,
LINK_XSTATS_TYPE_BRIDGE,
LINK_XSTATS_TYPE_BOND,
__LINK_XSTATS_TYPE_MAX
};
#define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1)

View File

@ -60,6 +60,7 @@
#define TUNSETSTEERINGEBPF _IOR('T', 224, int)
#define TUNSETFILTEREBPF _IOR('T', 225, int)
#define TUNSETCARRIER _IOW('T', 226, int)
#define TUNGETDEVNETNS _IO('T', 227)
/* TUNSETIFF ifr flags */
#define IFF_TUN 0x0001

View File

@ -292,10 +292,11 @@ struct sockaddr_in {
#define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000)
/* Defines for Multicast INADDR */
#define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */
#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
#define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */
#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
#define INADDR_ALLSNOOPERS_GROUP 0xe000006aU /* 224.0.0.106 */
#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
#endif
/* <asm/byteorder.h> contains the htonl type stuff.. */

View File

@ -178,13 +178,14 @@ struct in6_flowlabel_req {
#define IPV6_JOIN_ANYCAST 27
#define IPV6_LEAVE_ANYCAST 28
#define IPV6_MULTICAST_ALL 29
#define IPV6_ROUTER_ALERT_ISOLATE 30
/* IPV6_MTU_DISCOVER values */
#define IPV6_PMTUDISC_DONT 0
#define IPV6_PMTUDISC_WANT 1
#define IPV6_PMTUDISC_DO 2
#define IPV6_PMTUDISC_PROBE 3
/* same as IPV6_PMTUDISC_PROBE, provided for symmetry with IPv4
/* same as IPV6_PMTUDISC_PROBE, provided for symetry with IPv4
* also see comments on IP_PMTUDISC_INTERFACE
*/
#define IPV6_PMTUDISC_INTERFACE 4

13
src/basic/linux/update.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -eu
for i in *.h */*.h; do
if [[ $i == 'wireguard.h' ]]; then
curl https://raw.githubusercontent.com/WireGuard/WireGuard/master/src/uapi/$i -o $i
else
curl https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/$i -o $i
fi
sed -i -e 's/__user //g' -e '/^#include <linux\/compiler.h>/ d' $i
done

View File

@ -803,6 +803,12 @@ static const NLType genl_fou_types[] = {
[FOU_ATTR_IPPROTO] = { .type = NETLINK_TYPE_U8 },
[FOU_ATTR_TYPE] = { .type = NETLINK_TYPE_U8 },
[FOU_ATTR_REMCSUM_NOPARTIAL] = { .type = NETLINK_TYPE_FLAG },
[FOU_ATTR_LOCAL_V4] = { .type = NETLINK_TYPE_IN_ADDR },
[FOU_ATTR_PEER_V4] = { .type = NETLINK_TYPE_IN_ADDR },
[FOU_ATTR_LOCAL_V6] = { .type = NETLINK_TYPE_IN_ADDR },
[FOU_ATTR_PEER_V6] = { .type = NETLINK_TYPE_IN_ADDR},
[FOU_ATTR_PEER_PORT] = { .type = NETLINK_TYPE_U16},
[FOU_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32},
};
static const NLTypeSystem genl_fou_type_system = {

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <linux/fou.h>
#include <net/if.h>
#include <netinet/in.h>
#include <linux/ip.h>
@ -69,6 +70,26 @@ static int netdev_fill_fou_tunnel_message(NetDev *netdev, sd_netlink_message **r
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append FOU_ATTR_IPPROTO attribute: %m");
if (t->local_family == AF_INET) {
r = sd_netlink_message_append_in_addr(m, FOU_ATTR_LOCAL_V4, &t->local.in);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append FOU_ATTR_LOCAL_V4 attribute: %m");
} else {
r = sd_netlink_message_append_in6_addr(m, FOU_ATTR_LOCAL_V6, &t->local.in6);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append FOU_ATTR_LOCAL_V6 attribute: %m");
}
if (t->peer_family == AF_INET) {
r = sd_netlink_message_append_in_addr(m, FOU_ATTR_PEER_V4, &t->peer.in);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append FOU_ATTR_PEER_V4 attribute: %m");
} else {
r = sd_netlink_message_append_in6_addr(m, FOU_ATTR_PEER_V6, &t->peer.in6);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append FOU_ATTR_PEER_V6 attribute: %m");
}
*ret = TAKE_PTR(m);
return 0;
}
@ -150,6 +171,41 @@ int config_parse_ip_protocol(
return 0;
}
int config_parse_fou_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) {
union in_addr_union *addr = data;
FouTunnel *t = userdata;
int r, *f;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (streq(lvalue, "Local"))
f = &t->local_family;
else
f = &t->peer_family;
r = in_addr_from_string_auto(rvalue, f, addr);
if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r,
"Foo over UDP tunnel '%s' address is invalid, ignoring assignment: %s",
lvalue, rvalue);
return 0;
}
static int netdev_fou_tunnel_verify(NetDev *netdev, const char *filename) {
FouTunnel *t;

View File

@ -22,7 +22,12 @@ typedef struct FouTunnel {
uint16_t port;
int local_family;
int peer_family;
FooOverUDPEncapType fou_encap_type;
union in_addr_union local;
union in_addr_union peer;
} FouTunnel;
DEFINE_NETDEV_CAST(FOU, FouTunnel);
@ -33,3 +38,4 @@ FooOverUDPEncapType fou_encap_type_from_string(const char *d) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_fou_encap_type);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_protocol);
CONFIG_PARSER_PROTOTYPE(config_parse_fou_tunnel_address);

View File

@ -81,6 +81,8 @@ Tunnel.ISATAP, config_parse_tristate,
FooOverUDP.Protocol, config_parse_ip_protocol, 0, offsetof(FouTunnel, fou_protocol)
FooOverUDP.Encapsulation, config_parse_fou_encap_type, 0, offsetof(FouTunnel, fou_encap_type)
FooOverUDP.Port, config_parse_ip_port, 0, offsetof(FouTunnel, port)
FooOverUDP.Local, config_parse_fou_tunnel_address, 0, offsetof(FouTunnel, local)
FooOverUDP.Peer, config_parse_fou_tunnel_address, 0, offsetof(FouTunnel, peer)
L2TP.TunnelId, config_parse_l2tp_tunnel_id, 0, offsetof(L2tpTunnel, tunnel_id)
L2TP.PeerTunnelId, config_parse_l2tp_tunnel_id, 0, offsetof(L2tpTunnel, peer_tunnel_id)
L2TP.UDPSourcePort, config_parse_ip_port, 0, offsetof(L2tpTunnel, l2tp_udp_sport)

View File

@ -141,6 +141,8 @@ DynamicTransmitLoadBalancing=
Protocol=
Port=
Encapsulation=
Local=
Peer=
[Tap]
MultiQueue=
OneQueue=