diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-11-04 12:08:09 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-11-04 12:15:56 +0100 |
commit | e62c1f44dbb07d96a37674c0fc424785013fca24 (patch) | |
tree | f28924ea8c3b0edfd62ab028b7f2f1783e53559c | |
parent | 22c0098be76a59ff95da58a4cf49e387c81081e0 (diff) |
owfd: dhcp: cache if-label
We use "ip" to configure linux net interfaces. This avoids heavy netlink
operations in this small helper. To avoid cluttering the IP namespace, we
pass special labels to "ip". We cache this label so we don't have to
allocate it all the time.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r-- | src/dhcp.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -44,6 +44,7 @@ struct owfd_dhcp { struct owfd_dhcp_config config; int ifindex; + char *iflabel; GMainLoop *loop; int sfd; @@ -98,6 +99,8 @@ static void owfd_dhcp_teardown(struct owfd_dhcp *dhcp) if (dhcp->loop) g_main_loop_unref(dhcp->loop); + + free(dhcp->iflabel); } static void sig_dummy(int sig) @@ -129,6 +132,12 @@ static int owfd_dhcp_setup(struct owfd_dhcp *dhcp) goto error; } + r = asprintf(&dhcp->iflabel, "%s:openwfd", dhcp->config.interface); + if (r < 0) { + r = log_ERRNO(); + goto error; + } + dhcp->loop = g_main_loop_new(NULL, FALSE); sigemptyset(&mask); |