1 From Stefan Berger <stefanb@us.ibm.com>
2 https://bugzilla.redhat.com/show_bug.cgi?id=677527
4 --- libnl-1.1/lib/socket.c
5 +++ libnl-1.1/lib/socket.c
12 #include <netlink-local.h>
13 #include <netlink/netlink.h>
14 #include <netlink/utils.h>
15 @@ -117,12 +119,15 @@ static void __init init_default_cb(void)
18 static uint32_t used_ports_map[32];
19 +static pthread_mutex_t port_map_mutex = PTHREAD_MUTEX_INITIALIZER;
21 static uint32_t generate_local_port(void)
24 uint32_t pid = getpid() & 0x3FFFFF;
26 + pthread_mutex_lock(&port_map_mutex);
28 for (i = 0; i < 32; i++) {
29 if (used_ports_map[i] == 0xFFFFFFFF)
31 @@ -136,11 +141,15 @@ static uint32_t generate_local_port(void
33 /* PID_MAX_LIMIT is currently at 2^22, leaving 10 bit
34 * to, i.e. 1024 unique ports per application. */
35 - return pid + (n << 22);
37 + pthread_mutex_unlock(&port_map_mutex);
39 + return pid + (n << 22);
43 + pthread_mutex_unlock(&port_map_mutex);
45 /* Out of sockets in our own PID namespace, what to do? FIXME */
48 @@ -153,7 +162,10 @@ static void release_local_port(uint32_t
52 - used_ports_map[nr / 32] &= ~(1 << (nr % 32));
54 + pthread_mutex_lock(&port_map_mutex);
55 + used_ports_map[nr / 32] &= ~(1 << (nr % 32));
56 + pthread_mutex_unlock(&port_map_mutex);
60 --- libnl-1.1/lib/Makefile
61 +++ libnl-1.1/lib/Makefile
62 @@ -53,7 +53,7 @@ all:
65 $(OUT_SLIB): ../Makefile.opts $(OBJ)
66 - $(CC) -shared -Wl,-soname,libnl.so.1 -o $(OUT_SLIB) $(OBJ) $(LIBNL_LIB) -lc
67 + $(CC) -shared -Wl,-soname,libnl.so.1 -o $(OUT_SLIB) $(OBJ) $(LIBNL_LIB) -lc -lpthread
68 rm -f $(LN1_SLIB) ; $(LN) -s $(OUT_SLIB) $(LN1_SLIB)
69 rm -f $(LN_SLIB) ; $(LN) -s $(LN1_SLIB) $(LN_SLIB)