summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-08-08 13:08:57 -0700
committerMarcel Holtmann <marcel@holtmann.org>2009-08-08 13:08:57 -0700
commit18fb682a6a072762fc2dd587a299084836e0a1ff (patch)
tree9f2cba269d4a4d5dd8c48eb079fb85d1f3dfe7cd /src
parent326b5a87ca55dc46578283f2624ee451bdf29f4e (diff)
downloadconnman-18fb682a6a072762fc2dd587a299084836e0a1ff.tar.gz
connman-18fb682a6a072762fc2dd587a299084836e0a1ff.tar.bz2
connman-18fb682a6a072762fc2dd587a299084836e0a1ff.zip
Fix issues with hashing of RTNL interfaces and their flags
Diffstat (limited to 'src')
-rw-r--r--src/ipconfig.c35
-rw-r--r--src/rtnl.c16
2 files changed, 42 insertions, 9 deletions
diff --git a/src/ipconfig.c b/src/ipconfig.c
index dbf0bc83..764836ab 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -23,6 +23,12 @@
#include <config.h>
#endif
+#include <net/if.h>
+
+#ifndef IFF_LOWER_UP
+#define IFF_LOWER_UP 0x10000
+#endif
+
#include <gdbus.h>
#include "connman.h"
@@ -31,6 +37,7 @@ struct connman_ipconfig {
gint refcount;
int index;
char *interface;
+ unsigned int flags;
enum connman_ipconfig_method method;
};
@@ -121,8 +128,32 @@ int __connman_ipconfig_get_index(struct connman_ipconfig *ipconfig)
void __connman_ipconfig_update_link(struct connman_ipconfig *ipconfig,
unsigned flags, unsigned change)
{
- connman_info("%s {update} flags %u change %u", ipconfig->interface,
- flags, change);
+ GString *str;
+
+ if (flags == ipconfig->flags)
+ return;
+
+ ipconfig->flags = flags;
+
+ str = g_string_new(NULL);
+ if (str == NULL)
+ return;
+
+ if (flags & IFF_UP)
+ g_string_append(str, "UP");
+ else
+ g_string_append(str, "DOWN");
+
+ if (flags & IFF_RUNNING)
+ g_string_append(str, ",RUNNING");
+
+ if (flags & IFF_LOWER_UP)
+ g_string_append(str, ",LOWER_UP");
+
+ connman_info("%s {update} flags %u change %u <%s>",
+ ipconfig->interface, flags, change, str->str);
+
+ g_string_free(str, TRUE);
}
void __connman_ipconfig_add_address(struct connman_ipconfig *ipconfig,
diff --git a/src/rtnl.c b/src/rtnl.c
index 44126307..d7b317c3 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -167,19 +167,21 @@ static void process_newlink(unsigned short type, int index,
case ARPHRD_ETHER:
case ARPHRD_LOOPBACK:
case ARPHRD_NONE:
- ipconfig = g_hash_table_lookup(ipconfig_hash, &index);
+ ipconfig = g_hash_table_lookup(ipconfig_hash,
+ GINT_TO_POINTER(index));
if (ipconfig == NULL) {
ipconfig = connman_ipconfig_create(index);
if (ipconfig != NULL) {
g_hash_table_insert(ipconfig_hash,
- &index, ipconfig);
+ GINT_TO_POINTER(index), ipconfig);
__connman_rtnl_register_ipconfig(ipconfig);
-
- __connman_ipconfig_update_link(ipconfig,
- flags, change);
}
}
+
+ if (ipconfig != NULL)
+ __connman_ipconfig_update_link(ipconfig,
+ flags, change);
break;
}
@@ -217,7 +219,7 @@ static void process_dellink(unsigned short type, int index,
case ARPHRD_ETHER:
case ARPHRD_LOOPBACK:
case ARPHRD_NONE:
- g_hash_table_remove(ipconfig_hash, &index);
+ g_hash_table_remove(ipconfig_hash, GINT_TO_POINTER(index));
break;
}
}
@@ -917,7 +919,7 @@ int __connman_rtnl_init(void)
DBG("");
- ipconfig_hash = g_hash_table_new_full(g_int_hash, g_int_equal,
+ ipconfig_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, free_ipconfig);
sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);