--- a/vrrpd.c
+++ b/vrrpd.c
@@ -48,6 +48,7 @@ typedef unsigned char u8;
 /* local include */
 #include "vrrpd.h"
 #include "ipaddr.h"
+#include <libubus.h>
 
 int ip_id = 0;	/* to have my own ip_id creates collision with kernel ip->id
 		** but it should be ok because the packets are unlikely to be
@@ -106,6 +107,8 @@ char backup_reason[FILENAME_MAX+1];
 char master_reason[FILENAME_MAX+1];
 char temp[FILENAME_MAX+1];
 
+struct ubus_context *ubus;
+
 /****************************************************************
  NAME	: killvrrpd				
  AIM	:
@@ -1437,8 +1440,15 @@ static void write_ip_to_file( vrrp_rt *v
 
 /****************************************************************/
 
-static void state_goto_master( vrrp_rt *vsrv )
+static void state_goto_master(struct ubus_context *ubus, vrrp_rt *vsrv)
 {
+	struct events_log new_task = {
+		.table = LLOG_NETWORK,
+		.sender = "VRRP",
+		.priority = EVENTLOG_NOTICE,
+		.db_flag = 1
+		
+	};
 	vrrp_if	*vif = &vsrv->vif;
 	int i;
 
@@ -1474,12 +1484,7 @@ static void state_goto_master( vrrp_rt *
 	vrrpd_log(LOG_WARNING, "VRRP ID %d on %s: %s%swe are now the master router.", vsrv->vrid, vif->ifname,master_ipaddr ? ipaddr_to_str(master_ipaddr) : "", master_ipaddr ? " is down, " : "");
 	strcpy(backup_reason,"");
 	char status[10];
-	struct events_log new_task;
-	default_task(&new_task);
-	new_task.table = LOG_NETWORK;
-	new_task.sender = "VRRP";
-   new_task.priority = EVENTLOG_NOTICE;
-   new_task.db_flag = 1;
+	
 	/* set the VRRP MAC address -- rfc2338.7.3 */
 	if( !vsrv->no_vmac ){
 		vrrpd_log(LOG_WARNING, "VRRP ID %d change MAC %s",vsrv->vrid, vif->ifname);
@@ -1507,8 +1512,8 @@ static void state_goto_master( vrrp_rt *
     } else {
         new_task.text = "Router is in master mode";
     }
-	add_task(&new_task);
-
+    
+	llog_add_task(ubus, &new_task);
 	free(new_task.text);
 
 	vsrv->wantstate = VRRP_STATE_MAST;
@@ -1570,21 +1575,21 @@ static void state_leave_master( vrrp_rt
  AIM	:
  REMARK	: rfc2338.6.4.1
 ****************************************************************/
-static void state_init( vrrp_rt *vsrv )
+static void state_init(struct ubus_context *ubus, vrrp_rt *vsrv)
 {
 	char status[10];
-	struct events_log new_task;
-	default_task(&new_task);
-	new_task.table = LOG_NETWORK;
-	new_task.sender = "VRRP";
-   new_task.priority = EVENTLOG_NOTICE;
-   new_task.db_flag = 1;
+	struct events_log new_task = {
+		.table = LLOG_NETWORK,
+		.sender = "VRRP",
+		.priority = EVENTLOG_NOTICE,
+		.db_flag = 1
+	};
 	vrrpd_log(LOG_WARNING, "VRRP ID %d on %s: %s%s - INIT State (backup) -", vsrv->vrid, vsrv->vif.ifname, master_ipaddr ? ipaddr_to_str(master_ipaddr) : "", master_ipaddr ? " is up, " : "");
 	if ( vsrv->priority == VRRP_PRIO_OWNER ) {
-		 state_goto_master( vsrv );
+		 state_goto_master(ubus, vsrv);
 	}
 	if (vsrv->wantstate == VRRP_STATE_MAST ){
-		state_goto_master( vsrv );
+		state_goto_master(ubus, vsrv);
 	} else { 
 		int delay = 3*vsrv->adver_int + VRRP_TIMER_SKEW(vsrv);
 		VRRP_TIMER_SET( vsrv->ms_down_timer, delay );
@@ -1598,8 +1603,8 @@ static void state_init( vrrp_rt *vsrv )
         } else {
             new_task.text = "Router is in backup mode";
         }
-        add_task(&new_task);
 
+        llog_add_task(ubus, &new_task);
         free(new_task.text);
 		strcpy(status, "Backup");
 		write_to_file(vsrv, status);
@@ -1620,7 +1625,7 @@ static void state_init( vrrp_rt *vsrv )
  AIM	:
  REMARK	: rfc2338.6.4.2
 ****************************************************************/
-static void state_back( vrrp_rt *vsrv )
+static void state_back(struct ubus_context *ubus, vrrp_rt *vsrv)
 {
 	char		buf[300];	/* WORK: lame ! */
 	int		len	= vrrp_read( vsrv, buf, sizeof(buf) );
@@ -1639,7 +1644,7 @@ static void state_back( vrrp_rt *vsrv )
 		//the first time that the backup take the role it work but after loop if wantstate!= 0 *AA*
 		vrrpd_log(LOG_WARNING,"VRRP ID %d on %s: delay expired = %d no response after %d + %d ms VID %d", vsrv->vrid, vsrv->vif.ifname, vsrv->adver_int/VRRP_TIMER_HZ , vsrv->adver_int/VRRP_TIMER_HZ, vsrv->ms_down_timer/VRRP_TIMER_HZ, vsrv->vrid);
 		vsrv->wantstate = 0;
-		state_goto_master( vsrv );
+		state_goto_master(ubus, vsrv);
 		return;
 	}
 	if( !len )	return;
@@ -1661,7 +1666,7 @@ static void state_back( vrrp_rt *vsrv )
  AIM	:
  REMARK	: rfc2338.6.4.3
 ****************************************************************/
-static void state_mast( vrrp_rt *vsrv )
+static void state_mast(struct ubus_context *ubus, vrrp_rt *vsrv)
 {
 	char status[10];
 	uint32_t	addr[1024];
@@ -1670,12 +1675,12 @@ static void state_mast( vrrp_rt *vsrv )
 	int		len	= vrrp_read( vsrv, buf, sizeof(buf) );
 	struct iphdr	*iph	= (struct iphdr *)buf;
 	vrrp_pkt	*hd	= (vrrp_pkt *)((char *)iph + (iph->ihl<<2));
-	struct events_log new_task;
-	default_task(&new_task);
-	new_task.table = LOG_NETWORK;
-	new_task.sender = "VRRP";
-   new_task.priority = EVENTLOG_NOTICE;
-   new_task.db_flag = 1;
+	struct events_log new_task = {
+		.table = LLOG_NETWORK,
+		.sender = "VRRP",
+		.priority = EVENTLOG_NOTICE,
+		.db_flag = 1
+	};
 
 	if( vsrv->state != VRRP_STATE_BACK ){
 		if( vsrv->wantstate == VRRP_STATE_BACK ){
@@ -1709,8 +1714,8 @@ static void state_mast( vrrp_rt *vsrv )
             } else {
                 new_task.text = "Router is in backup mode";
             }
-            add_task(&new_task);
 
+            llog_add_task(ubus, &new_task);
             free(new_task.text);
 			strcpy(status, "Backup");
 			write_to_file(vsrv, status);
@@ -1801,7 +1806,7 @@ static void signal_end( int nosig )
 
 	if( vsrv->state == VRRP_STATE_MAST ){
 		vsrv->wantstate = VRRP_STATE_BACK; 
-		state_mast( vsrv );
+		state_mast(ubus, vsrv);
 		state_leave_master( vsrv, 1 );
 	}
 
@@ -2061,14 +2066,20 @@ int main( int argc, char *argv[] )
         /* first lock as down */
         killvrrpd(12,vsrv->vif.ifname);
 	strcpy(backup_reason,"INIT state");
+	
+	ubus = ubus_connect(NULL);
+	if (!ubus) {
+		vrrpd_log(LOG_WARNING, "Failed to connect to ubus\n");
+		return 1;
+	}
 
 	/* main loop */
 	while( 1 ){
 		if (monitor) {ethsup(vsrv);};
 		switch( vsrv->state ){
-		case VRRP_STATE_INIT:	state_init( vsrv ); break;
-		case VRRP_STATE_BACK:	state_back( vsrv ); break;
-		case VRRP_STATE_MAST:   state_mast( vsrv ); break;
+		case VRRP_STATE_INIT:	state_init(ubus, vsrv); break;
+		case VRRP_STATE_BACK:	state_back(ubus, vsrv); break;
+		case VRRP_STATE_MAST:   state_mast(ubus, vsrv); break;
 		}
 	}
 
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ CFLAGS= $(COMMON_CFLAGS) -Wall
 all: $(ALL_EXE)
 
 vrrpd : $(VRRPD_OBJS)
-	$(CC) $(PROF_OPT) -o $@ $^ -lrt -llog $(LINKLIB)
+	$(CC) $(PROF_OPT) -o $@ $^ -lrt -llog -lubus $(LINKLIB)
 
 atropos:$(ATROPOS_OBJS)
 	$(CC) $(PROF_OPT) -o $@ $^ -lrt -leventslog
