[systemd-commits] 2 commits - man/systemd.link.xml src/network
Tom Gundersen
tomegun at kemper.freedesktop.org
Sun Mar 9 10:23:07 PDT 2014
man/systemd.link.xml | 32 +++++++--------
src/network/networkd-link.c | 84 ++++++++++++++++++++---------------------
src/network/networkd-network.c | 4 -
src/network/networkd.h | 1
4 files changed, 56 insertions(+), 65 deletions(-)
New commits:
commit 7abaad1ab099b077ebd6452b14ef351483831245
Author: poma <pomidorabelisima at gmail.com>
Date: Sun Mar 9 18:12:50 2014 +0100
man: fix example in systemd.link
'man/systemd.link.xml' recovery from:
commit eac684ef1c29684b1bcd27a89c38c202e568e469
Author: Tom Gundersen <teg at jklm.no>
Date: Tue Feb 25 19:30:40 2014 +0100
man: split out systemd.net{work,dev}(5) from systemd-networkd(8)
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
index 718eb8e..3ad006e 100644
--- a/man/systemd.link.xml
+++ b/man/systemd.link.xml
@@ -348,25 +348,23 @@
<refsect1>
<title>Example</title>
<example>
- <title>/etc/systemd/network/bridge.netdev</title>
+ <title>/etc/systemd/network/wireless.link</title>
- <programlisting>[NetDev]
-Name=bridge0
-Kind=bridge</programlisting>
- </example>
- </refsect1>
-
- <refsect1>
- <title>Example</title>
- <example>
- <title>/etc/systemd/network/vlan1.netdev</title>
-
- <programlisting>[NetDev]
-Name=vlan1
-Kind=vlan
+ <programlisting>[Match]
+MACAddress=12:34:56:78:9a:bc
+Driver=brcmsmac
+Path=pci-0000:02:00.0-*
+Type=wlan
+Virtualization=no
+Host=my-laptop
+Architecture=x86-64
-[VLAN]
-Id=1</programlisting>
+[Link]
+Name=wireless0
+MTUBytes=1450
+BitsPerSecond=10M
+WakeOnLan=magic
+MACAddress=cb:a9:87:65:43:21</programlisting>
</example>
</refsect1>
commit a748b692dd1e436ca1ff56b8d567c065c2539e5a
Author: Tom Gundersen <teg at jklm.no>
Date: Sun Mar 9 14:43:37 2014 +0100
network: link - simplify code a bit and remove some debug logging
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index a97e347..fdc351f 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -116,31 +116,6 @@ int link_get(Manager *m, int ifindex, Link **ret) {
return 0;
}
-int link_add(Manager *m, struct udev_device *device, Link **ret) {
- Link *link = NULL;
- Network *network;
- int r;
-
- assert(m);
- assert(device);
-
- r = link_new(m, device, &link);
- if (r < 0)
- return r;
-
- *ret = link;
-
- r = network_get(m, device, &network);
- if (r < 0)
- return r == -ENOENT ? 0 : r;
-
- r = network_apply(m, network, link);
- if (r < 0)
- return r;
-
- return 0;
-}
-
static int link_enter_configured(Link *link) {
assert(link);
assert(link->state == LINK_STATE_SETTING_ROUTES);
@@ -994,10 +969,8 @@ static int link_update_flags(Link *link, unsigned flags) {
if (link->state == LINK_STATE_FAILED)
return 0;
- if (link->flags == flags) {
- log_debug_link(link, "link status unchanged: %#.8x", flags);
+ if (link->flags == flags)
return 0;
- }
if ((link->flags & IFF_UP) != (flags & IFF_UP))
log_info_link(link,
@@ -1038,8 +1011,8 @@ static int link_update_flags(Link *link, unsigned flags) {
}
}
- log_debug_link(link,
- "link status updated: %#.8x -> %#.8x", link->flags, flags);
+ log_debug_link(link, "link status updated: %#.8x -> %#.8x",
+ link->flags, flags);
link->flags = flags;
@@ -1271,8 +1244,6 @@ static int link_getlink_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
return 1;
}
- log_debug_link(link, "got link state");
-
link_update(link, m);
return 1;
@@ -1306,38 +1277,59 @@ static int link_getlink(Link *link) {
return 0;
}
-int link_configure(Link *link) {
+static int link_configure(Link *link) {
int r;
assert(link);
- assert(link->network);
assert(link->state == _LINK_STATE_INVALID);
r = link_getlink(link);
- if (r < 0) {
- link_enter_failed(link);
+ if (r < 0)
return r;
- }
return link_enter_enslave(link);
}
+int link_add(Manager *m, struct udev_device *device, Link **ret) {
+ Link *link = NULL;
+ Network *network;
+ int r;
+
+ assert(m);
+ assert(device);
+
+ r = link_new(m, device, &link);
+ if (r < 0)
+ return r;
+
+ *ret = link;
+
+ r = network_get(m, device, &network);
+ if (r < 0)
+ return r == -ENOENT ? 0 : r;
+
+ r = network_apply(m, network, link);
+ if (r < 0)
+ return r;
+
+ r = link_configure(link);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
int link_update(Link *link, sd_rtnl_message *m) {
unsigned flags;
int r;
assert(link);
+ assert(link->network);
assert(m);
if (link->state == LINK_STATE_FAILED)
return 0;
- r = sd_rtnl_message_link_get_flags(m, &flags);
- if (r < 0) {
- log_warning_link(link, "Could not get link flags");
- return r;
- }
-
if (link->network->dhcp && link->network->dhcp_mtu &&
!link->original_mtu) {
r = sd_rtnl_message_read_u16(m, IFLA_MTU, &link->original_mtu);
@@ -1358,6 +1350,12 @@ int link_update(Link *link, sd_rtnl_message *m) {
link->mac.ether_addr_octet[5]);
}
+ r = sd_rtnl_message_link_get_flags(m, &flags);
+ if (r < 0) {
+ log_warning_link(link, "Could not get link flags");
+ return r;
+ }
+
return link_update_flags(link, flags);
}
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index ca79d4f..6437ff4 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -208,10 +208,6 @@ int network_apply(Manager *manager, Network *network, Link *link) {
link->network = network;
- r = link_configure(link);
- if (r < 0)
- return r;
-
if (network->dns) {
r = manager_update_resolv_conf(manager);
if (r < 0)
diff --git a/src/network/networkd.h b/src/network/networkd.h
index d8cd7ec..0c01719 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -359,7 +359,6 @@ int link_new(Manager *manager, struct udev_device *device, Link **ret);
void link_free(Link *link);
int link_get(Manager *m, int ifindex, Link **ret);
int link_add(Manager *manager, struct udev_device *device, Link **ret);
-int link_configure(Link *link);
int link_update(Link *link, sd_rtnl_message *message);
More information about the systemd-commits
mailing list