summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-11-04 12:08:09 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2013-11-04 12:15:56 +0100
commite62c1f44dbb07d96a37674c0fc424785013fca24 (patch)
treef28924ea8c3b0edfd62ab028b7f2f1783e53559c
parent22c0098be76a59ff95da58a4cf49e387c81081e0 (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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/dhcp.c b/src/dhcp.c
index 7eb93e6..5b37f5f 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -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);