Commits

jsgf committed 168bdba

stomp various bugs

  • Participants
  • Parent commits d70f638

Comments (0)

Files changed (3)

 install_opts := -o root -g root
 
 CFLAGS += -Wall -Werror -std=gnu99 -g -DNP_ETC_DIR='"$(etcdir)"' \
-	-DNP_SCRIPT_DIR='"$(scriptdir)"' -ggdb3 -O
+	-DNP_SCRIPT_DIR='"$(scriptdir)"'
 
 netplugd: config.o netlink.o lib.o if_info.o main.o
 	$(CC) -o $@ $^
     int len = hdr->nlmsg_len - NLMSG_LENGTH(sizeof(*info));
 
     if (info->ifi_flags & IFF_LOOPBACK) {
-        goto done;
+        return 0;
     }
 
     if (len < 0) {
-        do_log(LOG_ERR, "Malformed netlink packet length");
+	do_log(LOG_ERR, "len = %d", len);
         return -1;
     }
 
         exit(1);
     }
 
+    char *name = RTA_DATA(attrs[IFLA_IFNAME]);
+
+    if (!if_match(name)) {
+        goto done;
+    }
+
     struct if_info *i;
 
     if ((i = if_info_get_interface(hdr, attrs)) == NULL) {
+	do_log(LOG_ERR, "if_info_get_interface returned NULL");
         return 0;
     }
 
         goto done;
     }
 
-    char *name = RTA_DATA(attrs[IFLA_IFNAME]);
-
-    if (!if_match(name)) {
-        goto done;
-    }
-
     do_log(LOG_INFO, "%s: flags 0x%08x -> 0x%08x", name, i->flags,
            info->ifi_flags);
 
     memset(&addr, 0, sizeof(addr));
     addr.nl_family = AF_NETLINK;
 
+    memset(&req, 0, sizeof(req));
     req.hdr.nlmsg_len = sizeof(req);
     req.hdr.nlmsg_type = RTM_GETLINK;
     req.hdr.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
                 int err;
 
                 if ((err = callback(hdr, arg)) == -1) {
-                    do_log(LOG_ERR, "Callback failed");
                     return;
                 }
             }
 
             if (callback) {
                 if ((err = callback(hdr, arg)) == -1) {
-                    do_log(LOG_ERR, "Callback failed");
                     return;
                 }
             }