diff options
author | Tom Gundersen <teg@jklm.no> | 2015-08-20 11:26:57 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-09-18 15:14:42 +0200 |
commit | 5707940ed31272d44ba2dcf0a74a3024256d2875 (patch) | |
tree | 12e077e4fa4a5d2c106bcc2162ec21400a1382d4 /src/libsystemd-network/sd-ipv4ll.c | |
parent | 94a355a1306ef51ab6c7f5264aaac35a54d5b54a (diff) | |
download | systemd-5707940ed31272d44ba2dcf0a74a3024256d2875.tar.gz |
sd-ipv4ll: don't allow changing MAC address whilst running
This requires the caller to stop and restart the statemachine if they want to
change the MAC address.
Diffstat (limited to 'src/libsystemd-network/sd-ipv4ll.c')
-rw-r--r-- | src/libsystemd-network/sd-ipv4ll.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index 6bb9b8c82d..2345e1aabb 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -2,6 +2,7 @@ This file is part of systemd. Copyright (C) 2014 Axis Communications AB. All rights reserved. + Copyright (C) 2015 Tom Gundersen systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -395,29 +396,15 @@ int sd_ipv4ll_set_index(sd_ipv4ll *ll, int interface_index) { } int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr) { - bool need_restart = false; - assert_return(ll, -EINVAL); assert_return(addr, -EINVAL); + assert_return(IN_SET(ll->state, IPV4LL_STATE_INIT, IPV4LL_STATE_STOPPED), -EBUSY); if (memcmp(&ll->mac_addr, addr, ETH_ALEN) == 0) return 0; - if (!IN_SET(ll->state, IPV4LL_STATE_INIT, IPV4LL_STATE_STOPPED)) { - log_ipv4ll(ll, "Changing MAC address on running IPv4LL " - "client, restarting"); - ll = ipv4ll_stop(ll, IPV4LL_EVENT_STOP); - need_restart = true; - } - - if (!ll) - return 0; - memcpy(&ll->mac_addr, addr, ETH_ALEN); - if (need_restart) - sd_ipv4ll_start(ll); - return 0; } |