Cleaned up the code and made it reentrant by locking a mutex around the netlink_unicast call