summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-11-17 21:01:20 +0100
committerTom Gundersen <teg@jklm.no>2013-11-17 23:11:11 +0100
commit8cd11a0f0f4ca05199e1166f6a07472b296f7455 (patch)
treed9971380a1327d4bb7f392bb67d7c2c5d75f3184 /src
parent16be43684f6d9bbd494b157682f5473460fbf98a (diff)
networkd: store netmask and mac address explicitly
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-address.c5
-rw-r--r--src/network/networkd-link.c6
-rw-r--r--src/network/networkd.h3
3 files changed, 12 insertions, 2 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index e02b1df864..75a9bae201 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -78,8 +78,7 @@ int address_configure(Manager *manager, Address *address, Link *link) {
if (address->family == AF_INET) {
struct in_addr broadcast;
- broadcast.s_addr = address->in_addr.in.s_addr |
- htonl(0xfffffffflu >> address->prefixlen);
+ broadcast.s_addr = address->in_addr.in.s_addr | address->netmask.s_addr;
r = sd_rtnl_message_append(req, IFA_BROADCAST, &broadcast);
if (r < 0) {
@@ -147,6 +146,8 @@ int config_parse_address(const char *unit,
}
n->prefixlen = (unsigned char) i;
+ n->netmask.s_addr = htonl(0xfffffffflu >> n->prefixlen);
+
address = strndup(rvalue, e - rvalue);
if (!address)
return log_oom();
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 085b8db2f8..d0a3dccd9b 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -29,6 +29,7 @@
int link_new(Manager *manager, struct udev_device *device, Link **ret) {
_cleanup_link_free_ Link *link = NULL;
uint64_t ifindex;
+ const char *mac;
int r;
assert(device);
@@ -42,6 +43,11 @@ int link_new(Manager *manager, struct udev_device *device, Link **ret) {
if (ifindex <= 0)
return -EINVAL;
+ mac = udev_device_get_sysattr_value(device, "address");
+ if (!mac)
+ return -EINVAL;
+
+ memcpy(&link->mac.ether_addr_octet[0], ether_aton(mac), ETH_ALEN);
link->ifindex = ifindex;
link->manager = manager;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index fd3b60a6cb..c019ceca76 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -64,6 +64,8 @@ struct Address {
unsigned char prefixlen;
char *label;
+ struct in_addr netmask;
+
union {
struct in_addr in;
struct in6_addr in6;
@@ -89,6 +91,7 @@ struct Link {
Manager *manager;
int ifindex;
+ struct ether_addr mac;
unsigned flags;