summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-02-01 16:59:28 +0100
committerThomas Haller <thaller@redhat.com>2015-03-03 11:18:12 +0100
commit9f2f751349a1e32ece34739ad28becd4cf62679a (patch)
tree045c3c7b46afa7d523e2692652b0da12e150eed5
parentc140f4599d84a1ad113ca4ede53e6b93381e9c4e (diff)
downloadNetworkManager-9f2f751349a1e32ece34739ad28becd4cf62679a.tar.gz
dhcp: add systemd's dhcp-identifier.c for dhcp_identifier_set_duid_en()
Also patch dhcp_identifier_set_iaid() to get the ifname via if_indextoname(), instead of udev. This also makes our local modification sd_dhcp6_client_set_ifname() obsolete, which will be removed next.
-rw-r--r--src/Makefile.am2
-rw-r--r--src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c13
-rw-r--r--src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h1
3 files changed, 16 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2120fc2188..ead105de4a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,6 +66,8 @@ SYSTEMD_DHCP_CFLAGS = \
libsystemd_dhcp_la_SOURCES = \
dhcp-manager/systemd-dhcp/src/libsystemd/sd-id128/sd-id128.c \
+ dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c \
+ dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h \
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-network.c \
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-packet.c \
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-internal.h \
diff --git a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c
index f7a1492363..c33761bc13 100644
--- a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c
+++ b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c
@@ -19,13 +19,18 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "nm-sd-adapt.h"
#include "sd-id128.h"
+#if 0 /* NM_IGNORED a*/
#include "libudev.h"
#include "udev-util.h"
#include "virt.h"
#include "sparse-endian.h"
+#else /* NM_IGNORED */
+#include <net/if.h>
+#endif /* NM_IGNORED */
#include "siphash24.h"
#include "dhcp6-protocol.h"
@@ -59,12 +64,17 @@ int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len) {
int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, uint32_t *_id) {
+#if 0 /* NM_IGNORED */
/* name is a pointer to memory in the udev_device struct, so must
have the same scope */
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
+#else /* NM_IGNORED */
+ char name_buf[IF_NAMESIZE];
+#endif /* NM_IGNORED */
const char *name = NULL;
uint64_t id;
+#if 0 /* NM_IGNORED */
if (detect_container(NULL) <= 0) {
/* not in a container, udev will be around */
_cleanup_udev_unref_ struct udev *udev;
@@ -84,6 +94,9 @@ int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, uint32_t
name = net_get_name(device);
}
}
+#else /* NM_IGNORED */
+ name = if_indextoname(ifindex, name_buf);
+#endif /* NM_IGNORED */
if (name)
siphash24((uint8_t*)&id, name, strlen(name), HASH_KEY.bytes);
diff --git a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h
index 643d4970d5..5d4da21cb0 100644
--- a/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h
+++ b/src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h
@@ -21,6 +21,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "nm-sd-adapt.h"
#include "macro.h"
#include "sparse-endian.h"