summaryrefslogtreecommitdiff
path: root/src/network/netdev
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@gmail.com>2019-05-16 12:16:19 +0530
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-05-18 10:25:36 +0900
commit8f02c9b0850152e2c0d09e53e9572a5c478f30c9 (patch)
tree6d1ae30b9fa6e1cd5b1b9c0c9041ed6ecef6bc38 /src/network/netdev
parentbe44e091621a71525b850c84fc149c644a63f779 (diff)
downloadsystemd-8f02c9b0850152e2c0d09e53e9572a5c478f30c9.tar.gz
networkd: FOU netdev add support to configure peer port
Diffstat (limited to 'src/network/netdev')
-rw-r--r--src/network/netdev/fou-tunnel.c18
-rw-r--r--src/network/netdev/fou-tunnel.h1
-rw-r--r--src/network/netdev/netdev-gperf.gperf1
3 files changed, 18 insertions, 2 deletions
diff --git a/src/network/netdev/fou-tunnel.c b/src/network/netdev/fou-tunnel.c
index 6ce2e5aec9..772f3db5e7 100644
--- a/src/network/netdev/fou-tunnel.c
+++ b/src/network/netdev/fou-tunnel.c
@@ -47,6 +47,12 @@ 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_PORT attribute: %m");
+ if (IN_SET(t->peer_family, AF_INET, AF_INET6)) {
+ r = sd_netlink_message_append_u16(m, FOU_ATTR_PEER_PORT, htobe16(t->peer_port));
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append FOU_ATTR_PEER_PORT attribute: %m");
+ }
+
switch (t->fou_encap_type) {
case NETDEV_FOO_OVER_UDP_ENCAP_DIRECT:
encap_type = FOU_ENCAP_DIRECT;
@@ -74,7 +80,7 @@ static int netdev_fill_fou_tunnel_message(NetDev *netdev, sd_netlink_message **r
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 {
+ } else if (t->local_family == AF_INET6) {
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");
@@ -84,7 +90,7 @@ static int netdev_fill_fou_tunnel_message(NetDev *netdev, sd_netlink_message **r
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 {
+ } else if (t->peer_family == AF_INET6){
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");
@@ -233,6 +239,14 @@ static int netdev_fou_tunnel_verify(NetDev *netdev, const char *filename) {
assert_not_reached("Invalid fou encap type");
}
+ if (t->peer_family == AF_UNSPEC && t->peer_port > 0)
+ return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
+ "FooOverUDP peer port is set but peer address not configured in %s. Rejecting configuration.",
+ filename);
+ else if (t->peer_family != AF_UNSPEC && t->peer_port == 0)
+ return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
+ "FooOverUDP peer port not set but peer address is configured in %s. Rejecting configuration.",
+ filename);
return 0;
}
diff --git a/src/network/netdev/fou-tunnel.h b/src/network/netdev/fou-tunnel.h
index 0402239c69..6304e6b549 100644
--- a/src/network/netdev/fou-tunnel.h
+++ b/src/network/netdev/fou-tunnel.h
@@ -21,6 +21,7 @@ typedef struct FouTunnel {
uint8_t fou_protocol;
uint16_t port;
+ uint16_t peer_port;
int local_family;
int peer_family;
diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf
index 0e712c55ae..6a6d9dc752 100644
--- a/src/network/netdev/netdev-gperf.gperf
+++ b/src/network/netdev/netdev-gperf.gperf
@@ -81,6 +81,7 @@ 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.PeerPort, config_parse_ip_port, 0, offsetof(FouTunnel, peer_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)