mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-12 09:17:44 +03:00
networkd: add support for peer address
This patch adds peer address support for networkd . In the [Address] a new configurable param is Peer. [Match] Name=ipip-tun [Address] Address=10.0.0.1/32 Peer=10.0.0.2/32
This commit is contained in:
parent
58587a7a0c
commit
c081882f07
@ -345,13 +345,25 @@ int address_configure(Address *address, Link *link,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address->family == AF_INET) {
|
if (!in_addr_null(address->family, &address->in_addr_peer)) {
|
||||||
r = sd_rtnl_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
|
if (address->family == AF_INET)
|
||||||
|
r = sd_rtnl_message_append_in_addr(req, IFA_ADDRESS, &address->in_addr_peer.in);
|
||||||
|
else if (address->family == AF_INET6)
|
||||||
|
r = sd_rtnl_message_append_in6_addr(req, IFA_ADDRESS, &address->in_addr_peer.in6);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_error("Could not append IFA_BROADCAST attribute: %s",
|
log_error("Could not append IFA_ADDRESS attribute: %s",
|
||||||
strerror(-r));
|
strerror(-r));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (address->family == AF_INET) {
|
||||||
|
r = sd_rtnl_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
|
||||||
|
if (r < 0) {
|
||||||
|
log_error("Could not append IFA_BROADCAST attribute: %s",
|
||||||
|
strerror(-r));
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address->label) {
|
if (address->label) {
|
||||||
@ -488,6 +500,7 @@ int config_parse_address(const char *unit,
|
|||||||
Network *network = userdata;
|
Network *network = userdata;
|
||||||
_cleanup_address_free_ Address *n = NULL;
|
_cleanup_address_free_ Address *n = NULL;
|
||||||
_cleanup_free_ char *address = NULL;
|
_cleanup_free_ char *address = NULL;
|
||||||
|
union in_addr_union *addr;
|
||||||
const char *e;
|
const char *e;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -507,6 +520,11 @@ int config_parse_address(const char *unit,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
if (streq(lvalue, "Address"))
|
||||||
|
addr = &n->in_addr;
|
||||||
|
else
|
||||||
|
addr = &n->in_addr_peer;
|
||||||
|
|
||||||
/* Address=address/prefixlen */
|
/* Address=address/prefixlen */
|
||||||
|
|
||||||
/* prefixlen */
|
/* prefixlen */
|
||||||
@ -532,7 +550,7 @@ int config_parse_address(const char *unit,
|
|||||||
return log_oom();
|
return log_oom();
|
||||||
}
|
}
|
||||||
|
|
||||||
r = net_parse_inaddr(address, &n->family, &n->in_addr);
|
r = net_parse_inaddr(address, &n->family, addr);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
|
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
|
||||||
"Address is invalid, ignoring assignment: %s", address);
|
"Address is invalid, ignoring assignment: %s", address);
|
||||||
|
@ -39,6 +39,7 @@ Network.DNS, config_parse_dns, 0,
|
|||||||
Network.NTP, config_parse_dns, 0, offsetof(Network, ntp)
|
Network.NTP, config_parse_dns, 0, offsetof(Network, ntp)
|
||||||
Network.Tunnel, config_parse_tunnel, 0, offsetof(Network, tunnel)
|
Network.Tunnel, config_parse_tunnel, 0, offsetof(Network, tunnel)
|
||||||
Address.Address, config_parse_address, 0, 0
|
Address.Address, config_parse_address, 0, 0
|
||||||
|
Address.Peer, config_parse_address, 0, 0
|
||||||
Address.Broadcast, config_parse_broadcast, 0, 0
|
Address.Broadcast, config_parse_broadcast, 0, 0
|
||||||
Address.Label, config_parse_label, 0, 0
|
Address.Label, config_parse_label, 0, 0
|
||||||
Route.Gateway, config_parse_gateway, 0, 0
|
Route.Gateway, config_parse_gateway, 0, 0
|
||||||
|
@ -211,6 +211,7 @@ struct Address {
|
|||||||
struct ifa_cacheinfo cinfo;
|
struct ifa_cacheinfo cinfo;
|
||||||
|
|
||||||
union in_addr_union in_addr;
|
union in_addr_union in_addr;
|
||||||
|
union in_addr_union in_addr_peer;
|
||||||
|
|
||||||
LIST_FIELDS(Address, addresses);
|
LIST_FIELDS(Address, addresses);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user