]> git.meshlink.io Git - catta/commitdiff
a few fixes in netlink handling
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Aug 2006 21:20:53 +0000 (21:20 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 30 Aug 2006 21:20:53 +0000 (21:20 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1289 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-autoipd/iface-linux.c
avahi-autoipd/main.c

index c2f24df7b8692a44b2b2abc4e8fa663c48506733..5e2996a8a171655556be1377e6fa75214a42823a 100644 (file)
@@ -121,7 +121,6 @@ static int process_nlmsg(struct nlmsghdr *n) {
         int l;
         uint32_t address = 0;
         Address *i;
-        char buf[32];
         
         ifa = NLMSG_DATA(n);
 
@@ -144,8 +143,6 @@ static int process_nlmsg(struct nlmsghdr *n) {
             a = RTA_NEXT(a, l);
         }
 
-        daemon_log(LOG_INFO, "%s", inet_ntop(AF_INET, &address, buf, sizeof(buf)));
-
         if (!address || is_ll_address(address))
             return 0;
 
@@ -189,7 +186,7 @@ static int process_response(int wait_for_done, unsigned seq) {
                 return -1;
             }
 
-            if (p->nlmsg_type == NLMSG_DONE && wait_for_done && p->nlmsg_seq == seq)
+            if (p->nlmsg_type == NLMSG_DONE && wait_for_done && p->nlmsg_seq == seq && (pid_t) p->nlmsg_pid == getpid())
                 return 0;
 
             if (p->nlmsg_type == NLMSG_ERROR) {
@@ -201,9 +198,6 @@ static int process_response(int wait_for_done, unsigned seq) {
                 }
             }
 
-            if ((pid_t) p->nlmsg_pid != getpid())
-                continue;
-
             if (process_nlmsg(p) < 0)
                 return -1;
         }
@@ -272,7 +266,7 @@ int iface_process(Event *event) {
     if (process_response(0, 0) < 0)
         return -1;
 
-    if (b && !!addresses)
+    if (b && !addresses)
         *event = EVENT_ROUTABLE_ADDR_UNCONFIGURED;
     else if (!b && addresses)
         *event = EVENT_ROUTABLE_ADDR_CONFIGURED;
index 200cab048f24ba87f79114692b432c83cee073bc..feb88ee8a1f284afed9a08be587821b7fcf78959 100644 (file)
@@ -230,14 +230,14 @@ static void set_state(State st, int reset_counter) {
 static int add_address(int iface, uint32_t addr) {
     char buf[64];
 
-    daemon_log(LOG_INFO, "Selected address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf)));
+    daemon_log(LOG_INFO, "Configuring address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf)));
     return 0;
 }
 
 static int remove_address(int iface, uint32_t addr) {
     char buf[64];
     
-    daemon_log(LOG_INFO, "Removing address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf)));
+    daemon_log(LOG_INFO, "Unconfiguring address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf)));
     return 0;
 }
 
@@ -464,6 +464,8 @@ static int loop(int iface, uint32_t addr) {
 
             daemon_log(LOG_INFO, "Successfully claimed IP address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf)));
             set_state(STATE_RUNNING, 0);
+
+            next_wakeup_valid = 0;
             
         } else if (event == EVENT_PACKET) {
             ArpPacketInfo info;
@@ -514,10 +516,11 @@ static int loop(int iface, uint32_t addr) {
 
             daemon_log(LOG_INFO, "A routable address has been configured.");
 
-            set_state(STATE_SLEEPING, 1);
-            
             if (state == STATE_RUNNING || state == STATE_ANNOUNCING)
                 remove_address(iface, addr);
+
+            set_state(STATE_SLEEPING, 1);
+            next_wakeup_valid = 0;
             
         } else if (event == EVENT_ROUTABLE_ADDR_UNCONFIGURED && state == STATE_SLEEPING) {
 
@@ -655,7 +658,6 @@ fail:
 
 /* TODO:
 
-- netlink
 - man page
 - user script
 - chroot/drop privs/caps