summaryrefslogtreecommitdiff
path: root/src/network/networkd-address.c
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2014-07-07 14:58:56 +0530
committerTom Gundersen <teg@jklm.no>2014-07-07 13:32:14 +0200
commitc081882f07617e56bcbce54105068137e4e0bb52 (patch)
tree6b249bf6c0b90eb1aa05a062e6dbe5b1f213ce7b /src/network/networkd-address.c
parent58587a7a0c3bf5595190486781d3bbc00654c6ef (diff)
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
Diffstat (limited to 'src/network/networkd-address.c')
-rw-r--r--src/network/networkd-address.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 1ba2108316..8c4ef9964b 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -345,13 +345,25 @@ int address_configure(Address *address, Link *link,
return r;
}
- if (address->family == AF_INET) {
- r = sd_rtnl_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
+ if (!in_addr_null(address->family, &address->in_addr_peer)) {
+ 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) {
- log_error("Could not append IFA_BROADCAST attribute: %s",
+ log_error("Could not append IFA_ADDRESS attribute: %s",
strerror(-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) {
@@ -488,6 +500,7 @@ int config_parse_address(const char *unit,
Network *network = userdata;
_cleanup_address_free_ Address *n = NULL;
_cleanup_free_ char *address = NULL;
+ union in_addr_union *addr;
const char *e;
int r;
@@ -507,6 +520,11 @@ int config_parse_address(const char *unit,
if (r < 0)
return r;
+ if (streq(lvalue, "Address"))
+ addr = &n->in_addr;
+ else
+ addr = &n->in_addr_peer;
+
/* Address=address/prefixlen */
/* prefixlen */
@@ -532,7 +550,7 @@ int config_parse_address(const char *unit,
return log_oom();
}
- r = net_parse_inaddr(address, &n->family, &n->in_addr);
+ r = net_parse_inaddr(address, &n->family, addr);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Address is invalid, ignoring assignment: %s", address);