summaryrefslogtreecommitdiff
path: root/src/network/networkd-netdev.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-04-19 17:14:36 +0200
committerTom Gundersen <teg@jklm.no>2014-04-19 18:41:58 +0200
commita21df104887552e8558d6c11388dff466641a031 (patch)
tree078168997edd6b273747c8dfe8234751b4366ac3 /src/network/networkd-netdev.c
parentc6315a7afc905c0b41901cf8e204306296ebb640 (diff)
networkd: netdev - give up early when setting already set ifindex
We may receive RTM_NEWLINK messages with missing LINKINFO after the initial NEWLINK message, don't bother verifying these, just drop out early after checking that the ifindex is not in conflict.
Diffstat (limited to 'src/network/networkd-netdev.c')
-rw-r--r--src/network/networkd-netdev.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 30cb74b8b7..717ecdf0e5 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -392,6 +392,29 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
return -EINVAL;
}
+ r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
+ if (r < 0) {
+ log_error_netdev(netdev, "Could not get ifindex: %s", strerror(-r));
+ netdev_enter_failed(netdev);
+ return r;
+ } else if (ifindex <= 0) {
+ log_error_netdev(netdev, "Got invalid ifindex: %d", ifindex);
+ netdev_enter_failed(netdev);
+ return r;
+ }
+
+
+ if (netdev->ifindex > 0) {
+ if (netdev->ifindex != ifindex) {
+ log_error_netdev(netdev, "Could not set ifindex to %d, already set to %d",
+ ifindex, netdev->ifindex);
+ netdev_enter_failed(netdev);
+ return -EEXIST;
+ } else
+ /* ifindex already set to the same for this netdev */
+ return 0;
+ }
+
r = sd_rtnl_message_read_string(message, IFLA_IFNAME, &received_name);
if (r < 0) {
log_error_netdev(netdev, "Could not get IFNAME");
@@ -437,24 +460,6 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
return r;
}
- r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
- if (r < 0) {
- log_error_netdev(netdev, "Could not get ifindex: %s", strerror(-r));
- netdev_enter_failed(netdev);
- return r;
- } else if (ifindex <= 0) {
- log_error_netdev(netdev, "Got invalid ifindex: %d", ifindex);
- netdev_enter_failed(netdev);
- return r;
- }
-
- if (netdev->ifindex > 0 && netdev->ifindex != ifindex) {
- log_error_netdev(netdev, "Could not set ifindex to %d, already set to %d",
- ifindex, netdev->ifindex);
- netdev_enter_failed(netdev);
- return -EEXIST;
- }
-
netdev->ifindex = ifindex;
netdev_enter_ready(netdev);